applescript

Passing quotes “do shell script” in AppleScript… Again

僤鯓⒐⒋嵵緔 提交于 2019-12-11 19:18:47
问题 I have the following line in AppleScript set msgDate to (current date) as string set removalString to "\"rm -f ~/Library/LaunchAgents/com.playlister.\"" as string do shell script "echo do shell script " & removalString & msgDate & ".plist" & ">> ~/Library/Playlister/" & msgDate & ".applescript" What I'm trying to do, yet again, is pass the string do shell script "rm -f ~/Library/LaunchAgents/com.playlister.whateverthedatestampis.plist" with the quotes in the correct place. I'm moving stuff

Applescript freezes when extracting email from mail

荒凉一梦 提交于 2019-12-11 19:15:06
问题 I'm running an applescript to extract all the email adress from all the messages in my boss's inbox and it freezes on his computer and works fine on mine. my computer is running Snow leopard with mail 4.6 and his is running Lion with mail 5.3 if that makes any difference. Also my inbox only has around 400 mails since i don't usually use mail and only got those messages to test the script and his has over 60 000. The script ran through my email in around 20 seconds and on his took 2 minutes to

Error making folders in Applescript

喜欢而已 提交于 2019-12-11 18:59:05
问题 So, i'm getting an error while running this: on hazelProcessFile(theFile) set text item delimiters to ":" set filename to last text item of (theFile as text) set text item delimiters to "." if filename contains "." then set base to text items 1 thru -2 of filename as text set extension to "." & text item -1 of filename else set base to filename set extension to "" end if set text item delimiters to {"720p", "HDTV", "x264", "IMMERSE", "-", "E01", "…", "E02", "EVOLVE"} set ti to text items of

Installing OSX applications in bulk from the command-line

痴心易碎 提交于 2019-12-11 18:19:33
问题 I want to automate the process of installing an app on a Mac. After Googling I found the Terminal command below to install the app to the target machine without prompting for a password. sudo visudo rajasekaranr ALL=(root) NOPASSWD: /usr/sbin/installer sudo installer -store -pkg "/User/MyName/Downloads/Network Recording Player.pkg" -target / How do I achieve the above command in Applescript? Or is there any better way to automate the process of installing an app on a Mac? Also pls confirm

AppleScript works wonders on its own but does not work when called from the plugin

a 夏天 提交于 2019-12-11 17:58:57
问题 I know that using AppleScript cannot get access to the content of the newly created user-writing, so I use GUI Scripting. But I want Mail.app to contain its own button, which has added to the newly created files I send from my desired directory. I have a plugin for Mail.app have a script that is called by my own button. The script works wonders on its own, but it does not work when called from the plugin. What am I doing wrong? error { NSAppleScriptErrorAppName = "System Events";

Javascript within AppleScript 'missing value' (for clicking button in Safari)

独自空忆成欢 提交于 2019-12-11 16:46:23
问题 I have the following AppleScript with Javascript contained: set buttontext to "Add Option" set buttonloc to 1 tell application "Safari" activate tell window 1 do JavaScript "var buttonTags = document.getElementsByTagName(\"button\"); var searchText = \"" & buttontext & "\"; var found; for (var i = 0; i < buttonTags.length; i++) {if (buttonTags[i].textContent == searchText) { found = buttonTags[i]; break; } } buttonTags[" & buttonloc & "].click();" end tell end tell It compiles fine but upon

How do I read a file as a byte array in AppleScript

本秂侑毒 提交于 2019-12-11 16:14:32
问题 I am trying to read filebytes using AppleScript or JXA (I don't know which one is better yet). I already have tried this code: set theFile to (choose file with prompt "Select a file to read:") open for access theFile set fileContents to (read theFile) close access theFile However that code will read the file as a string and store it in fileContents. I need this to be a byte array. 回答1: I have experimented a little and devised a number of methods with which a file's contents might be read into

How to run multiple lines of commands in Terminal from AppleScript?

自闭症网瘾萝莉.ら 提交于 2019-12-11 16:09:29
问题 Please refer to this question first, unable to read opensslv.h:No such file or directory Based on that I need to run the following three line Terminal commands using AppleScript, /tmp/ssl/openssl-1.0.1h/Configure darwin64-x86_64-cc ––prefix=/usr no-threads shared make -f /tmp/ssl/openssl-1.0.1h/Makefile sudo make -f /tmp/ssl/openssl-1.0.1h/Makefile install I tried two methods I created text files with .command and .sh extensions and added the above three lines. Then tried to run it from

Can Applescript send arrow keys via key down?

这一生的挚爱 提交于 2019-12-11 14:59:34
问题 I am trying to control google earth using the arrow keys, however, I want to do this with applescript. Essentially this code should work and I'll tell you what it actually does. tell application "System Events" delay 3 key down 124 #Value of key right delay 3 key up 124 end tell This code should wait for me to go to google earth, then it will hold the right arrow key for 3 seconds. However, it just hits 'a'. I saw some recommendations to do the following: key down (key code 124) This sort of

Using Applescript to zip and unzip a folder

不打扰是莪最后的温柔 提交于 2019-12-11 14:57:05
问题 I have never used applescript before and I'm trying to find out how to zip a folder on the desktop, that's all and it's giving me a hard time 回答1: If you're happy to use Applescript to just invoke sh, you can use do shell script "zip /Users/you/Desktop/out.zip /Users/you/Desktop/in.file" do shell script "unzip -f /Users/you/out.zip" (The -f option is "freshen", which will stop unzip from asking if you want to overwrite files. To always overwrite, use -o .) 来源: https://stackoverflow.com