applescript

Py-appscript: How to configure mail created by reply()

I'm trying to reply to a mail in Mail.app with py-appscript. I tried the code below, from appscript import * mailapp = app('Mail') # get mail to be replied msg = mailapp.accounts.first.mailboxes.first.messages.first # create reply mail reply_msg = mailapp.reply(msg) # set mail (got error) reply_msg.visible.set(True) reply_msg.subje...

Stopping my room getting too hot via AppleScript + a USB Thermometer?!

Hi StackOverflowers! So I'm a coder, I do PHP, JavaScript, and Objective-C. I'm currently working on a website prettymuch full-time and, being 16, don't really have an 'office' except a desk in my bedroom... So I'm spending quite a long time in my room coding this website and I have a bit of a problem. My bedroom is at the back of our ...

Change Dialog Box Text With AppleScript?

Simply, is it possible to change a "static text" field in an Apple system dialog box? Specifically I am looking into changing some label text of a password popup. I have tried using AppleScript via GUI scripting: tell application "System Events" try tell window 1 of process "loginwindow" repeat until not (value o...

How do I move first responder with applescript?

I want to address the following annoyance with iTunes: After I have searched for a track (by pressing cmd+opt+f to move to the search field) I want to be able to play the first track in the songs list. Ideally I would like cmd+enter to start playing the first track in the song list and also move the focus to the song list. For example ...

Changing the path to a file in iTunes with AppleScript

I am trying to write an iTunes script that takes the selected tracks, moves the files to a different folder on my hard drive, and then update their location in iTunes. The overall flow will be something like this: Get selection Determine path to selection Move items to destination Update referenced path in iTunes I used the suggesti...

Apple codes used in Applescript-able applications

I read some examples of code necessary to make an application Applescript-able, but I still don't understand if the Apple codes used to identify a command, a class, a property can be any value I want (with the exception of the code for the application class), and if they must be registered in some site. Is there a list of codes with a p...

Specify a Finder item by its path

is it possible to specify a Finder item by its path? e.g. I want to refresh the icon of a single item. So far, to do this, I call update on every item of the front window: tell application "Finder" to update every item in front window But this only works if the folder currently has the item. Is it possible to specify an item with its ...

Running Applescript from a Cocoa application

I want to run a simple applescript in a cocoa application. I read the apple documentation on the matter but it was too confusing for me (a beginner) to understand. tell application "iTunes" to play ...

Saving Contents of OSAScriptView as a ".scpt" file into a predefined folder.

Hello there, First, I'm totally new to Obj-C please go easy on me :D I'm building an application, which basically does the same thing that AppleScript Editor does. I have used an OSAScriptView, and what I would like to do is to save the contents of this OSAScriptView as a .scpt file in a predefined folder. (like /documents/myscripts...

Working with a file by pathname/URI using Finder + ScriptingBridge

I'm using the generated Finder.h headers from the sdef utility, and it appears that a lot of Finder SB methods require objects of type FinderItem to do anything meaningful with. How would I go about creating one of them objects based on a path to or URI of the file? The farthest I've got is the [SBObject initWithProperties] method bri...

Run multiple commands in multiple Terminal windows with a single bash line

Here's an interesting problem: Using the AppleScript method to launch a new command in a Terminal window fails if Terminal is "busy"; more precisely, it will open a new window but fail to run the command. For example, try copy+pasting this line in: osascript -e 'tell application "Terminal" to do script "foo"'; osascript -e 'tell applica...

Using AppleScript to send mail attachment through default email client

Is it possible in any way to send an email attachment through the user's default email client using AppleScript? I'm assuming there is no easy way of doing this, as the programs themselves have to implement AppleScript and every email client will implement it differently and require a different script for sending an email with an attachm...

Editing .doc document using AppleScript

I am trying to batch convert some .doc files to .pdf I am pretty sure I've got the concept right, I just do not know how to reference the format to change the file format when I "Save As" set F to choose folder tell application "Finder" set P to (files of entire contents of F) repeat with I from 1 to number of items in P set this_it...

Logging in AppleScriptObjC in Xcode

I'm writing code in AppleScript to glue an Obj-C Cocoa app to some other stuff. I'm very unfamiliar with AppleScript on also learning Cocoa, so of course I have all kinds of bugs in my code to work out, and I need at least some logging. However, output from the AppleScript 'log' command doesn't seem to end up in XCode's debugger consol...

Java - Expected “"” but found unknown token

I am receiving this error when trying to execute applescript from my java application. The code is as follows: String script = "tell application \"Terminal\" to do shell script \"/System/Library/CoreServices/Menu\\ Extras/user.menu/Contents/Resources/CGSession -suspend\" "; ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngi...

How to perform equivalent of AppleScript "copy" command from Scripting Bridge?

Is there a way to do a remote copy within a container from Scripting Bridge? In AppleScript, this looks like "copy [element] of [container] to [location in container]". For example, in the context of a tell to a TextEdit document, you can "copy first paragraph of its text to end of its text" to copy the first paragraph to the end of th...

Cached iTunes Cover Art

Hi, I need to fetch cached cover art from iTunes. Currently I'm working with the scripting bridge, but it only fetches covers that are embedded in the tracks. I've also tried this method here http://stackoverflow.com/questions/1433035/fetch-itunes-album-artwork-without-itunes-running but it seems to be broken (at least in iTunes 9.2)...

Iterating through file line by line in AppleScript?

I am trying to figure out how to iterate through a file line by line in AppleScript. Similar to a bash script like so: for LINE in $(cat file) do echo ${LINE} done Any tips? Thanks! ...

How to read a file and open Safari with the read result with Mac (AppleScript)?

I need to open multiple Safari (or open the tab is OK) based on the read result. For example, if a file has http://a.com http://b.com I want to open a.com and b.com using Safari. How can I do that with Mac/AppleScript? Maybe I can run python calling "open -a Safari "http://a.com", but I guess AppleScript is the tool for this kin...

How do I solve this "Can't continue count" problem in an AppleScript app that deals with parameters?

I'm trying out a simple AppleScript I found online: on run argv set rtn to ((count of argv) as text) & " parameters passed. The parameters were: " repeat with arg in argv set rtn to rtn & " " & (arg as text) & " " end repeat return rtn end run I saved it as an Application. Everytime I double click it from the Finder, I get...