topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 2:31 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: IDEA:Check for program exit and offer to close other programs  (Read 19908 times)

paarkhi

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 90
    • View Profile
    • Donate to Member
I am looking for a utility (ahk script is fine) which sits in the background and waits until a certain program is started, and then exited (checking every second or two).  when the program exists after running, it should check for a list of programs i specify that might also still be left running, and offer to close them.

As an example:
When i run and then exit firefox, i want the utility to check if my standalone downloader application is still running, and if so, offer to close it.

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #1 on: October 07, 2009, 11:36 PM »
I don't think this is enough for a full-fledged application.  I'll write you an AHK script that you can adjust and modify accordingly.  What you're asking for is rather simple to do.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #2 on: October 08, 2009, 12:07 AM »
(Before you replied skwire I did a small rudimentary app in AutoIt3.)

The program is called RunGroup.  You can run more than one copy.  The idea is to put a copy of RunGroup.exe in a folder and run it.  The first time it will quit saying you must have an .ini file.  It will generate the .ini.  You just filll in the Master Program and up to 4 SubPrograms.  (Don't use double quotes even if there is a space in the path.)  

Here's an example .ini filled in:

[Settings]
MainProgram=C:\Windows\system32\notepad.exe
SubProgram1=C:\Program Files (x86)\FavesSoft\FavesSA.exe
SubProgram2=C:\Program Files (x86)\JGsoft\EditPadLite\EditPadLite.exe
SubProgram3=
SubProgram4=


How it works is, it launches all the subprograms, then launches Main Program and waits for it to finish.  After Main Program is closed, it checks if each SubProgram is running.  If so, it gives a MsgBox do you want to kill it?  If you click Yes, it's killed.  Very simple.  You can have a different folder with RunGroup.exe for each .ini file.

It's primitive, but as skwire says, it's a pretty elementary task.
I looked around some of the freeware sites and I didn't notice a launcher that's combined with a monitor like this.  Kind of surprises me.  There probably are some that I didn't happen to hit on.

RunGroup.zip just has the RunGroup.exe in it.  It's pretty simple so you shouldn't need more instructions than this post.


edit: oh, one other thing.  If you want to pass a command line onto the Main Program, run RunGroup.exe with a command line and it will be passed on.  In the example above if you did this command at a command prompt:
RunGroup  Readme.txt

then notepad would open with Readme.txt if it exists.
If you don't like command prompts you can make a shortcut with the command line as part of the Target line etc..

edit2: AutoIt3 scripts compiled to .exe can give false positives in anti-virus programs.  Must be something in the exe wrapper that matches a signature in some of them. You can run the program inside something like Sandboxie to see what it does if you don't trust it. :)
« Last Edit: October 08, 2009, 12:14 AM by MilesAhead »

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #3 on: October 08, 2009, 12:53 AM »
Sweet.   :)  I'll wait to hear back from paarkhi to see if your app suits his needs before I start. 

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #4 on: October 08, 2009, 03:10 PM »
Sweet.   :)  I'll wait to hear back from paarkhi to see if your app suits his needs before I start. 

 :Thmbsup:

paarkhi

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 90
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #5 on: October 09, 2009, 07:02 AM »
Sorry Guys, bad on my part, actually I was Disconnected from my Internet Account, as there is a digging work going on in our area...
@Skwire, I'd be very glad for the AHK script which I can adjust and modify....
Please Looking forward

« Last Edit: October 09, 2009, 07:38 AM by paarkhi »

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #6 on: October 09, 2009, 07:06 AM »
Based on what MilesAhead said, his app can be easily modified with an INI file.

paarkhi

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 90
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #7 on: October 09, 2009, 07:31 AM »
@MilesAhead, Here is the feedback for your app Run Group (Im Facing Problems)
First Time when I run, it asks for an ini file (as you said) Ok so it quits
then when it creates an ini file and when entered the data and executed the program, it runs them and although the process is running it pops up a dialog saying "Kill C:\.......",
Totally Not working"
Here what I've done
1) Downloaded and unzipped the RunGroup in a folder and executed it for the first time, said the error msg.
2) edit the ini created by the program and executed, but result as above said

attached here with the ini

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #8 on: October 09, 2009, 03:49 PM »
Look in task manager and see if the name of the running process is the same as the one in the Kill dialog without the path.  IOW, if both say "notepad.exe" for notepad.  Some of these programs use a program to launch them, but that's not what is running.  For example, Gigaget.exe download manager actually uses GigagetShell.exe to launch.  When I add Gigaget.exe as a subprogram, it kills it.

The running program has to have the same name as the launched program, without the path.

edit:

Here's what I mean about adding the subprogram to be killed if the names are different:

[Settings]
MainProgram=C:\Program Files (x86)\Minefield\firefox.exe
SubProgram1=C:\Program Files (x86)\Giganology\Gigaget\GigagetShell.exe
SubProgram2=C:\Program Files (x86)\Giganology\Gigaget\Gigaget.exe
SubProgram3=
SubProgram4=


See if that scheme works for you.
« Last Edit: October 09, 2009, 03:52 PM by MilesAhead »

paarkhi

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 90
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #9 on: October 10, 2009, 01:14 AM »
The problem is not that it starts, although it is but it starts and asks as soon as that do you want to kill...
Sorry but I couldn't make it to work.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #10 on: October 10, 2009, 02:49 PM »
edit: deleted mumblings as I figured out how to do it later. :)
« Last Edit: October 10, 2009, 05:35 PM by MilesAhead »

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #11 on: October 10, 2009, 04:12 PM »
edit:  the strategy I used is I launch the subprograms, launch the master program, as it may be passing a command line to first instance so a browser could open a tab, or whatnot.  Then instead of using ShellExecuteWait I just check for the master program running.  As long as some exe with the same name as master program is running, RunGroup will just loop.

If you need to kill RunGroup without closing the master program you can exit it from the Tray Icon Menu.

I'll upload again after substituting for the default AutoIt icon.

« Last Edit: October 10, 2009, 05:39 PM by MilesAhead »

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #12 on: October 10, 2009, 04:41 PM »
edit:  see next post.   Same program but has custom icon for the task tray.
(nothing special, just teal background with white RB on it) :)

« Last Edit: October 10, 2009, 06:00 PM by MilesAhead »

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #13 on: October 10, 2009, 05:51 PM »
RunGroup with its own icon

Ok, I added an enhancement to clean off the task tray if the app being killed is a tray app.  That way you don't have to mouse over the tray icon to get rid of it.
« Last Edit: October 10, 2009, 06:19 PM by MilesAhead »

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #14 on: October 10, 2009, 06:27 PM »
paarkhi I hope it works for you.  I've ended up making a QuickLaunch shortcut to use this with Firefox and GigaGet.  No sense running GigaGet if FF isn't up. :)

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #15 on: October 10, 2009, 07:38 PM »
I see where it's using too much CPU.  I'll add a Sleep() to the idle loop.  That should bring it down.  New version coming up in a bit.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #16 on: October 10, 2009, 07:41 PM »
Version 1.02 uses very little CPU now.

edit: seems to be working very well.  The only other issue is if you click on RunGroup Tray Icon, it will pause the script.  You'll see the check mark.  Just click on that if it's checked to resume it again.  Other than that it seems to be pretty stable now.  On Vista64 and Windows 7 I'm showing less than 1% CPU used.

edit2: updated icon so 'RG' is a bit easier to see.


« Last Edit: October 10, 2009, 10:45 PM by MilesAhead »

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #17 on: October 10, 2009, 11:26 PM »
Now has a Readme file and is on FavesSoft downloads page:

http://www.favessoft.com/downloads.html

The link is near the bottom of the page.
« Last Edit: October 10, 2009, 11:43 PM by MilesAhead »

paarkhi

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 90
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #18 on: October 12, 2009, 07:47 AM »
First of all I beg your apology for not responding, As you must be knowing I'm the second in "mousering", it is because my internet account sometimes goes for holidays for days....

Now if possible I'd also like to set the closing duration of the sub program after the main program

Thanks

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #19 on: October 12, 2009, 02:29 PM »
Done.  Download v. 1.03 from my download page.
Run it once to get the KillDelay setting in the .ini file.

If KillDelay is 0 you will be prompted to kill sub programs as before.
If other than 0, all sub programs will be killed without prompting.

Values less than min will be set to min (about 1/100th second)
Values greater than max will be set to max(about 10 seconds)

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #20 on: October 12, 2009, 02:47 PM »
Just uploaded v. 1.04   Only change is it calls the function to clean off dead tray icons twice with a short delay between.  The function just moves the mouse along the tray, then returns to the current position.  By scanning twice it should eliminate most orphaned tray icons.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #21 on: October 12, 2009, 06:10 PM »
btw you can also put the path of a shortcut in the .ini file if you need to pass params to a sub program.  Just make a shortcut with the needed param in the target line.  Then put the path to the .lnk file instead of the exe.

paarkhi

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 90
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #22 on: October 13, 2009, 12:18 AM »
Icons in the tray of the closed programs doesn't get cleaned up in windows 7

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #23 on: October 13, 2009, 03:16 PM »
Icons in the tray of the closed programs doesn't get cleaned up in windows 7

Did you try the latest v. 1.04 ?  I hit it twice now. It's working for me on Vista64 and 7.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA:Check for program exit and offer to close other programs
« Reply #24 on: October 13, 2009, 05:06 PM »
Updated to v. 1.05   Added About, Show Readme, and Donate commands to the tray menu.  About digs out the file version from the resource so no need to use explorer Property page to check the file version.

The About box automagically closes after 5 seconds.