SXGuy Posted January 18, 2007 Share Posted January 18, 2007 (edited) Can anyone tell me how can i set variables to each key send in a loop? basically, i want to be able to send x and y until a variable and then send z, repeat. $Wait is the variable for z. So for example, if $Wait is 4 seconds, i would want to send X and Y for 4 seconds, and then Z once, then repeat the loop. Ive included part of the script below, that i know would need to be changed GUICtrlRead ($Wait) While 1 Sleep(5) if $AL = 1 then send("x") if $AA = 1 then send("y") If $AS = 1 then send("z") EndIf WEnd Any ideas? Edited January 18, 2007 by SXGuy Link to comment Share on other sites More sharing options...
SXGuy Posted January 18, 2007 Author Share Posted January 18, 2007 Is there no one who can give any advice at all??? Link to comment Share on other sites More sharing options...
madmax Posted January 18, 2007 Share Posted January 18, 2007 Can anyone tell me how can i set variables to each key send in a loop? basically, i want to be able to send x and y until a variable and then send z, repeat. $Wait is the variable for z. So for example, if $Wait is 4 seconds, i would want to send X and Y for 4 seconds, and then Z once, then repeat the loop. Ive included part of the script below, that i know would need to be changed GUICtrlRead ($Wait) While 1 Sleep(5) if $AL = 1 then send("x") if $AA = 1 then send("y") If $AS = 1 then send("z") EndIf WEnd Any ideas? Yeah you can do it like so: For $i in myArray Send("{" & $i & "}") Next Link to comment Share on other sites More sharing options...
SXGuy Posted January 18, 2007 Author Share Posted January 18, 2007 i tried that, but it didnt work so well, either it sent whatever value my variable was along with the key, or it sent my variable in raw format.I need my variable to cause a delay in a keypress, but still maintain the loop of sending other keypresses.So if my script isWhile 1If A1 = 1 send ("x")If A2 = send ("Y")EndIfWEndAnd the delay variable i want to use is in GUICtrlRead ($Wait).As it stands, if i press the hotkey for x and y, it will send x and y together in a continously loop, which is fine, however, what if i want to make Y delay for a certain amount of time before it sends the key again BUT have x still being sent during that delay?ive tried using $Wait as a Sleep variable, but that will make all keys being sent, delay until the end of $Wait, and thats not what i want, ive tried jumping out of the while statment to another function of the hotkey for Y is pressed, and then using an expression there, but it still has the same effect. Link to comment Share on other sites More sharing options...
xcal Posted January 18, 2007 Share Posted January 18, 2007 (edited) So for example, if $Wait is 4 seconds, i would want to send X and Y for 4 seconds, and then Z once, then repeat the loop. Just answering to that part. HotKeySet('{esc}', 'quit') ;exit the script with escape HotKeySet('{F2}', 'toggle') ;toggle the action with F2 $doit = False $Wait = InputBox('', 'Enter time in seconds') While 1 While $doit $time = TimerInit() Do Send("x") Send("y") Sleep(50) Until TimerDiff($time) > $Wait * 1000 Send("z") WEnd Sleep(50) WEnd Func toggle() $doit = Not $doit EndFunc Func quit() Exit EndFunc edit - forgot a sleep() Edited January 18, 2007 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
SXGuy Posted January 18, 2007 Author Share Posted January 18, 2007 (edited) EDIT: i took what you suggested, and edited it, with a few things, and now works perfectly thanks for your help Edited January 19, 2007 by SXGuy Link to comment Share on other sites More sharing options...
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