Hello everyone.
I am trying to figure out how to send appleevents to an external program. What I want to accomplish is to open a text document in a editor that supports the external editor protocol as described here http://www.codingmonkeys.de/techpubs/externaleditor/pbxexternaleditor.html.
Here is my code so far, What am I doing wrong? _filePath is the path to the file and _lnnum is the line number where I want to place the caret. I am using PyObjc but no api in cocoa seems to exist so I use various other modules.


def openInExternalEditor(self, _filePath, _lnnum):
import aetools, struct
editor = aetools.TalkTo('TxMt', 0) # TxMt = textmate a texteditor
keyDirectObject = '----'
keyAEPosition = 'sopk'
_code = 'aeve' # kCoreEventClass
_subcode = 'odoc' # kAEOpenDocuments
SelectionRange=struct.pack('hhllll', 0, int(_lnnum), 0,0,0,0)
_arguments = {}
_arguments[keyDirectObject] = _filePath
_arguments[keyAEPosition] = SelectionRange
_attributes = {}
editor.send(_code, _subcode, _arguments, _attributes)


Thanks in advance
Joachim Mårtensson
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to