Jump to content

[SOLVED] Applescript to play a song fails

Recommended Posts

I am using the 'Play song' from iTunes as a workflow. The debugger shows"


[2019-02-28 17:37:53][ERROR: input.scriptfilter] Code 1: filters/playsong.applescript: execution error: Not authorized to send Apple events to iTunes. (-1743)



I know this is an issue with Mojave and the new 'sandbox' security bubble they put around interacting with the OS; I just don't know how to give it access. Alfred is already enabled in the seurity section.


Any thoughts? 

SS  2019-02-28 at 5.45.44 PM.png

SS  2019-02-28 at 5.47.20 PM.png

Edited by billiesoniq

Share this post

Link to post

@billiesoniq scroll down past "Full Disk Access" in the Security & Privacy prefs, and under "Automation", make sure iTunes is ticked for Alfred.


macOS should have asked automatically for you to grant this access, but if you missed the popup, it may have been left unticked, preventing Alfred's access.




Share this post

Link to post

What do you do when trying to use iTunes.app in Catalina instead of Music.app? (For those of us who won't give it up: Retroactive)


I assume there's a way to force / trigger Alfred to ask for permission for other various apps (such as iTunes.app)? Sadly SizzlingKeys has still been an up and down ride (sometimes won't work at all) and so I'm left trying to use something like http://www.packal.org/workflow/itunes-seeking.

Share this post

Link to post
35 minutes ago, ylluminate said:

I'm just really wanting to control the full iTunes app via key combos.


You can do that, but you'll have to put it together yourself with Hotkeys and AppleScripts (from the link Andrew posted above).

Share this post

Link to post

Well I think that's what I essentially did - the problem, however, is that the automation permission is not being set in Preferences... only for Music.app (see this, Music.app is the only one and I can't add more manually).  I'm trying to figure out allow that script I noted above (com.tylast.itunesseeking) to actually execute. Note the screencast here wherein I show the hotkey activation of the script with the error / problem results below in the debug panel and then the source that's being used at the end:



And here is the skip-back script I noted from above here:

on alfred_script(q)
  tell application "iTunes"
	if player state is playing then
		--get the current track time:
		set currTime to get player position
		if currTime < 10 then
			--go to start of the track:
			set currSkip to 0
			--otherwise, skip backwards 
			set currSkip to currTime - 5
		end if
		set player position to currSkip --skip to new position
	end if
  end tell
end alfred_script



Share this post

Link to post

I don't know anything about Catalina (I don't have it and have no intention of installing it), but you shouldn't use "Run NSAppleScript". Put your scripts in a regular Run Script action with Language = /usr/bin/osascript (AS) instead.


Run NSAppleScript behaves weirdly sometimes, and it blocks Alfred, too. Don't use it unless you have a good reason to.

Share this post

Link to post

So you're saying that I should set up a new workflow that uses "Run Script" instead of "Run NSAppleScript"? So to do the following steps:

1) Workflows

2) Click "+" -> "Blank Workflow"

3) "[+]" (Set up Alfred Remote pages for this project)

4) "+" ("Add Remote Page")

5) Assign title, etc.

6) at grid, click "+" square and "Run Script" from menu.

7) select "/usr/bin/osascript (AS)" & insert script...


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.

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