appscript

Apple Event Handler Failure (Python/AppScript)

I have written the following really simple python script to change the desktop wallpaper on my mac (based on this thread): from appscript import app, mactypes import sys fileName = sys.argv[1:] app('Finder').desktop_picture.set(mactypes.File(fileName)) However when I run it I get the following output: Traceback (most recent cal...

How to read the background color of a cell through a (ruby) script from Microsoft Excel on Mac Osx?

I want to get the background color of a cell of an Excel worksheet. I have already tried the following: begin; require 'rubygems'; rescue LoadError; end require 'appscript' f = MacTypes::Alias.path(File.join(File.dirname(__FILE__), "planning.xls")) excel = Appscript.app("Microsoft Excel") excel.activate excel.open f w1 = excel.workshee...

Apple Event Handler Failure (Ruby/AppScript) while trying to growl

I'm trying to growl from Ruby/Appscript, based on this sample Applescript code: tell application "GrowlHelperApp" set the enabledNotificationsList to {"Mail Notification"} register as application "MailWidgetGrowlHelper" all notifications enabledNotificationsList default notifications enabledNotificationsList icon of application ...

Getting multiple properties at the same time in Appscript

I am using Appscript - a Python interface to AppleScript - in a project of mine that basically gets data from a Mac application. Here is a sample code: asobj = app('Things').to_dos()[0] self.id = asobj.id() self.name = asobj.name() self.status = asobj.status() Every invocation of the properties (id, name, status) does...

How can I invoke custom Scripting Additions using Python Appscript?

Assuming I have a new scripting addition, does appscript recognize them, and how do you invoke them using appscript? ...

Appscript to write iTunes artwork

I'm trying to capture artwork from a pict file and embed into a track on iTunes using python appscript. I did something like this: imFile = open('/Users/kartikaiyer/temp.pict','r') data = imFile.read() it = app('iTunes') sel = it.current_track.get() sel.artworks[0].data_.set(data[513:]) I get an error OSERROR: -1731 MESSAGE: Unknow...

Reading bytestreams in Python

I'm using Python appscript to write artwork to my iTunes Songs. I have a file stored in .pict format and when i use the normal open and read() routines, it reads the content as a string (encoded in utf-8). imFile = open('/Users/kartikaiyer/temp.pict','r') data = imFile.read() it = app('iTunes') sel = it.current_track.get() sel.artworks...

Getting the Current Table in Numbers (Python/Appscript)

How do I access the current table in Numbers using py-appscript? For posterity, the program I created using this information clears all the cells of the current table and returns the selection to cell A1. I turned it into a Service using a python Run Shell Script in Automator and attached it to Numbers. from appscript import * N...

Set Selection in Numbers (Python/Appscript)

How do you set the selection for a table in Numbers using py-appscript? This seems like it should be really simple to do but the solution is frustratingly evasive. I can get the current selection: current_table.selection_range and I can get its cells: current_table.selection_range.cells() but trying to set() either of them gets...

How does one feed a list of files into an app with appscript and Python?

Get your newb-shields up, I'm about to sprinkle you with some. I'm trying to get Photoshop CS4 to open a folderful of JPEG images with AppScript+Python, which could be described like so in BASH: #!/bin/bash for F in `ls ~/Desktop/test`; do open -a "Adobe Photoshop CS4" $F # proceed to mutilate the image appearance done I'm f...

How to set value of current Numbers cell using Py-Appscript

This seems like a straightforward operation but I am stumped. How do you set value of current Numbers cell using Py-Appscript? ...

How would I write the following rb-appscript in objc-appscript?

The documentation in the appscript objc-trunk randomly uses ruby in the section called "Performance Issues". require "appscript" include Appscript desiredEmail = '[email protected]' p app('Address Book').people[ its.emails.value.contains(desiredEmail) ].name.get How would this be written in Objective-C? I apologize ...

How do I add artwork to an iTunes track with obj-c AppScript?

aTrack is an ITReference* object, value is an NSImage* object, initialized via a URL to a jpeg. [[[[[aTrack artworks] data_] set] to:value] send]; I get the following message in GDB: 2010-03-09 16:59:42.860 Sandbox[2260:a0f] Can't pack object of class NSImage (unsupported type): <NSImage 0x10054a440 Size={0, 0} Reps=( I then tried ...

How would I write the following applescript in Obj-C AppScript? ASTranslate was of no help =(

The translation tool isn't able to translate this working code. I copied it out of a working script. set pathToTemp to (POSIX path of ((path to desktop) as string)) -- change jpg to pict tell application "Image Events" try launch set albumArt to open file (pathToTemp & "albumart.jpg") save albumArt...

appscript on OSX 10.6.3 / Python 2.6.1

I am having some trouble getting appscript installed on OS/X 10.6.3 / Python 2.6.1. When I issue sudo easy_install appscript I get "unable to execute gcc-4.2: No such file or directory". Even when I do export CC=/Developer/usr/bin/gcc-4.2 (a valid gcc-4.2 executable), easy_install barks. What could be the issue? Disclaimer: OS/X new...

AppleScript: I copied the Finder selection to the clipboard. Can I get the full path to the copied items?

I have one or many files and/or folders selected in the Finder. I manually copy them to the clipboard/pasteboard (⌘C). To keep things simple, let's say I just copied one single normal file. The ideal solution, however, would deal with many files and a mixed selection with folders, aliases. Now that this file is on the clipboard, I want...

Translate Applescrip [key code 125 using command down] to appscript

Hi, how to translate the following Applescript to appscript: tell application "System Events" key code 0 using command down end tell I want to perform "Command + A"-like short cut, i.e., select all texts. ...

py-appscript & events

Is it possible to subscribe to events using py-appscript ? Example: I'd like to get a callback when a user changes a rating on iTunes. ...