What is the opposite of launch?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 78
- Joined: Sat Apr 17, 2010 9:21 am
What is the opposite of launch?
I manage a number of LC Runtimes from one dashboard (also Runtime) with the launch command.
That works perfect.
But now I also want to close the runtimes from that same Dashboard.
How to do that?
Thanks
Rob van der Sloot
That works perfect.
But now I also want to close the runtimes from that same Dashboard.
How to do that?
Thanks
Rob van der Sloot
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: What is the opposite of launch?
Hi.
Just a guess, but does the "close Process" command fit here?
Craig
Just a guess, but does the "close Process" command fit here?
Craig
-
- Livecode Opensource Backer
- Posts: 78
- Joined: Sat Apr 17, 2010 9:21 am
Re: What is the opposite of launch?
Hi dunbarx,
That won't work, because the close proces command is only applicable to files who were opened by the "open process" command and that's only for background processing data.
thanks anyway,
Rob
That won't work, because the close proces command is only applicable to files who were opened by the "open process" command and that's only for background processing data.
thanks anyway,
Rob
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: What is the opposite of launch?
No. This is only a proposal of the dictionary.open process ... that's only for background processing ...
But on Mac you can open only one instance of an app at one time.
After using open process you can check openProcesses() or openProcessIDs().
(Don't use LC 8, where openProcess is defunct).
For apps opened by open process that can NOT be closed by close process (as is the case on Mac*) you can try kill process (which works with LC 9 here also on Mac). Or, better, use the applescript given below by Thierry.
*[I opened erroneously a bug report: The dict already says, that close process is not supported on MacOS!]
Last edited by [-hh] on Thu Jun 13, 2019 6:43 pm, edited 1 time in total.
shiftLock happens
Re: What is the opposite of launch?
@hh: Rob isn't entirely wrong in his assertion. The open process commands are designed to work with command-line / UNIX executables; rather than app bundles. From memory, the 'launch' command is more appropriate for app bundles.
@Rob: On macOS usually the best way to start and stop macOS apps (i.e. desktop apps) is using applescript I think... There's no direct way to 'cleanly' close a running macOS app - but applescript can be used to cause the system to send a 'close app' event which the app may or may not decide to honour.
@Rob: On macOS usually the best way to start and stop macOS apps (i.e. desktop apps) is using applescript I think... There's no direct way to 'cleanly' close a running macOS app - but applescript can be used to cause the system to send a 'close app' event which the app may or may not decide to honour.
Re: What is the opposite of launch?
Here is how I do that in one of my LC tutorial:LCMark wrote: There's no direct way to 'cleanly' close a running macOS app - but applescript can be used....
Code: Select all
try
get shell(format( \
"osascript -e 'tell application \"MidiKeys\" to quit'"))
get shell(format( \
"osascript -e 'tell application \"MIDIMonitor.app\" to quit without saving'"))
end try
HTH,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
-
- Livecode Opensource Backer
- Posts: 78
- Joined: Sat Apr 17, 2010 9:21 am
Re: What is the opposite of launch?
OK, thanks again, but for the time being I am interested in a solution for W10.
Re: What is the opposite of launch?
I use something for Windows too, if i have time tonight and remember this thread i can post it here.
The working is similair to that of MacOs by calling the shell.
Even for Linux this is possible.
The working is similair to that of MacOs by calling the shell.
Even for Linux this is possible.
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: What is the opposite of launch?
There are ways to use OS command line tools to find the target process and kill it. And depending on what those processes are doing, that may be okay.
But sometimes pulling the rug out from under a running process can be problematic.
Because the processes here are LiveCode standalones, it may be worth the modest effort to establish socket comms between those and the controlling app, to allow the controlling app to send it a message to quit, or any other messages that may be useful to run in such a worker pool.
But sometimes pulling the rug out from under a running process can be problematic.
Because the processes here are LiveCode standalones, it may be worth the modest effort to establish socket comms between those and the controlling app, to allow the controlling app to send it a message to quit, or any other messages that may be useful to run in such a worker pool.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: What is the opposite of launch?
If this is the stack that starts another stack i have this in stack script closestackhandler:
If this is the stack whcih is started by the other stack i have this in the closestackhandler:
now i found that clicking on the X in Macos does not close the stack, in Macos i need to close the app via the menu. I don't know why, because clicking the X should also activate the close stack handler
Code: Select all
if the environment is "standalone application" then
send "closeStack" to stack"yourapp"
end if
Code: Select all
if the environment is "standalone application" then
if the platform is "Win32" then
--added /T and /F, /T Terminates process and any child processes started by it, /F Forcefully Terminate process
put "taskkill.exe" & space & "/F" & space & "/T" & space & "/IM" & space & "yourapp.exe" into tCommandToExec
put shell (tCommandToExec)
else
if the platform is "MacOS" then
put "osascript -e 'quit app" & quote & "youapp" & quote & "'" into tCommandToExec
-- of pkill yourapp
put shell (tCommandToExec)
else
if the platform is "Linux" then
put shell("killall yourapp")
end if
end if
end if
-
- VIP Livecode Opensource Backer
- Posts: 7228
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: What is the opposite of launch?
Clicking the X closes the window only. Most apps on Mac act this way since the user may want to open another document from the File menu. If you want to quit instead, add your quitting code to a CloseStack Request handler.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: What is the opposite of launch?
Hi Jacque,
this is in my closestackrequest handler
plus of course the closeStack handler like in he above post where also this is in:
quit
pass closeStack
this is in my closestackrequest handler
Code: Select all
on closeStackRequest
answer "Zeker weten dat je wil stoppen?" with "Ja" or "Nee"
if it is "Ja" then
pass closeStackRequest
else
if it is "Nee" then
exit to top
end if
end if
end closeStackRequest
quit
pass closeStack
-
- VIP Livecode Opensource Backer
- Posts: 7228
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: What is the opposite of launch?
Ah. You're ahead of me already.
I'd think that passing the request would trigger the closeStack handler so I'm not sure why it doesn't. Have you tried putting a breakpoint in the closeStack handler to see if it runs? If it doesn't you may have to call "closeStack" yourself.
I'd think that passing the request would trigger the closeStack handler so I'm not sure why it doesn't. Have you tried putting a breakpoint in the closeStack handler to see if it runs? If it doesn't you may have to call "closeStack" yourself.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: What is the opposite of launch?
Ok i can try that, thanks for the suggestion.