Sign in to follow this  
Followers 0
Guest mechman

Hotkeys?

4 posts in this topic

Hey folks. I just recently got into programming with AutoIt, and frankly, I'm more then impressed with its simplicity for its abilities. Anyways, I have a simple question. I would like to know how to trigger a command loop with a hotkey .. example, I have a loop to click a spot every 5 seconds, but I want to beging that loop once someone presses "Ctrl + E" or something like that. The same with pausing the loop as well, enabling it to start again once needed with the same hotkey. I hope you understand what I mean. Much thanks!

- mech

Share this post


Link to post
Share on other sites



Change the placement of the mouse to suit you, and you might want to add one more while in the loop.

AdlibEnable("pause"); this keeps running at all times till you exit.

HotKeySet("^e","pauseset"); uses the CTRL+e key to change the value of $Pause
$Pause = -1

sleep(500)
While 1
 mousemove(100,100,0)
 mouseclick("left")
 sleep(1000) ; sleep for 1 second before repeating
Wend

Func pauseset()
   $Pause = $Pause * -1
EndFunc

Func pause()
   While $Pause = -1
        Sleep(500)
   Wend
EndFunc

You might want it only to click if the active window is up

AdlibEnable("pause"); this keeps running at all times till you exit.

HotKeySet("^e","pauseset"); uses the CTRL+e key to change the value of $Pause
$Pause = -1

sleep(500)
While 1
clicker()
 sleep(1000) ; sleep for 1 second before repeating
Wend

func clicker()
if winactive("MyProgram") then mouseclick("left",1,1,1,1)
endfunc

Func pauseset()
   $Pause = $Pause * -1
EndFunc

Func pause()
   While $Pause = -1
        Sleep(500)
   Wend
EndFunc

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

Ah, your awesome, that's perfect. Thanks! :whistle:

- mech

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0