Its2l82die Posted September 29, 2010 Posted September 29, 2010 (edited) Hi guys, My problem is a script which I don't really know how to write. I want to have a HotKeySet type of function that will run the function only when the key is pressed and when I let it go it will stop(using some kind of loop inside of course), rather than press key X and the function is running until X is pressed again, like so: HotKeySet("{1}","Single") Func Single () $1 = Not $1 EndFunc While 1 While $1 ControlSend($hwnd,"","","{F2}") Sleep(200) ControlSend($hwnd,"","","{F4}") WEnd WEnd And make the function be in a certain sleep mode if its possible(not the old "while 1 sleep(x) wend" type of thing), cause I cant be wasting valuable RAM resources. Thanks in advance, Its2l82die EDIT: Found my answer using {X Down} please close of delete this thread there is no more use in it, and sorry for opening it. Edited September 29, 2010 by Its2l82die
jebus495 Posted September 29, 2010 Posted September 29, 2010 (edited) Hi guys, My problem is a script which I don't really know how to write. I want to have a HotKeySet type of function that will run the function only when the key is pressed and when I let it go it will stop(using some kind of loop inside of course), rather than press key X and the function is running until X is pressed again, like so: HotKeySet("{1}","Single") Func Single () $1 = Not $1 EndFunc While 1 While $1 ControlSend($hwnd,"","","{F2}") Sleep(200) ControlSend($hwnd,"","","{F4}") WEnd WEnd And make the function be in a certain sleep mode if its possible(not the old "while 1 sleep(x) wend" type of thing), cause I cant be wasting valuable RAM resources. Thanks in advance, Its2l82die EDIT: Found my answer using {X Down} please close of delete this thread there is no more use in it, and sorry for opening it. You may also want to try the _IsPressed() function. Every key has a numerical value for use with the function. You can find the number for every key in the help file for the function. You could do something like this: While _IsPressed(55) ;DO SOME STUFF WHILE KEY IS PRESSED WEnd Loop begins when the key is pressed and loops until the key is released. Edited September 29, 2010 by jebus495
Its2l82die Posted September 29, 2010 Author Posted September 29, 2010 This one looks useful too, as it turns out HotKeySet("{1 Down}","Single") doesn't yield any result although it doesn't give any error either. I guess it's just the way that autoit is built, no using Hotkeyset with key down. I'll give your method a try, Thanks.
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