Jump to content

Alfred applescript does something different than when executed with keyboardmaestro


Recommended Posts

Posted (edited)

As the title says, I noticed this odd behavior. I am trying to execute the following applescript: 

 

tell application "System Events"
	set frontApp to first application process whose frontmost is true
	set frontAppName to name of frontApp
	
	tell frontApp
		tell menu bar 1
			tell menu 1 of menu bar item frontAppName
				tell menu item "Services"
					tell menu "Services"
						click first menu item whose name contains "My Item"
					end tell
				end tell
			end tell
		end tell
	end tell
end tell

 

When executed with keyboard maestro (hotkey) or the script editor, it does exactly what I expect: Search for a menu item under Services and click it. 

However, when doing the same in alfred (also hotkey, tried main thread and through 'run script'), the 'Edit' menu item just flashes shortly and that's it. 

 

Anyone an idea why this happens? 

Edited by dvcrn
Posted

No, but I wouldn't use that script to do what you're doing.  I would just set a keyboard shortcut within macOS for that particular service.  You don't need to use Keyboard Maestro or Alfred or UI scripting.

Posted
16 hours ago, CJK said:

No, but I wouldn't use that script to do what you're doing.  I would just set a keyboard shortcut within macOS for that particular service.  You don't need to use Keyboard Maestro or Alfred or UI scripting.

 

I personally don't like how macOS manages shortcuts and the lack of sync is a little annoying so I rather have my script collection that can go from simple things, to more complex actions that link different apps if needed.

 

A variation of the script above for example is part of a automation that chains different services together, like sending a piece of text to a few apps instead of just one

Posted

Hello @dvcrn,

 

We can’t properly help you without access to your Workflow.


Debugging can already be hard with access to the code, and you’re asking us to guess yours from a description. There are multiple places where your code or Workflow setup may be going wrong. Without looking at it we’re shooting in the dark, which is a waste of time for everyone involved (including you).


Read the Reporting Problems with Workflows topic, as it gives a nice overview on how to build an effective report.

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