Jump to content

AppleScript Workflow Help -- Clicking missing menubar items (Hubstaff)


Recommended Posts

I am trying to get the time tracking service Hubstaff (http://www.hubstaff.com) to "Start Working" when I type in hubstaff. Here's my script:

on alfred_script(q)
tell application "Hubstaff" to activate
	tell application "System Events"
		tell process "Hubstaff"
			click menu item "Start Working"
		end tell
	end tell
end tell
end alfred_script

I think the issue is that I'm not finding the proper menu. When I select Hubstaff, it doesn't activate it's own items on the menu bar. Rather, you access Hubstaff using it's icon in the menubar. How do I reach that menu with AppleScript?

 

Thanks for your help!

Link to comment
  • 4 years later...
on clickDockMenu(theMenuItem)
  tell application "System Events"
	tell process "Dock"
	  tell UI element "Hubstaff" of list 1
	    perform action "AXShowMenu"
		tell menu "Hubstaff"
		  tell menu item theMenuItem
			perform action "AXPress"
		  end tell
		end tell
	  end tell
	end tell
  end tell
end clickDockMenu
clickDockMenu("Start Working")

This clicks "Start Working" in Hubstaff's menu from the Dock. Under the right circumstances, it should give you what you want.

 

@Obed

Edited by Dattwood
Link to comment

 

List of valid parameters when calling clickDockMenu:

["Hubstaff", "Start Working", "Add Note", "Hide Timer", "Projects", "Sign Out", "Open Dashboard", "Add/Edit Time", "Report an Error", "Help Center", "About Hubstaff", "Preferences…", "Check for Updates...", "Options", "Show All Windows", "Hide", "Hide Others", "Quit "Force Quit"]

 

Example calls:

clickDockMenu("Preferences…")
clickDockMenu("Start Working")
clickDockMenu("Add Note")

 

Notes:

  • This list can be seen by right-clicking Hubstaff's icon in the Dock.
  • Hubstaff should be running before the call is made.
Edited by Dattwood
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...