Applescript QuickTime pro save export settings - macos

I am trying to save export setting of Quicktime movie to a file using AppleScript. This is my code:
set file2save to (choose file name default location (path to desktop) default name "setting.qtes")
tell application "QuickTime Player 7"
tell document "video.mov"
save export settings for QuickTime movie to file2save
end tell
end tell
But I get error "QuickTime Player 7 got an error: An error of type -2107 has occurred." number -2107
This error occurs on the "save export settings" line...
What am I doing wrong?
Thanks.
Here's the screenshot:

as far as I can tell the problem is that functions is no longer supported can't find anything regarding it in the dictionary
still wasn't working for me but I foundthis thread which looks like it may help

This works for me. You can see that I got the doc name from Quicktime to make sure it was correct, so your problem is with the document name. Note that if the movie is frontmost then you can also use terms like "tell first document".
set file2save to (choose file name default location (path to desktop) default name "setting.qtes")
tell application "QuickTime Player 7"
set docName to name of first document
tell document docName
save export settings for QuickTime movie to file2save
end tell
end tell

Related

How could I use applescript to play keynote slids?

everyone
I try to use applescript to play my keynote slid,but occure error
set thisFile to "/Users/usrname/Desktop/cardtest.key"
tell application "Keynote"
activate
open thisFile
start thisFile from the first slide of thisFile
end tell
this code will open keynote file successfully,but can't run slids.
the error was keynote error : can't make "path" become type "document".
I tried to use:
tell slideshow 1
but another error: slideshow should be the end of sentence, should not have 1.
have no idea why.
You are going to start a POSIX path rather than a Keynote document.
This is exactly what the error is telling you.
You have to use the reference to the opened document
set thisFile to "/Users/usrname/Desktop/cardtest.key"
tell application "Keynote"
activate
set currentDocument to open thisFile
tell currentDocument to start from first slide
end tell

Simple Applescript - Quicktime Issue Play Song

I'm trying to do a very basic thing using Applescript but I'm having trouble. I am trying to create a very simple Applescript to just open a plain vanilla MP3 file on my desktop with QuickTime Player.
I want to use QuickTime and have it open so user can control it etc.
The basic problem is that the file name or folder path seems to be sometimes randomly causing problems especially when it has spaces in the name or the path folder names etc.
If I double click on any file they all open in QuickTime.
I created a very basic short audio file and saved it with a few different names like:
test1.mp3
test 1.mp3
this is a test.mp3
Then I created this very simple Applescript below.
generally = test1.mp3 will almost always open and start playing, however the other Versions with spaces in the title often produce and error (open thesong line fails i think) like:
The document “test1.mp3” could not be opened.
The file isn’t compatible with QuickTime Player.
error "QuickTime Player got an error: Can’t get document 1. Invalid index." number -1719 from document 1
think this is because it can't open the file.
Any help would be appreciated.
Applescript ...
tell application "Finder"
--varied attempts like this...
set thesong to "drive:Users:me:Desktop:music:test1.mp3" as string
set thesong to "drive:Users:me:Desktop:music:test1.mp3"
set thesong to "drive:Users:me:Desktop:music:this is an audio test.mp3" as string
set thesong to "drive:Users:me:Desktop:test1.mp3" as string
end tell
tell application "QuickTime Player"
activate
open thesong
play document 1
end tell
Also I tried adding delays thinking that QuickTime needed time to open before open / play song - but still have random fails...
tell application "QuickTime Player"
activate
delay 3
open thesong
delay 3
play document 1
end tell
The Finder is not needed and the delays are not needed either.
Assuming the file is on the desktop create a relative HFS path and add the alias keyword after the open command
set theSong to (path to desktop as text) & "test1.mp3"
tell application "QuickTime Player"
activate
set activeDocument to open alias theSong
play activeDocument
end tell
If the file is in the folder music on the desktop the path is
set theSong to (path to desktop as text) & "music:test1.mp3"
In AppleScript, there are differences between a string, a POSIX file («class furl») , and an alias.
When you do set thesong to "drive:Users:me:Desktop:music:test1.mp3" as string that creates a string, which is just plain text. QuickTime Player's open command requires either a POSIX file or an alias, which is why you get an error message (it doesn't know what to do with a plain text string).
While you ultimately need to end up with a POSIX file or alias, you can start with a string and then coerce it to the type you want.
Either of the open commands below should work:
set posixFile to "/Users/you/Desktop/file.mp3" as POSIX file
set aliasFile to ":Users:you:Desktop:file.mp3" as alias
tell app "QuickTime Player"
set theDoc to open posixFile
-- or set theDoc to open aliasFile
play theDoc
end tell

Can't set Desktop Background on Mac with AppleScript

I am trying to set the Desktop Wallpaper of my Mac(Running latest version of Catalina). But I keep getting this error message when trying to run my apple script.
error "System Events got an error: Can’t set file \"Library:Desktop Pictures:Ink Cloud.jpg:\" of current desktop to file \"Library:Desktop Pictures:Ink Cloud.jpg:\" of current desktop." number -10006 from file "Library:Desktop Pictures:Ink Cloud.jpg:" of current desktop
here is my code
tell application "System Events"
tell current desktop
set picture rotation to 0
set picture to file "Library:Desktop Pictures:Ink Cloud.jpg:"
end tell
end tell
I've been able to change all the other properties of the Desktop except the actual photo. I also tried using / for the file path. I have tried different file paths. But still not luck. Any help or advice would be greatly appreciated.
Running the code
tell application "System Events"
set currentPicturePath to picture of current desktop
end tell
reveals that the path is supposed to be a (slash separated) POSIX path
tell application "System Events"
tell current desktop
set picture rotation to 0
set picture to "/Library/Desktop Pictures/Ink Cloud.jpg"
end tell
end tell
Your (colon separated) HFS path contains two mistakes:
An HFS path (unlike the POSIX path) starts always with a disk name.
Only references to folders and packages have a trailing colon.

AppleScript to launch and loop a video?

I need to write an AppleScript so that it will open QuickTime Player, play the movie from the specific file, and set it to loop in full screen. Help please I am a noob at writing AppleScripts.
This is what I have so far but it does not seem to work. :(
tell application "QuickTime Player"
open file "Macintosh HDN:Users:lalayana:Downloads:TV Master Keynote.m4v"
set the looping of movie 1 to true
play movie 1
end tell
The easiest way to do it is probably to assign the value returned by open file to a variable, and then tell that variable (that is, tell that movie) to do what it needs to do.
tell application "QuickTime Player"
set theMovie to open file "Macintosh HDN:Users:lalayana:Downloads:TV Master Keynote.m4v"
tell theMovie
set the presenting to true
set the looping to true
play
end tell
--use this to see what properties can be modified
--get the properties of theMovie
end tell
You can uncomment get the properties of theMovie to see what properties are available to modify.
If that doesn’t work for you, you’ll also need to specify exactly what you mean by “it does not seem to work”. That is, what error occurs, if an error occurs, or what happens differently than what you expect. I’ve verified that the above does work with a movie on my end.
I just had this problem and the solution above did not work for my apple computer, so I modified the script to get it to work. I wanted to the script to launch on boot, which I accomplished by going to System Preferences -> Users -> Login Items.
tell application "QuickTime Player"
set theMovie to open file "Users:danielmcclane:Downloads:startvideo.mov"
tell theMovie
set the looping of theMovie to true
set the present of theMovie to true
play
end tell
end tell
This worked for me. I use it to play video art pieces at the museum I work at. It works.
tell application "QuickTime Player"
activate
open alias "Users:ebowen:Desktop:MOUND_1.32GB_h264.mov"
play the front document
end tell
tell application "System Events" to tell process "QuickTime Player"
set frontmost to true
tell menu bar item 5 of menu bar 1
click menu item "Enter Full Screen" of menu 1
click menu item "Loop" of menu 1
end tell
end tell

How can I get the currently open file's path in photoshop (cs5) with applescript?

How can I get the currently open file's path in photoshop (cs5) with applescript?
I'm using CS5 on Mac OSX 10.7
I've tried the answer below and it gives the following error in the Applescript Editor:
error "Adobe Photoshop CS5 got an error: Can’t get document 1.
Invalid index." number -1719 from document 1
UPDATE: I have tested the code below in CS5 and Mac OS 10.7 and can confirm that this works even with a simple switch of tell application "Adobe Photoshop CS4" to tell application "Adobe Photoshop CS5". The error that you are getting is the result of there either not being a document open in the first place since you are targeting document 1. You can easily check for this with the following:
tell application "Adobe Photoshop CS5"
set documentCount to count documents
if documentCount > 0 then
set theDocument to document 1
set theFilePath to file path of theDocument
return theFilePath
else
-- no documents open. what to do?
end if
end tell
OLD ANSWER: I don't have CS5 (yet), but here it is for CS4, and I imagine CS5's version won't be too different, if at all, since Adobe has done a good job normalizing the API since CS3:
tell application "Adobe Photoshop CS4"
set theDocument to document 1
set theFilePath to file path of theDocument
return theFilePath
end tell
--> Result: Macintosh HD:path:to:file:filename.ext

Resources