AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Open for 20 min or more detect

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
icefreez



Joined: 15 May 2007
Posts: 39

PostPosted: Fri Feb 22, 2008 6:37 pm    Post subject: Open for 20 min or more detect Reply with quote

I am looking to detect if a window has been open for longer than 20 min, and display a msgbox if has been. The catch is I am launching multiple windows one after the other.

So lets say I have the windows opening in order, Window1, Window2, Window3. But they all have the same Title. I am guessing I will need to detect them by Window title, then check to see if their PID matches the last PID found or something like that.

Any idea on how to archive this?
Back to top
View user's profile Send private message
icefreez



Joined: 15 May 2007
Posts: 39

PostPosted: Fri Feb 22, 2008 7:23 pm    Post subject: Reply with quote

Well this is not coded very well but I think I figured it out.

Checks at 1 sec intervals. If the window has been open longer than 5 seconds (ticks / loops) it prompts you with a msgbox. This is useful to me for monitoring a window that has an open connection. It is supposed to usually disconnect after about 20-30 min so I made this script to warn me if a window (connection) gets stuck past that time.

Note: for this example code I am using an empty notepad window for testing.

Code:
tick = 0
timer = 5 ;sets the time to wait until prompt
loop
{
   top:
   sleep, 1000
   WinPIDLAST = %WinPID%
   WinGet, WinPID, PID, Untitled - Notepad ;get PID of window title.
   if(!WinPID) {
   goto, top
   }
   

   if (WinPID != WinPIDLAST)
   {
   tick = 0
   }
   else if(WinPID = WinPIDLAST)
   {
   tick++
      if(tick > timer)
      {
      msgbox, Window stuck?
      }
   }
}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group