I have written this script function
on GetWindowLocation()
set front_app to (path to frontmost application as Unicode text)
tell application front_app
item 1 of (get bounds of front window)
end tell
end GetWindowLocation
on GetDockStatus()
tell application "System Events" to get the autohide of the dock preferences
end GetDockStatus
if I am on the desktop with no windows up it errors.
How can I check if a window is on screen, so I can put an if statement to not
run it if a window is not on the screen.
Probably the easiest fix here would be to simply catch the error:
You could also try checking the
count of windowsbefore trying to reference thefront window, but that’s somewhat more prone to errors (as the window may disappear before you grab its bounds).