 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
icefreez
Joined: 15 May 2007 Posts: 39
|
Posted: Fri Feb 22, 2008 6:37 pm Post subject: Open for 20 min or more detect |
|
|
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 |
|
 |
icefreez
Joined: 15 May 2007 Posts: 39
|
Posted: Fri Feb 22, 2008 7:23 pm Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|