Can someone help me understand why this script goes crazy when I run it?
It is a looped script which includes a Left mouse click at one of 12 locations depending on the circumstances.
Fortunately, the click locations are evenly spaced vertically so I initially calculated the 12 vertical locations in a spreadsheet then pasted the exact cords for the 12 possible locations in the script. That way, I could simply remove a semicolon from one of the lines, to get the click location I wanted.
For example, the following script (which works great) executes the left-click at the 5th location (4610, 1171) each time it loops:
Code: Select all
F1::
;Sleep lengths:
short := 99
medium := 999
long := 2299
Loop, 68
{
CoordMode, Mouse, Screen
GoSub, CaptureNotepadLine ; includes activating notepad
;Click, 4610, 635 ; 1st field
;Click, 4610, 769 ; 2nd field
;Click, 4610, 903 ; 3rd field
;Click, 4610, 1037 ; 4th field
Click, 4610, 1171 ; 5th field
;Click, 4610, 1305 ; 6th field
;Click, 4610, 1439 ; 7th field
;Click, 4610, 1573 ; 8th field
;Click, 4610, 1707 ; 9th field
;Click, 4610, 1841 ; 10th field
;Click, 4610, 1975 ; 11th field
;Click, 4610, 2109 ; 12th field
Sleep, short
Send ^v
Sleep, short
;Click, 4565, 505 ; next entry
Click, 4385, 1895 ; create new entry
Sleep, short
}
Return
here:
Code: Select all
F1::
;Sleep lengths:
short := 99
medium := 999
long := 2299
;Position variables:
lower := 1915 ; vertical location of the bottom field
upper := 615 ; vertical location of the top field
difference := lower - upper ; pixel distance between top and bottom fields
denominator := 10 ; number of fields
increment := difference / denominator ; vertical distance between any two fields
xBase := 4460 ; horizontal position for each click
yBase := 590 ; vertical position for the middle of the top field
Loop, 68
{
CoordMode, Mouse, Screen
GoSub, CaptureNotepadLine ; includes activating notepad
;Click, %xBase%, %yBase%+0*%increment% ; click 1st field
;Click, %xBase%, %yBase%+1*%increment% ; click 2nd field
;Click, %xBase%, %yBase%+2*%increment% ; click 3rd field
;Click, %xBase%, %yBase%+3*%increment% ; click 4th field
Click, %xBase%, %yBase%+4*%increment% ; click 5th field
;Click, %xBase%, %yBase%+5*%increment% ; click 6th field
;Click, %xBase%, %yBase%+6*%increment% ; click 7th field
;Click, %xBase%, %yBase%+7*%increment% ; click 8th field
;Click, %xBase%, %yBase%+8*%increment% ; click 9th field
;Click, %xBase%, %yBase%+9*%increment% ; click 10th field
;Click, %xBase%, %yBase%+10*%increment% ; click 11th field
;Click, %xBase%, %yBase%+11*%increment% ; click 12th field
Sleep, short
Send ^v
Sleep, short
;Click, 4565, 505 ; next entry
Click, 4385, 1895 ; create new entry form
Sleep, short
}
Return
Thanks