[Pythonmac-SIG] Solved! How do I send appleevents to an external
program
Joachim Mårtensson
joachimm at mac.se
Sun Jan 30 16:24:47 CET 2005
This code will open a texteditor with the caret positon on a specific
line. Beware of the datefield (last field in the struct) so that you
dont let different editors interfer with your changes to the document.
def openInExternalEditor(self, _filePath, _lnnum, _editor =
'/Applications/TextMate.app'):
from aem.send import Application
import struct
from Carbon.File import FSSpec
SelectionRange=struct.pack('hhllll', 0, int(_lnnum)-1, 1,1,0,0)
Application(_editor).event('aevt',
'odoc',{'----':FSSpec(_filePath),'kpos':SelectionRange}).send()
Thanks for the help, especially Hamish Sanderson who helped me out
(off-list).
Joachim Mårtensson
More information about the Pythonmac-SIG
mailing list