On Feb 25, 2006, at 5:41 PM, Adam Ernst wrote:
Any tips for converting AppleScripts to AppleEvent code? I'm trying to
convert the following two scripts, but I barely know where to start.
tell application "System Events"
make new login item at end
with properties {path:"/Applications/TextEdit.app",
hidden:false}
end tell
tell application "System Events"
properties of every login item
end tell
My application AE Monitor does exactly what you're looking for. There's
a free 30-day demo available here:
http://software.oxalyn.com/AEMonitor/
Here's an example of the code it generates for your first example:
Function AEMSendAE() as AppleEvent
Dim ae as AppleEvent
Dim r as integer
Dim m as memoryBlock
Dim AEGizmoString as string
Declare Function AEBuildParameters lib "CarbonLib" (theevent as
integer, theerror as integer, inputstring as ptr) as integer
ae=NewAppleEvent("core", "crel", "sevs")
AEGizmoString="'kocl':type('logi'), 'insh':'insl'{'kobj':'null'(),
'kpos':enum('end ')},
'prdt':reco{'ppth':"+chr(34)+"/Applications/TextEdit.app"+chr(34)+",
'hidn':false}"
m=newmemoryBlock(len(AEGizmoString)+1)
m.stringvalue(0, len(AEGizmoString)+1)=AEGizmoString
r=AEBuildParameters(ae.ptr, 0, m)
if r=0 and ae.send then
return ae
else
return nil
end
End Function
This example uses the AEGizmo format, which supports any Apple Event
data. REALbasic's AppleEvent object don't support the "at end"
parameter, so you unusable code with the regular RB code generator, but
this is a good example of what AE Monitor can do:
Function AEMSendAE() as AppleEvent
Dim AERecordParam as AppleEventRecord
Dim ae as AppleEvent
ae=NewAppleEvent("core", "crel", "sevs")
ae.MacTypeParam("kocl")="logi"
(Unsupported parameter of type 'insl')
AERecordParam=new AppleEventRecord
ae.RecordParam("prdt")=AERecordParam
if ae.send then
return ae
else
return nil
end
End Function
Eric M. Williams
Oxalyn Software
http://software.oxalyn.com/
AE Monitor
http://software.oxalyn.com/AEMonitor/
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>