469,949 Members | 2,184 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,949 developers. It's quick & easy.

Windows - window status (Running vs Not Responding)

Does anyone know how to determine the window status (Running or Not
Responding)? I've tried various methods with no success...

This would be on a variety of Windows systems, but all at least XP,
and mostly server 2003. Everyone will have Python 2.5.1 on them, and
the script would be running locally.

Any ideas?
Apr 11 '08 #1
18 2993
On Apr 11, 1:45 pm, rdahlstrom <roger.dahlst...@gmail.comwrote:
Does anyone know how to determine the window status (Running or Not
Responding)? I've tried various methods with no success...

This would be on a variety of Windows systems, but all at least XP,
and mostly server 2003. Everyone will have Python 2.5.1 on them, and
the script would be running locally.

Any ideas?

Basically, I'm looking for something similar to the Process.Responding
property in System.Diagnostics...
Apr 11 '08 #2
rdahlstrom wrote:
On Apr 11, 1:45 pm, rdahlstrom <roger.dahlst...@gmail.comwrote:
>Does anyone know how to determine the window status (Running or Not
Responding)? I've tried various methods with no success...

This would be on a variety of Windows systems, but all at least XP,
and mostly server 2003. Everyone will have Python 2.5.1 on them, and
the script would be running locally.

Any ideas?


Basically, I'm looking for something similar to the Process.Responding
property in System.Diagnostics...
Well one (slightly drastic) possibility might be to use IronPython [1]
or Python.NET [2] to invoke the .Net functionality directly. AFAIK there
is no direct alternative: I believe that WMI can be a useful match
for System.Diagnostics but doesn't deal with windows (ie user-interface
elements). Presumably you could find a top-level window for each
process, using something vaguely like this [3] coupled with this [4]
and send it a suitable SendMessage to "ping" it. Haven't done it myself
but can't see why it shouldn't work.

All a bit handwavey but maybe it'll point you somewhere...

TJG

[1] http://www.codeplex.com/Wiki/View.as...ame=IronPython
[2] http://pythonnet.sourceforge.net/
[3] http://timgolden.me.uk/python/wmi_co...ning_processes
[4]
http://timgolden.me.uk/python/win32_...ubprocess.html
Apr 11 '08 #3
On Apr 11, 2:10 pm, rdahlstrom <roger.dahlst...@gmail.comwrote:
On Apr 11, 1:45 pm, rdahlstrom <roger.dahlst...@gmail.comwrote:
Does anyone know how to determine the window status (Running or Not
Responding)? I've tried various methods with no success...
This would be on a variety of Windows systems, but all at least XP,
and mostly server 2003. Everyone will have Python 2.5.1 on them, and
the script would be running locally.
Any ideas?

Basically, I'm looking for something similar to the Process.Responding
property in System.Diagnostics...
Hmmm...I think you should re-post to the Python win32 group. They'll
know the answer, if there is one. Here's the link to get signed up:
http://mail.python.org/mailman/listinfo/python-win32

Also, you might take a look at the WMI module:

http://tgolden.sc.sabren.com/python/wmi.html

I'm pretty sure it can do that, but I don't know how. I did find an
article on it:

http://www.informit.com/articles/art...19489&seqNum=4

If you're better than I am, you can probably translate this to the
Python equivalent. Zenoss also has some monitoring software that's
open source Python code.

Mike
Apr 11 '08 #4
Mike Driscoll wrote:
http://www.informit.com/articles/art...19489&seqNum=4

If you're better than I am, you can probably translate this to the
Python equivalent. Zenoss also has some monitoring software that's
open source Python code.
I'm afraid that article only allows you to determine whether
a known executable is running, If that's what the OP's after,
then you can do as much by querying WMI thusly:

<code>
import wmi
c = wmi.WMI ()

EXE = "notepad.exe"
for process in c.Win32_Process (Caption=EXE):
print process
break
else:
print "None found"

</code>

TJG
Apr 11 '08 #5
On Apr 11, 3:46 pm, Tim Golden <m...@timgolden.me.ukwrote:
rdahlstrom wrote:
On Apr 11, 1:45 pm, rdahlstrom <roger.dahlst...@gmail.comwrote:
Does anyone know how to determine the window status (Running or Not
Responding)? I've tried various methods with no success...
This would be on a variety of Windows systems, but all at least XP,
and mostly server 2003. Everyone will have Python 2.5.1 on them, and
the script would be running locally.
Any ideas?
Basically, I'm looking for something similar to the Process.Responding
property in System.Diagnostics...

Well one (slightly drastic) possibility might be to use IronPython [1]
or Python.NET [2] to invoke the .Net functionality directly. AFAIK there
is no direct alternative: I believe that WMI can be a useful match
for System.Diagnostics but doesn't deal with windows (ie user-interface
elements). Presumably you could find a top-level window for each
process, using something vaguely like this [3] coupled with this [4]
and send it a suitable SendMessage to "ping" it. Haven't done it myself
but can't see why it shouldn't work.

All a bit handwavey but maybe it'll point you somewhere...

TJG

[1]http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython
[2]http://pythonnet.sourceforge.net/
[3]http://timgolden.me.uk/python/wmi_cookbook.html#running_processes
[4]http://timgolden.me.uk/python/win32_how_do_i/find-the-window-for-my-s...
You know, I thought about sending it a message, but I found that, in
testing, I am able to move, resize, and copy text from a "Not
Responding" window. I was having a tough time figuring out a suitable
message that I could send a generic window, one that I had no idea
about what it had available to me. Other than sending it a graceful
exit message (which I really don't want to do), have you any ides
about what to send it?
Apr 11 '08 #6
On Apr 11, 3:54 pm, Mike Driscoll <kyoso...@gmail.comwrote:
On Apr 11, 2:10 pm, rdahlstrom <roger.dahlst...@gmail.comwrote:
On Apr 11, 1:45 pm, rdahlstrom <roger.dahlst...@gmail.comwrote:
Does anyone know how to determine the window status (Running or Not
Responding)? I've tried various methods with no success...
This would be on a variety of Windows systems, but all at least XP,
and mostly server 2003. Everyone will have Python 2.5.1 on them, and
the script would be running locally.
Any ideas?
Basically, I'm looking for something similar to the Process.Responding
property in System.Diagnostics...

Hmmm...I think you should re-post to the Python win32 group. They'll
know the answer, if there is one. Here's the link to get signed up:http://mail.python.org/mailman/listinfo/python-win32

Also, you might take a look at the WMI module:

http://tgolden.sc.sabren.com/python/wmi.html

I'm pretty sure it can do that, but I don't know how. I did find an
article on it:

http://www.informit.com/articles/art...19489&seqNum=4

If you're better than I am, you can probably translate this to the
Python equivalent. Zenoss also has some monitoring software that's
open source Python code.

Mike
I thought about posting to the win32 group, but in looking at all of
the win32 apis, I couldn't find anything that did this - other than
System.Diagnostic in c#, which isn't available to win32 (nor would you
expect it to be, I guess)
Apr 11 '08 #7
On Apr 11, 3:46 pm, Tim Golden <m...@timgolden.me.ukwrote:
rdahlstrom wrote:
On Apr 11, 1:45 pm, rdahlstrom <roger.dahlst...@gmail.comwrote:
Does anyone know how to determine the window status (Running or Not
Responding)? I've tried various methods with no success...
This would be on a variety of Windows systems, but all at least XP,
and mostly server 2003. Everyone will have Python 2.5.1 on them, and
the script would be running locally.
Any ideas?
Basically, I'm looking for something similar to the Process.Responding
property in System.Diagnostics...

Well one (slightly drastic) possibility might be to use IronPython [1]
or Python.NET [2] to invoke the .Net functionality directly. AFAIK there
is no direct alternative: I believe that WMI can be a useful match
for System.Diagnostics but doesn't deal with windows (ie user-interface
elements). Presumably you could find a top-level window for each
process, using something vaguely like this [3] coupled with this [4]
and send it a suitable SendMessage to "ping" it. Haven't done it myself
but can't see why it shouldn't work.

All a bit handwavey but maybe it'll point you somewhere...

TJG

[1]http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython
[2]http://pythonnet.sourceforge.net/
[3]http://timgolden.me.uk/python/wmi_cookbook.html#running_processes
[4]http://timgolden.me.uk/python/win32_how_do_i/find-the-window-for-my-s...
I had actually contemplated using ctypes and linking the .dll
directly, but even though I'm running 32 bit Python, some of the
machines that I want to run this on are 64 bit windows, so it doesn't
work. If I get desperate, I'll check out IronPython, but I'd really
like to stay (as much as possible) with our standard package (2.5.1
with wmi/win32)
Apr 11 '08 #8
On Apr 11, 3:22 pm, Tim Golden <m...@timgolden.me.ukwrote:
Mike Driscoll wrote:
http://www.informit.com/articles/art...19489&seqNum=4
If you're better than I am, you can probably translate this to the
Python equivalent. Zenoss also has some monitoring software that's
open source Python code.

I'm afraid that article only allows you to determine whether
a known executable is running, If that's what the OP's after,
then you can do as much by querying WMI thusly:

<code>
import wmi
c = wmi.WMI ()

EXE = "notepad.exe"
for process in c.Win32_Process (Caption=EXE):
print process
break
else:
print "None found"

</code>

TJG
Tim,

Oh well. I guess my Google-Fu failed me this time around. Thanks for
looking at it though.

Mike
Apr 11 '08 #9
rdahlstrom wrote:
On Apr 11, 1:45 pm, rdahlstrom <roger.dahlst...@gmail.comwrote:
>Does anyone know how to determine the window status (Running or Not
Responding)? I've tried various methods with no success...

This would be on a variety of Windows systems, but all at least XP,
and mostly server 2003. Everyone will have Python 2.5.1 on them, and
the script would be running locally.

Any ideas?


Basically, I'm looking for something similar to the Process.Responding
property in System.Diagnostics...
Well one (slightly drastic) possibility might be to use IronPython [1]
or Python.NET [2] to invoke the .Net functionality directly. AFAIK there
is no direct alternative: I believe that WMI can be a useful match
for System.Diagnostics but doesn't deal with windows (ie user-interface
elements). Presumably you could find a top-level window for each
process, using something vaguely like this [3] coupled with this [4]
and send it a suitable SendMessage to "ping" it. Haven't done it myself
but can't see why it shouldn't work.

All a bit handwavey but maybe it'll point you somewhere...

TJG

[1] http://www.codeplex.com/Wiki/View.as...ame=IronPython
[2] http://pythonnet.sourceforge.net/
[3] http://timgolden.me.uk/python/wmi_co...ning_processes
[4]
http://timgolden.me.uk/python/win32_...ubprocess.html
Jun 27 '08 #10
On Apr 11, 2:10 pm, rdahlstrom <roger.dahlst...@gmail.comwrote:
On Apr 11, 1:45 pm, rdahlstrom <roger.dahlst...@gmail.comwrote:
Does anyone know how to determine the window status (Running or Not
Responding)? I've tried various methods with no success...
This would be on a variety of Windows systems, but all at least XP,
and mostly server 2003. Everyone will have Python 2.5.1 on them, and
the script would be running locally.
Any ideas?

Basically, I'm looking for something similar to the Process.Responding
property in System.Diagnostics...
Hmmm...I think you should re-post to the Python win32 group. They'll
know the answer, if there is one. Here's the link to get signed up:
http://mail.python.org/mailman/listinfo/python-win32

Also, you might take a look at the WMI module:

http://tgolden.sc.sabren.com/python/wmi.html

I'm pretty sure it can do that, but I don't know how. I did find an
article on it:

http://www.informit.com/articles/art...19489&seqNum=4

If you're better than I am, you can probably translate this to the
Python equivalent. Zenoss also has some monitoring software that's
open source Python code.

Mike
Jun 27 '08 #11
Mike Driscoll wrote:
http://www.informit.com/articles/art...19489&seqNum=4

If you're better than I am, you can probably translate this to the
Python equivalent. Zenoss also has some monitoring software that's
open source Python code.
I'm afraid that article only allows you to determine whether
a known executable is running, If that's what the OP's after,
then you can do as much by querying WMI thusly:

<code>
import wmi
c = wmi.WMI ()

EXE = "notepad.exe"
for process in c.Win32_Process (Caption=EXE):
print process
break
else:
print "None found"

</code>

TJG
Jun 27 '08 #12
On Apr 11, 3:46 pm, Tim Golden <m...@timgolden.me.ukwrote:
rdahlstrom wrote:
On Apr 11, 1:45 pm, rdahlstrom <roger.dahlst...@gmail.comwrote:
Does anyone know how to determine the window status (Running or Not
Responding)? I've tried various methods with no success...
This would be on a variety of Windows systems, but all at least XP,
and mostly server 2003. Everyone will have Python 2.5.1 on them, and
the script would be running locally.
Any ideas?
Basically, I'm looking for something similar to the Process.Responding
property in System.Diagnostics...

Well one (slightly drastic) possibility might be to use IronPython [1]
or Python.NET [2] to invoke the .Net functionality directly. AFAIK there
is no direct alternative: I believe that WMI can be a useful match
for System.Diagnostics but doesn't deal with windows (ie user-interface
elements). Presumably you could find a top-level window for each
process, using something vaguely like this [3] coupled with this [4]
and send it a suitable SendMessage to "ping" it. Haven't done it myself
but can't see why it shouldn't work.

All a bit handwavey but maybe it'll point you somewhere...

TJG

[1]http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython
[2]http://pythonnet.sourceforge.net/
[3]http://timgolden.me.uk/python/wmi_cookbook.html#running_processes
[4]http://timgolden.me.uk/python/win32_how_do_i/find-the-window-for-my-s...
You know, I thought about sending it a message, but I found that, in
testing, I am able to move, resize, and copy text from a "Not
Responding" window. I was having a tough time figuring out a suitable
message that I could send a generic window, one that I had no idea
about what it had available to me. Other than sending it a graceful
exit message (which I really don't want to do), have you any ides
about what to send it?
Jun 27 '08 #13
On Apr 11, 3:54 pm, Mike Driscoll <kyoso...@gmail.comwrote:
On Apr 11, 2:10 pm, rdahlstrom <roger.dahlst...@gmail.comwrote:
On Apr 11, 1:45 pm, rdahlstrom <roger.dahlst...@gmail.comwrote:
Does anyone know how to determine the window status (Running or Not
Responding)? I've tried various methods with no success...
This would be on a variety of Windows systems, but all at least XP,
and mostly server 2003. Everyone will have Python 2.5.1 on them, and
the script would be running locally.
Any ideas?
Basically, I'm looking for something similar to the Process.Responding
property in System.Diagnostics...

Hmmm...I think you should re-post to the Python win32 group. They'll
know the answer, if there is one. Here's the link to get signed up:http://mail.python.org/mailman/listinfo/python-win32

Also, you might take a look at the WMI module:

http://tgolden.sc.sabren.com/python/wmi.html

I'm pretty sure it can do that, but I don't know how. I did find an
article on it:

http://www.informit.com/articles/art...19489&seqNum=4

If you're better than I am, you can probably translate this to the
Python equivalent. Zenoss also has some monitoring software that's
open source Python code.

Mike
I thought about posting to the win32 group, but in looking at all of
the win32 apis, I couldn't find anything that did this - other than
System.Diagnostic in c#, which isn't available to win32 (nor would you
expect it to be, I guess)
Jun 27 '08 #14
On Apr 11, 3:46 pm, Tim Golden <m...@timgolden.me.ukwrote:
rdahlstrom wrote:
On Apr 11, 1:45 pm, rdahlstrom <roger.dahlst...@gmail.comwrote:
Does anyone know how to determine the window status (Running or Not
Responding)? I've tried various methods with no success...
This would be on a variety of Windows systems, but all at least XP,
and mostly server 2003. Everyone will have Python 2.5.1 on them, and
the script would be running locally.
Any ideas?
Basically, I'm looking for something similar to the Process.Responding
property in System.Diagnostics...

Well one (slightly drastic) possibility might be to use IronPython [1]
or Python.NET [2] to invoke the .Net functionality directly. AFAIK there
is no direct alternative: I believe that WMI can be a useful match
for System.Diagnostics but doesn't deal with windows (ie user-interface
elements). Presumably you could find a top-level window for each
process, using something vaguely like this [3] coupled with this [4]
and send it a suitable SendMessage to "ping" it. Haven't done it myself
but can't see why it shouldn't work.

All a bit handwavey but maybe it'll point you somewhere...

TJG

[1]http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython
[2]http://pythonnet.sourceforge.net/
[3]http://timgolden.me.uk/python/wmi_cookbook.html#running_processes
[4]http://timgolden.me.uk/python/win32_how_do_i/find-the-window-for-my-s...
I had actually contemplated using ctypes and linking the .dll
directly, but even though I'm running 32 bit Python, some of the
machines that I want to run this on are 64 bit windows, so it doesn't
work. If I get desperate, I'll check out IronPython, but I'd really
like to stay (as much as possible) with our standard package (2.5.1
with wmi/win32)
Jun 27 '08 #15
On Apr 11, 3:22 pm, Tim Golden <m...@timgolden.me.ukwrote:
Mike Driscoll wrote:
http://www.informit.com/articles/art...19489&seqNum=4
If you're better than I am, you can probably translate this to the
Python equivalent. Zenoss also has some monitoring software that's
open source Python code.

I'm afraid that article only allows you to determine whether
a known executable is running, If that's what the OP's after,
then you can do as much by querying WMI thusly:

<code>
import wmi
c = wmi.WMI ()

EXE = "notepad.exe"
for process in c.Win32_Process (Caption=EXE):
print process
break
else:
print "None found"

</code>

TJG
Tim,

Oh well. I guess my Google-Fu failed me this time around. Thanks for
looking at it though.

Mike
Jun 27 '08 #16
rdahlstrom <ro*************@gmail.comwrote:
>Basically, I'm looking for something similar to the Process.Responding
property in System.Diagnostics...
You probably want to use IsHungAppWindow():

IsHungAppWindow Function

You call the IsHungAppWindow function to determine if
Microsoft Windows considers that a specified application is not
responding. An application is considered to be not responding
if it is not waiting for input, is not in startup processing,
and has not called PeekMessage within the internal timeout period
of 5 seconds.

Syntax

BOOL IsHungAppWindow(
HWND hWnd
);

...

You can use EnumWindows() to enumerate the all the top level windows.

Ross Ridge

--
l/ // Ross Ridge -- The Great HTMU
[oo][oo] rr****@csclub.uwaterloo.ca
-()-/()/ http://www.csclub.uwaterloo.ca/~rridge/
db //
Jun 27 '08 #17
Ross Ridge wrote:
rdahlstrom <ro*************@gmail.comwrote:
>Basically, I'm looking for something similar to the Process.Responding
property in System.Diagnostics...

You probably want to use IsHungAppWindow():
Brilliant! So simple when you find out. Thanks.

(Added to my list of things I never knew I never
knew about Windows).

TJG
Jun 27 '08 #18
On Apr 11, 11:18 pm, Ross Ridge <rri...@caffeine.csclub.uwaterloo.ca>
wrote:
rdahlstrom <roger.dahlst...@gmail.comwrote:
Basically, I'm looking for something similar to the Process.Responding
property in System.Diagnostics...

You probably want to use IsHungAppWindow():

IsHungAppWindow Function

You call the IsHungAppWindow function to determine if
Microsoft Windows considers that a specified application is not
responding. An application is considered to be not responding
if it is not waiting for input, is not in startup processing,
and has not called PeekMessage within the internal timeout period
of 5 seconds.

Syntax

BOOL IsHungAppWindow(
HWND hWnd
);

...

You can use EnumWindows() to enumerate the all the top level windows.

Ross Ridge

--
l/ // Ross Ridge -- The Great HTMU
[oo][oo] rri...@csclub.uwaterloo.ca
-()-/()/ http://www.csclub.uwaterloo.ca/~rridge/
db //
Holy crap, so simple, yet so awesome. Thanks!
Jun 27 '08 #19

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by Robert Mark Bram | last post: by
6 posts views Thread by Charles Neitzel | last post: by
44 posts views Thread by Viken Karaguesian | last post: by
4 posts views Thread by tshad | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.