applescript

Find Mac OSX version installed using AppleScript

ε祈祈猫儿з 提交于 2021-02-06 23:55:10
问题 How can I find which version of OSX is installed on my Mac by using AppleScript? I want to install an app programatically and run different pkg files based on the version. Thanks 回答1: I'm not on a Mac, so there may be a better way to do this, but the first approach that comes to mind is just executing a shell command to query the OS version. http://developer.apple.com/technotes/tn2002/tn2065.html#TNTAG2 http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man1/sw_vers.1.html

Waiting for do shell script to finish

只愿长相守 提交于 2021-02-06 12:51:40
问题 I'm trying to create an app in Xcode using Applescript to convert PDF's. The problem is that I need Xcode/AppleScript to wait for each 'do shell script' command to finish processing before it starts the next. Is there a way of detecting that each script has finished? e.g. tell application "System Events" do shell script "/opt/local/bin/convert task1.tif output1.pdf" end tell tell application "System Events" do shell script "/opt/local/bin/convert task2.tif output2.pdf" end tell Thanks,

Waiting for do shell script to finish

随声附和 提交于 2021-02-06 12:50:49
问题 I'm trying to create an app in Xcode using Applescript to convert PDF's. The problem is that I need Xcode/AppleScript to wait for each 'do shell script' command to finish processing before it starts the next. Is there a way of detecting that each script has finished? e.g. tell application "System Events" do shell script "/opt/local/bin/convert task1.tif output1.pdf" end tell tell application "System Events" do shell script "/opt/local/bin/convert task2.tif output2.pdf" end tell Thanks,

AppleScript from App Error: skipped scripting addition “/Library/ScriptingAdditions/Adobe Unit Types.osax” because it is not SIP-protected

扶醉桌前 提交于 2021-01-29 14:38:30
问题 Trying to run a script from our app and get this error message, even with something simple like: tell application "Finder" display dialog "Hello World" end tell Have set the appropriate Entitlements like: "com.apple.security.scripting-targets" and "com.apple.security.temporary-exception.apple-events:before:10.8" App has nothing to do with Adobe... 回答1: The "skipped scripting addition..." error is merely a warning, not a fatal error. It is informing you that it tried to load a particular

Assign pathnames returned from bash command(s) to an AppleScript list

≡放荡痞女 提交于 2021-01-29 11:19:40
问题 I want to prompt the paths of the 10 recently added files of a directory (recursively) in Applescript as a list. This works fine in bash: SAVEIFS=$IFS IFS=$(echo -en "\n\b") array=(`find . -type f -print0 | xargs -0 ls -t | head -n 10`) echo "${array[*]}" IFS=$SAVEIFS I’d like to store the resulting array in an Applescript Variable: set l to (do shell script "______________") How can I put the bash part into a working 1-liner? Maybe there is also an Applescript-only solution? 回答1: When you

Automator “copy finder object” with AppleScript

让人想犯罪 __ 提交于 2021-01-29 09:26:46
问题 I have created an Apple Automator service that receives PDFs encrypts them copies the encrypted PDF to a destination folder renames the encrypted PDF These are all commands from the Automator. However, the copying as an Automator command can only copy to a pre-defined folder. I would like to control this part by an AppleScript which reads out the user name and selects a folder accordingly: on run {input, parameters} set user_script to "echo $USER" set username to do shell script user_script

AppleScript - Geographic Location

喜夏-厌秋 提交于 2021-01-29 06:40:35
问题 Is it possible to write a script that identifies my location? I am trying to make an if statement that lets my laptop find my location at a certain time and tell me things I need to do at that location 回答1: This may request for you to authorise Script Editor to have access to your location service (don't forget to turn Location Services on), so you may need to run the script a second time once access has been granted. use framework "CoreLocation" use framework "Foundation" use scripting

applescript do shell command “command not found”

安稳与你 提交于 2021-01-28 12:10:12
问题 I am new to applescript and command line tools. I installed a command line tool to control the brightness of the iMac in Terminal. I installed the following: https://github.com/nriley/brightness After installing, I noticed a new exec file in /usr/local/bin/ called "brightness". The Internet told me, that applescript only knows the command lines found in /bin/sh. "brightness" is not found there, and I can't copy the exec file to this directory. So it makes sense, that I get the error "sh:

How to create XML from a string (not a file) in Applescript?

故事扮演 提交于 2021-01-28 11:50:35
问题 I have an Applescript that receive an XML string formatted as parameter, and I would like to read/parse data. Received string looks like: <?xml version="1.0" encoding="utf-8" ?> <win> <name>Documents</name> <target>SSD:Documents:</target> <listview>1</listview> <sidebar>0</sidebar> <bounds>1200, 630, 1825, 1080</bounds> </win> I saw examples with XML files but I can't figure how to populate a record based upon received string. Final record could be like this: set myRecord to {name:_XML

Use AppleScript to change System Preferences without being visible?

做~自己de王妃 提交于 2021-01-28 08:02:55
问题 I would like to change settings in System Preferences without the user seeing things happen. If I have a script that starts like: tell application "System Preferences" activate set current pane to pane "com.apple.preference.sound" end tell the System Preference window will be shown to the user. I'd like to know if there is a way to do it in the background somehow, or at least keep the window minimized. (Example script can be found in this question.) 回答1: You might be able to do what you want