applescript

Xcode 4 : Can I get a path to the currently active file via AppleScript?

眉间皱痕 提交于 2019-12-05 07:14:24
I am trying to write a custom xcode4 behavior to check out the current active file with Perforce. I know I can write a custom behavior to run when hit a key (e.g., F1 ) I'd like that custom behavior to launch an AppleScript (or any kind of script for that matter) that discerns the currently "active" source document in Xcode, get its path, and attempt to check it out via Perforce. As far as I can tell AppleScript is the best way to get to the target document as it can navigate the Xcode DOM easily. Given that, the DOM itself is a maze. Can this be done? Yes. tell application "Xcode" set

Speed up AppleScript UI scripting?

此生再无相见时 提交于 2019-12-05 07:01:45
问题 I'm using NetShade as a proxy service and thought I could try to automate the switching between the different proxies as a nice start for my first AppleScript script. The NetShade-app has no AppleScript support, so I have to use UI scripting. After a few tries (and some posts here) I managed to have a script, that switches the proxies via the menu bar item (here is a picture of it, since I can't post it inline due to reputation limit). Unfortunately my code is extremely slow (≈6sec), which

How to build & run Xcode with Applescript?

倖福魔咒の 提交于 2019-12-05 06:23:01
问题 I'm trying to emulate Xcode's ⌘-R keystroke in another editor (namely, Vim); I thought I would be able to do this with some shell scripting & applescript, but it doesn't seem to be working correctly: open -a Xcode "MyProj.xcodeproj" osascript -e 'tell app "Xcode"' -e 'build' -e 'launch' -e 'end tell' The problem with this is it launches the app regardless of whether Xcode reports errors. Is there any way to fix this? 回答1: I use: osascript -e 'tell application "Xcode" activate set

How can I identify the current terminal emulator from a bash script?

无人久伴 提交于 2019-12-05 06:06:15
I've got a script that will open a new tab in the OS X Terminal application and I'm trying to add support for iTerm2. Unfortunately, the methods to open tabs in the two terminal emulators are different. How could I tell which of the two is being used, or is open, to conditionally run the correct script? Shaun I'm not sure how to tell iTerm and iTerm2 apart, but check the $TERM_PROGRAM envar. For me (Mac OS X 10.7), it returns Apple_Terminal for Terminal.app , and iTerm.app for iTerm2. You should be able to: ps -p $$ | tail -1 | awk '{print $NF}' I realize this sounds sarcastic, though why didn

How to refresh finder window?

喜你入骨 提交于 2019-12-05 04:33:21
问题 I want to refresh icon for particular file/folder in Finder application. FNNotifyByPath( (const UInt8 *)folderPath, kFNDirectoryModifiedMessage, kNilOptions ); FNNotifyByPath is not working for this. Now i am trying with appleScript +(void) refreshIconForItem : (NSString *)itemPath { NSString *source=[NSString stringWithFormat:@"tell application \"Finder\" to update \"%@\"",[NSString stringWithUTF8String:itemPath]]; NSAppleScript *update=[[NSAppleScript alloc] initWithSource:source];

Applescript path to application using variable

こ雲淡風輕ζ 提交于 2019-12-05 04:19:12
问题 If I have an applescript snippet such as this tell application "Finder" set thePath to (POSIX path of (path to application "MyApp")) end tell it will return to me "/Applications/MyApp.app" Now, what I can't seem to figure out is how to instead specify "MyApp" via a variable rather than the literal. My applescript reads in some XML values, one of them being the name of the application I'm interesting in. I've tried this: tell application "Finder" set thePath to (POSIX path of (path to

Get Photoshop's action list using Objective-C

£可爱£侵袭症+ 提交于 2019-12-05 04:02:24
问题 I'm writing an application for OSX using C++ and Obj-C that interacts with Photoshop. I've been using NSAppleScript with dynamically built AppleScripts to drive Photoshop (yes, it's a little scary...) I would love to be able to drive Photoshop a different way, so if anyone knows a better way, I'm open to it! Unfortunately, I can't use ScriptingBridge as I can't tie my users to Leopard. The big problem came just the other night when I went to query the action list from Photoshop to display to

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

喜夏-厌秋 提交于 2019-12-05 03:39:17
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? 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" OpenURL "http://rubyquicktips.tumblr.com/" end tell blubb this works, but opens your welcome site in first

Applescript and iCal interaction

為{幸葍}努か 提交于 2019-12-05 03:10:27
问题 I'm trying to write an AppleScript to query iCal and find all the events I've got for a given date, in any calendar. I started by writing a simple script that does something simple with every event in a given calendar: tell application "iCal" tell calendar "Reuniones" set the_events to every event repeat with an_event in the_events -- do something with every event set value to summary of an_event end repeat end tell end tell However, this simple script is taken a lot of time to execute (a few

AppleScript - System Events Error : Access for assistive devices is disabled

◇◆丶佛笑我妖孽 提交于 2019-12-05 02:58:57
I have a problem with AppleScript and System Events. I have check "Enable access for assistive devices" in the “Universal Access” preference pane in System Preferences. When I try : arch -i386 osascript -e 'tell application "System Events" to get the position of every window of every process' I have this error : System Events got an error: Access for assistive devices is disabled. (-25211) Do you have any idea ? Thanks a lot The problem is not the assistive devices. AppleScript seems to incorrectly return that error code when it tries to access windows of a process that can never have any