0

I have a simple AppleScript which tells me url of active window in specific browser

tell application "Opera"
   get URL of active tab of window 1
end tell

However I would like to see Apple Events needed to run that script, probable some of these: https://developer.apple.com/documentation/coreservices/apple_events?language=objc My final goal is to code same script but using Apple Core Services.

I have checked Script Editor but I do not see any tab or menu where that information is displayed. Is there any way to translate that script?

Thanks in advance and regards

RuLoViC
  • 825
  • 7
  • 23
  • Why? Building Apple events from scratch is a royal pain and the old C API is particularly arcane and gnarly. Best approach is to call into AppleScript via the [AppleScript-ObjC bridge](http://appscript.sourceforge.net/asoc.html), which makes AppleScript script objects and handlers appear as Cocoa classes/instances and methods to your ObjC/Swift code. – foo Dec 05 '18 at 08:48

1 Answers1

4

Yes, there are several such ways. My favorite is to use Script Debugger, which just translates the AppleScript into raw Apple events for you. Alternatively, you can run your AppleScript in an environment where export AEDebugSends=1; export AEDebugReceives=1 has been turned on.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • I have tried both ways and i see this: {core,getd target='psn '[Opera] {----={form=prop,want=prop,seld=URL ,from={form=prop,want=prop,seld=acTa,from={form=indx,want=cwin,seld=1,from=NULL-impl}}}} attr:{csig=65536 returnID=15130} Could you help me to understand what is going on? – RuLoViC Dec 05 '18 at 18:29
  • Yes but not in the comments to this question. I answered correcting the question you asked; your comment proves that. That is the raw Apple event you asked for. The fact that you don’t know how to read it is another matter. – matt Dec 05 '18 at 18:32
  • added new question then, https://stackoverflow.com/questions/53638803/translate-into-apple-events-applescript – RuLoViC Dec 05 '18 at 18:47