Jump to content

Bug? Alfred Remote NSAppleScript (space)


Recommended Posts

Hi Guys,

 

when I run a Script in Alfred Remote that controls a submenu item the script doesn't work because of a space in the Menu Item.

Apple TV (Airplay) can't be selected.

 

When I run the script in OS X Script-Editor, the script works like expected.

 

Is this a Bug in Alfred?

 

Any idea how to make a workaround?

 

Thanks in advance.

on alfred_script()
activate application "Deezer"
tell application "System Events"
	tell process "Deezer"
		click menu item "Apple TV (Airplay)" of menu 1 of menu item "Output-Geräte" of menu 1 of menu bar item "Controls" of menu bar 1
	end tell
end tell
end alfred_script

NSAppleScript.png

Link to comment
  • 2 weeks later...

With all other Airplay Devices the script works. Also with the "Interne Lautsprecher" but they are also called "Standard" in the Script. I changed it to "Interne Lautsprecher (Eingebaut)" and it still works. It's strange. Only the "Apple TV (Airplay)" is not responding and not switching to it. 

Link to comment

That is weird.
 
Does "Apple TV (Airplay)" always work from Script Editor?
 
There's one more thing I can think of. Could you save the script from Script Editor. Save two copies, the first as File Format: Script and the second as File Format: Text. I've no idea what the German equivalent is, but the file extensions should be .scpt and .applescript respectively. Then try running these from Terminal with osascript myscript.scpt and osascript myscript.applescript.
 
My thinking is that AppleScripts behave differently depending on whether they're compiled (.scpt) or not (.applescript).

Link to comment

Really appreciate your support deanishe. Thanks.

 

Good point with the Script-Editor.. ;) 

 

It gives also an error back. Only with Apple TV

activate application "Deezer"
tell application "System Events"
	tell process "Deezer"
		click menu item "Apple TV (Airplay)" of menu 1 of menu item "Output-Geräte" of menu 1 of menu bar item "Controls" of menu bar 1
	end tell
end tell

 

error "„System Events“ hat einen Fehler erhalten: „menu item \"Apple TV (Airplay)\" of menu 1 of menu item \"Output-Geräte\" of menu 1 of menu bar item \"Controls\" of menu bar 1 of process \"Deezer\"“ kann nicht gelesen werden." number -1728 from menu item "Apple TV (Airplay)" of menu 1 of menu item "Output-Geräte" of menu 1 of menu bar item "Controls" of menu bar 1 of process "Deezer"

 

 

Doing as you recommend with the Terminal and .scpt and .applescript of course then I also get an error.

 

 

Daniels-iMac:~ Daniel$ osascript /Users/Daniel/Desktop/myscript.scpt

/Users/Daniel/Desktop/myscript.scpt: execution error: System Events got an error: Can’t get menu item "Apple TV (Airplay)" of menu 1 of menu item "Output-Geräte" of menu 1 of menu bar item "Controls" of menu bar 1 of process "Deezer". (-1728)

 

Daniels-iMac:~ Daniel$ osascript /Users/Daniel/Desktop/myscripttxt.applescript

/Users/Daniel/Desktop/myscripttxt.applescript:84:216: execution error: System Events got an error: Can’t get menu item "Apple TV (Airplay)" of menu 1 of menu item "Output-Geräte" of menu 1 of menu bar item "Controls" of menu bar 1 of process "Deezer". (-1728)

 

So maybe something is wrong with the Deezer App? Strange. 

Link to comment

It's strange that all the other outputs work, though.
 
There are a couple of things I can think of that might shed more light on it. This workflow allows you to search the active application's menus in Alfred. You could try that and see what it shows for "Airplay" or "Apple TV".
 
Also, if you have Xcode installed, there's an app called Accessibility Inspector in it (/Applications/Xcode.app/Contents/Applications/Accessibility Inspector.app).
 
Run that app, then hover over the "Apple TV (Airplay)" menu item in Deezer. Check what Accessibility Inspector shows. In particular, accessibilityTitle. It's possible that it's expecting a different name.

 

If that doesn't provide any useful information, I'm afraid I'm all out of ideas…

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