Jump to content

[SOLVED] Programmatically know if Alfred search box is open?


Recommended Posts

Hi,

I have a cron job using an external trigger to open Alfred's search box.
If the alfred search box is already open, it closes it and open a new one instead.
I'd like to "skip" a specific cron execution if Alfred's search box is already opened

Can I know if it's open programmatically / or through a component in the workflow?

Thanks

Link to comment

You can use AppleScript to ask System Events if Alfred has any windows:

tell application "System Events"
	repeat with _process in (processes whose name is "Alfred")
		return (count of windows of _process)
	end repeat
	return 0
end tell

If it doesn't return 0, Alfred's window is open.

Link to comment
12 hours ago, deanishe said:

You can use AppleScript to ask System Events if Alfred has any windows:


tell application "System Events"
	repeat with _process in (processes whose name is "Alfred")
		return (count of windows of _process)
	end repeat
	return 0
end tell

If it doesn't return 0, Alfred's window is open.

works - thank you :)

Link to comment
  • vitor changed the title to [SOLVED] Programmatically know if Alfred search box is open?

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...