DonationCoder.com Forum

DonationCoder.com Software => Coding Snacks => Topic started by: aidan_cage on November 16, 2007, 07:50 PM

Title: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: aidan_cage on November 16, 2007, 07:50 PM
hello
I'm looking for a small program that would allow me to set certain programs, or a program and a window, or certain windows to open and close in unison
my example for a service like this would be to open my music player, which is set to open Last.fm simultaneously, then to close BOTH when I close one

as things are, I don't need Last.fm to be running unless I am scrobbling my listened to tracks to my profile, which I am only doing when I am running my music player.  I'd like to be able to kill both programs when I close my music player.

Likewise, I'd love to kill Live Messenger when I click to close it.
sigh, it is beyond me

thanks, Tristan
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: mouser on November 18, 2007, 12:57 AM
not a bad idea.
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: aidan_cage on December 05, 2007, 04:55 PM
it seems to be more difficult than I first thought...
It is more something that I'd like to have, than something I am able to create right now :(
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: lanux128 on December 05, 2007, 11:38 PM
Likewise, I'd love to kill Live Messenger when I click to close it.

i could help you with this but i can't understand certain things such as:

1. how does Last.fm operates? (not a Last.fm user)
2. do you mean to say that you can't exit Live Messenger normally?
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: justice on December 06, 2007, 07:30 AM
@ live messenger: when u use the close button on the interface it minimizes instead, you have to right click the tray icon and choose Exit.
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: lanux128 on December 06, 2007, 09:13 PM
exactly, that's why i thought he was having problems with exiting Live Messenger..

[ You are not allowed to view attachments ]
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: aidan_cage on December 14, 2007, 09:08 AM
aHa!  Exactly.  I have been using Nobar for a little while to hide my taskbar.  In this way it takes an extra step for me to close applications that refuse to close via their on screen windows.  WLM is one of them, and LastFM is another.  LastFM opens automatically when I launch my music software, but when I choose to quit the music software, LastFM remains open in the sidebar--waiting. 

I think that I can make individual shortcuts to batch files that run shortcuts and scripts to accomplish this task, but I would really like a simple layout program that can accomplish this.

http://cybernetnews.com/2007/12/13/cybernotes-shortcuts-to-end-processes-and-programs/

I found this site to have some information.
So I guess I could set up single instance shortcuts that I could launch to terminate a couple programs at one time.
I guess it will do.
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: lanux128 on December 16, 2007, 06:25 PM
or you can use Farr (https://www.donationcoder.com/Software/Mouser/findrun/index.html) instead which comes with a plugin called ProcessKill. This plugin when invoked will show a list of running processes and you can choose which one to kill..

[ You are not allowed to view attachments ]
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: aidan_cage on December 16, 2007, 06:42 PM
this makes me feel even sillier for having paid into Dash Command
FARR would do that for me? awww, how sweet.
That would be an easy way to deal with things.  I guess I was originally thinking of a small program with a GUI similar to Tooler that would allow processes to be paired and unpaired, closed and opened.  Thanks for the info on FARR, I'll have to give it a try.  It would still require the conscious steps of my thinking about closing the programs when they're open.  It seems to also require steps, and maybe more steps than just running Nobar.exe, then right clicking the offending programs to close them.
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: lanux128 on December 16, 2007, 07:01 PM
in addition to plugins, Farr also supports aliases.. take a look at this thread for more usage example: FARR V2 core alias tables (https://www.donationcoder.com/forum/index.php?topic=9342.0).

if you want a single script that toggles open/close state then a Autohotkey (http://www.autohotkey.com/) script similar to this can do the trick..
;Run metapad only if it is not already started
Process, Exist, metapad.exe
If ErrorLevel = 0
  Run, C:\Program Files\metapad\metapad.exe
Else  ;close the app
  WinClose, ahk_class metapad
Return
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: aidan_cage on December 16, 2007, 08:35 PM
that's a little above my learning, but I'm curving up there
Thanks for the ideas, I'll continue to read, learn, and implement
PEACE
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: lanux128 on December 16, 2007, 08:56 PM
a good idea but i did some googling & came up with this script (http://www.msgpluslive.net/scripts/view/241-Exit-Messenger/). you can create a shortcut from this script with the related parameter and call it from Farr..

[ You are not allowed to view attachments ]
• Exit Messenger 1.1 (http://www.msgpluslive.net/scripts/view/241-Exit-Messenger/)

also let me know if you need any other help..
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: aidan_cage on December 17, 2007, 06:19 PM
hey!  thanks for helping me out with that!
I found a program that works well for my needs and purposes
http://www.nirsoft.net/utils/nircmd.html
Nircmd.exe
I can throw arguments at it and it will bend my wants to my will to my computer's processes
Thanks, and I hope someone else finds it useful
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: Armando on April 09, 2008, 07:47 PM
Hi Lanux. I just bumped on that thread, looking for an easy way to close/start a bunch of apps. Your little AHK script seems like it should do fine. But I'm struggling to find the windows class names. How can I find them ? Thanks.  :)
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: lanux128 on April 09, 2008, 09:20 PM
Armando, you can use the "AU3 Spy" program that is available with Autohotkey. here, in the screenshot you can see how it shows the ahk_class of Process Explorer. there are plenty of other tools as well, i'll go digging in the threads if you want. :)

[ You are not allowed to view attachments ]
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: Armando on April 09, 2008, 10:11 PM
Perfect. Thanks a lot Lanux. You don't have to do more work.  :) I'll see what I can do with that.
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: lanux128 on April 09, 2008, 10:52 PM
ok, let me know if you need anything else. btw, congrats on your 1500th (https://www.donationcoder.com/forum/index.php?topic=2625.msg109403#msg109403) post. 8)
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: rjbull on April 10, 2008, 03:47 AM
you can use the "AU3 Spy" program that is available with Autohotkey.

Lanux128,

Is there a direct way to save the AU3 Spy information to a file?  Or do you just have to run the mouse over the AU3 Spy window to mark the text and save it via the clipboard?

Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: lanux128 on April 10, 2008, 10:47 AM
rjbull: normally i just use Shift+Alt+Tab between the program that i want to check on with AU3 Spy then it's all the usual copy-paste at work. a quick tip: when AU3 Spy gets focus, you can press the down key to select all text.

another good alternative is AHK Window Info 0.9 (http://www.autohotkey.com/forum/topic8732.html) which is being actively developed by toralf at the AHK forums.
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: ak_ on April 10, 2008, 01:16 PM
Likewise, I'd love to kill Live Messenger when I click to close it.
I gave it a shot :
;; Kick messenger
;; by ak

~LButton::
SetBatchLines, -1
CoordMode, Mouse, Screen
SetMouseDelay, -1
SetKeyDelay, -1
MouseGetPos, ClickX, ClickY, winID

Wingetclass winClass, ahk_id %winID%
Winget winPID, PID, ahk_id %winID%

if (winClass != "MSBLWindowClass")
  return
if IsOverCloseButton(ClickX, ClickY, winID)
  Process close, %winPID%
return

IsOverCloseButton(x, y, hWnd)
{
   SendMessage, 0x84,, (x & 0xFFFF) | (y & 0xFFFF) << 16,, ahk_id %hWnd%
   return (ErrorLevel == 20)
}

It works on my computer. It kills Live Messenger's process when you click its close button. The only problem with killing the process is that Messenger's tray icon stays visible (until you hover it with your mouse). At least that's what it does on my XP.

EXE version here :
[ You are not allowed to view attachments ]
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: Armando on April 10, 2008, 07:10 PM
Interesting.

I tried the lazy way... I decided to use the "ReRun" AHK application by skromel (reruns any atart up application that's not running). Unfortunately, I ran into a BSOD. My guess is that rerun tried to rerun some already runing programs (like my firewall : Online Armor) -- and gave me all kinds of errors before finally BSODing.

Anyhow, I'm still trying to find an easy way to stop or pause a bunch of apps while my laptop is on battery power, and (semi manually) restart them all as soon as I replug it. If I don't find anything, I might just try writing a little script with everything that's been proposed in this thread. The problem is of course to close these applications that need to be closed via the system tray (or else... they won't close)... I guess I could also use some kind of safe  AHK  "kill" command directly on the processes -- will  have to do some research.
Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: rjbull on April 11, 2008, 04:43 AM
when AU3 Spy gets focus, you can press the down key to select all text.

Thanks!  I didn't know that.  DC's a great place for sharing know-how  :)

another good alternative is AHK Window Info 0.9 (http://www.autohotkey.com/forum/topic8732.html) which is being actively developed by toralf at the AHK forums.

Thanks again...  I sometimes use ShoWin or WinScraper, but they don't always work.  The Window Info built into PowerPro also doesn't have a way of saving the data automatically, thought there's a script to do it that I haven't tried.

Title: Re: IDEA: Ability to set certain programs/windows to open and close in unison
Post by: Fred Nerd on April 25, 2008, 07:44 AM
The only problem with killing the process is that Messenger's tray icon stays visible (until you hover it with your mouse). At least that's what it does on my XP.
Common problem with XP, I often end up with tray icons which have to be moused away. Once ended up with 3 network connections when only one was running (and slowly at that :)