applescript

Use string variable as Applescript command argument

陌路散爱 提交于 2021-01-28 07:25:00
问题 I'm trying to do the following: on cleanup(x) tell application "Finder" clean up window 1 by x end tell end cleanup cleanup("name") However since x variable is a string, the clean up command doesn't accept it and exits with error. Is there a way to convert the string to something that the commands accepts or some other solution to unquote the variable without using if, else statements like this: on cleanup(x) tell application "Finder" if x is "name" then clean up window 1 by name end if end

Photoshop rename to layer name

故事扮演 提交于 2021-01-28 07:01:14
问题 I need a script to choose a folder, open the Photoshop files in the folder, then rename the files to the current name of layer plus the file extension. (Each of the layers will be named differently as the images have been created with a data merge. All I have so far is opening one image and getting the layer name, I can't figure out the repeat and the rename of the file: set inputFolder to choose folder tell application "Finder" set filesList to files in inputFolder set myDoc to item 1 of

Rename window title in OS X with AppleScript or terminal

允我心安 提交于 2021-01-27 18:19:34
问题 I'm trying to change a window title with AppleScript but I've no success. tell application "Finder" to set name of window "oldWinName" to "newWinName" Also tried call method "setTitle:" of (window "oldWinName") with parameter {"newWinName"} Any ideas out there? Regards 回答1: window of which application? eg, for terminal.app tell application "Terminal" set custom title of window 1 to "hello world" end tell or, for textedit.app tell application "TextEdit" set name of window 1 to "hello world"

Applescript play music from iTunes URL

有些话、适合烂在心里 提交于 2021-01-27 11:48:58
问题 The following script will open a track in iTunes use application "iTunes" property trackURL : "itmss://itunes.apple.com/us/album/brahms-violin-concerto-in-d-major-op-77-iii-allegro/145533236?i=145533044&uo=4" open location trackURL Now, asking "iTunes" to play it does not work because the track is highlighted but not properly selected, i.e., it requires a manual mouse click to select it and play it. How can I select the highlighted track? Or how could I ask "iTunes" to play the song?!

Why doesn't this simple applescript work any more in ML mail.app (as a rule)

时间秒杀一切 提交于 2021-01-24 10:57:23
问题 It works only when you right click on the mail message and choose "run rules", but not on incoming messages (without interaction). The first dialog is shown both when incoming or running manually, but the second dialog (with the id) is only shown when running manually. Nothing is shown in console.log Any ideas? using terms from application "Mail" on perform mail action with messages theMessages for rule theRule tell application "Mail" repeat with theMessage in theMessages display dialog

OSX Associate a shell script with a file extension?

自古美人都是妖i 提交于 2021-01-22 03:53:25
问题 I want to associate the .exe file extension with a shell script that launches wine. What is the best way to do this? From what I've gathered, I need to create an AppleScript that will call wine, but how do I get the name of the input file in the AppleScript? If there is a better way to do this, let me know, but as far as I know this is the best way. 回答1: You can use an AppleScript application to do this - files are passed to the open handler, the same as a droplet, for example: on open

OSX Associate a shell script with a file extension?

回眸只為那壹抹淺笑 提交于 2021-01-22 03:52:13
问题 I want to associate the .exe file extension with a shell script that launches wine. What is the best way to do this? From what I've gathered, I need to create an AppleScript that will call wine, but how do I get the name of the input file in the AppleScript? If there is a better way to do this, let me know, but as far as I know this is the best way. 回答1: You can use an AppleScript application to do this - files are passed to the open handler, the same as a droplet, for example: on open

OSX Associate a shell script with a file extension?

对着背影说爱祢 提交于 2021-01-22 03:51:05
问题 I want to associate the .exe file extension with a shell script that launches wine. What is the best way to do this? From what I've gathered, I need to create an AppleScript that will call wine, but how do I get the name of the input file in the AppleScript? If there is a better way to do this, let me know, but as far as I know this is the best way. 回答1: You can use an AppleScript application to do this - files are passed to the open handler, the same as a droplet, for example: on open

Using Python in Place of AppleScript

一世执手 提交于 2021-01-21 08:55:51
问题 I often use Applescript to accomplish basic tasks like opening and closing programs, sometimes going a little more in-depth like running a specific Xcode program's unit tests. I'm learning Python, and I love it. I haven't been able to find much documentation relating AppleScript to Python. My question is: On Mac OS X, can Python be used in place of AppleScript to accomplish the tasks mentioned above? And if so, does anyone know of a good resource to learn more about the topic? 回答1: Python can

applescript oneliner

和自甴很熟 提交于 2021-01-01 06:37:45
问题 Is it possible to join applescript lines into one (in ruby it can be done using ; )? 回答1: Not really. The most that can be done is to take a simple if-then statement and make it into one line... if (variable) then return true end if ...becomes... if (variable) then return true If you were to include the osascript command in a shell script, then multiple line scripts must delimited with -e ... osascript -e 'if (variable) then' -e 'return true' -e 'end if' But that's about the extent of it.