Open Safari with URL from command line and get process handle

后端 未结 1 1446
情书的邮戳
情书的邮戳 2020-12-28 18:52

I know there are several ways in MacOS to open Safari with a given URL from the command line like

open -a Safari http://stackoverflow.com

O

相关标签:
1条回答
  • 2020-12-28 19:16

    in AppleScript, after opening Safari with URL

    tell application "Safari" to open location "http://stackoverflow.com/"
    

    you may obtain the process object by

    tell application "System Events" to set proc to application process "Safari"
    

    the proc object will have pid, bundle id and etc attached to it.

    Also please note that Safari 5+ runs in a multi-process architecture: a master process and several rendering process, the above code will get you the master process only; rendering processes are not easily accessible, nor does it make much sense to control any individual rendering process.

    0 讨论(0)
提交回复
热议问题