applescript (appleevent) help

Hello,
I have this old snippet that, when called, it crashes the app. Yes, it is very very old and it even calls Carbon.framework. Yet for an app of mine it would be useful.

Without this code, the system will not ask users if they allow the app to access Quick Time Player, and consequently the app fails to work.

Or is there some code that could be added to the plist file, that could achieve the same purpose, i.e. ask users if they allow the app to access Quick Time Player?
I say this, because, in another app of mine, to access Contacts I have added the relevant strings in its plist file.

Thanks.

[code]Public Function GetAEReplyError(theEvent as AppleEvent) as integer
dim i,j,k As Integer
dim s As OSType

If theEvent Is Nil then Return 0

If theEvent.ReplyPtr=0 then Return 0

dim replyEvent as new MemoryBlock(4)
replyEvent.Long(0)=theEvent.ReplyPtr
replyEvent=replyEvent.Ptr(0)

If StrComp(replyEvent.StringValue(0, 4), “null”,0)=0 then Return 0

Soft Declare Function AESizeOfParam Lib “Carbon.framework” (theAppleEvent as Integer,theAEKeyword as OSType,typeCode as Integer,dataSize as Integer) as Int16

If AESizeOfParam(theEvent.ReplyPtr,“errn”,0,0)<>0 then Return 0//because an error code has not been set

//Soft Declare Function AEPutParamPtr Lib “Carbon.framework” (theAppleEvent as Integer,theAEKeyword as OSType,typeCode as OSType,ByRef dataPtr as Integer,dataSize as Integer) as Short
Soft Declare Function AEGetParamPtr Lib “Carbon.framework” (theAppleEvent as Integer,theAEKeyword as OSType,typeCode as OSType,ByRef actualType as OSType,ByRef dataPtr as Integer,MaxSize As Integer,ByRef DataSize As Integer) as Int16
k=AEGetParamPtr(theEvent.ReplyPtr,“errn”,“long”,s,i,4,j)
//(theAppleEvent as Integer,theAEKeyword as OSType,typeCode as OSType,actualType as OSType,ByRef dataPtr as Integer,MaxSize As Integer,ByRef DataSize As Integer) as Short
//Call AEPutParamPtr(theEvent.ReplyPtr,“errn”,“long”,replyCode,4)
Return i
End Function
[/code]

What are you trying to accomplish?

The app creates/plays music (noteplayer), and it gives the opportunity to create audio-files thru Quick Time Player.
The code above used to trigger a system-dialog asking users if they allowed the app to access QTP. Allowing it, the app used to be able to play its music while QTP recorded it and saved it as audio-file.
At present, with the above code commented/removed in order to avoid the crash, the system-dialog does not pop up, and QTP does not record the music.

[Edit] So, I’m looking for a way to have the system-dialog pop-up.
Thanks.

I think you may want to consider reverting back to using Apple Script; rather than sending Apple Events directly. I would also suggest looking at an alternative method as I personally believe that Apple Script is being phased out by Apple.

I don’t know if it will help, but AVFoundation may have the API you need to convert a midi file into an AIFF, MP3 or MP4 file.

Meantime I found a workaround (see Appleevents in Xojo docs): adding a info.plist file in the IDE, the system asked for confirmation, and now QTP records and saves again.
But I agree, AVFoundation should be the way.

<dict> <key>NSAppleEventsUsageDescription</key> <string>Access to QuickTimePlayer is needed</string> </dict>

Applescript cannot call any system event in a MAS app anyway.

Yes, Applescripts in a MAS app nowadays can be tricky and as you said MAS may reject a binary.
I try avoiding unnecessary applescript callings, for instance, I launch QTP thru declares, leaving the rest (recording etc.) to applescripts/appleevents.
A few hours ago MAS put this app of mine “on sale”.