I am writing a script to help make my job a little easier as it often involves hundreds of click per account reviewed. Im trying to use ImageSearch to check for the location of a button that gets displaced if a notification appears.
The notification appears at the end of loop so it needs closed every loop. This is to help create a consistent work environment for the script as right now it has a decent chance to fail.
So basically:
If Button is in Location A continue with rest of script
If Button is in Location B Click Left to close notification then proceed with rest of script
Code: Select all
RunPCScript(FileName, FileContents) {
CoordMode, Mouse, Screen ; Set CoordMode to Mouse for MouseClick command
Loop, Parse, FileContents, `n ; Iterate through each line in the FileContents
{
if (GetKeyState("Esc", "P")) ; Check for the Esc key
break ; If ESC is pressed, break the loop
CurrentLine := A_LoopField ; Extract the current line
Clipboard := % CurrentLine ; Store current line to clipboard
If (Clipboard = "")
break ; Exit the loop if clipboard is empty
Sleep, 10
Click, left, 2250, 700
Send, {Home}
ImageSearch, ix, iy, 3235, 435, 3460, 500, %A_ScriptDir% "\Images\" AccountButton.png
If (ErrorLevel = 0) {
Click, Left, 3420, 418 ; Clicks the X to close the notification if Button is in shifted location
Sleep, 100
break
} Else If (ErrorLevel = 1) {
Loop {
Sleep, 100
ImageSearch, ix, iy, 3235, 375, 3450, 425, %A_ScriptDir% "\Images\" AccountButton.png
If (ErrorLevel = 0)
break
}
}
Sleep, 1000
Click, Left, 3400, 550 ; Clicks Add Button
Sleep, 250
Click, Left, 2900, 267 ; Clicks to open the Entry Field
Sleep, 250
Click, Left, 2900, 300 ; Clicks the Entry Field
Sleep, 250
Send, ^v ; Paste the current line
Sleep, 10
Loop ; Waits for the blue bar to appear to ensure line is correctly selected
{
PixelGetColor, color, 1000, 330
if (color = 0xB77A33) {
break
}
Sleep, 10
}
Send, {Enter} ; Press Enter to add the line to the account
Sleep, 100
Click, Left, 3623, 344 ; Clicks the Add Button
Sleep, 250
Send, {Enter} ; Press Enter to confirm the line will be added
Sleep, 10
}
}