Getting off-topic maybe but I did this from java.
For example...
CmdJHTML: terminated Firefox /Applications/Firefox.app pid = 3932640
CmdJHTML: launched Firefox /Applications/Firefox.app pid = 3.264063e+08
As you can see it is a bit off on getting the pid.
This was a 'real world' example of creating a Cocoa class from java
on the fly...
public CocoaMonitor() {
if (initsel == nil) { // Class setup complete?
if (createClassDefinition("CocoaMonitor","NSObject")) {
CocoaMonitor_class = getClass(getName());
}
I liked it enough I added it to my application as a normal
'automation' type function. I was adding things of that sort in at
the time.
I'm not familiar enough with loginwindow that I want to test with
that though. So it may or may not work there.