Jump to content
dvcrn

Alfred applescript does something different than when executed with keyboardmaestro

Recommended Posts

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

Share this post


Link to post

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.

Share this post


Link to post
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

Share this post


Link to post

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.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...