applescript

Alias to make emacs open a file in a new buffer (NOT frame) and be activated/come to front?

有些话、适合烂在心里 提交于 2019-12-22 08:18:02
问题 What I have so far is alias em="open -a /Applications/Emacs.app "$@" && osascript -e 'tell application "Emacs.app" to activate'" But I am stumped. With that code, em file.txt will activate, but won't open the file . And I get '22:23: syntax error: Expected end of line but found unknown token. (-2741)' Doing alias em=open -a /Applications/Emacs.app "$@" Works fine and then it will open the file, but obviously not bring emacs to the front. And for some strange reason osascript -e 'tell

Mail Rules using JavaScript for Automation instead of AppleScript

妖精的绣舞 提交于 2019-12-22 05:27:17
问题 I'm trying to build a Mail.app rule (on OS X Yosemite) using Javascript for Automation instead of AppleScript, but I'm stuck on the basics. I see this code in AppleScript: using terms from application "Mail" on perform mail action with messages theMessages for rule theRule # actual code here end perform mail action with messages end using terms from but I'm unclear how this translates to JavaScript. Do I define a function? Set a callback? I'm unclear. I see that there is the

How do I instruct Applescript to open a new Firefox window with a link?

[亡魂溺海] 提交于 2019-12-22 04:26:13
问题 my code looks like this tell application "Firefox" open location "http://rubyquicktips.tumblr.com/" end tell but if I have Firefox open, the link will open in a new tab. But I want the link to open in a new Firefox window. How can I accomplish that? 回答1: try this... tell application "Firefox" OpenURL "http://rubyquicktips.tumblr.com/" end tell or try this... tell application "Firefox" to activate tell application "System Events" to keystroke "n" using command down tell application "Firefox"

How to keep an application activated/in foreground while a script is running?

≯℡__Kan透↙ 提交于 2019-12-22 01:40:34
问题 I'm using Applescript to automate deployment of applications from Xcode 4. I use System Events to click the menu items in the menu bar for that. I have the whole thing working, but with one quirk. If the user clicks elsewhere while my script is running, that is the XCode 4 window goes out of foreground, my entire script fails. Is there a way to force Xcode to be in the foreground from my script? Now, if only Xcode 4 was at least as scriptable as Xcode 3, I wouldn't have to resort to GUI

Strings in Applescript depends on the system language - are there universal names?

蹲街弑〆低调 提交于 2019-12-22 01:00:44
问题 I write some Applescripts that are gonna be deployed on machines set to different languages. I just realised that when I, for example, is waiting for an application to open a window (e.g., a Save/Open dialog) my scripts fail because on systems set to other languages these windows are not called Save or Open anymore, but rather have a translated name. How do I handle this? Do windows have "universal base name" I can look for rather than the name I Accessibility Inspector shows? And I guess

Strings in Applescript depends on the system language - are there universal names?

二次信任 提交于 2019-12-22 00:34:01
问题 I write some Applescripts that are gonna be deployed on machines set to different languages. I just realised that when I, for example, is waiting for an application to open a window (e.g., a Save/Open dialog) my scripts fail because on systems set to other languages these windows are not called Save or Open anymore, but rather have a translated name. How do I handle this? Do windows have "universal base name" I can look for rather than the name I Accessibility Inspector shows? And I guess

How to display modal window using osascript or AppleScript in OS X

你离开我真会死。 提交于 2019-12-21 21:53:53
问题 How to display modal(over all apps, windows) window using osascript or AppleScript in OS X 10.6.8 and later. Here a script I do: #!/bin/bash osascript -e 'tell app "System Events" to display dialog "My Dialog" buttons {"OK"} default button 1 with title "My Dialog" with icon caution' The problem is that it's not modal. How to fix the following issue? 回答1: I wrote a script recently to monitor my macbook battery when it got low. To make sure I didn't miss the alert I did the following... repeat

How to access Apple Music album art in iTunes via Apple Script

橙三吉。 提交于 2019-12-21 21:34:56
问题 I'm trying to create an application that sets the desktop background to the album artwork of the current song playing in iTunes, but have come across an issue where my script can't read the album art of an Apple Music song unless it has been added to the user's music collection or playlist. Currently I am using this code to extract the album art. -- get the raw bytes of the artwork into a var tell application "iTunes" to tell artwork 1 of current track set srcBytes to raw data -- figure out

Change icon of folder with AppleScript?

偶尔善良 提交于 2019-12-21 21:25:27
问题 i've create an AppleScript very helpful to me and i wish if it is possible to automatically change the folder icon. This script is very simple, it create one folder, then create one empty text file in the same folder. Here is the script: tell application "Finder" set newfolder to make new folder with properties {name:My Folder} make new file at newfolder with properties {name:"read_me.txt"} end tell Is it possible to automatically change the folder icon? (I own my custom folder icon (.icns)

How to look up a word in the Mac OS X dictionary with AppleScript?

萝らか妹 提交于 2019-12-21 20:29:17
问题 How can I look up a word in the Mac OS X dictionary through AppleScript? 回答1: Dictionary.app is not scriptable but it supports its own URL scheme, which you can exploit from AppleScript: open location "dict://mandolin" 来源: https://stackoverflow.com/questions/2567604/how-to-look-up-a-word-in-the-mac-os-x-dictionary-with-applescript