Sorry but if you are going to do that, just use image snapshots to get who'sever coordinates from whatever location.
on a different note. Just use this:
; AutoClickTest
CoordMode, Mouse, Screen
MouseGetPos, xpos, ypos
xpos := xpos - 150
Gui, +AlwaysOnTop
Gui, Add, Checkbox, x40 y40 vChkState gAutoClickit, Auto-Click
Gui, Add, Text, w60 x20 y63 Left,Click Speed
Gui, Add, Edit, w150 x80 y60 vTimeBetweenSetsOfClicks, 8000
Gui, Add, Edit, w250 x20 y90, Test Data
Gui, Add, Button, x40 y120 w40 h30 Default, &Quit
Gui, Add, Button, x180 y120 w40 h30 gTestButton, &Test
Gui, Show, h200 w300 x%xpos% y%ypos%, AlwaysOnTop AutoClickTest
;TimeBetweenSetsOfClicks = ClickSpeed ; in milliseconds
NumberOfClicks = 1
MouseMovementTimeout = 2000 ; how long after mouse stops moving to start (in milliseconds)
Return
AutoClickit:
GuiControlGet, ChkState
if ChkState = 1
{
LastNoMove := A_TickCount
clickon = False
SetTimer, ChkMouse, 250
}
else
{
SetTimer, ChkMouse, Off
SetTimer, Clickit, Off
}
Return
ChkMouse:
GuiControlGet, TimeBetweenSetsOfClicks
MouseGetPos,x1,y1
x3 := x1 - x2
y3 := y1 - y2
if (x3 = 0 and y3 = 0)
{
NoMove := A_TickCount - LastNoMove
if NoMove >= %MouseMovementTimeout%
{
if clickon = False
{
clickon = True
Gosub, Clickit
SetTimer, Clickit, %TimeBetweenSetsOfClicks%
}
LastNoMove := A_TickCount
}
}
else
{
SetTimer, Clickit, Off
clickon = False
LastNoMove := A_TickCount
}
Sleep, 100
GuiControl,, Edit2, x1:%x1% x2:%x2% y1:%y1% y2:%y2% Click: %clickon%
x2 = %x1%
y2 = %y1%
Return
Clickit:
MouseClick, Left,,, %NumberOfClicks%
Return
TestButton:
SoundBeep
Return
ButtonQuit:
GuiClose:
ExitApp
The code is pretty old, lifted from the AHK forum about for 5 years ago after a Crystal Cove event damaged my fucking mouse button.
Never clicked a submit box repeatedly again...
For cruncher I adjust timer to 8000 <- milliseconds.
That gets it to repeat 10 times before closing.
Also, for your code, instead of sleeping 1000 and clicking left, which is pointless the UI is gray for about 70000
just 1 Sleep 6000 followed by a click...
if you need to keep clicking anyway, then I'd suggest a loop statement...
To get the cruncher coordinates:
ImageSearch answerX, answerY, 0, 0, A_ScreenWidth, A_ScreenHeight, ./CruncherImage.png
if (ErrorLevel = 2) {
MsgBox Could not conduct search for the cruncher. You are an idiot and did not create the image or rename it in this script.
} else if (ErrorLevel = 1) {
MsgBox The cruncher is NOT on the screen... Retard...
} else {
answerX := answerX-10
answerY := answerY-5
MouseMove %answerX%, %answerY%
Click 1
}
And let's not forget, the image of the cruncher needs to be smaller then the cruncher, and if you do the search the coordinates of the image search should be matched up the the approximate location of the inventory - that to avoid clicking the cruncher if it's been placed in the bag.
Why smaller then the square of the menu? because the fucking menu puts a green halo on shit when it drags it out of bags or considers it "new"... Same fore cards.