Jump to content

Clicking a popup window button with applescript

Recommended Posts

Hi folks,


I've read several threads here where people report having issues with pop-up windows.

I'm new to Alfred/Alfred remote so I don't know yet how to put this into an automized Alfred command, but I have successfully solved this with a few AppleScript lines, startet via Automator.

So if you can execute Applescript code via Alfred, this should work as well.


This is what I've done (Explanation follows after the code lines):

tell application "System Events" to tell process "yourProcess"
	set frontmost to true
	delay 0.2
	click button "Akzeptieren" of window 1
end tell

I used this to start an App that always pops up with an annoying popup window that you can't get rid of. So instead of launching the app, I launch the Automator program which launches my App and then sends the popup into Nirwana with these Applescript lines ;-)


This approach is based on the UI accessibility control features of "SystemEvents" (you need to turn Accessibility on in security settings. 


Downside of this is that you need to know the logical names of the UI Elements (here name of the button "Akzeptieren" and name of the window "1"), that you can figure out via Xcode / Open developer tools / Accessibility Inspector.


And instead of "yourProcess" you have to fill in your app's name...


Some effort for  getting it right, but then it works like a charm...


I hope that my ideas help you out.


If anyone could point out to me quickly how I embed this into Alfred remote, I'd be happy too...






Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...