Hello I am using this Apple script in Automator to auto launch and play in full screens video using quick time.
tell application "QuickTime Player"
set theMovie to open file "Users:ronaldwise:Movies:Jarvis Startup.mp4"
tell theMovie
set the presenting to true
set the looping to false
play
end tell
end tell
The Script runs just fine when I press play in automator however, when I try and start the automation application outside of automator I receive this Message.
"The action "Run AppleScript" encountered an error "Not authorized to send Apple Events to QuickTime Player"
My Automation workflow looks like this
Workflow screenshot
I have allowed access to Security privacy > Accessability to the following apps: Terminal, Consul, AEServer, Automator, Consul, and Quicktime player.
I have allowed access to Security Privacy>Full Disk Access to the same above listed programs.
I have allowed access to Security Privacy > Automation to the following: Automator>QuickTime Player and Terminal>Finder
I am at a loss any help please.
The error has nothing to do with Accessibility and Full Disk Access
You have to add the key NSAppleEventsUsageDescription in Info.plist of the script application.
Open the application package in Finder with Right-click > Show Package Contents, then open the Info.plist file in Contents with a text editor and insert
<key>NSAppleEventsUsageDescription</key>
<string>Jarvis needs to control QuickTime Player</string>
The position of the key value pair is irrelevant but it must not follow directly a key line.
Related
Was wondering if there is any way to run a small piece of apple script when I launch an application on OS X?
I have a hard-drive which need to be mounted in order for the app to run right. I did this apple script already:
on run
try
do shell script "diskutil mountDisk disk2"
delay 3
tell application "Application"
run
end tell
on error
tell application "Application"
quit
end tell
set question to display dialog "Error." buttons {"OK"}
set answer to button returned of question
if answer is equal to "OK" then
close
end if
end try
end run
But even tho this works great and the hard-drive spins up before the app starts.
I would like to add the diskutil mountDisk disk2 and delay directly in front of the real application when its starting so I can double click files for that app say in my downloads folder. Which will run the script before it opens the clicked file in the app. So I wont have to start the application with another application each time i download a new file for it. Is this even possible?
Shortly:
It's not possible unless the application itself supports some inhook and outhook functionality.
How can I prevent an Apple Script application from crashing whenever the computer logs out or goes to sleep?
I'm currently working on an application that sets the desktop background to the album art of the current song playing in iTunes, however if I put my display to sleep, iTunes will continue to play music but my application will crash, meaning that the desktop background is no longer updating when I return to the computer.
This is the code I'm using to set the wallpaper:
tell desktop 2
set picture to fileName
end tell
where fileName is name of the iTunes artwork of the current song, which has been extracted and saved to the desktop.
It says desktop 2 as I have two different applications for each screen, and conduct testing on my 2nd screen.
This is the error I get when running in Automator and putting the display to sleep:
The action “Run AppleScript” encountered an error.
System Events got an error: Can’t get desktop 2. Invalid index.
I am getting the same results on my primary display also.
How can I stop this script from encountering an error when the display is asleep?
Any suggestions would be greatly appreciated, as I'd love anyone who wants it to have this application.
The safest way is to check if the item exists
if exists desktop 2 then
tell desktop 2
set picture to fileName
end tell
end if
or wrap the code in a try block which ignores any error.
try
tell desktop 2
set picture to fileName
end tell
end try
Every time i open this specific script, other applications open with it and i haven't even clicked on run. Applications like Appstore and system information open, and they are only mentioned in the script once, halfway through:
tell application "Grab" to quit
tell application "Network Utility" to quit
tell application "System Information" to quit
tell application "Terminal" to quit
tell application "Keychain Access" to quit
tell application "Disk Utility" to quit
tell application "Bluetooth File Exchange" to quit
tell application "Boot Camp Assistant" to quit
tell application "AirPort Utility" to quit
tell application "Activity Monitor" to quit
tell application "App Store" to quit
tell application "iTunes" to quit
Why does this happen?
When you open the script in script editor, it will open all necessary apps in order to load their library terminology. It has always operated this way. It's especially annoying when you open someone's script that has tell blocks to apps that you don't have installed.
This does not answer the question because you already have the answer.
But, here's how to not open these applications when you want to edit the script.
Just put the application name in a variable.
set appNames to {"Grab", "Network Utility", "System Information", "Terminal", "Keychain Access", "Disk Utility", "Bluetooth File Exchange", "Boot Camp Assistant", "AirPort Utility", "Activity Monitor", "App Store", "iTunes"}
repeat with tName in appNames
quit application tName
end repeat
An AppleScript can’t tell an app to do something if that app is not running. So if a script includes a “tell” statement that targets a specific app, that app has to run along with the script. It’s the same as invoking a PHP library function in a PHP script. If you use a strpos function in a PHP script, then that PHP script can’t run without strpos also running.
This is by design because the purpose of AppleScript is to create workflows that include multiple apps working in concert on a specific task. AppleScript itself has almost no built-in functionality — your AppleScripts get their functionality from Mac apps, Unix apps, and network services.
In the script you’re working with, you can comment-out those lines (put two dashes in front of each line) if you know that those apps will not be running, because all it is doing there is telling those apps to Quit. That AppleScript is not using those apps for any real functionality.
I have a habit of working/studying while listening to music. And since the Mac I am connected to at work doesn't have all the songs I want, I normally listen to the songs via iTunes from the iPhone Playlists option.
For this, everytime I connect my iPhone to the computer, iTunes detects it, then I have to manually goto the 'iPhone' button in the application, and then "On my iPhone", and then select the playlist, and play a song.
Is there anyway of automating this process ? What I'm looking for, is as soon as I connect my iPhone, iTunes should open the playlist inside my iPhone automatically, and start playing a song at random.
I've tried automating it with Automator. But that doesn't seem to be working. There's something wrong I'm doing in AppleScript ::
tell application "iTunes"
play playlist named "Sasha" of source of type iPhone
end tell
Ha !! I figured it out !! And then I created an applet that would do this for me using AppleScript.
And then, I published the steps/code for the same on my blog below. Here's the link ::
Explanation of Code :: How to start playing songs from your iOS device automatically on your Mac
And the code for the same ::
tell application "iTunes"
set theCurrentPlaylist to view of front browser window
set myiPhone to some source whose kind is iPod
set mainPhonePlaylist to playlist "Sasha" of myiPhone
set the view of the front browser window to mainPhonePlaylist
set EQ enabled to true
play playlist named "Sasha" of myiPhone
set myRandomSong to random number from 1 to count of tracks of (get view of front window)
play track myRandomSong of mainPhonePlaylist
end tell
I'm trying to get remove mouse events working and I'm attempting to use this little script:
set machineB to "eppc://user:pw#myothermac.local"
tell application "Finder" of machine machineB
say "Hello This is so stupid"
end tell
tell application "System Events" of machine machineB
click at {100, 100}
end tell
The script say's fine, but throws the following error:
error "System Events got an error: Can’t continue click." number -1708
–1708 <reference> doesn’t understand the <commandName> message.
What am I doing wrong? I can use it to "click" on my own machine (at least it doesn't throw errors)?
[Edit]
this is related to my other question here.
You can't do this. Applescript and its tell blocks work in the context of the Mac running the application; you can send commands to the Finder on your home Mac because you are running it, but you can't send commands to the instance of Finder on a target Mac. If you are able to run an application located on the target machine from your home Mac, then the application will behave as if it is being run on the home Mac.
If you are looking to do complex remote actions, then I suggest Apple Remote Desktop or another similar method.