This may be old news, but my search for a solution came up empty.
I sometimes would like to get the unix process id of the current application (typically a stay-open application) from within its own code. The following returns the current application’s process id:
set currAppAlias to path to me
tell application "System Events"
tell processes to set {applicationAliases, processIDs} to {its application file, its unix id}
repeat with i from 1 to applicationAliases's length
if applicationAliases's item i = currAppAlias then
set currAppProcessId to processIDs's item i
exit repeat
end if
end repeat
end tell
currAppProcessId --> unix process id of the current application
Thanks. I’m used to assigning a unique bundle identifier to Cocoa and Cocoa applescript apps but have not done that with vanilla Applescript apps. Would you recommend modifying the CFBundleIdentifier property in the Info.plist file directly, or is there an alternative way?