applescript

In Applescript, why do local variables in handlers capture "with" labeled parameters?

In Applescript, if you declare a handler using "with" labeled parameters, local variables get the values of the arguments and the parameters themselves are undefined. For example: on bam of thing with frst and scnd local eat_frst return {thing: thing, frst:frst, scnd:scnd} -- this line throws an error end bam bam of "bug-AWWK!" ...

How do I get the window id and tab number of a Terminal window using AppleScript via the ScriptingBridge?

I can open a Terminal tab using the following AppleScript: tell application "Terminal" set myTab to do script "exec sleep 1" get myTab end tell This returns a string like: tab 1 of window id 3263 of application "Terminal". This is great, I can see the window id 3263 and tab number 1 (although I don't know how to query myTab to...

Apple Events from Applescripts

Hi: I'm planning to make a little applescripts to do some action when iTunes change the song in playing, but i can't found how to put my script to listen for the apple event that should launch iTunes when the track change. Did anyone knows? i know you can make a objetive-c application can register whith Apple Events Manager to listen f...

AppleScript Editor, write message to the "Result" window

I am using the Mac OS X Apple Script Editor and (while debugging) instead of writing a lot of display dialog statements, I'd like to write the results of some calculation in the window below, called "Result" (I have the German UI here, so the translation is a guess). So is there a write/print statement that I can use for putting messages...

Applescript - How to iterate over tracks

Hi, I'm a newbie in applescript. I was trying to learn it from various sources, such as Doug's site, macscripter and this forum Just for learning purposes, I was trying to print on the screen all the tracks names using this code: tell application "iTunes" set myTracks to (tracks of library playlist 1) repeat with aTrack in myT...

Applescript iTunes dictionary explanations

I am wondering what the different color schemes mean in the following: What does the blue C tag mean? and the purple one? Disclaimer: absolute OSX newbie here... please be gentle ;-) ...

pyobj access to iTunes application

Let's say I managed to get the dictionary opened for iTunes in the Applescript editor: How would I access the "search" commands using Python with pyobjc? I know I get can hold of the iTunes application using: iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes") but after I do a dir on it, I don't see the sear...

Mail "Can't continue" for a AppleScript function

I'm trying to write an AppleScript for use with Mail (on Snow Leopard) to save image attachments of messages to a folder. The main part of the AppleScript is: property ImageExtensionList : {"jpg", "jpeg"} property PicturesFolder : path to pictures folder as text property SaveFolderName : "Fetched" property SaveFolder : PicturesFolder &...

Can you access AppleScript APIs from shell script on Mac OS X?

I already do a lot with shell scripts on the Mac, but I loathe AppleScript, and I would love to be able to access Mac apps' APIs in some other way. Does anyone know any other way to get the power of AppleScript without the pain of its horrible syntax and meager documentation (and its slowness, if possible)? ...

Window bounds set on window using AppleScript in OS X are being ignored

I am trying to create a small AppleScript to create and move some Terminal windows around my screen. The problem I am running into is that in some cases, it seems that OS X is ignoring the bounds I am setting. Using the AppleScript Editor: tell application "Terminal" to set the bounds of the first window to {0, 50, 600, 700} tell appli...

AppleScript: Transforming a TXT file in a list

I have a txt plain file that has a list of numbers. One number per line, like: 978-972-722-649-8 978-972-722-646-7 978-972-722-627-6 978-972-722-625-2 978-972-722-594-1 etc. This list is on a file called file.txt, was created and saved on TextEdit using Western (ISO Latin 1) encoding. Now I am trying to use Applescript to read this ...

Applescript: cleaning a string

I have this string that has illegal chars that I want to remove but I don't know what kind of chars may be present. I built a list of chars that I want not to be filtered and I built this script (from another one I found on the web). on clean_string(TheString) --Store the current TIDs. To be polite to other scripts. set previou...

pdf2swf using MAC OS Batch command or Apple script

How do I write a batch process on the Mac for pdf2swf, I want to convert all pdfs in a folder into swf. But pdf2swf doesn't have a option to convert a folder of pdfs to swfs, you have to do it one at a time. I'm not sure how if I should use a Apple script or a Shell script, either one I'm not sure how to get or assign a file name variabl...

Speech Recognition Server Does Not Stay Open

I am trying to create a simple program that loops for user speech input using com.apple.speech.recognitionserver. My code thus far is as follows: set user_response to "start" repeat while user_response is not equal to "Exit" tell application id "com.apple.speech.recognitionserver" set user_response to listen for {"Time", "Weather",...

programmatically updating iTunes track location

I would like to modify the filesystem path for tracks on itunes programmatically, so that I can apply a string transformation to some of the tracks locations (which are now stored in a different places on the filesystem). I've tried using AppleScript to update the location property of the relevant tracks but I get an end-of-file error w...

How to paste special in Excel using Applescript?

I am using Applescript to create a macro where data is transferred from several files to a single file. Data is copied with copy range the_range destination clipboard and pasted with paste worksheet active sheet destination range "A1" The problem is that most of the formatting is lost and I have not managed to get the "paste specia...

Scripting window positioning in OS X

My primary computing setup is a macbook pro with a large external monitor. I'm looking for a convenient way of moving a number of the windows of open programs from the laptop screen to the external monitor when I plug it in. I've seen a few partial scripts for accomplishing this, but nothing comprehensive. Ideally I'd like to specify ...

Creating iPhoto albums using Cocoa Scripting Bridge

I'm tearing my hair out trying to create a new album from a Cocoa Application. In applescript it's a nice simple procedure: tell application "iPhoto" new album name "Album" end tell But I can't work out how this is done in Cocoa via the Scripting Bridge. I've tried this: iPhotoApplication *iPhoto = [SBApplication applicationWithB...

Send AppleScript to remote computer in Objective-C

How do you use Objective-C (iPhone) to send an AppleScript to a remote computer (on same network) to be executed? I think something like NSNetService would be of use here, but I don't know. EDIT: Ok, to clarify, all I want to do is send a command ID or something and then the Computer associate that with the corresponding AppleScript co...

Accessing dock icon right-click menu items with AppleScript

Is there any way to get an AppleScript to access the menu items that come up when you right click on a dock icon? Specifically, here's what I want to do: I use Google Chrome as my web browser on MacOS X Snow Leopard. I am a keyboard shortcut addict, and I use QuickSilver to create keyboard shortcuts for anything I can. One of the mos...