MrBlack Posted August 26, 2011 Posted August 26, 2011 (edited) Hello, i made a simple script (which for me doesent look that simple) and im stuck. Basically the script should check some pixel and send some keystrokes, all i want is: to press Tab, send the keystokes untill pixel changes the color, when the color has changed to start over again from Tab. Here is the code i managed to put together from Autoit help: Global $Paused HotKeySet( "{F7}", "_TogglePause" ) Func _TogglePause() $Paused = Not $Paused While Not $Paused Sleep( 250 ) ToolTip( 'Script is "Paused', 0, 0 ) WEnd EndFunc While 1 If $Paused Then Send('{TAB down}') Sleep(1000) Send('{TAB up}') Sleep(1000) $test = PixelGetColor(439, 49) If $test == 0xF59053 Then Do Send('{2 down}') Sleep(3500) Send('{2 up}') Until @error Else EndIf EndIf wend it does what it supossed to do but only once and if i press F7 to pause it it doesent start again when i press F7, i think is something about EndIF. Thanks in advance, have a nice day. Edited August 26, 2011 by MrBlack
hannes08 Posted August 26, 2011 Posted August 26, 2011 Hello Mr. Black,your script may not leave the While ... Wend loop in your function.It would be better to display the tooltip in the main loop. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
MrBlack Posted August 26, 2011 Author Posted August 26, 2011 Hello Mr. Black,your script may not leave the While ... Wend loop in your function.It would be better to display the tooltip in the main loop.can you be more specific, im not even average user in Autoit?
hannes08 Posted August 26, 2011 Posted August 26, 2011 I changed your Script a bit: Global $Paused HotKeySet( "{F7}", "_TogglePause" ) While 1 If $Paused Then ToolTip( '', 0, 0 ) Send('{TAB down}') Sleep(1000) Send('{TAB up}') Sleep(1000) $test = PixelGetColor(439, 49) If $test == 0xF59053 Then Do Send('{2 down}') Sleep(3500) Send('{2 up}') Until @error ;<<<<<<<<<<<<<<<<<<<<<< EndIf Else ToolTip( 'Script is "Paused', 0, 0 ) EndIf Wend Func _TogglePause() $Paused = Not $Paused EndFunc Please have a look at the line marded with the "<<<<<<". Where should this @error come from? Maybe you should think again about your condition checks... Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
MrBlack Posted August 26, 2011 Author Posted August 26, 2011 (edited) I changed your Script a bit: Global $Paused HotKeySet( "{F7}", "_TogglePause" ) While 1 If $Paused Then ToolTip( '', 0, 0 ) Send('{TAB down}') Sleep(1000) Send('{TAB up}') Sleep(1000) $test = PixelGetColor(439, 49) If $test == 0xF59053 Then Do Send('{2 down}') Sleep(3500) Send('{2 up}') Until @error ;<<<<<<<<<<<<<<<<<<<<<< EndIf Else ToolTip( 'Script is "Paused', 0, 0 ) EndIf Wend Func _TogglePause() $Paused = Not $Paused EndFunc Please have a look at the line marded with the "<<<<<<". Where should this @error come from? Maybe you should think again about your condition checks... Can u give me a hint about how to set that "Until" the color is other than the one i selected, and after that to start from begining with Tab down...? Edited August 26, 2011 by MrBlack
MrBlack Posted August 26, 2011 Author Posted August 26, 2011 (edited) I made another try: Global $Paused HotKeySet( "{F7}", "_TogglePause" ) Func _TogglePause() $Paused = Not $Paused While Not $Paused Sleep( 250 ) ToolTip( 'Script is "Paused', 0, 0 ) WEnd ToolTip( "" ) EndFunc While 1 Send('{TAB down}') Sleep(1000) Send('{TAB up}') Sleep(500) ;$hp = "0xF59053" If PixelGetColor(439, 49) == "0xF59053" Then Do Send('{2 down}') Sleep(1000) Send('{2 up}') Sleep(3500) Until PixelGetColor(439, 49) <> "0xF59053" Sleep(200) EndIf WEnd Now it loops only the send Tab part. What im doing wrong? Is possible that PixelGetColor not to work? Edited August 26, 2011 by MrBlack
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