The script runs a product export from LightSpeed POS every night, except it’s now broken. It worked for more than two years.
on ShtWait(ProcName, WndwName, btnName, DelayTime)
do shell script "logger -t 'EXPORT-PRODUCTS' 'Sheet Wait '" & WndwName & " Button " & btnName
log "Sheet Wait " & btnName
tell application "System Events"
tell application process ProcName
set ShtFound to false
repeat while ShtFound is false
if button btnName of sheet of window WndwName exists then
set ShtFound to true
end if
log DelayTime & " second delay"
delay DelayTime
end repeat
end tell
end tell
end ShtWait
tell application "System Events"
tell application process ProcName
tell button btnName of sheet of window WndwName
perform action "AXPress"
end tell
end tell
end tell
The Reply is
tell application “System Events”
exists button “Replace” of sheet of window “Save Export” of application process “Lightspeed”
→ true
(1, second delay)
perform action “AXPress” of button “Replace” of sheet of window “Save Export” of application process “Lightspeed”
→ error number -1708
Result:
error “System Events got an error: action "AXPress" of button "Replace" of sheet of window "Save Export" of application process "Lightspeed" doesn’t understand the “perform” message.” number -1708 from action “AXPress” of button “Replace” of sheet of window “Save Export” of application process “Lightspeed”
So the button exists, but I can’t press it.
I use the same basic procedure several times in this script, and it continues to work. The only obvious difference is the
button Y of sheet of window X
In every other case, it’s
button Y of window X
on BtnClick(ProcName, WndwName, btnName)
do shell script "logger -t 'EXPORT-PRODUCTS' 'ButtonClick '" & WndwName & " Button " & btnName
log "Button Click " & WndwName & " " & btnName
set DelayTime to 3
set btnFound to false
tell application "System Events"
tell application process ProcName
repeat while btnFound is false
if button btnName of window WndwName exists then
log "Delay " & DelayTime & " to check button " & btnName & " again, then press"
set btnFound to true
delay DelayTime
tell button btnName of window WndwName
perform action "AXPress"
end tell
end if
end repeat
end tell
end tell
end BtnClick
Unfortunately, it takes over an hour to run the export, and I don’t know how to otherwise get that
button of sheet of window
This worked up until the upgrade to El Capitan. I don’t know what changes occurred. I know it broke some other folk’s scripts. I find that logging to the console usually helps me with debugging.
Any ideas?