Hi I am currently trying to speed up the following code
; Press Esc to terminate script, Pause/Break to "pause"
Global $Paused, $counter = 0
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d
;;;; Body of program would go here;;;;
While 1
$coord = PixelSearch( 1490, 720, 1776, 720, 0x202020, 0 )
If @error = 0 Then ;; if color found the do action
MouseMove($coord[0],$coord[1])
mouseclick("left")
Sleep(15)
Else ;; if not wait 5 secs and repeat
Sleep(1000)
EndIf
Wend
;;;;;;;;
Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip('Script is "Paused"',0,0, $counter, 1)
WEnd
ToolTip("")
EndFunc
Func Terminate()
Exit 0
EndFunc
Func ShowMessage()
MsgBox(4096,"","This is a message.")
EndFunc
the above "works" but I think that searching 4 specific pixels for 0x202020 rather than a range of pixels would be much faster? So I used Autoit window info to gather the following information
pixel1 1400, 530 0x202020
pixel2 1560, 530 0x202020
pixel3 1700, 530 0x202020
pixel4 1850, 530 0x202020
now with my basic knowledge I understand that using if/else I would need to set the pixelsearch to for the first location which seeing the correct pixel colour would click the mouse
While 1
$coord = PixelSearch( 1400, 530, 1400, 530, 0x202020, 0 )
If @error = 0 Then ;; if color found the do action
MouseMove($coord[0],$coord[1])
mouseclick("left")
Sleep(15)
Else ;; if not wait 5 secs and repeat
Sleep(1000)
EndIf
Wend
and if 0x202020 was not present at 1400, 530 it would then check 1560, 530 and if not present there it would check 1700, 530 and so on. looped
so I am guessing that that information would go in the else section but I am having trouble converting my thinking into correct code
Any help would be much appreciated.