Simple script

09/02/2015 19:09 floz1994#1
Hello, to begin with I would like to say hello, I'm a new guy here, If the post doesn't belong here you are welcome to move it. Soo... I need help with writing simple script using AutoIt, below I'm showing you guys how would it look like.

- Start/Stop key = Alt + Pause Break

when start key pressed:

- Press F1, wait 2 seconds, use right click
wait 2 seconds
- Press F2, wait 2 seconds, use right click
wait 2 seconds
- Press F3, wait 2 seconds, use right click
continue pressing "F3, wait 2 seconds, use right click" for 1-2 minutes and then repeat F1, F2 and again F3 (loop)

Also I would like the script to use the right click where the mouse is set at, no need for setting coordinates.

I'm looking forward to hear from you guys.
09/02/2015 23:06 WJNeeson#2
Hi floz

next time, please use [Only registered and activated users can see links. Click Here To Register...]
its for simple script requests

PHP Code:

HotKeySet
("!{PAUSE}""_Start")
HotKeySet("{ESC}""_Exit")

;
sets the hot key "alt+pause" for function _start
;sets the hot key "esc" for function _exit

Global $isPaused True

;bool for toggle start/pause

While 1
    
If $isPaused False Then
        
;checks if bot is on/off
        
;if on then...
        ;
everything in this while will be repeated until you press alt+pause again
        Send
("{F1}")
        ;
sends key F1
        Sleep
(2000)
        ;
sleeps for 2000ms 2s
        MouseClick
("Right")
        ;
uses right click (mouse)

        
Send("{F2}")
        
Sleep(2000)
        
MouseClick("Right")

        
$timer TimerInit()
        ;
sets a timer
        $diff 
TimerDiff($timer)
        ;
reads the time difference to TimerInit()
        While 
$diff 120000
            
;while the timer difference is less than 120000ms (2min).....
            
$diff TimerDiff($timer)
            ;
read diff again otherwise it will always be as big as before the while
            
Send("{F3}")
            
Sleep(2000)
            
MouseClick("Right")
        
WEnd
    
EndIf
    ;if 
off then ask again
WEnd

Func _Start
()
    ;function 
which is called by pressing alt+pause
    
If $isPaused False Then $isPaused True
    
If $isPaused True Then $isPaused False
EndFunc

Func _Exit
()
    Exit
EndFunc 
very simple explanations in the comments (with ; at the beginning)
09/02/2015 23:35 floz1994#3
perfect, what about F3? will it repeat for 1-2 minutes then go back to F1, F2 and repeating again?

The F2 function is not working, the script is not even using it
09/03/2015 15:45 WJNeeson#4
f1, f2, f3 for 2 mins
go back

try to add #requireadmin at the top
09/03/2015 16:03 floz1994#5
Okay, I'm not sure now if that's what you meant..

F1, F2, F3 for 2 mins... - meaning all of them are going to work for 2 minutes in a loop?

I need: F1+RIGHT MOUSE and F2+RIGHT MOUSE for single use and then loop F3 so its keep pressing it and right mouse click for 2 minutes

could you fix that for me? and add the #requireadmin thing you were talking about

The script doesn't read function F2, looks like its skipping it
The pause is not working, you can start it but can't pause it
09/03/2015 21:10 WJNeeson#6
check the code

PHP Code:
#RequireAdmin

HotKeySet("!{PAUSE}""_Start")
HotKeySet("{ESC}""_Exit")

Global 
$isPaused True

While 1
    
If $isPaused False Then
        Send
("{F1}")
        
Sleep(2000)
        
MouseClick("Right")
    
Sleep(2000)

        
Send("{F2}")
        
Sleep(2000)
        
MouseClick("Right")
    
Sleep(2000)

        
$timer TimerInit()
        
$diff TimerDiff($timer)
        While 
$diff 120000
            $diff 
TimerDiff($timer)
            
Send("{F3}")
            
Sleep(2000)
            
MouseClick("Right")
            
Sleep(2000)
        
WEnd
    
EndIf
WEnd

Func _Start
()
    If 
$isPaused False Then $isPaused True
    
If $isPaused True Then $isPaused False
EndFunc

Func _Exit
()
    Exit
EndFunc 
when you press alt+pause
everthing below "If $isPaused = False Then" will happen
->
send f1
wait 2s
right click
wait 2s

send f2
wait 2s
right click
wait 2s

timer will be set for 2m
during this 2m
->
send f3
wait 2s
right click
wait 2s
repeat until time is > 2m

go back and repeat everything

when you press alt+pause again
->
script will finish this operation (if you press alt+pause after the script presses f1 it will first do f2 and the 2mins f3)

my bad that the pause wasnt working