Welcome Guest.   Make a donation to an author on the site November 23, 2014, 04:14:54 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2012! Download dozens of custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1] 2 Next   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: IDEA:Check for program exit and offer to close other programs  (Read 9113 times)
paarkhi
Supporting Member
**
Posts: 87


see users location on a map View Profile Give some DonationCredits to this forum member
« on: October 07, 2009, 01:57:22 PM »

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.
Logged
skwire
Global Moderator
*****
Posts: 4,158



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #1 on: October 07, 2009, 11:36:16 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.
Logged

MilesAhead
Member
**
Posts: 5,042



View Profile WWW Give some DonationCredits to this forum member
« Reply #2 on: October 08, 2009, 12:07:39 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. smiley

* RunGroup.zip (280.12 KB - downloaded 219 times.)
« Last Edit: October 08, 2009, 12:14:43 AM by MilesAhead » Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
skwire
Global Moderator
*****
Posts: 4,158



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #3 on: October 08, 2009, 12:53:50 AM »

Sweet.   smiley  I'll wait to hear back from paarkhi to see if your app suits his needs before I start. 
Logged

MilesAhead
Member
**
Posts: 5,042



View Profile WWW Give some DonationCredits to this forum member
« Reply #4 on: October 08, 2009, 03:10:33 PM »

Sweet.   smiley  I'll wait to hear back from paarkhi to see if your app suits his needs before I start. 

 Thmbsup
Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
paarkhi
Supporting Member
**
Posts: 87


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #5 on: October 09, 2009, 07:02:28 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:21 AM by paarkhi » Logged
skwire
Global Moderator
*****
Posts: 4,158



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #6 on: October 09, 2009, 07:06:40 AM »

Based on what MilesAhead said, his app can be easily modified with an INI file.
Logged

paarkhi
Supporting Member
**
Posts: 87


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #7 on: October 09, 2009, 07:31:12 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

* RunGroup.ini (0.18 KB - downloaded 171 times.)
Logged
MilesAhead
Member
**
Posts: 5,042



View Profile WWW Give some DonationCredits to this forum member
« Reply #8 on: October 09, 2009, 03:49:43 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:47 PM by MilesAhead » Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
paarkhi
Supporting Member
**
Posts: 87


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #9 on: October 10, 2009, 01:14:53 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.
Logged
MilesAhead
Member
**
Posts: 5,042



View Profile WWW Give some DonationCredits to this forum member
« Reply #10 on: October 10, 2009, 02:49:48 PM »

edit: deleted mumblings as I figured out how to do it later. smiley
« Last Edit: October 10, 2009, 05:35:36 PM by MilesAhead » Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
MilesAhead
Member
**
Posts: 5,042



View Profile WWW Give some DonationCredits to this forum member
« Reply #11 on: October 10, 2009, 04:12:17 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:39 PM by MilesAhead » Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
MilesAhead
Member
**
Posts: 5,042



View Profile WWW Give some DonationCredits to this forum member
« Reply #12 on: October 10, 2009, 04:41:20 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) smiley

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

"It's only called research if you didn't find it the first time."
-- MilesAhead
MilesAhead
Member
**
Posts: 5,042



View Profile WWW Give some DonationCredits to this forum member
« Reply #13 on: October 10, 2009, 05:51:02 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.

* RunGroup.zip (268.64 KB - downloaded 213 times.)
« Last Edit: October 10, 2009, 06:19:33 PM by MilesAhead » Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
MilesAhead
Member
**
Posts: 5,042



View Profile WWW Give some DonationCredits to this forum member
« Reply #14 on: October 10, 2009, 06:27:35 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. smiley
Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
MilesAhead
Member
**
Posts: 5,042



View Profile WWW Give some DonationCredits to this forum member
« Reply #15 on: October 10, 2009, 07:38:06 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.
Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
MilesAhead
Member
**
Posts: 5,042



View Profile WWW Give some DonationCredits to this forum member
« Reply #16 on: October 10, 2009, 07:41:33 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.



* RunGroup.zip (269.19 KB - downloaded 252 times.)
« Last Edit: October 10, 2009, 10:45:00 PM by MilesAhead » Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
MilesAhead
Member
**
Posts: 5,042



View Profile WWW Give some DonationCredits to this forum member
« Reply #17 on: October 10, 2009, 11:26:07 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:55 PM by MilesAhead » Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
paarkhi
Supporting Member
**
Posts: 87


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #18 on: October 12, 2009, 07:47:14 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
Logged
MilesAhead
Member
**
Posts: 5,042



View Profile WWW Give some DonationCredits to this forum member
« Reply #19 on: October 12, 2009, 02:29:15 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)
Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
MilesAhead
Member
**
Posts: 5,042



View Profile WWW Give some DonationCredits to this forum member
« Reply #20 on: October 12, 2009, 02:47:01 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.
Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
MilesAhead
Member
**
Posts: 5,042



View Profile WWW Give some DonationCredits to this forum member
« Reply #21 on: October 12, 2009, 06:10:35 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.
Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
paarkhi
Supporting Member
**
Posts: 87


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #22 on: October 13, 2009, 12:18:06 AM »

Icons in the tray of the closed programs doesn't get cleaned up in windows 7
Logged
MilesAhead
Member
**
Posts: 5,042



View Profile WWW Give some DonationCredits to this forum member
« Reply #23 on: October 13, 2009, 03:16:04 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.
Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
MilesAhead
Member
**
Posts: 5,042



View Profile WWW Give some DonationCredits to this forum member
« Reply #24 on: October 13, 2009, 05:06:53 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.
Logged

"It's only called research if you didn't find it the first time."
-- MilesAhead
Pages: [1] 2 Next   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.035s | Server load: 0.22 ]