473,418 Members | 2,019 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

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 3216
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Stefan Hinz | last post by:
Degan, jumping in to try and solve some problems that look pretty obvious to me ... > #options for default service (mysqld2) > (mysqld2) It should be , not (mysqld2).
16
by: Robert Mark Bram | last post by:
Hi All! Is there a way to reference a window by name without doing something like this: open (, 'windowName'); The open method will open a blank window if there is no window with such a name....
8
by: Serge | last post by:
Hi, I have some intensive code that is running on my main thread. I try to show a status update on a 'status form'. The problem that i have is that because it is running in the same thread the...
6
by: Charles Neitzel | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
14
by: | last post by:
Hi All, I am little confused here, hope you can help me. While processing WM_POWERBROADCAST (wParam=PBT_APMQUERYSUSPEND), I MUST to do some lengthy operation(30 sec) before system Suspends or...
44
by: Viken Karaguesian | last post by:
Hello all, On occasion I want to open hyperlinks (images, etc.) in a new window. In the past, I've used target="_blank" to open the link in a new window. However, using the "target" attribute...
4
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to...
15
by: Angelo | last post by:
Hi all, I'm using a FileSystemWatcher to monitor a directory. I want the FSW to pop up my already instantiated but invisible form. However, I'm running into some problems with this. 1) In...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.