Quit a running app programatically

Hello,

Lets say I have myApp1 open, I need to quit myApp1 from a pushbutton in myApp2 which is running.

How can I do that?

Thanks.

Lennox

Call Quit.

Thanks Paul,

Wouldn’t that quit myApp2?

I would like to quit myApp1 from a pushbutton in myApp2 which is running.

Thanks

Your myApp2 needs to have access to the process of myApp1.

You could use an IPCSocket to communicate with both apps, telling it to close the IPCSocket again and quit the app.

Thanks Derk,

Would you be generous enough to provide some code?

Thanks.

Lennox

There is sample code in the Language Reference IIRC.

Thanks peter,

I entered “IIRC” without the quotes and the result is “Could not find any results for search”.

The IPCSocket class implements the Readable and Writeable class interfaces.

What should I query?

Thanks.

Lennox

Sorry - If I Recall Correctly.

http://documentation.xojo.com/index.php/IPCSocket

Thanks Peter,

I checked that already but cannot see the light…
The IPCSocket class implements the Readable and Writeable class interfaces.

I can do it in Windows using a VBScript… KillProcess

How can I do it in Mac?

Thanks.

Lennox

AppleScript.

if application id "my.bundle.identifier" is running then
  tell application id "my.bundle.identifier" to quit
end if

Replace with your app’s bundle id, of course.

Sorry. I misread your post. AppleScript or an IPCSocket for communication between the apps would certainly work as others have suggested.

Thanks Kem,
Works great.Thanks again.
Lennox