Malacant Posted April 9, 2008 Posted April 9, 2008 Ok, so I have been using AutoIt scripts for a long time now, but never got to writing my own. I decided that I would give it a try. Basically what the script does that I am working on is moving an item, clicking a button and repeating. The second script is scanning a pixel, once it changes, clicking it. They both are working, but I would like to have a loop in it so I wouldn't have to keep clicking the hotkeys. Script for moving the item: Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{HOME}", "Terminate") While 1 Sleep(100) WEnd Func TogglePause() MouseMove (470, 345, 4) MouseClick ("Left") MouseMove (377, 352, 4) MouseClick ("Left") MouseMove (320, 458, 4) MouseClick ("Left") EndFunc Func Terminate() Exit 0 EndFunc Script for scanning the pixel: HotKeySet("{HOME}","_end") HotKeySet("{PAUSE}","_start") While 1 Sleep(100) WEnd Func _start() $a = PixelGetColor(374,249) Do Sleep(10) $b = PixelGetColor(374,249) Until $a = $b MouseClick("left",320,458,1,1) TrayTip("","",1) EndFunc Func _end() Exit 0 EndFunc As you can see I have to hit the hotkey to perform the function, which is fine, but I would like to know how I could make it loop by hitting a button. Like, if I hit the hotkey, it will continue looping until I hit it again. Any help would be appreciated Thanks in advance! -Malacant
Squirrely1 Posted April 9, 2008 Posted April 9, 2008 (edited) Malacant - welcome to the AutoIt forums. This looks like it would work for your first example: HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{HOME}", "Terminate") Global $tog_switch = False While 1 Sleep(60) WEnd Func TogglePause() If Not $tog_switch Then HotKeySet("{PAUSE}", "SwitchToggle") While Not $tog_switch MouseMove(470, 345, 4) MouseClick("Left") MouseMove(377, 352, 4) MouseClick("Left") MouseMove(320, 458, 4) MouseClick("Left") WEnd EndIf EndFunc ;==>TogglePause Func SwitchToggle() $tog_switch = Not $tog_switch EndFunc ;==>SwitchToggle Func Terminate() Exit 0 EndFunc ;==>Terminate Edited April 9, 2008 by Squirrely1 Das Häschen benutzt Radar
Malacant Posted April 9, 2008 Author Posted April 9, 2008 Thank you Squirrely1 I was able to take what you showed me in my first example and use it for my second script also. Both work great now! Thanks again. -Malacant
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