I'm scripting some pre-determined Clicks and Sends at a specific window.
Sometimes a click will not end up at the desired location, it may click on a different window and now all subsequent inputs from my script will be sent to the wrong window/location.
Here is the executing part of the code which I can't seem to make 100% consistent.
CoordMode, Mouse, Window
SetTitleMatchMode, 2
<!p::
Click, 60, 270
Send, %dp%{Tab}{Tab}{Tab}{Tab}%e1%{Tab}^a ; Plate thickness and layout
Send, %PLh% ; Plate Height
Click, 60, 130
Sleep 100
Click, 263, 45
Sleep 20
Click, 263, 45
Sleep 20
Click, 370, 48
Sleep 100
Click, %Mx%, %My% ; Bolt Diameters (M16: 40, 135) (M20: 40, 150) (M24: 40, 170) (M27: 40, 190) (M30: 40, 210)
Sleep 50
Click, 60, 160
Send, {Tab}{Tab}{Tab}%w1%{Tab}{Tab}^a ; Hor Bolt center distance
Sleep 50
Send, 0{Tab}^a ; Edge distance
Send, 0 ; Edge distance
Sleep 100
Click, 60, 190
Sleep 100
Send, {Tab}{Tab}%e3% ; Vert interm distance
Send, {Tab}{Tab}{Tab}{Tab}{Tab}%e2% ; vert outside bolt dist
Click, 60, 295
Sleep 100
Send, {Tab}%Stiff%{Tab}{Tab}{Tab}%Stiff% ; Stiffener thickness
Sleep 100
Click, 60, 320
Sleep 100
Send, %Weld%{Tab}{Tab}{Tab}%Weld%{Tab}{Tab}%Weld%{Tab}{Tab}%Weld%{Tab}{Tab}%Weld% ; Weld thickness
Return
If any of the clicks in this section of code result in activating an undesired window then I would like my script to stop and give a warning.
I could insert an If Winactive statement for every click, but that feels very inelegant to me, perhaps there is a better solution?
(I could also ask how to make this script more consistent which I've already tried to do by inserting Sleep commands, but that's a different question. The main culprit seems to be clicking drop-down boxes, but it's tough to determine that since I can't debug AHK code by running line-by-line)
Thanks in advance