Drew Posted February 1, 2008 Posted February 1, 2008 Alright. What I'm doing, is writing a program that will repeatedly click the left mouse button continuously until I press the same hotkey to turn it off. In the script, I press ` to begin clicking. When I press ` , I want it to keep clicking until I press it again. Here's what I have so far, but I can turn off the clicking without hitting TAB to close the program. I've run out of ideas on this. HotKeySet('{tab}', '_Exit') HotKeySet('`', '_HotKey') While 1 $mousepos = MouseGetPos() wend If @error Then $Error = 1 Else $Error = 0 EndIf $mousepos = MouseGetPos() Func _HotKey() While 1 MouseClick( "left") WEnd EndFunc Func _Exit() MsgBox( 0, "Thanks!", "This will close the program.") Exit EndFunc
Drew Posted February 1, 2008 Author Posted February 1, 2008 would it work somehow with a different loop?
Achilles Posted February 1, 2008 Posted February 1, 2008 HotKeySet('{esc}', '_Exit') HotKeySet('`', '_HotKey') $clicking = False While 1 Sleep(200); IMPORTANT <- without this line your script would use 100% cpu usage If $clicking then MouseClick( "left") wend Func _HotKey() $clicking = Not $clicking EndFunc Func _Exit() MsgBox( 0, "Thanks!", "This will close the program.") Exit EndFuncWhy do I always decide to help people when I should be doing homework? Ask if you have any questions about the code... My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Drew Posted February 1, 2008 Author Posted February 1, 2008 Very interesting way of going about it. I understand how it works, but I don't fully understand WHY it works that way. ( If you get what I mean. ) What exactly does this part mean: $clicking = NOT $clicking and how does it link $clicking to MouseClick()
Drew Posted February 1, 2008 Author Posted February 1, 2008 I just tried the script out , works great. Thanks a ton man.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now