Reviving and ancient thread here. (Though it seems to be the wrong forum for it.)
I’ve been poking around on this. I have an AS Studio app that’s always been developed as a background app with NSUIElement = 1 in the info.plist. I’ve changed that now to = 0 (normal app).
I’d like to be able to switch it back and forth and tried the write-to Info.plist approach from an external script. (Despite knowing that’s not advised.) Won’t go into details but I now see why
Anyway, it seems this is not too hard to pull off in C. You must start it background but you can programmatically make it a dock app while running.
but how could I do it in AS Studio with a call method?
Also, is the unix id property of a process the same as the PSN? So would this be a viable start?
start app with NSUIElement = 1 in Info.plist; background
on will finish launching
-- read user defaults
if not run_background then
tell application "System Events"
set tproc to item 1 of (every process whose name contains "MyAppName")
set psn to unix id of tproc
set OSStatus_return to call method TransformProcessType with parameter (psn)
end will finish launching
I managed to get this to work with a custom class, sort of. so don’t sweat any replies too much now. but still curious to know:
a) about the unix id = psn?
b) whether TransformProcessType can be called directly without creating a custom class
c) if there’s any other easy way to do this that I’m missing
one problem with my implementation:
if my app is saved in a position in the dock, when launched “transformed” into a normal app, the “active” glowing arrow icon (what’s that called?) in the dock is not shown. conversely, when I take it out of the dock, then when launch it from the finder it shows as a normal application in the dock would, but at the end of the list. that’s a little irritating…