brotherS
Master of Good Ideas
Honorary Member

Posts: 2,105
To make a difference, be different.
|
 |
« on: February 09, 2006, 03:08:06 AM » |
|
Hi,
I'd love a little tool to automatically close certain programs after I haven't used them for x minutes. I'm not sure if that's an easy task or not, but I could really use such a tool to auto-close some programs!
It would be perfect if I could specify the number of minutes for each program/exe after which IdleClose should kick in.
|
|
|
|
« Last Edit: February 15, 2006, 05:16:58 AM by brotherS »
|
Logged
|
Thank you.
|
|
|
|
Gerome
|
 |
« Reply #1 on: February 09, 2006, 04:20:41 AM » |
|
Hi, If you gimme the name of the API that allows to retrieve the Status of a running program, i can make a sample to demonstrate easily how to do this job 
|
|
|
|
|
Logged
|
Yours, (¯`·._.FBSL Help file] (¯`·._.Â
|
|
|
|
allen
|
 |
« Reply #2 on: February 09, 2006, 07:01:58 AM » |
|
. . . and if it could automatically click "save" when the program pops up asking if you'd like to, it'd be even smarter 
|
|
|
|
|
Logged
|
|
|
|
|
brotherS
Master of Good Ideas
Honorary Member

Posts: 2,105
To make a difference, be different.
|
 |
« Reply #3 on: February 09, 2006, 07:09:54 AM » |
|
Hi, If you gimme the name of the API that allows to retrieve the Status of a running program, i can make a sample to demonstrate easily how to do this job  Err... sorry, no idea... . . . and if it could automatically click "save" when the program pops up asking if you'd like to, it'd be even smarter  Hehe... I would use it only for programs that don't need to save anything. 
|
|
|
|
|
Logged
|
Thank you.
|
|
|
|
jgpaiva
|
 |
« Reply #4 on: February 09, 2006, 07:13:52 AM » |
|
The good news is: THIS CAN BE DONE! And actually, is a nice idea. I just made a small sketch on how to do it in ahk: [ copy or print] ;IdleClose WinGet, id, list,,,Program Manager WindowList = Loop, %id% {  StringTrimRight, this_id, id%a_index%, 0  WinGetTitle, this_name, ahk_id %this_id%  if this_name !=  {   MsgBox, the name is: %this_name%`nand it has this id: %this_id%   ;£ divides the srting for the several programs existing   ;§ divides the string between {ahk_id} and {time_idle}   windowlist =%windowlist%£%this_id%§0  } } Loop, Parse, WindowList, £ {  Loop,Parse, A_LoopField,§  {  If A_Index = 1   Id =%A_LoopField%  else   MsgBox, Id: %Id%`nidle time: %A_LoopField%  } } return The code above lists all windows that exist (and have name!!), and puts their ids to a list, folowed by another parameter, that will be used to put the time idle. After that, it runs through that list, and gets the ids and time idle again. I launched this code, because i need to know if it finds the windows you'd like it to find. In my computer, it found every window i had open, please run it in yours and tell me if something is missing! The problem is, that i don't think you'd like it to close every window, possibilly it should leave some windows open. And i still don't know how to handle a small thing that was forgotten in this post: how about when you go away, and leave the pc? When you return, it'd have closed all the programs you have. Maybe the concept should be redefined. I'll try to do this program today during the afternoon, I'll keep you posted 
|
|
|
|
|
Logged
|
|
|
|
|
Cpilot
|
 |
« Reply #5 on: February 09, 2006, 07:17:46 AM » |
|
I would think you could enumerate all the open windows then flag the foreground window with GetForegroundWindow,then set all the others on a timer list to close at interval? The one with focus would be exempt from the timer.
|
|
|
|
|
Logged
|
|
|
|
brotherS
Master of Good Ideas
Honorary Member

Posts: 2,105
To make a difference, be different.
|
 |
« Reply #6 on: February 09, 2006, 07:18:39 AM » |
|
The problem is, that i don't think you'd like it to close every window, possibilly it should leave some windows open. And i still don't know how to handle a small thing that was forgotten in this post: how about when you go away, and leave the pc? When you return, it'd have closed all the programs you have. Maybe the concept should be redefined.
 I'd prefer if it would be based on active .exe processes, since I run some apps in tray icon mode only. And it really *should* close them whether I don't use them or leave the PC for an hour. That's where the different idle time for each .exe comes into play. Remember, I do not want to close ALL running programs, just a chosen few (but without having to select them again and again each day). I won't mind just having to edit a script by myself to add those to a list, of course you could create a GUI too if you like that 
|
|
|
|
« Last Edit: February 09, 2006, 07:24:13 AM by brotherS »
|
Logged
|
Thank you.
|
|
|
|
jgpaiva
|
 |
« Reply #7 on: February 09, 2006, 07:26:19 AM » |
|
Ooops brotherS.. I understood you completely wrong. That's easier to do, i think  So, the idea here is to have a script that contains a list of processes to be closed, and close them if that processes' windows have not been used for a specifiably amount of time, right?
|
|
|
|
|
Logged
|
|
|
|
|
jgpaiva
|
 |
« Reply #8 on: February 09, 2006, 07:34:54 AM » |
|
I made this small sketch of the script's core, please check if it's what you want, if it is, say something, and i'll convert this to a program  [ copy or print] -> Load Process List -> wait for each of the processes -> for each processes, launch a timer -> last window active set to null GoTo Loop loop: if window active is last window active sleep 200 GoTo Loop if last window active's process is in the list activate process's timer if window active's process is in the list, stop window active's process's timer last window active set to name of window active GoTo Loop
|
|
|
|
|
Logged
|
|
|
|
brotherS
Master of Good Ideas
Honorary Member

Posts: 2,105
To make a difference, be different.
|
 |
« Reply #9 on: February 09, 2006, 09:15:50 AM » |
|
Yes, now you got what I was trying to say  But I doubt this will work for apps like FDM (Free Download Manager, read about it on http://www.donationcoder....um/index.php?topic=1801.0) since they normally just show their tray icon, so there's no window that could be checked for activity...
|
|
|
|
|
Logged
|
Thank you.
|
|
|
|
Gerome
|
 |
« Reply #10 on: February 09, 2006, 09:19:12 AM » |
|
Hehe  Yes, now you got what I was trying to say  But I doubt this will work for apps like FDM (Free Download Manager, read about it on http://www.donationcoder....um/index.php?topic=1801.0) since they normally just show their tray icon, so there's no window that could be checked for activity... : I bet you should try with the appropriated SendMessage, or with a language that well knows how to handle with a pico precision how to speak correctly with those kinda stuff 
|
|
|
|
« Last Edit: February 09, 2006, 09:20:49 AM by Gerome »
|
Logged
|
Yours, (¯`·._.FBSL Help file] (¯`·._.Â
|
|
|
|
jgpaiva
|
 |
« Reply #11 on: February 09, 2006, 09:31:13 AM » |
|
Gerome: If you can do this in Fbsl, please do, as i think I can't do that program in ahk (i mean, i started using ahk 2 weeks ago, i'm no expert  ) brotherS: I also don't think that can work with those windows, using ahk, but maybe skrommel does. What i can do, is do the sketch i presented before, that is within my knowledge reach  If nobody presents a better solution to do this, I will do it. Otherwise, i will only use it 
|
|
|
|
|
Logged
|
|
|
|
|
skrommel
|
 |
« Reply #12 on: February 09, 2006, 11:28:31 AM » |
|
|
|
|
|
|
Logged
|
|
|
|
brotherS
Master of Good Ideas
Honorary Member

Posts: 2,105
To make a difference, be different.
|
 |
« Reply #13 on: February 09, 2006, 12:19:47 PM » |
|
Hi skrommel! I tried that one last year but didn't like the fact that I always saw the Task Manager icon in the tray, also it was quite complicated to use and (probably because I missed something) I didn't get it to work correctly... But the Task Manager icon in the tray was my main reason not to use it, I really can't stand having something there that's changing all of the time. 
|
|
|
|
|
Logged
|
Thank you.
|
|
|
brotherS
Master of Good Ideas
Honorary Member

Posts: 2,105
To make a difference, be different.
|
 |
« Reply #14 on: February 15, 2006, 05:16:41 AM » |
|
Found a simple solution for my idea: [ copy or print] ;2006-02-15 ;kill certain programs after x hours of idle time #Persistent AutoExec8: SetTimer, AutoKill, 25000 ; ; 3600000 milliseconds = 1 hour ; 5400000 milliseconds = 1,5 hours ; 7200000 milliseconds = 2 hours ; 7200000 milliseconds = 2 hours ; 9000000 milliseconds = 2,5 hours ; AutoKill: ; TrayTip, test, test If A_TimeIdlePhysical > 5400000 process, close, fdm.exe If A_TimeIdlePhysical > 9000000 process, close, winamp.exe return Sure, it won't watch the process itself, but I figured that's simple enough and comes close to what I wanted. 
|
|
|
|
|
Logged
|
Thank you.
|
|
|
|
tmpusr
|
 |
« Reply #15 on: March 24, 2010, 12:22:30 AM » |
|
I need to automatically close only certain kinds of windows like Explorer and Everything (search) after they've been inactive for n seconds. I don't need help with closing any other tasks. Option: Learn to exclude windows with a title that has stayed open for n seconds more than n times, i.e., stop auto-closing popular windows. Also posted to JustCloseSomeTasks http://www.donationcoder....16018.msg199584#msg199584Is that against the rules?
|
|
|
|
« Last Edit: March 24, 2010, 04:32:06 PM by tmpusr »
|
Logged
|
|
|
|
|