[python-win32] Visibility information
Good morning PyWin32-users, I am using the PyWin32 package and I am wondering if there is any way to get visibility information of a button (I only know the handle). Is that possible and is there any code snippet, you could pass to me? I am looking for something like isVisible(hwnd) returns True or False. Thank you! Greetings from Germany, Stefan George ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Visibility information
From: Stefan George I am using the PyWin32 package and I am wondering if there is any way to get visibility information of a button (I only know the handle). Is that possible and is there any code snippet, you could pass to me? I am looking for something like isVisible(hwnd) returns True or False. It's pretty simple: import win32gui button_handle = ... is_visible = win32gui.IsWindowVisible(button_handle) The win32gui contains all GUI related Windows API functions. PyWin32's help file is great for looking up Windows functions and their respective modules. Just switch to the Index tab, type the function name and you'll find a help page with the parameters, return type and containing module of each API function. ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Maybe the wrong newsgroup to ask ?
hello, I'm trying to kill processes, I started myself with subprocess.popen, under windows XP, Python 2.6 Why are the subprocess.Popen methods kill() and terminate () not working, while a simple suggestion from this newsgroup, shown below, works perfect ? thanks, Stef Mientki My_Process = subprocess.popen ( ...) handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, My_Process.PID) try: win32api.TerminateProcess(handle,0) win32api.CloseHandle(handle) except: #the process might already be closed by the user pass ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Boolean type changed in Python 3.0?
Mark - just wondered if you had any update on this? I'm very happy to run some diagnostic tests for you on my setup, if this would help? If you need to send me debug versions or anything then please do, or let me know if I can provide any further info that would help to diagnose. I can do my best to net down the problem and promise not to just spam you with any output - I spend my days debugging various other problems so am pretty familiar with providing useful info. Thanks, appreciate it. Sunny -Original Message- From: Mark Hammond [mailto:skippy.hamm...@gmail.com] Sent: 05 January 2010 07:58 To: Sunny Carter Cc: python-win32@python.org Subject: Re: [python-win32] Boolean type changed in Python 3.0? On 5/01/2010 3:51 AM, Sunny Carter wrote: > Hi all, > I'm trying my posting again with a different subject so that it is > more generic. > I am having problems calling across the win32 API using a Boolean > argument in Python 3.0 (False in my python script) which is not > recognised as a Boolean (The error I get back from setattr is 'Boolean > value expected'). > Has the way that a Boolean is represented changed in Python 3.0? This > worked fine in Python 2.6. I cannot get it to work and have tried > values of False,True,0 and 1, all to no avail. > It sounds like a bug in the win32com API for 3.0 to me. > Further details below. > Many thanks to anyone that can help, I expect something subtle is going on with boolean conversions in 3.x, but the test suite does have coverage of booleans, so I'm really not sure what the problem could be. I don't have photoshop so I'm unable to reproduce - I intend revisiting the tests to see if I can spot an edge case which isn't tested, but I'm yet to get to that after the holidays... Cheers, Mark ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Boolean type changed in Python 3.0?
On 27/01/2010 8:21 AM, Sunny Carter wrote: Mark - just wondered if you had any update on this? I believe Roger checked a fix in for this over the last few days. I'm not sure when a new binary build will be available though, but probably not within a few weeks... Cheers, Mark ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Boolean type changed in Python 3.0?
Fabulous - thanks for the update. Sunny -Original Message- From: Mark Hammond [mailto:skippy.hamm...@gmail.com] Sent: 27 January 2010 17:28 To: Sunny Carter Cc: python-win32@python.org Subject: Re: [python-win32] Boolean type changed in Python 3.0? On 27/01/2010 8:21 AM, Sunny Carter wrote: > Mark - just wondered if you had any update on this? I believe Roger checked a fix in for this over the last few days. I'm not sure when a new binary build will be available though, but probably not within a few weeks... Cheers, Mark ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Maybe the wrong newsgroup to ask ?
Stef Mientki wrote: > > I'm trying to kill processes, > I started myself with subprocess.popen, > under windows XP, Python 2.6 > > Why are the subprocess.Popen methods kill() and terminate () not working, > while a simple suggestion from this newsgroup, shown below, works > perfect ? > ... > > My_Process = subprocess.popen ( ...) > handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, > My_Process.PID) > try: > win32api.TerminateProcess(handle,0) > win32api.CloseHandle(handle) > except: #the process might already be closed by the user > pass There shouldn't be any difference. If you look at the code in subprocess. it calls the same API. The handle returned from CreateProcess has all access rights, including PROCESS_TERMINATE. Can you show us your original code? -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Maybe the wrong newsgroup to ask ?
On 27-01-2010 20:07, Tim Roberts wrote: Stef Mientki wrote: I'm trying to kill processes, I started myself with subprocess.popen, under windows XP, Python 2.6 Why are the subprocess.Popen methods kill() and terminate () not working, while a simple suggestion from this newsgroup, shown below, works perfect ? ... My_Process = subprocess.popen ( ...) handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, My_Process.PID) try: win32api.TerminateProcess(handle,0) win32api.CloseHandle(handle) except: #the process might already be closed by the user pass There shouldn't be any difference. If you look at the code in subprocess. it calls the same API. The handle returned from CreateProcess has all access rights, including PROCESS_TERMINATE. Can you show us your original code? Good Question Tim. Showing the code is always difficult for me, because I encapsulate these complex things. The code I gave above doesn't work either :-) I use a kill method that also kills the children and seems to be the essential thing is this situation, (btw why are there children ?) thanks for the tip, cheers, Stef import os import subprocess import time if __name__ == '__main__': My_Path = os.path.split ( __file__ ) [0] cwd = os.path.join ( My_Path, '..', 'Pylab_Works', 'pylab_works_programs', 'PyJamas_Test') filename = os.path.join ( cwd, 'Een_Vraag_Test.py' ) Process = subprocess.Popen ( [ 'python', filename ], cwd = cwd , shell = ( os.name == 'nt') ) print Process.pid time.sleep ( 5 ) Process.kill () #Process.terminate () print 'Kill or terminate Doesnt succeed' time.sleep ( 2 ) import win32api import win32con handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, Process.pid) try: win32api.TerminateProcess(handle,0) win32api.CloseHandle(handle)#close api except: #the process might already be closed by the user pass print 'This still Doesnt works' time.sleep ( 2 ) PID = Process.pid Children = [] import win32com.client WMI = win32com.client.GetObject ( 'winmgmts:' ) processes = WMI.InstancesOf ( 'Win32_Process' ) for process in processes: pid= process.Properties_ ( 'ProcessID' ).Value parent = process.Properties_ ( 'ParentProcessId' ).Value if parent == PID : Children.append ( pid ) #Insert the parent at the top Children.insert ( 0, PID ) import win32api import win32con for PID in Children : handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, PID) try: win32api.TerminateProcess(handle,0) win32api.CloseHandle(handle) except: #the process might already be closed by the user pass print 'Finally this works' ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Maybe the wrong newsgroup to ask ?
On 10-01-27 06:12 AM, Stef Mientki wrote: hello, I'm trying to kill processes, I started myself with subprocess.popen, under windows XP, Python 2.6 Why are the subprocess.Popen methods kill() and terminate () not working, while a simple suggestion from this newsgroup, shown below, works perfect ? Note that the kill method will not kill any child processes. If you want to be able to kill the launched process and all of it's child processes, see here: http://benjamin.smedbergs.us/blog/2006-12-11/killableprocesspy/ Cheers, Todd ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Maybe the wrong newsgroup to ask ?
Stef Mientki wrote: > > Showing the code is always difficult for me, because I encapsulate > these complex things. > The code I gave above doesn't work either :-) > I use a kill method that also kills the children and seems to be the > essential thing is this situation, > (btw why are there children ?) There are child processes because you are setting "shell" to true. Thus, subprocess actually launches cmd.exe, and cmd.exe launches Python. Is there a reason you need a subshell, or was that superstition? -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] makepy or genpy issue: no get_accChildCount?
Hey, I am trying to use pywin32 to do program automation. Basically, I need to get an IAccessible object and call functions on it. Here is what I did: x = pythoncom.AccessibleObjectFromWindow(3803742, 0, pythoncom.IID_IDispatch) (3803742 is the HWND of an internet explorer window) Then I do: z = win32com.client.gencache.EnsureDispatch(x) Now "z" is an IAccessiable object: win32com.gen_py.1EA4DBF0-3C3B-11CF-810C-00AA00389B71x0x1x1.IAccessible.IAccessible instance at 0x15279168 But when I did "dir(z)", I only see: ['CLSID', 'GetaccDefaultAction', 'GetaccDescription', 'GetaccHelp', 'GetaccHelpTopic', 'GetaccKeyboardShortcut', 'Getacc Name', 'GetaccRole', 'GetaccState', 'GetaccValue', 'SetaccName', 'SetaccValue', '_ApplyTypes_', '__doc__', '__eq__', '__ getattr__', '__init__', '__module__', '__ne__', '__repr__', '__setattr__', '_get_good_object_', '_get_good_single_object _', '_oleobj_', '_prop_map_get_', '_prop_map_put_', 'accChild', 'accDoDefaultAction', 'accHitTest', 'accLocation', 'accN avigate', 'accSelect', 'coclass_clsid'] Although MSDN lists function *get_accChildCount* as a function IAccessible must support, I don't see it in the method list of "z". Why? Please help! Thanks a lot! xin ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Maybe the wrong newsgroup to ask ?
On 28-01-2010 00:08, Tim Roberts wrote: Stef Mientki wrote: Showing the code is always difficult for me, because I encapsulate these complex things. The code I gave above doesn't work either :-) I use a kill method that also kills the children and seems to be the essential thing is this situation, (btw why are there children ?) There are child processes because you are setting "shell" to true. Thus, subprocess actually launches cmd.exe, and cmd.exe launches Python. Is there a reason you need a subshell, or was that superstition? thanks Tim, I set Shell = True, to get rid of that ugly black dos box, but on second thought pythonw and Shell=False is a better solution. cheers, Stef ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32