From jeffpeery at yahoo.com Sun Dec 2 03:02:14 2007 From: jeffpeery at yahoo.com (Jeff Peery) Date: Sat, 1 Dec 2007 18:02:14 -0800 (PST) Subject: [python-win32] problem accessing OPC clients from thread Message-ID: <256718.29520.qm@web43144.mail.sp1.yahoo.com> Hello, I'm getting in a bit over my head here and need some help. I'm running a simple wxpython application that runs a thread in the background. The thread is supposed to read and write data to/from an OPC server - which I use to communicate to a PLC (programmable logic controller, for process automation). My OPC module works well for just reading and writing to the OPC server; however when I try to read and write to the OPC server from within the thread it doesn't work. I get this error: Here's the snippet from my thread: # connect to server opcServerName = 'the server name goes here' opcItemName = 'the opc item goes here' (server, group) = myOPC.connectServer(opcServerName) item = myOPC.addItem(opcItemName, group) value = myOPC.readItemValue(item) # the value return a tuple of info including a value and timestamp and quality Here's the error that's returned: line 124, in readItemValue return opcItem.Read(0x1) File "", line 3, in Read File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line 258, in _ApplyTypes_ result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args) com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147221008), None) I attached my OPC module, if its important to include the wxapp I can do that to, but it's pretty apparent that the problem only happens when I call my OPC funcitons from within a thread... I suppose its also worthwhile to mention that I need to access the OPC module from within a thread (thats not the main applications thread) because I'm trying to aquire data from a PLC and I want to do that continuously and not lock up my program. Any ideas on how I might get this thing to work within the thread? Thanks! Jeff --------------------------------- Get easy, one-click access to your favorites. Make Yahoo! your homepage. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071201/46dad53a/attachment.htm -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: myOPC.py Url: http://mail.python.org/pipermail/python-win32/attachments/20071201/46dad53a/attachment.txt From teekaysoh at gmail.com Sun Dec 2 05:44:48 2007 From: teekaysoh at gmail.com (TK Soh) Date: Sun, 2 Dec 2007 04:44:48 +0000 Subject: [python-win32] release status of pythonwin build 212 Message-ID: <58b84f8e0712012044r3b221851s1c100d4fd23ddbf3@mail.gmail.com> Just wondering if there's any update on the release of pythonwin build 212 installer. Any news? From graham.bloice at trihedral.com Mon Dec 3 11:21:35 2007 From: graham.bloice at trihedral.com (Graham Bloice) Date: Mon, 03 Dec 2007 10:21:35 +0000 Subject: [python-win32] problem accessing OPC clients from thread In-Reply-To: <256718.29520.qm@web43144.mail.sp1.yahoo.com> References: <256718.29520.qm@web43144.mail.sp1.yahoo.com> Message-ID: <4753D8AF.7010509@trihedral.com> Jeff Peery wrote: > Hello, > I'm getting in a bit over my head here and need some help. I'm running > a simple wxpython application that runs a thread in the background. > The thread is supposed to read and write data to/from an OPC server - > which I use to communicate to a PLC (programmable logic controller, > for process automation). My OPC module works well for just reading and > writing to the OPC server; however when I try to read and write to the > OPC server from within the thread it doesn't work. I get this error: > > Here's the snippet from my thread: > # connect to server > opcServerName = 'the server name goes here' > opcItemName = 'the opc item goes here' > (server, group) = myOPC.connectServer(opcServerName) > item = myOPC.addItem(opcItemName, group) > value = myOPC.readItemValue(item) > # the value return a tuple of info including a value and timestamp and > quality > Here's the error that's returned: > line 124, in readItemValue > return opcItem.Read(0x1) > File "", line 3, in Read > File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", > line 258, in _ApplyTypes_ > result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, > retType, argTypes) + args) > com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, > 0, -2147221008), None) The error code indicated (-2147221008) or 0x800401F0, is "CoInitialize has not been called". I would guess that you haven't done that on your thread. Try adding a pythoncom.CoInitialize() or CoInitializeEx(0 call to the start of the thread. You might need the Ex version to set the correct threading model. > > I attached my OPC module, if its important to include the wxapp I can > do that to, but it's pretty apparent that the problem only happens > when I call my OPC funcitons from within a thread... > > I suppose its also worthwhile to mention that I need to access the OPC > module from within a thread (thats not the main applications thread) > because I'm trying to aquire data from a PLC and I want to do that > continuously and not lock up my program. > > Any ideas on how I might get this thing to work within the thread? Thanks! > Although I think your code will work, it's not using OPC in it's normal event driven mode of operation where the OPC Server will send an event when the data read from the PLC changes. You are using a polling mode, via ReadItemValue(). If you added an event handler for the DataChange event of the group then you would be automatically informed of any data (or quality) changes without the need for a polling thread. One caveat of this is that you need to have a unique client handle for each data item in the group and the supplied code always seems to just use a constant '1' in the call to OPCItems.AddItem(). (in addItem()). -- Regards, Graham Bloice From rjones at redhat.com Mon Dec 3 19:01:39 2007 From: rjones at redhat.com (Richard W.M. Jones) Date: Mon, 03 Dec 2007 18:01:39 +0000 Subject: [python-win32] Can Win32 python load Cygwin-compiled DLLs? Message-ID: <47544483.5040206@redhat.com> I'm trying to seek a definitive answer to the question: Can Win32 python load Cygwin-compiled DLLs? We have a C library (http://libvirt.org/) which has Python bindings. Because the library relies on a lot of POSIX stuff we have only got so far as to compile it under Cygwin. Using the Cygwin version of Python I can import the library fine. Now for various reasons[*] I want to take the library (cygvirt.dll) and Python bindings (cygvirtmod.dll) and load them into the native Win32 python. I discovered from the FAQ that cygvirtmod.dll had to be renamed to cygvirtmod.pyd. However when Win32 python tries to 'import cygvirtmod' it just hangs (no CPU, but cannot be killed with ^C). There is no error message. Is this something that just fundamentally cannot be done, or is there something I can do to fix this? Rich. [*] 'Various reasons' being I want to use PyGTK without requiring an X server. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903 -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3237 bytes Desc: S/MIME Cryptographic Signature Url : http://mail.python.org/pipermail/python-win32/attachments/20071203/6dd454ad/attachment.bin From jeffpeery at seametrics.com Mon Dec 3 20:50:35 2007 From: jeffpeery at seametrics.com (Jeff Peery) Date: Mon, 3 Dec 2007 11:50:35 -0800 Subject: [python-win32] problem accessing OPC clients from thread (Graham Bloice) Message-ID: <006e01c835e5$c60ca700$4400000a@seametrics.local> Graham, thanks for the beta! I think my main problem is that I don't really understand this code; I didn't write it. Could you recommend a book/website that describes what these functions like 'group.OPCItems.AddItem' do? For example I don't really know what a 'group' is or what the addItem() parameters are, or how to interpret that error code that you interpreted, and I'm not really sure if this code will work for other OPC servers other than the automation direct server. Also, where might I go learn about how to setup the event handler for a data change event? Thanks again, I appreciate your help! Jeff Message: 1 Date: Mon, 03 Dec 2007 10:21:35 +0000 From: Graham Bloice Subject: Re: [python-win32] problem accessing OPC clients from thread To: python-win32 at python.org Message-ID: <4753D8AF.7010509 at trihedral.com> Content-Type: text/plain; charset=ISO-8859-1 Jeff Peery wrote: > Hello, > I'm getting in a bit over my head here and need some help. I'm running > a simple wxpython application that runs a thread in the background. > The thread is supposed to read and write data to/from an OPC server - > which I use to communicate to a PLC (programmable logic controller, > for process automation). My OPC module works well for just reading and > writing to the OPC server; however when I try to read and write to the > OPC server from within the thread it doesn't work. I get this error: > > Here's the snippet from my thread: > # connect to server > opcServerName = 'the server name goes here' > opcItemName = 'the opc item goes here' > (server, group) = myOPC.connectServer(opcServerName) > item = myOPC.addItem(opcItemName, group) value = > myOPC.readItemValue(item) # the value return a tuple of info including > a value and timestamp and quality Here's the error that's returned: > line 124, in readItemValue > return opcItem.Read(0x1) > File "", line 3, in Read > File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", > line 258, in _ApplyTypes_ > result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, > retType, argTypes) + args) > com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, > 0, -2147221008), None) The error code indicated (-2147221008) or 0x800401F0, is "CoInitialize has not been called". I would guess that you haven't done that on your thread. Try adding a pythoncom.CoInitialize() or CoInitializeEx(0 call to the start of the thread. You might need the Ex version to set the correct threading model. > > I attached my OPC module, if its important to include the wxapp I can > do that to, but it's pretty apparent that the problem only happens > when I call my OPC funcitons from within a thread... > > I suppose its also worthwhile to mention that I need to access the OPC > module from within a thread (thats not the main applications thread) > because I'm trying to aquire data from a PLC and I want to do that > continuously and not lock up my program. > > Any ideas on how I might get this thing to work within the thread? Thanks! > Although I think your code will work, it's not using OPC in it's normal event driven mode of operation where the OPC Server will send an event when the data read from the PLC changes. You are using a polling mode, via ReadItemValue(). If you added an event handler for the DataChange event of the group then you would be automatically informed of any data (or quality) changes without the need for a polling thread. One caveat of this is that you need to have a unique client handle for each data item in the group and the supplied code always seems to just use a constant '1' in the call to OPCItems.AddItem(). (in addItem()). -- Regards, Graham Bloice -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071203/5f9d87d0/attachment-0001.htm From david.london at sentai.com Mon Dec 3 22:02:20 2007 From: david.london at sentai.com (David London) Date: Mon, 3 Dec 2007 14:02:20 -0700 Subject: [python-win32] Problems starting services - any advice? Message-ID: <200712031402.20879.david.london@sentai.com> Hello all, I'm encountering some strangeness when running my python code on a windows machine and I was wondering if anyone had any advice, I have a number of python services (8) that run on a client machine, monitoring various database tables or folders, doing something with the data, then sleeping for a given amount of time and repeating. Normally, I have installed and run these services as "local system" and they have worked without any problems. For the latest client, they have asked that we run all of the services as a specific user. This is where I'm running into problems. When I attempt to start the 8th service, it gives me an error (error 1053: The service did not respond to the start or control request in a timely fashion). It doesn't matter what order I start them in, the eighth service always fails to start. And if I change the service back to run as "local service" it runs without problem. I'm pretty sure that this is not a windows specific problem, since I can create another user (with the same permissions) and when I attempt to start the service it gives me the same error. It appears as if there is some internal limit on the number of services that pywin can handle. Has anyone else encountered this? Or have any advice on where I could look to see what errors are being generated? I can not find any logs or error messages when the services fail to start. This is happening on a windows server 2003 R2, standard edition, with service pack 2. I'm using python 2.5, with pywin32-210. Python is not installed in the default location (we put it in d:\python25), but the pywin installation has not been modified. The python class that handles the service has been attached. Any suggestions would be helpful and appreciated. Thanks, David London Sentai Software david.london at sentai.com -------------- next part -------------- A non-text attachment was scrubbed... Name: EventMailService.py Type: application/x-python Size: 3715 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20071203/f78b73f4/attachment.bin From jeffpeery at yahoo.com Mon Dec 3 23:15:37 2007 From: jeffpeery at yahoo.com (Jeff Peery) Date: Mon, 3 Dec 2007 14:15:37 -0800 (PST) Subject: [python-win32] problem accessing OPC clients from thread Message-ID: <679563.93419.qm@web43138.mail.sp1.yahoo.com> thanks for the beta! I think my main problem is that I don't really understand this code; I didn't write it. Could you recommend a book/website that describes what these functions like 'group.OPCItems.AddItem' do? For example, how do I know what a 'group' is or what the addItem() parameters are, or how to interpret that error code that you interpreted, and I'm not really sure if this code will work for other OPC servers other than the automation direct server. Also, where might I go learn about how to setup the event handler for a data change event? Thanks again, I appreciate your help! Jeff Jeff Peery wrote: > Hello, > I'm getting in a bit over my head here and need some help. I'm running > a simple wxpython application that runs a thread in the background. > The thread is supposed to read and write data to/from an OPC server - > which I use to communicate to a PLC (programmable logic controller, > for process automation). My OPC module works well for just reading and > writing to the OPC server; however when I try to read and write to the > OPC server from within the thread it doesn't work. I get this error: > > Here's the snippet from my thread: > # connect to server > opcServerName = 'the server name goes here' > opcItemName = 'the opc item goes here' > (server, group) = myOPC.connectServer(opcServerName) > item = myOPC.addItem(opcItemName, group) value = > myOPC.readItemValue(item) # the value return a tuple of info including > a value and timestamp and quality Here's the error that's returned: > line 124, in readItemValue > return opcItem.Read(0x1) > File "", line 3, in Read > File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", > line 258, in _ApplyTypes_ > result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, > retType, argTypes) + args) > com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, > 0, -2147221008), None) The error code indicated (-2147221008) or 0x800401F0, is "CoInitialize has not been called". I would guess that you haven't done that on your thread. Try adding a pythoncom.CoInitialize() or CoInitializeEx(0 call to the start of the thread. You might need the Ex version to set the correct threading model. > > I attached my OPC module, if its important to include the wxapp I can > do that to, but it's pretty apparent that the problem only happens > when I call my OPC funcitons from within a thread... > > I suppose its also worthwhile to mention that I need to access the OPC > module from within a thread (thats not the main applications thread) > because I'm trying to aquire data from a PLC and I want to do that > continuously and not lock up my program. > > Any ideas on how I might get this thing to work within the thread? Thanks! > Although I think your code will work, it's not using OPC in it's normal event driven mode of operation where the OPC Server will send an event when the data read from the PLC changes. You are using a polling mode, via ReadItemValue(). If you added an event handler for the DataChange event of the group then you would be automatically informed of any data (or quality) changes without the need for a polling thread. One caveat of this is that you need to have a unique client handle for each data item in the group and the supplied code always seems to just use a constant '1' in the call to OPCItems.AddItem(). (in addItem()). -- Regards, Graham Bloice --------------------------------- Never miss a thing. Make Yahoo your homepage. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071203/9ef76880/attachment.htm From timr at probo.com Mon Dec 3 23:21:06 2007 From: timr at probo.com (Tim Roberts) Date: Mon, 03 Dec 2007 14:21:06 -0800 Subject: [python-win32] Problems starting services - any advice? In-Reply-To: <200712031402.20879.david.london@sentai.com> References: <200712031402.20879.david.london@sentai.com> Message-ID: <47548152.8080709@probo.com> David London wrote: > Hello all, > I'm encountering some strangeness when running my python code on a windows > machine and I was wondering if anyone had any advice, > > I have a number of python services (8) that run on a client machine, > monitoring various database tables or folders, doing something with the data, > then sleeping for a given amount of time and repeating. > Normally, I have installed and run these services as "local system" and they > have worked without any problems. > For the latest client, they have asked that we run all of the services as a > specific user. This is where I'm running into problems. > When I attempt to start the 8th service, it gives me an error (error 1053: The > service did not respond to the start or control request in a timely fashion). > It doesn't matter what order I start them in, the eighth service always fails > to start. And if I change the service back to run as "local service" it runs > without problem. > I'm pretty sure that this is not a windows specific problem, since I can > create another user (with the same permissions) and when I attempt to start > the service it gives me the same error. > Why does that make you think it is not a "windows specific problem"? > It appears as if there is some internal limit on the number of services that > pywin can handle. > > Has anyone else encountered this? Or have any advice on where I could look to > see what errors are being generated? I can not find any logs or error > messages when the services fail to start. > This is not a Python issue. It turns out to be a Windows issue. Every service that runs with a real user ID gets its own "desktop", separate from the console desktop. Each desktop gets a chunk of heap space for all of the applications running on that desktop, carved from a global desktop heap. The size of each heap is about 3MB, but the global heap has a non-configurable size of 48MB. Those were the numbers as of Windows 2000, although it sounds like they aren't that much different now. In the old days, you used to be able to adjust the size of this heap by tweaking a registry entry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems In the "Windows" value, there's a parameter like "SharedSection=1024,3072". The suggestion is to change that to 1024,3072,512. However, on my XP SP2 machine, that's already what it says. Do your services need to interact with the user? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon Dec 3 23:33:11 2007 From: timr at probo.com (Tim Roberts) Date: Mon, 03 Dec 2007 14:33:11 -0800 Subject: [python-win32] problem accessing OPC clients from thread In-Reply-To: <006e01c835e5$c60ca700$4400000a@seametrics.local> References: <006e01c835e5$c60ca700$4400000a@seametrics.local> Message-ID: <47548427.6000703@probo.com> Jeff Peery wrote: > > Graham, > > thanks for the beta! I think my main problem is that I don?t really > understand this code; I didn?t write it. Could you recommend a > book/website that describes what these functions like > ?group.OPCItems.AddItem? do? For example I don?t really know what a > ?group? is or what the addItem() parameters are, or how to interpret > that error code that you interpreted, and I?m not really sure if this > code will work for other OPC servers other than the automation direct > server. > Although I can understand your frustration, I want to make sure you understand that the trouble you reported has nothing to do with the OPC tools or their usage. It is quite complicated to use COM objects in a multithreaded application. A COM object is allowed to declare itself as single-threaded; in that case, COM takes extra steps to transfer control over to a single thread before calling that object. To do that, COM has to have some per-thread data structures to communicate between threads. The way that setup gets done is by calling the CoInitialize API (exposed in Python as pythoncom.CoInitialize). If a multithreaded application expects to use COM objects in several threads, it is REQUIRED to call CoInitialize from every thread. The pywin32 library will call CoInitialize on the main thread for you, but YOU are responsible for calling it from your secondary threads. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From david.london at sentai.com Mon Dec 3 23:50:48 2007 From: david.london at sentai.com (David London) Date: Mon, 3 Dec 2007 15:50:48 -0700 Subject: [python-win32] Problems starting services - any advice? In-Reply-To: <47548152.8080709@probo.com> References: <200712031402.20879.david.london@sentai.com> <47548152.8080709@probo.com> Message-ID: <200712031550.49181.david.london@sentai.com> On Monday 03 December 2007 3:21:06 pm Tim Roberts wrote: > David London wrote: > > Hello all, > > I'm encountering some strangeness when running my python code on a > > windows machine and I was wondering if anyone had any advice, > > > > I have a number of python services (8) that run on a client machine, > > monitoring various database tables or folders, doing something with the > > data, then sleeping for a given amount of time and repeating. > > Normally, I have installed and run these services as "local system" and > > they have worked without any problems. > > For the latest client, they have asked that we run all of the services as > > a specific user. This is where I'm running into problems. > > When I attempt to start the 8th service, it gives me an error (error > > 1053: The service did not respond to the start or control request in a > > timely fashion). It doesn't matter what order I start them in, the eighth > > service always fails to start. And if I change the service back to run as > > "local service" it runs without problem. > > I'm pretty sure that this is not a windows specific problem, since I can > > create another user (with the same permissions) and when I attempt to > > start the service it gives me the same error. > > Why does that make you think it is not a "windows specific problem"? Because I didn't consider memory issues when I was thinking about the cause of the problem. > > > It appears as if there is some internal limit on the number of services > > that pywin can handle. > > > > Has anyone else encountered this? Or have any advice on where I could > > look to see what errors are being generated? I can not find any logs or > > error messages when the services fail to start. > > This is not a Python issue. It turns out to be a Windows issue. > > Every service that runs with a real user ID gets its own "desktop", > separate from the console desktop. Each desktop gets a chunk of heap > space for all of the applications running on that desktop, carved from a > global desktop heap. The size of each heap is about 3MB, but the > global heap has a non-configurable size of 48MB. Those were the numbers > as of Windows 2000, although it sounds like they aren't that much > different now. > > In the old days, you used to be able to adjust the size of this heap by > tweaking a registry entry: > HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session > Manager\Subsystems > In the "Windows" value, there's a parameter like > "SharedSection=1024,3072". The suggestion is to change that to > 1024,3072,512. However, on my XP SP2 machine, that's already what it says. > > Do your services need to interact with the user? The services never interact with the user. So, it's sounding like I'm just going to have to tell the client that the services need to run as "local service". David From jeffpeery at seametrics.com Tue Dec 4 02:16:43 2007 From: jeffpeery at seametrics.com (Jeff Peery) Date: Mon, 3 Dec 2007 17:16:43 -0800 Subject: [python-win32] problem accessing OPC clients from thread Message-ID: <000301c83613$55ebbb90$4400000a@seametrics.local> Ok, thanks. If I have a multithreaded application but use COM objects only within the secondary thread is pythoncom.CoInitialize() still required? So if I understand correctly, I could go the route I'm headed, but my code might be simpler and more reliable if I setup an event handler for the DataChange event of the group (as Graham pointed out). If that is the case, where might I go to learn about how to set that up? I appreciate your help! Jeff -----Original Message----------------------------------- Message: 4 Date: Mon, 03 Dec 2007 14:33:11 -0800 From: Tim Roberts Subject: Re: [python-win32] problem accessing OPC clients from thread To: Python-Win32 List Message-ID: <47548427.6000703 at probo.com> Content-Type: text/plain; charset=UTF-8 Jeff Peery wrote: > > Graham, > > thanks for the beta! I think my main problem is that I don?t really > understand this code; I didn?t write it. Could you recommend a > book/website that describes what these functions like > ?group.OPCItems.AddItem? do? For example I don?t really know what a > ?group? is or what the addItem() parameters are, or how to interpret > that error code that you interpreted, and I?m not really sure if this > code will work for other OPC servers other than the automation direct > server. > Although I can understand your frustration, I want to make sure you understand that the trouble you reported has nothing to do with the OPC tools or their usage. It is quite complicated to use COM objects in a multithreaded application. A COM object is allowed to declare itself as single-threaded; in that case, COM takes extra steps to transfer control over to a single thread before calling that object. To do that, COM has to have some per-thread data structures to communicate between threads. The way that setup gets done is by calling the CoInitialize API (exposed in Python as pythoncom.CoInitialize). If a multithreaded application expects to use COM objects in several threads, it is REQUIRED to call CoInitialize from every thread. The pywin32 library will call CoInitialize on the main thread for you, but YOU are responsible for calling it from your secondary threads. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071203/1cdd1627/attachment.htm From timr at probo.com Tue Dec 4 02:37:49 2007 From: timr at probo.com (Tim Roberts) Date: Mon, 03 Dec 2007 17:37:49 -0800 Subject: [python-win32] problem accessing OPC clients from thread In-Reply-To: <000301c83613$55ebbb90$4400000a@seametrics.local> References: <000301c83613$55ebbb90$4400000a@seametrics.local> Message-ID: <4754AF6D.5050709@probo.com> Jeff Peery wrote: > > > > If I have a multithreaded application but use COM objects only within > the secondary thread is pythoncom.CoInitialize() still required? > Every thread that will use COM services has to have run CoInitialize at some point. Pythoncom will automatically do a CoInitalize, but only in your main thread. From those two statements, you can see the answer to your question is YES. > So if I understand correctly, I could go the route I?m headed, but my > code might be simpler and more reliable if I setup an event handler > for the DataChange event of the group (as Graham pointed out). If that > is the case, where might I go to learn about how to set that up? > I'd Google for "pythoncom com event handling". It looks like there are some good hits there. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Tue Dec 4 02:40:14 2007 From: timr at probo.com (Tim Roberts) Date: Mon, 03 Dec 2007 17:40:14 -0800 Subject: [python-win32] Problems starting services - any advice? In-Reply-To: <200712031550.49181.david.london@sentai.com> References: <200712031402.20879.david.london@sentai.com> <47548152.8080709@probo.com> <200712031550.49181.david.london@sentai.com> Message-ID: <4754AFFE.4000406@probo.com> David London wrote: > The services never interact with the user. > So, it's sounding like I'm just going to have to tell the client that the > services need to run as "local service". > I suspect so. However, I should point out that the articles I got that information from were rather old. I'm surprised that such a limitation would have survived clear into Server 2003, but I also have to say that your symptoms match the problem description pretty well. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From n3atione at hotmail.com Wed Dec 5 11:37:47 2007 From: n3atione at hotmail.com (Alex Garipidis) Date: Wed, 5 Dec 2007 12:37:47 +0200 Subject: [python-win32] How can I edit a string inside a textbox Message-ID: Hello everybody, I have a Tkinter Textbox in my application. I want to scan the textbox for a symbol, defined by me as a "mark", and change the word that is inside or next to that symbol. This is what i mean: If a user types this to the textbox: "Hello @everybody, how are you doing?" I want to scan this string for the "@" character (or something else) and edit the word next to it (or "inside" it, e.g. "@everybody@"), "everybody" in this case, and make it have a color for example or make it underlined. I suspect that the answer is in the tag methods of Textbox but so far I haven't found an answer yet. Maybe I'm looking in the wrong direction :) Thank you all _________________________________________________________________ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071205/3e732c34/attachment.htm From patrick at gxlinc.com Wed Dec 5 19:04:20 2007 From: patrick at gxlinc.com (Patrick Li) Date: Wed, 5 Dec 2007 10:04:20 -0800 Subject: [python-win32] How to get command line parameters of running processes via pywin32 Message-ID: <2b5a48740712051004k6e6fd2a0me2a24bb62e447aea@mail.gmail.com> Hi, I am interested in scanning the user's process table periodically and getting the list of running process names as well as their command line parameters. For the process names, I am able to get the list of pids using win32process.EnumProcesses and then use win32api.OpenProcess and win32process.GetModuleFileNameEx to get the names. However, I couldn't find anywhere in the doc that tells me how to get the command line parameters for them as well. Then I found the WMI module on http://tgolden.sc.sabren.com/python/wmi_cookbook.html#running_processes that seems to do the trick: import wmi c = wmi.WMI () for process in c.Win32_Process (): print process.CommandLine Is that the most efficient way to get the command line parameters? My program will need to scan the process table quite often, so I am trying to make this operation as lightweight as noticeable. Thanks, Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071205/b1421600/attachment.htm From timr at probo.com Wed Dec 5 19:30:02 2007 From: timr at probo.com (Tim Roberts) Date: Wed, 05 Dec 2007 10:30:02 -0800 Subject: [python-win32] How to get command line parameters of running processes via pywin32 In-Reply-To: <2b5a48740712051004k6e6fd2a0me2a24bb62e447aea@mail.gmail.com> References: <2b5a48740712051004k6e6fd2a0me2a24bb62e447aea@mail.gmail.com> Message-ID: <4756EE2A.3030004@probo.com> Patrick Li wrote: > > I am interested in scanning the user's process table periodically and > getting the list of running process names as well as their command > line parameters. > > For the process names, I am able to get the list of pids using > win32process.EnumProcesses and then use win32api.OpenProcess and > win32process.GetModuleFileNameEx to get the names. However, I > couldn't find anywhere in the doc that tells me how to get the command > line parameters for them as well. > > Then I found the WMI module on > http://tgolden.sc.sabren.com/python/wmi_cookbook.html#running_processes > that seems to do the trick: > import wmi > c = wmi.WMI () > for process in c.Win32_Process (): > print process.CommandLine > > Is that the most efficient way to get the command line parameters? My > program will need to scan the process table quite often, so I am > trying to make this operation as lightweight as noticeable. That's the only way. The command line is stored in the process' private memory; there is no API to go fetch it. Why do you need to get this information "quite often"? What problem are you solving? What you describe is going to be a resource-intensive operation. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mail at timgolden.me.uk Thu Dec 6 10:59:59 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 06 Dec 2007 09:59:59 +0000 Subject: [python-win32] How to get command line parameters of running processes via pywin32 In-Reply-To: <4756EE2A.3030004@probo.com> References: <2b5a48740712051004k6e6fd2a0me2a24bb62e447aea@mail.gmail.com> <4756EE2A.3030004@probo.com> Message-ID: <4757C81F.402@timgolden.me.uk> Tim Roberts wrote: > Patrick Li wrote: >> I am interested in scanning the user's process table periodically and >> getting the list of running process names as well as their command >> line parameters. >> >> For the process names, I am able to get the list of pids using >> win32process.EnumProcesses and then use win32api.OpenProcess and >> win32process.GetModuleFileNameEx to get the names. However, I >> couldn't find anywhere in the doc that tells me how to get the command >> line parameters for them as well. >> >> Then I found the WMI module on >> http://tgolden.sc.sabren.com/python/wmi_cookbook.html#running_processes >> that seems to do the trick: >> import wmi >> c = wmi.WMI () >> for process in c.Win32_Process (): >> print process.CommandLine >> >> Is that the most efficient way to get the command line parameters? My >> program will need to scan the process table quite often, so I am >> trying to make this operation as lightweight as noticeable. > > That's the only way. The command line is stored in the process' private > memory; there is no API to go fetch it. > > Why do you need to get this information "quite often"? What problem are > you solving? What you describe is going to be a resource-intensive > operation. The wmi module is a bit sluggish and can be a CPU hog (especially when running intrinsic events). There are a couple of tips here on getting a bit of speed out of things, and if you want to come forward with a particular bit of code I might be able to give you some pointers: http://timgolden.me.uk/python/wmi-tutorial.html#speeding-things-up TJG From mc at mclaveau.com Thu Dec 6 12:57:49 2007 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 6 Dec 2007 12:57:49 +0100 Subject: [python-win32] How to get command line parameters of running processes via pywin32 In-Reply-To: <4756EE2A.3030004@probo.com> References: <2b5a48740712051004k6e6fd2a0me2a24bb62e447aea@mail.gmail.com> <4756EE2A.3030004@probo.com> Message-ID: <34EE4FCC99E54C0CAFB83608F83D42C3@MCI1330> Hi! WMI don't get command-line arguments, on windows released prior XP. Another (external) solution is commandline.exe tool. See : http://www.develop.com/us/technology/resourcedetail.aspx?id=ebf17b42-c3ee-47ee-8c53-73381e710c45 or http://www.bearcanyon.com/tools/ (Running Process Command Line Utility) @-salutations Michel Claveau From mharriger at gmail.com Thu Dec 6 17:42:31 2007 From: mharriger at gmail.com (Matt Harriger) Date: Thu, 6 Dec 2007 10:42:31 -0600 Subject: [python-win32] Using DDE to launch a file in an existing window Message-ID: <1eaa8ee20712060842n173f7167s356272765a950b53@mail.gmail.com> Hello all, I have a question about using DDE to launch a file in an existing application when double-clicked from explorer. I'm trying to use the built-in windows functionality for doing this by setting the application and topic keys in HKCR\my_file_type\shell\open\ddeexec. I also have HKCR\my_file_type\shell\open\command set up to launch my python script if windows can't find the application through dde ( i.e. it's not currently running). The python script create a server and registers the system topic as the very first thing it does. When I double-click a file of this type in Explorer, I get an error dialog saying that "windows cannot find ' filename.ext' Make sure you typed the name correctly...". Has anyone else been able to open a file in a running application this way? Thanks, --Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071206/5472356e/attachment.htm From timr at probo.com Thu Dec 6 19:41:41 2007 From: timr at probo.com (Tim Roberts) Date: Thu, 06 Dec 2007 10:41:41 -0800 Subject: [python-win32] Using DDE to launch a file in an existing window In-Reply-To: <1eaa8ee20712060842n173f7167s356272765a950b53@mail.gmail.com> References: <1eaa8ee20712060842n173f7167s356272765a950b53@mail.gmail.com> Message-ID: <47584265.4030604@probo.com> Matt Harriger wrote: > > I have a question about using DDE to launch a file in an existing > application when double-clicked from explorer. I'm trying to use the > built-in windows functionality for doing this by setting the > application and topic keys in HKCR\my_file_type\shell\open > \ddeexec. I also have HKCR\my_file_type\shell\open\command set up to > launch my python script if windows can't find the application through > dde ( i.e. it's not currently running). The python script create a > server and registers the system topic as the very first thing it does. > When I double-click a file of this type in Explorer, I get an error > dialog saying that "windows cannot find ' filename.ext' Make sure you > typed the name correctly...". Has anyone else been able to open a file > in a running application this way? Are you really using DDE? DDE is an antique protocol that is virtually extinct today. It's interesting to see someone trying to find a modern use for it. Can you dump the whole HKCR\my_file_type registry key and show it to us? Mail it to me privately, if you want. I'll see if anything looks unusual. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mharriger at gmail.com Thu Dec 6 20:20:18 2007 From: mharriger at gmail.com (Matt Harriger) Date: Thu, 6 Dec 2007 13:20:18 -0600 Subject: [python-win32] Using DDE to launch a file in an existing window In-Reply-To: <47584265.4030604@probo.com> References: <1eaa8ee20712060842n173f7167s356272765a950b53@mail.gmail.com> <47584265.4030604@probo.com> Message-ID: <1eaa8ee20712061120q537c9234r1d82c32f7dd5a51c@mail.gmail.com> Does windows provide a different/better/newer way than the ddeexec registry key to open a file in an existing window? Is the accepted way to do this now to take your arguments on the command line to a new instance of your application, then find your own open application and tell it to open the file? I'm open to any suggestions of a better way to do this. (side note: DDE may be antiquated, but internet explorer and firefox under windows XP both use this method to open a URL in an existing window if you, for example, type the URL in the run box). Here's an export from my registry. This example is not exactly as described above (it talks to the topic named "test", rather than the system topic) [HKEY_CLASSES_ROOT\ft000005] "EditFlags"=dword:00000000 "BrowserFlags"=dword:00000008 @="filetest file" [HKEY_CLASSES_ROOT\ft000005\shell] @="open" [HKEY_CLASSES_ROOT\ft000005\shell\open] [HKEY_CLASSES_ROOT\ft000005\shell\open\command] @="\"e:\\python24\\python.exe\" \"e:\\development\\filetest\\filetest.py\"" [HKEY_CLASSES_ROOT\ft000005\shell\open\ddeexec] @="open(%1)" [HKEY_CLASSES_ROOT\ft000005\shell\open\ddeexec\Application] @="filetest" [HKEY_CLASSES_ROOT\ft000005\shell\open\ddeexec\Topic] @="test" Sample code for filetest.py: import win32ui import dde from pywin.mfc import object class DdeSystemTopic(object.Object): def __init__(self): object.Object.__init__(self, dde.CreateServerSystemTopic()) def Exec(self, cmd): print "Exec:", cmd class DdeOtherTopic(object.Object): def __init__(self, topicName): object.Object.__init__(self, dde.CreateTopic(topicName)) def Exec(self, cmd): print "Exec:", cmd server = dde.CreateServer() server.AddTopic(DdeSystemTopic()) server.AddTopic(DdeOtherTopic('test')) server.Create("filetest") while 1: win32ui.PumpWaitingMessages(0, -1) Thanks! On Dec 6, 2007 12:41 PM, Tim Roberts wrote: > Matt Harriger wrote: > > > > I have a question about using DDE to launch a file in an existing > > application when double-clicked from explorer. I'm trying to use the > > built-in windows functionality for doing this by setting the > > application and topic keys in HKCR\my_file_type\shell\open > > \ddeexec. I also have HKCR\my_file_type\shell\open\command set up to > > launch my python script if windows can't find the application through > > dde ( i.e. it's not currently running). The python script create a > > server and registers the system topic as the very first thing it does. > > When I double-click a file of this type in Explorer, I get an error > > dialog saying that "windows cannot find ' filename.ext' Make sure you > > typed the name correctly...". Has anyone else been able to open a file > > in a running application this way? > > Are you really using DDE? DDE is an antique protocol that is virtually > extinct today. It's interesting to see someone trying to find a modern > use for it. > > Can you dump the whole HKCR\my_file_type registry key and show it to > us? Mail it to me privately, if you want. I'll see if anything looks > unusual. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071206/4701aa6e/attachment.htm From nytrokiss at gmail.com Sat Dec 8 19:27:09 2007 From: nytrokiss at gmail.com (James Matthews) Date: Sat, 8 Dec 2007 19:27:09 +0100 Subject: [python-win32] Nice Python Cartoon! Message-ID: <8a6b8e350712081027x538af86ck326d405f1c5f6697@mail.gmail.com> http://xkcd.com/353/ -- http://search.goldwatches.com/?Search=Movado+Watches http://www.jewelerslounge.com http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071208/1db4e0cd/attachment.htm From mc at mclaveau.com Sat Dec 8 22:06:29 2007 From: mc at mclaveau.com (Michel Claveau) Date: Sat, 8 Dec 2007 22:06:29 +0100 Subject: [python-win32] How to get command line parameters of runningprocesses via pywin32 In-Reply-To: <34EE4FCC99E54C0CAFB83608F83D42C3@MCI1330> References: <2b5a48740712051004k6e6fd2a0me2a24bb62e447aea@mail.gmail.com><4756EE2A.3030004@probo.com> <34EE4FCC99E54C0CAFB83608F83D42C3@MCI1330> Message-ID: <4F26307442334A7DB4C28000754750FD@MCI1330> Hi! > Thanks for the info. Do you know if the tool would work for XP and Vista > as well? > Thanks, > Patrick Yes, it run fine (on XP & Vista ultimate). @-salutations -- Michel Claveau __________________________________________ __________________________________________ On 12/6/07, Michel Claveau < mc at mclaveau.com> wrote: Hi! WMI don't get command-line arguments, on windows released prior XP. Another (external) solution is commandline.exe tool. See : http://www.develop.com/us/technology/resourcedetail.aspx?id=ebf17b42-c3ee-47ee-8c53-73381e710c45 or http://www.bearcanyon.com/tools/ (Running Process Command Line Utility) @-salutations Michel Claveau From mc at mclaveau.com Mon Dec 10 00:12:52 2007 From: mc at mclaveau.com (Michel Claveau) Date: Mon, 10 Dec 2007 00:12:52 +0100 Subject: [python-win32] Mailslot In-Reply-To: <4F26307442334A7DB4C28000754750FD@MCI1330> References: <2b5a48740712051004k6e6fd2a0me2a24bb62e447aea@mail.gmail.com><4756EE2A.3030004@probo.com><34EE4FCC99E54C0CAFB83608F83D42C3@MCI1330> <4F26307442334A7DB4C28000754750FD@MCI1330> Message-ID: <7A27D7CC822342399F623B2E5D84B28E@MCI1330> Hi! Mailslot is a simple & fast IPC (Inter Processus Call) (who use UDP & SMB). It's inside Windows from long time ago. With Vista, the (re)-new tool Waitfor.exe can use it, for synchronize batchs, applis or scripts (in local computer or in a LAN). This next code show the use of Python+PyWin32 for send a signal to Mailslot. Like a "client" Mailslot: import win32file,win32con mailslot = win32file.CreateFile(r'\\.\mailslot\waitfor.exe\ALERTTEST', win32file.GENERIC_WRITE, 0, None, win32con.CREATE_NEW, 0, None) win32file.WriteFile(mailslot, "ABC") mailslot.Close() Now, my problem is: I am not able to write a Mailslot server. I don't found any wrapper of the (kernel32) CreateMailslot et ReadFile functions. On this subject, Google is not my friend... Any idea? Perhaps a feature for the next release of PyWin32? Thank you to have read me. Michel Claveau From manjeetusw at gmail.com Mon Dec 10 11:08:40 2007 From: manjeetusw at gmail.com (Manjeet Singh) Date: Mon, 10 Dec 2007 21:08:40 +1100 Subject: [python-win32] JPEG to TIFF conversion Message-ID: <9b4e3f460712100208g7e996403k15c5451afac779bf@mail.gmail.com> Hi, I am a new to the image conversion /compression concepts. I have few thousands of images which were scanned in Uncompressed JPEG format(.Tiff and .Jpeg). I am required to convert them to standard tiff files(CCIT Group4). Is there any way to accomplish this in Python? I will be thankful for the comments and suggestions. I am using Python 2.3. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071210/de4d090c/attachment.htm From sjmachin at lexicon.net Mon Dec 10 13:00:42 2007 From: sjmachin at lexicon.net (John Machin) Date: Mon, 10 Dec 2007 23:00:42 +1100 Subject: [python-win32] JPEG to TIFF conversion In-Reply-To: <9b4e3f460712100208g7e996403k15c5451afac779bf@mail.gmail.com> References: <9b4e3f460712100208g7e996403k15c5451afac779bf@mail.gmail.com> Message-ID: <475D2A6A.2@lexicon.net> Manjeet Singh wrote: > Hi, > I am a new to the image conversion /compression concepts. I have > few thousands of images which were scanned in Uncompressed JPEG > format(.Tiff and .Jpeg). I am required to convert them to standard > tiff files(CCIT Group4). Is there any way to accomplish this in > Python? I will be thankful for the comments and suggestions. I am > using Python 2.3. http://www.pythonware.com/products/pil/ This may do the job -- check its manual (data formats in an appendix). Runs on any Python-supported platform, not just win32. Cheers, John From niki at vintech.bg Mon Dec 10 11:31:32 2007 From: niki at vintech.bg (niki) Date: Mon, 10 Dec 2007 12:31:32 +0200 Subject: [python-win32] JPEG to TIFF conversion In-Reply-To: <9b4e3f460712100208g7e996403k15c5451afac779bf@mail.gmail.com> References: <9b4e3f460712100208g7e996403k15c5451afac779bf@mail.gmail.com> Message-ID: <475D1584.1050808@vintech.bg> Manjeet Singh wrote: > Hi, > I am a new to the image conversion /compression concepts. I have few > thousands of images which were scanned in Uncompressed JPEG format(.Tiff > and .Jpeg). I am required to convert them to standard tiff files(CCIT > Group4). Is there any way to accomplish this in Python? I will be > thankful for the comments and suggestions. I am using Python 2.3. Try PIL (Python imaging library) Niki From le.dahut at laposte.net Mon Dec 10 16:57:09 2007 From: le.dahut at laposte.net (le dahut) Date: Mon, 10 Dec 2007 16:57:09 +0100 Subject: [python-win32] modify environment variable Message-ID: <475D61D5.4000303@laposte.net> Hello, A python program launched at user logon rewrites some registry keys such as "HKCU\Software\Microsoft\Windows\Current Version\Explorer\User Shell Folders\AppData" but explorer keeps using the old value. How can I make windows reload the registry since the users have a mandatory profile and the value can be different depending on the machine they are connecting to or the group they are member of ? Thanks, K. From timr at probo.com Mon Dec 10 19:49:39 2007 From: timr at probo.com (Tim Roberts) Date: Mon, 10 Dec 2007 10:49:39 -0800 Subject: [python-win32] modify environment variable In-Reply-To: <475D61D5.4000303@laposte.net> References: <475D61D5.4000303@laposte.net> Message-ID: <475D8A43.7090405@probo.com> le dahut wrote: > > A python program launched at user logon rewrites some registry keys such > as "HKCU\Software\Microsoft\Windows\Current Version\Explorer\User Shell > Folders\AppData" but explorer keeps using the old value. > Right, because Explorer is already running by the time your app launches. You need to notify (or restart) Explorer of the change. > How can I make windows reload the registry since the users have a > mandatory profile and the value can be different depending on the > machine they are connecting to or the group they are member of ? > "The machine they are connecting to"? What does that mean? Windows certainly supports the concept of a "roaming profile", where a given user gets the same profile setup no matter what machine they are on. The domain controller sets that up by copying the profile files and setting up the registry entries the first time they login on each machine. You can also use a domain login script to make these kinds of changes. Doing this stuff in a script called from the Startup group is the wrong way to do it. You should be able to use SHSetFolderPath to do this, but it isn't exported by name. You have to use GetProcAddress to fetch the address by ordinal. That's going to make it pretty hard to use from Python. An alternative is to use the IKnownFolder interface, which has a SetPath method to do this. But again, I think you are trying to install a hack solution for something that is fully supported by the normal Windows IT infrastructure. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon Dec 10 20:00:25 2007 From: timr at probo.com (Tim Roberts) Date: Mon, 10 Dec 2007 11:00:25 -0800 Subject: [python-win32] Mailslot In-Reply-To: <7A27D7CC822342399F623B2E5D84B28E@MCI1330> References: <2b5a48740712051004k6e6fd2a0me2a24bb62e447aea@mail.gmail.com><4756EE2A.3030004@probo.com><34EE4FCC99E54C0CAFB83608F83D42C3@MCI1330> <4F26307442334A7DB4C28000754750FD@MCI1330> <7A27D7CC822342399F623B2E5D84B28E@MCI1330> Message-ID: <475D8CC9.2060307@probo.com> Michel Claveau wrote: > Mailslot is a simple & fast IPC (Inter Processus Call) (who use UDP & SMB). > It's inside Windows from long time ago. > > With Vista, the (re)-new tool Waitfor.exe can use it, for synchronize > batchs, applis or scripts (in local computer or in a LAN). > > This next code show the use of Python+PyWin32 for send a signal to Mailslot. > Like a "client" Mailslot: > > import win32file,win32con > mailslot = > win32file.CreateFile(r'\\.\mailslot\waitfor.exe\ALERTTEST', > win32file.GENERIC_WRITE, 0, None, win32con.CREATE_NEW, 0, None) > win32file.WriteFile(mailslot, "ABC") > mailslot.Close() > > > Now, my problem is: I am not able to write a Mailslot server. I don't > found any wrapper of the (kernel32) CreateMailslot et ReadFile functions. > > On this subject, Google is not my friend... > You can use ctypes to do this, of course. http://www.asahi-net.or.jp/~sy7a-ht/sipc.py Once you have the handle, you don't really need ReadFile and WriteFile. You can use the Python I/O routines. Not sure it's any better. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mc at mclaveau.com Mon Dec 10 23:02:24 2007 From: mc at mclaveau.com (Michel Claveau) Date: Mon, 10 Dec 2007 23:02:24 +0100 Subject: [python-win32] Mailslot In-Reply-To: <475D8CC9.2060307@probo.com> References: <2b5a48740712051004k6e6fd2a0me2a24bb62e447aea@mail.gmail.com><4756EE2A.3030004@probo.com><34EE4FCC99E54C0CAFB83608F83D42C3@MCI1330> <4F26307442334A7DB4C28000754750FD@MCI1330><7A27D7CC822342399F623B2E5D84B28E@MCI1330> <475D8CC9.2060307@probo.com> Message-ID: <39E32E3869414E09AF0753BF6E52912E@MCI1330> Hi, Tim! Your code-link-example (sipc.py) don't run ("failure...") ; but with your other indications, and after much of research and attempts, and especially much of chance, I succeeded in coding a Mailslot server. Time to give a little in form the pieces of codes, thus some examples of interactions with BATCH (with waitfor.exe), and I will show you that. But, considering my current workload, that will take a few days... @-salutations Michel Claveau From cappy2112 at gmail.com Mon Dec 10 09:11:29 2007 From: cappy2112 at gmail.com (Tony Cappellini) Date: Mon, 10 Dec 2007 00:11:29 -0800 Subject: [python-win32] (in) Active State PyWin32 list Message-ID: <8249c4ac0712100011h4a67c409hfe6850f7d1110d19@mail.gmail.com> What's up with the archives on Active State? The PyWin32 arives stop in 2006. Are there any searchable archives for this list- where the user doe snot have to search each month separately? thanks From andrea.gavana at gmail.com Mon Dec 10 23:23:50 2007 From: andrea.gavana at gmail.com (Andrea Gavana) Date: Mon, 10 Dec 2007 23:23:50 +0100 Subject: [python-win32] SetClassLong on wx.PopupWindow breaks PyOpenGL and VTK Message-ID: Hi All, Sorry for the half off-topic question, but I am not sure if a solution to this problem can be found in wxPython or in pywin32 (or in ctypes). Using the class declared below, I am able to create a popup window with some shadow on it (I use it for FlatMenu). When I construct a popup window in this way, all the windows in my app which contain an OpenGL widget or a VTK widget do not repaint their background correctly (there is always an effect of see-through on them). If I comment out the call to SetClassLong everything works fine and the windows correctly repaint their background. I seem to recall someone writing that calling SetClassLong on a single window like that actually apply the shadowy style to all the windows in the application. If this is correct, is there a workaround to this problem? It's not easy to provide a sample app to demonstrate the problem, but I'll do my best. In the meanwhile, could someone suggest a possible cause/solution to this problem (even if it is a shot in the dark)? Thank you for any hint. import wx import win32api class ShadowPopupWindow(wx.PopupWindow): """ Base class for generic FlatMenu derived from wx.PopupWindow. """ def __init__(self): """ Default class constructor. """ parent = wx.GetApp().GetTopWindow() if not parent: raise Exception("Can't create menu without parent!") wx.PopupWindow.__init__(self, parent) GCL_STYLE= -26 cstyle= win32gui.GetClassLong(self.GetHandle(), GCL_STYLE) if cstyle & CS_DROPSHADOW == 0: win32api.SetClassLong(self.GetHandle(), GCL_STYLE, cstyle | CS_DROPSHADOW) Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.alice.it/infinity77/ From timr at probo.com Mon Dec 10 23:32:54 2007 From: timr at probo.com (Tim Roberts) Date: Mon, 10 Dec 2007 14:32:54 -0800 Subject: [python-win32] (in) Active State PyWin32 list In-Reply-To: <8249c4ac0712100011h4a67c409hfe6850f7d1110d19@mail.gmail.com> References: <8249c4ac0712100011h4a67c409hfe6850f7d1110d19@mail.gmail.com> Message-ID: <475DBE96.4000900@probo.com> Tony Cappellini wrote: > What's up with the archives on Active State? > The PyWin32 arives stop in 2006. > > Are there any searchable archives for this list- where the user doe > snot have to search each month separately? > Gmane keeps a mirror of this mailing list. They call it gmane.comp.python.windows. http://dir.gmane.org/gmane.comp.python.windows -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From larry.bates at websafe.com Mon Dec 10 23:47:17 2007 From: larry.bates at websafe.com (Larry Bates) Date: Mon, 10 Dec 2007 16:47:17 -0600 Subject: [python-win32] JPEG to TIFF conversion In-Reply-To: <9b4e3f460712100208g7e996403k15c5451afac779bf@mail.gmail.com> References: <9b4e3f460712100208g7e996403k15c5451afac779bf@mail.gmail.com> Message-ID: Manjeet Singh wrote: > Hi, > I am a new to the image conversion /compression concepts. I have few > thousands of images which were scanned in Uncompressed JPEG format(.Tiff > and .Jpeg). I am required to convert them to standard tiff files(CCIT > Group4). Is there any way to accomplish this in Python? I will be > thankful for the comments and suggestions. I am using Python 2.3. > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 PIL can convert to TIF, but can't save as compressed TIF. You can use an external program like tiffcp to compress them. I've done this before by writing the file, then calling os.system to run tiffcp. -Larry From mc at mclaveau.com Mon Dec 10 23:52:53 2007 From: mc at mclaveau.com (Michel Claveau) Date: Mon, 10 Dec 2007 23:52:53 +0100 Subject: [python-win32] (in) Active State PyWin32 list In-Reply-To: <8249c4ac0712100011h4a67c409hfe6850f7d1110d19@mail.gmail.com> References: <8249c4ac0712100011h4a67c409hfe6850f7d1110d19@mail.gmail.com> Message-ID: Hi! Look here: http://mail.python.org/pipermail/python-win32/ Perso, I see up December-2007 @+ Michel Claveau From rwupole at msn.com Tue Dec 11 00:28:12 2007 From: rwupole at msn.com (Roger Upole) Date: Mon, 10 Dec 2007 18:28:12 -0500 Subject: [python-win32] Mailslot Message-ID: I've added CreateMailslot, GetMailslotInfo and SetMailslotInfo to win32file, so they should be available in the next release. Roger From mhammond at skippinet.com.au Tue Dec 11 00:30:03 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 11 Dec 2007 10:30:03 +1100 Subject: [python-win32] modify environment variable In-Reply-To: <475D61D5.4000303@laposte.net> References: <475D61D5.4000303@laposte.net> Message-ID: <008601c83b84$997f2e70$cc7d8b50$@com.au> > A python program launched at user logon rewrites some registry keys > such > as "HKCU\Software\Microsoft\Windows\Current Version\Explorer\User Shell > Folders\AppData" but explorer keeps using the old value. > > How can I make windows reload the registry since the users have a > mandatory profile and the value can be different depending on the > machine they are connecting to or the group they are member of ? Broadcasting a WM_SETTINGCHANGE message to all Windows might do what you want, and cause explorer to reload its env variables. Other processes already executing which don't look for this message will not be changed though... Cheers, Mark From mc at mclaveau.com Tue Dec 11 07:27:12 2007 From: mc at mclaveau.com (Michel Claveau) Date: Tue, 11 Dec 2007 07:27:12 +0100 Subject: [python-win32] Mailslot In-Reply-To: References: Message-ID: <2924E3317D2B4A8CBC837D5F3B401D45@MCI1330> Hi! > I've added CreateMailslot, GetMailslotInfo and SetMailslotInfo to > win32file, so they should be available in the next release. 3 points : - thanks, Roger - Aaaaarrrrggghhhh! All this work, and all this time spent (by me), for nothing! - thanks, Roger!!! @-salutations Michel Claveau From le.dahut at laposte.net Tue Dec 11 14:39:32 2007 From: le.dahut at laposte.net (le dahut) Date: Tue, 11 Dec 2007 14:39:32 +0100 Subject: [python-win32] modify environment variable In-Reply-To: <475D8A43.7090405@probo.com> References: <475D61D5.4000303@laposte.net> <475D8A43.7090405@probo.com> Message-ID: <475E9314.3080806@laposte.net> Actually I use winlogon notification http://www.codeproject.com/KB/system/winlogon_notification_package.aspx to launch an app that reads a configuration file on a samba PDC server and write some registry keys. The configuration file depends on : - user name or group - machine name (there's a concept of machine group based on machine names) thus configuration file can be \\\netlogon\\.xml With graphical app that contains a database of registry keys and descriptions about them ("User cannot access printer configuration", "Hide checked drivers from My Computer" etc.). So at logon, the program rewrites also the Desktop, Start Menu, ... and AppData paths. This is done before explorer starts (eventually kill and restart it if it runs). But in a command line prompt "cmd" 'echo %appdata%' doesn't return the path written in the registry. And I've noticed that some application gets AppdData path from something like "os.environ['APPDATA']". What can I do to solve this ? Tim Roberts wrote : > le dahut wrote: >> A python program launched at user logon rewrites some registry keys such >> as "HKCU\Software\Microsoft\Windows\Current Version\Explorer\User Shell >> Folders\AppData" but explorer keeps using the old value. >> > > Right, because Explorer is already running by the time your app > launches. You need to notify (or restart) Explorer of the change. > >> How can I make windows reload the registry since the users have a >> mandatory profile and the value can be different depending on the >> machine they are connecting to or the group they are member of ? >> > > "The machine they are connecting to"? What does that mean? Windows > certainly supports the concept of a "roaming profile", where a given > user gets the same profile setup no matter what machine they are on. > The domain controller sets that up by copying the profile files and > setting up the registry entries the first time they login on each > machine. You can also use a domain login script to make these kinds of > changes. Doing this stuff in a script called from the Startup group is > the wrong way to do it. > > You should be able to use SHSetFolderPath to do this, but it isn't > exported by name. You have to use GetProcAddress to fetch the address > by ordinal. That's going to make it pretty hard to use from Python. An > alternative is to use the IKnownFolder interface, which has a SetPath > method to do this. But again, I think you are trying to install a hack > solution for something that is fully supported by the normal Windows IT > infrastructure. > From timr at probo.com Tue Dec 11 18:17:53 2007 From: timr at probo.com (Tim Roberts) Date: Tue, 11 Dec 2007 09:17:53 -0800 Subject: [python-win32] Mailslot In-Reply-To: <2924E3317D2B4A8CBC837D5F3B401D45@MCI1330> References: <2924E3317D2B4A8CBC837D5F3B401D45@MCI1330> Message-ID: <475EC641.1050506@probo.com> Michel Claveau wrote: >> I've added CreateMailslot, GetMailslotInfo and SetMailslotInfo to >> win32file, so they should be available in the next release. >> > > 3 points : > - thanks, Roger > - Aaaaarrrrggghhhh! All this work, and all this time spent (by me), for > nothing! > Hey, now, this wasn't wasted time at all! First of all, your exploration and your potential work around will be recorded for posterity in the archives of this mailing list. Someone who comes by next year with the same question will be able to look at the path you went down, and make their choice based on the version of things they are required to run. Second of all, "ctypes" is the Swiss army knife of Windows Python programming. Any expertise you gained in ctypes usage while exploring this will pay back handsomely the next time you are faced with a similar problem. Third of all, it has been educational for all of us. I've been doing Windows programming for 17 years, and in all that time, I have never come across a good use for a mailslot that couldn't be better solved in another way. It's interesting to me that you have such an application. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From basti at benkers-rock.de Tue Dec 11 21:16:34 2007 From: basti at benkers-rock.de (Sebastian Friebe) Date: Tue, 11 Dec 2007 21:16:34 +0100 Subject: [python-win32] USB access using win32file.deviceIOcontrol Message-ID: <1476839760.20071211211634@benkers-rock.de> Hi all, I'm trying to get access to a USB mass storage device in order to send low-level SCSI commands, like TEST_UNIT_READY and REQUEST_SENSE. I'm looking for a pure Python solution using the deviceIOcontrol function out of the win32file package. Does anyone has experience with it? I heared about libusb_win32 and pyUSB, but I couldn't figure out if these are really required. I guess these packages are needed just in case you want to do higher level operations in an application, right? Thanks for your help in advance and best regards, Sebastian From timr at probo.com Tue Dec 11 22:24:27 2007 From: timr at probo.com (Tim Roberts) Date: Tue, 11 Dec 2007 13:24:27 -0800 Subject: [python-win32] USB access using win32file.deviceIOcontrol In-Reply-To: <1476839760.20071211211634@benkers-rock.de> References: <1476839760.20071211211634@benkers-rock.de> Message-ID: <475F000B.5030904@probo.com> Sebastian Friebe wrote: > I'm trying to get access to a USB mass storage device in order to send > low-level SCSI commands, like TEST_UNIT_READY and REQUEST_SENSE. > I'm looking for a pure Python solution using the deviceIOcontrol > function out of the win32file package. > > Does anyone has experience with it? > > I heared about libusb_win32 and pyUSB, but I couldn't figure out if > these are really required. I guess these packages are needed just in > case you want to do higher level operations in an application, right? This can't be done as you have described it. The problem is that the SCSI-like command set is only used between the USB mass storage driver (usbstor.sys) and the USB host controller driver. Above usbstor.sys, the device looks like a standard mass storage device. There are no hooks in usbstor.sys to allow you to send commands like this, nor does usbstor.sys allow you to send USB packets directly. Neither libusb-win32 nor pyUSB will help, because there is already a driver handling the device. libusb installs its own generic driver, but it can't install a driver if another one has already claimed the device. Theoretically, you could write an INF file to force your device to be claimed by libusb's driver, and then use libusb commands to talk to the device. You would then be in COMPLETE control of the device. However, that also means it won't be recognized as a mass storage device. It will just be a generic USB device. It may be that the easiest course of action for you is to write a lower filter driver to sit between usbstor.sys and USBD, and have it expose a "control" device object. Such a thing CAN be opened and manipulated using the win32file APIs. Do you have any driver experience at your shop? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From larry.bates at websafe.com Wed Dec 12 16:01:47 2007 From: larry.bates at websafe.com (Larry Bates) Date: Wed, 12 Dec 2007 09:01:47 -0600 Subject: [python-win32] JPEG to TIFF conversion In-Reply-To: References: <9b4e3f460712100208g7e996403k15c5451afac779bf@mail.gmail.com> Message-ID: Larry Bates wrote: > Manjeet Singh wrote: >> Hi, >> I am a new to the image conversion /compression concepts. I have few >> thousands of images which were scanned in Uncompressed JPEG format(.Tiff >> and .Jpeg). I am required to convert them to standard tiff files(CCIT >> Group4). Is there any way to accomplish this in Python? I will be >> thankful for the comments and suggestions. I am using Python 2.3. >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 > > PIL can convert to TIF, but can't save as compressed TIF. You can use an > external program like tiffcp to compress them. I've done this before by writing > the file, then calling os.system to run tiffcp. > > -Larry Manjeet Singh Wadhwa wrote: > Hi Larry, > Thanks a lot for your information. I really appreciate it. Do you know any site where I can get the code from to convert my file into Tiff using PIL . > > > From: *Larry Bates* > > Date: Dec 11, 2007 9:47 AM > Subject: Re: [python-win32] JPEG to TIFF conversion > To: python-win32 at python.org > > > Manjeet Singh wrote: > > Hi, > > I am a new to the image conversion /compression concepts. I have few > > thousands of images which were scanned in Uncompressed JPEG format(.Tiff > > and .Jpeg). I am required to convert them to standard tiff files(CCIT > > Group4). Is there any way to accomplish this in Python? I will be > > thankful for the comments and suggestions. I am using Python 2.3. > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > PIL can convert to TIF, but can't save as compressed TIF. You can use an > external program like tiffcp to compress them. I've done this before by writing > the file, then calling os.system to run tiffcp. > > -Larry > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > Warm Regards, > > *Manjeet Singh Wadhwa * > > > FileNet BPM and Document Imaging Solutions > > *Extension 20716* > * > ------------------------------------------------------------------------ > * > > ********************************************************************** > > ***** IMPORTANT INFORMATION ***** > > This document should be read only by those persons to whom it is > > addressed and its content is not intended for use by any other > > persons. If you have received this message in error, please notify > > us immediately. Please also destroy and delete the message from > > your computer. Any unauthorised form of reproduction of this message > > is strictly prohibited. > > > > St George Bank Limited AFSL 240997, Advance Asset Management Limited > > AFSL 240902, St George Life Limited AFSL 240900, ASGARD Capital Management Limited > > AFSL 240695 and Securitor Financial Group Limited AFSL 240687 is not liable for > > the proper and complete transmission of the information contained in > > this communication, nor for any delay in its receipt. > > ********************************************************************** > > > Are all your images single pages and do you want to create single page TIF files? If so it is quite easy: from PIL import Image # # Assumptions: your .jpg files are 256 bit color (or grayscale) # im=Image.open(inputFile) im2=im.convert('1') # convert to black and white im2.save(outputFile, 'TIFF') where: inputFile is your .JPG file outputFile is your .TIF file then use: tiffcp -c g4 outputfile.tif outputfileG5.tif On the other hand, if you want to create multi-page tiffs it is quite a bit more complicated. This creates uncompressed TIF file. I've used NetPBM Hope this helps. -Larry From basti at benkers-rock.de Wed Dec 12 19:58:40 2007 From: basti at benkers-rock.de (Sebastian Friebe) Date: Wed, 12 Dec 2007 19:58:40 +0100 Subject: [python-win32] USB access using win32file.deviceIOcontrol In-Reply-To: <1476839760.20071211211634@benkers-rock.de> References: <1476839760.20071211211634@benkers-rock.de> Message-ID: <1644953368.20071212195840@benkers-rock.de> Tim Roberts wrote: > This can't be done as you have described it. > > The problem is that the SCSI-like command set is only used between the > USB mass storage driver (usbstor.sys) and the USB host controller > driver. Above usbstor.sys, the device looks like a standard mass > storage device. There are no hooks in usbstor.sys to allow you to send > commands like this, nor does usbstor.sys allow you to send USB packets > directly. I saw an implementation in C++ using the winAPI DeviceIOControl() function to do low-level SCSI operations on a USB mass storage device. It is defined as follows: BOOL WINAPI DeviceIoControl( __in HANDLE hDevice, __in DWORD dwIoControlCode, __in_opt LPVOID lpInBuffer, __in DWORD nInBufferSize, __out_opt LPVOID lpOutBuffer, __in DWORD nOutBufferSize, __out_opt LPDWORD lpBytesReturned, __inout_opt LPOVERLAPPED lpOverlapped ); following settings have been applied: dwIoControlCode = IOCTL_SCSI_PASS_THROUGH_DIRECT lpInBuffer = lpOutBuffer = a structure containing several settings like PATH, TARGET, LUN IDs and CDB[] array and a buffer for input and output data So if your statement is right, this should even not work under C++, right? But it does. Are there maybe some other stuff what makes it different? I really would like to understand that topic. Do you know some good references where I can find detailed information about USB handling under Windows environment? My first attempt to get it running under Python looks like this: IOCTL_SCSI_PASS_THROUGH_DIRECT = 0x4D014 disk_handle=win32file.CreateFile("\\\\.\\j:", win32con.GENERIC_READ|win32con.GENERIC_WRITE|win32con.GENERIC_EXECUTE, win32file.FILE_SHARE_READ |win32file.FILE_SHARE_WRITE, None, win32con.OPEN_EXISTING, 0, None); data = array.array("B", byte_list) string = win32file.DeviceIoControl(disk_handle,IOCTL_SCSI_PASS_THROUGH_DIRECT, data, 0, None) It seems that Windows excepted the control code, cause if I use a wrong one, I get an SYSTEM ERROR 50 - which is 'The request is not supported.' If I use the right control code I get sometimes the SYSTEM ERROR 1450 - "Insufficient system resources exist to complete the requested service." So it seemsfor me, that at least a contact to the USB driver is possible. What do you think? Thanks again for your help. Sebastian From timr at probo.com Wed Dec 12 20:29:05 2007 From: timr at probo.com (Tim Roberts) Date: Wed, 12 Dec 2007 11:29:05 -0800 Subject: [python-win32] USB access using win32file.deviceIOcontrol In-Reply-To: <1644953368.20071212195840@benkers-rock.de> References: <1476839760.20071211211634@benkers-rock.de> <1644953368.20071212195840@benkers-rock.de> Message-ID: <47603681.4080102@probo.com> Sebastian Friebe wrote: > I saw an implementation in C++ using the winAPI DeviceIOControl() > function to do low-level SCSI operations on a USB mass storage device. > It is defined as follows: > > BOOL WINAPI DeviceIoControl( > ... > following settings have been applied: > dwIoControlCode = IOCTL_SCSI_PASS_THROUGH_DIRECT > lpInBuffer = lpOutBuffer = a structure containing several settings > like PATH, TARGET, LUN IDs and CDB[] > array and a buffer for input and output > data > > So if your statement is right, this should even not work under C++, > right? But it does. > OK, you talked me into it. > Are there maybe some other stuff what makes it different? > I really would like to understand that topic. > Do you know some good references where I can find detailed information > about USB handling under Windows environment? > > My first attempt to get it running under Python looks like this: > > IOCTL_SCSI_PASS_THROUGH_DIRECT = 0x4D014 > That number is correct. > disk_handle=win32file.CreateFile("\\\\.\\j:", > win32con.GENERIC_READ|win32con.GENERIC_WRITE|win32con.GENERIC_EXECUTE, > win32file.FILE_SHARE_READ |win32file.FILE_SHARE_WRITE, > None, > win32con.OPEN_EXISTING, > 0, > None); > GENERIC_EXECUTE should not be required, but if your C++ example had it, you might as well keep it. Does the CreateFile succeed? You get a reasonable handle? Note that on Vista you must be elevated to open a volume directly. > data = array.array("B", byte_list) > string = win32file.DeviceIoControl(disk_handle,IOCTL_SCSI_PASS_THROUGH_DIRECT, data, 0, None) > > It seems that Windows excepted the control code, cause if I use a > wrong one, I get an SYSTEM ERROR 50 - which is 'The request is not > supported.' > That's fundamentally correct. How are you creating the SCSI_PASS_THROUGH structure in "byte_list"? Are you sure it is 42 bytes? Are you setting all the fields correctly? How are you setting the DataBuffer pointer? Have you set the Length field correctly? I would have guessed it would be easier to use the struct module to build the buffer, rather than array. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From basti at benkers-rock.de Wed Dec 12 21:41:15 2007 From: basti at benkers-rock.de (Sebastian Friebe) Date: Wed, 12 Dec 2007 21:41:15 +0100 Subject: [python-win32] USB access using win32file.deviceIOcontrol In-Reply-To: <47603681.4080102@probo.com> References: <1476839760.20071211211634@benkers-rock.de> <1644953368.20071212195840@benkers-rock.de> <47603681.4080102@probo.com> Message-ID: <1517516963.20071212214115@benkers-rock.de> Tim Roberts wrote: TR> That's fundamentally correct. How are you creating the TR> SCSI_PASS_THROUGH structure in "byte_list"? Are you sure it is 42 TR> bytes? Are you setting all the fields correctly? How are you setting TR> the DataBuffer pointer? Have you set the Length field correctly? That's exactly my problem. I know there are some pointers in the C++ structure pointing to the data inside the structure. But I don't have an idea at all, how to port it to Python. Could you give me an example of a very basic SCSI command, like the TEST_UNIT_READY ? Tim Roberts wrote: TR> I would have guessed it would be easier to use the struct module to TR> build the buffer, rather than array. I didn't know if it would work, so I started with a very strait forward approach. I extracted the content of the SCSI_PASS_THROUGH in my C++ example into a array of bytes. I included the byte stream I found into my byte_list. e.g. SCSI_TEST_UNIT_READY=[0x2C,0x00,0x00,0x00,0x01,0x00,0x06,0x18,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ 0x00,0x00,0x00,0x00] byte_list = SCSI_TEST_UNIT_READY If the basic functionality is proven, I planned to go for a more object oriented approach like: class SCSI_PASS_THROUGH_DIRECT(object): def __init__(self, cdbLength = 16, transfer_length, transfer_direction): self.Length = 0 # USHORT Length; self.ScsiStatus = 0 # UCHAR ScsiStatus; self.PathId = 0 # UCHAR PathId; self.TargetId = 1 # UCHAR TargetId; self.Lun = 0 # UCHAR Lun; self.CdbLength = cdbLength # UCHAR CdbLength; self.SenseInfoLength = 24 # UCHAR SenseInfoLength; self.DataIn = transfer_direction # UCHAR DataIn; self.DataTransferLength = transfer_length # ULONG DataTransferLength; self.TimeOutValue = 2 # ULONG TimeOutValue; self.DataBuffer = 0 # PVOID DataBuffer; self.SenseInfoOffset = 0 # ULONG SenseInfoOffset; self.Cdb = [] # UCHAR Cdb[16]; But again, I don't know how to handle the buffer pointers inside the structure. From timr at probo.com Wed Dec 12 22:20:33 2007 From: timr at probo.com (Tim Roberts) Date: Wed, 12 Dec 2007 13:20:33 -0800 Subject: [python-win32] USB access using win32file.deviceIOcontrol In-Reply-To: <1517516963.20071212214115@benkers-rock.de> References: <1476839760.20071211211634@benkers-rock.de> <1644953368.20071212195840@benkers-rock.de> <47603681.4080102@probo.com> <1517516963.20071212214115@benkers-rock.de> Message-ID: <476050A1.5040101@probo.com> Sebastian Friebe wrote: > That's exactly my problem. > I know there are some pointers in the C++ structure pointing to the > data inside the structure. But I don't have an idea at all, how to > port it to Python. > > Could you give me an example of a very basic SCSI command, like the > TEST_UNIT_READY ? > I'm afraid I can't. I write Windows drivers for a living, so I do an awful lot of DeviceIoControl calls, but so far we have managed to avoid working the disk arena. > I didn't know if it would work, so I > started with a very strait forward approach. > I extracted the content of the SCSI_PASS_THROUGH in my C++ example > into a array of bytes. > I included the byte stream I found into my byte_list. > e.g. > SCSI_TEST_UNIT_READY=[0x2C,0x00,0x00,0x00,0x01,0x00,0x06,0x18,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ > 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ > 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ > 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ > 0x00,0x00,0x00,0x00] > The length says 0x2C, which is 44 decimal, but unless I have miscounted, there are 0x44 bytes of data there, which is 64 decimal. > byte_list = SCSI_TEST_UNIT_READY > > If the basic functionality is proven, I planned to go for a more > object oriented approach like: > > class SCSI_PASS_THROUGH_DIRECT(object): > def __init__(self, cdbLength = 16, transfer_length, transfer_direction): > self.Length = 0 # USHORT Length; > self.ScsiStatus = 0 # UCHAR ScsiStatus; > I'm afraid that you will end up battling against the language here. I have three possible suggestions for you. 1. Consider using ctypes. ctypes includes mechanisms where you can build up C structures in a Pythonic way, almost exactly like you have done here. 2. Consider using SWIG. Swig will allow you to build a C or C++ DLL that can be called directly from Python. You could hide the pointer ugliness inside the C code, and still wrap it with a Python class. Swig is extraordinarily powerful, although there is a bit of a learning curve if you need to do anything unusual. There are lots of good example, however. 3. Consider using boost.python. If you know C++, the Boost libraries include a very good set of template classes that let you build Python object in C++ in a more natural way. Like option 2, this would let you put the sticky parts in C++ and the fun parts in Python. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From carl at personnelware.com Thu Dec 13 02:39:05 2007 From: carl at personnelware.com (Carl Karsten) Date: Wed, 12 Dec 2007 19:39:05 -0600 Subject: [python-win32] OT - move gnome launch bar Message-ID: <47608D39.4080306@personnelware.com> I am searching for the right place to ask this question. pretty sure it is something gnome related. very sure it isn't MS Windows, but I am hoping someone here knows... In Unbuntu/gnome, I want a python program to move the top and bottom launcher bars to the left and right. Anyone know where I should ask? Carl K From timr at probo.com Thu Dec 13 03:07:02 2007 From: timr at probo.com (Tim Roberts) Date: Wed, 12 Dec 2007 18:07:02 -0800 Subject: [python-win32] OT - move gnome launch bar In-Reply-To: <47608D39.4080306@personnelware.com> References: <47608D39.4080306@personnelware.com> Message-ID: <476093C6.4080001@probo.com> Carl Karsten wrote: > I am searching for the right place to ask this question. pretty sure it is > something gnome related. very sure it isn't MS Windows, but I am hoping someone > here knows... > > In Unbuntu/gnome, I want a python program to move the top and bottom launcher > bars to the left and right. > > Anyone know where I should ask? > There is a standard mechanism for communicating with the window manager in X, but you'll have to ask on a Gnome-specific group to find out the exact API for it. My first stop would probably be comp.os.linux.x. Even if they don't know, they'll know where to point next. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From sidnei at enfoldsystems.com Thu Dec 13 03:07:24 2007 From: sidnei at enfoldsystems.com (Sidnei da Silva) Date: Thu, 13 Dec 2007 00:07:24 -0200 Subject: [python-win32] OT - move gnome launch bar In-Reply-To: <47608D39.4080306@personnelware.com> References: <47608D39.4080306@personnelware.com> Message-ID: On Dec 12, 2007 11:39 PM, Carl Karsten wrote: > I am searching for the right place to ask this question. pretty sure it is > something gnome related. very sure it isn't MS Windows, but I am hoping someone > here knows... > > In Unbuntu/gnome, I want a python program to move the top and bottom launcher > bars to the left and right. > > Anyone know where I should ask? Try the pygtk mailing lists, or the #pygtk irc channel. -- Sidnei da Silva Enfold Systems http://enfoldsystems.com Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214 From cappy2112 at gmail.com Thu Dec 13 07:31:32 2007 From: cappy2112 at gmail.com (Tony Cappellini) Date: Wed, 12 Dec 2007 22:31:32 -0800 Subject: [python-win32] python-win32 Digest, Vol 57, Issue 14 In-Reply-To: References: Message-ID: <8249c4ac0712122231o3bcfca12g314484d2362b6469@mail.gmail.com> Message: 4 Date: Wed, 12 Dec 2007 21:41:15 +0100 From: Sebastian Friebe Subject: Re: [python-win32] USB access using win32file.deviceIOcontrol To: Python-Win32 List Message-ID: <1517516963.20071212214115 at benkers-rock.de> Content-Type: text/plain; charset=us-ascii Tim Roberts wrote: TR> That's fundamentally correct. How are you creating the TR> SCSI_PASS_THROUGH structure in "byte_list"? Are you sure it is 42 TR> bytes? Are you setting all the fields correctly? How are you setting TR> the DataBuffer pointer? Have you set the Length field correctly? Don't forget the data direction variable. That's equally as important. You'll light up your screen blue as the day, if you get a driver which isn't robust. Test unit read does not transfer any data so the data transfer length should be zero, in the CDB and the data direction must variable must be set to whatever indicates no data transfer. >>cdbLength = 16 I would think the CDB should be set to 6, since test unit ready is a 6-buye command, but if 16 worked in your C++ example, tha should be fine here too. >>But I don't have an idea at all, how to port it to Python. Tim mentioned the struct module, and I would agree, but there may be other ways. class SCSI_PASS_THROUGH_DIRECT(object): >>But again, I don't know how to handle the buffer pointers inside the structure. Nor do I. You may have to call a DLL from Python to pass a pointer to the SCSI pass thru layer. There may be a way to do this with ctypes though. From cappy2112 at gmail.com Thu Dec 13 07:49:04 2007 From: cappy2112 at gmail.com (Tony Cappellini) Date: Wed, 12 Dec 2007 22:49:04 -0800 Subject: [python-win32] USB access using win32file.deviceIOcontrol Message-ID: <8249c4ac0712122249m3a8567a9i534d9acda096343f@mail.gmail.com> I recently wrote some C code to send SATA commands to a system drive, using the ATA pass through layer. I found this news group very helpful, since it deals with drivers. http://groups.google.com/group/microsoft.public.windowsxp.device_driver.dev/topics I wouldn't mentioned Python on that newsgroup though. If you post any questions, pretend your doing it from C. You may not get any help if you say you're trying to do it from Python. ;-) Also- you should try to write the C or C++ code to actually send the command first, until you get the mechanism down, then use ctypes or a C DLL to be called from Python. Also, stick with the Test Unit Ready command or any other command that doesn't transfer data. It will be easier to work out the mechanism that way. When you start transferring data, drivers like the buffers to be aligned to some specific boundary. Rather than get hung up on data transfer now, you can deal with that later once you understand how to get a simple command across. Message: 4 Date: Wed, 12 Dec 2007 21:41:15 +0100 From: Sebastian Friebe Subject: Re: [python-win32] USB access using win32file.deviceIOcontrol To: Python-Win32 List Message-ID: <1517516963.20071212214115 at benkers-rock.de> Content-Type: text/plain; charset=us-ascii class SCSI_PASS_THROUGH_DIRECT(object): From jeffpeery at yahoo.com Fri Dec 14 01:31:55 2007 From: jeffpeery at yahoo.com (Jeff Peery) Date: Thu, 13 Dec 2007 16:31:55 -0800 (PST) Subject: [python-win32] problem accessing OPC clients from thread In-Reply-To: <4755343C.8040605@trihedral.com> Message-ID: <139960.95080.qm@web43143.mail.sp1.yahoo.com> Hello, I've gotten my OPC client to work well under a multi threaded wxApp. Now I am trying to create a single threaded App because, from what I've learned from users on this list, it is a simpler and cleaner way to do ththings. I've setup a test script that allows me to catch DataChange events (see attached code). This seems to work well. Now I'm one step from putting it into my wxApp, and I'm wondering how can I do this? Ideally I want the OnDataChange method to be a method in my wxApp. But it is instead a method that is part of the GroupEvents class. Do I need to post an event from the GroupEvents.OnDataChange method to the wxApp so that I can catch the data change event in the wxApp? How is this typically done? Big Thanks! Jeff Graham Bloice wrote: Jeff Peery wrote: > thanks for the beta! > > I think my main problem is that I don't really understand this code; I > didn't write it. Could you recommend a book/website that describes > what these functions like 'group.OPCItems.AddItem' do? For example, > how do I know what a 'group' is or what the addItem() parameters are, > or how to interpret that error code that you interpreted, and I'm not > really sure if this code will work for other OPC servers other than > the automation direct server. > > Also, where might I go learn about how to setup the event handler for > a data change event? > > Thanks again, I appreciate your help! > Jeff > The canonical definition of the OPC Automation interface API is the OPC DA Auto 2.02 Specification. DA stands for Data Acquisition. The originators of this document are the OPC Foundation, at http://www.opcfoundation.org, and the specification is *so* open you have to become a member to download it (at a cost of USD 1500). Grrr. However, if your Google fu is up to it you might find a copy lying around elsewhere, as I have run across it on several OPC Vendors sites. I think I've also found it with several OPC Servers. I would recommend that you get the Matrikon OPC Simulation server for testing, this installs the Matrikon OPC Explorer which is a useful client app to work out what's happening when your client doesn't work. This might give you the docs. The document goes under various names such as opcda20_auto.doc. Note that the docs are VB (VB6) based, but not too difficult to convert to python. You will also want to read up on creating event handlers in PyWin -- Regards, Graham Bloice --------------------------------- Looking for last minute shopping deals? Find them fast with Yahoo! Search. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071213/75748e86/attachment.htm From jeffpeery at yahoo.com Fri Dec 14 01:36:37 2007 From: jeffpeery at yahoo.com (Jeff Peery) Date: Thu, 13 Dec 2007 16:36:37 -0800 (PST) Subject: [python-win32] problem accessing OPC clients from thread In-Reply-To: <4755343C.8040605@trihedral.com> Message-ID: <677837.70693.qm@web43140.mail.sp1.yahoo.com> .... I forgot to attach the code. here it is. Thanks. Jeff Graham Bloice wrote: Jeff Peery wrote: > thanks for the beta! > > I think my main problem is that I don't really understand this code; I > didn't write it. Could you recommend a book/website that describes > what these functions like 'group.OPCItems.AddItem' do? For example, > how do I know what a 'group' is or what the addItem() parameters are, > or how to interpret that error code that you interpreted, and I'm not > really sure if this code will work for other OPC servers other than > the automation direct server. > > Also, where might I go learn about how to setup the event handler for > a data change event? > > Thanks again, I appreciate your help! > Jeff > The canonical definition of the OPC Automation interface API is the OPC DA Auto 2.02 Specification. DA stands for Data Acquisition. The originators of this document are the OPC Foundation, at http://www.opcfoundation.org, and the specification is *so* open you have to become a member to download it (at a cost of USD 1500). Grrr. However, if your Google fu is up to it you might find a copy lying around elsewhere, as I have run across it on several OPC Vendors sites. I think I've also found it with several OPC Servers. I would recommend that you get the Matrikon OPC Simulation server for testing, this installs the Matrikon OPC Explorer which is a useful client app to work out what's happening when your client doesn't work. This might give you the docs. The document goes under various names such as opcda20_auto.doc. Note that the docs are VB (VB6) based, but not too difficult to convert to python. You will also want to read up on creating event handlers in PyWin -- Regards, Graham Bloice --------------------------------- Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071213/2b2abee9/attachment.htm -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: testOPC.py Url: http://mail.python.org/pipermail/python-win32/attachments/20071213/2b2abee9/attachment.txt From wojtulek at gmail.com Fri Dec 14 09:26:00 2007 From: wojtulek at gmail.com (Wojtek P) Date: Fri, 14 Dec 2007 09:26:00 +0100 Subject: [python-win32] MS Word and Python - how to disable SaveAs event? Message-ID: <4ed0e9d00712140026r287eb525p34e7f2fd00e931c8@mail.gmail.com> Hello! I try use Microsoft Word and OpenOffice with Python - and i have some problems. How to disable "Save As" in word from python code, or how to cancel this function when user use it? This code below doesn't work :/ wxPython 2.8.4.2 Python 2.4.4 from win32com.client import DispatchWithEvents, Dispatch import msvcrt, pythoncom import time, sys import types import os import threading import wx stopEvent = threading.Event() ############################## ################################################# class WordEvents: ############################################################################### def OnDocumentChange(self): self.seen_events["OnDocumentChange"] = None print "OnDocumentChange" def OnWindowActivate(self, doc, wn): self.seen_events["OnWindowActivate"] = None print "OnWindowActivate" def OnQuit(self): print "OnQuit" self.seen_events["OnQuit"] = None stopEvent.set() def OnStartup(self): print "OnStartup" self.seen_events["OnStartup"] = None def OnDocumentBeforeSave(self, Doc, SaveAsUI, Cancel): print "OnDocumentBeforeSave" print "SaveAsUI:", SaveAsUI if SaveAsUI: Cancel = True return self.seen_events["OnDocumentBeforeSave"] = None def OnDocumentBeforeClose(self): print "OnDocumentBeforeClose" self.seen_events["OnDocumentBeforeClose"] = None ############################################################################### class MyWord: ############################################################################### def __init__(self): self.wordApp = None self.wordDoc = None def __del__(self): pythoncom.CoUninitialize() def Init(self): self.wordApp = DispatchWithEvents('Word.Application', WordEvents) self.wordApp.seen_events = {} self.wordApp.Visible = 0 self.wordDoc = self.wordApp.Documents.Add() def Start(self): print "Start..." s = self.wordDoc.Sentences(1) s.Text = 'Hello world !' self.wordDoc.Saved = 1 self.wordApp.Visible = 1 def WaitForFinish(self): while True: pythoncom.PumpWaitingMessages() try: if not self.wordApp.Visible: # jesli zamkniecie worda to czas wyjsc return 0 except pythoncom.com_error: pass return 1 def Wait(self): return self.WaitForFinish() def Stop(self): self.wordApp.Quit() ############################################################################### word_ed = MyWord() word_ed.Init() word_ed.Start() word_ed.Wait() -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071214/e527879f/attachment.htm From timr at probo.com Fri Dec 14 18:39:22 2007 From: timr at probo.com (Tim Roberts) Date: Fri, 14 Dec 2007 09:39:22 -0800 Subject: [python-win32] MS Word and Python - how to disable SaveAs event? In-Reply-To: <4ed0e9d00712140026r287eb525p34e7f2fd00e931c8@mail.gmail.com> References: <4ed0e9d00712140026r287eb525p34e7f2fd00e931c8@mail.gmail.com> Message-ID: <4762BFCA.6060904@probo.com> Wojtek P wrote: > > I try use Microsoft Word and OpenOffice with Python - and i have some > problems. How to disable "Save As" in word from python code, or how to > cancel this function when user use it? This code below doesn't work :/ You can't. This is not a Python issue. Word simply does expose any mechanism to disable specific menu items. Why would you want to? Are you thinking of this as a way to "protect" a document? If so, you are misguided. If you need a way to display documents in a read-only manner, then you need to do the display yourself, without using Word. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mayank_johri at ml.com Fri Dec 14 17:11:43 2007 From: mayank_johri at ml.com (Johri, Mayank (GTI)) Date: Fri, 14 Dec 2007 11:11:43 -0500 Subject: [python-win32] python and Windows Resource Files. Message-ID: <354AE678C54C7540AF76CB09AAEF16EE0397DDC6@MLNYC724MB.amrs.win.ml.com> Hello, I am writing a python program which uses Windows Resources for GUI (i.e. Dialog boxes), does anyone know a good starting point or tutorials to get & set values of common controls such as List view, button, textBox etc for it. Thanks and Regards, Mayank Johri Ph: 212.647.3076 -------------------------------------------------------- This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing. -------------------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071214/82718b66/attachment.htm From timr at probo.com Sat Dec 15 01:20:47 2007 From: timr at probo.com (Tim Roberts) Date: Fri, 14 Dec 2007 16:20:47 -0800 Subject: [python-win32] python and Windows Resource Files. In-Reply-To: <354AE678C54C7540AF76CB09AAEF16EE0397DDC6@MLNYC724MB.amrs.win.ml.com> References: <354AE678C54C7540AF76CB09AAEF16EE0397DDC6@MLNYC724MB.amrs.win.ml.com> Message-ID: <47631DDF.4060102@probo.com> Johri, Mayank (GTI) wrote: > > I am writing a python program which uses Windows Resources for GUI > (i.e. Dialog boxes), does anyone know a good starting point > or tutorials to get & set values of common controls such as List view, > button, textBox etc for it. How are you creating the dialog? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Sat Dec 15 01:43:51 2007 From: timr at probo.com (Tim Roberts) Date: Fri, 14 Dec 2007 16:43:51 -0800 Subject: [python-win32] python and Windows Resource Files. In-Reply-To: <47631DDF.4060102@probo.com> References: <354AE678C54C7540AF76CB09AAEF16EE0397DDC6@MLNYC724MB.amrs.win.ml.com> <47631DDF.4060102@probo.com> Message-ID: <47632347.3040206@probo.com> Tim Roberts wrote: > Johri, Mayank (GTI) wrote: > >> >> I am writing a python program which uses Windows Resources for GUI >> (i.e. Dialog boxes), does anyone know a good starting point >> or tutorials to get & set values of common controls such as List view, >> button, textBox etc for it. >> > > How are you creating the dialog? > It occurred to me after I sent this that it could be misinterpreted. What I meant to ask was, "how are you getting the dialog on the screen?" -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From bgailer at alum.rpi.edu Sat Dec 15 04:04:00 2007 From: bgailer at alum.rpi.edu (bob gailer) Date: Fri, 14 Dec 2007 22:04:00 -0500 Subject: [python-win32] MS Word and Python - how to disable SaveAs event? In-Reply-To: <4ed0e9d00712140026r287eb525p34e7f2fd00e931c8@mail.gmail.com> References: <4ed0e9d00712140026r287eb525p34e7f2fd00e931c8@mail.gmail.com> Message-ID: <47634420.1090109@alum.rpi.edu> Wojtek P wrote: > Hello! > > I try use Microsoft Word and OpenOffice with Python - and i have some > problems. How to disable "Save As" in word from python code, or how to > cancel this function when user use it? This code below doesn't work :/ > > wxPython 2.8.4.2 > Python 2.4.4 > > > > from win32com.client import DispatchWithEvents, Dispatch > import msvcrt, pythoncom > import time, sys > import types > import os > import threading > import wx > stopEvent = threading.Event() > > ############################## > ################################################# > class WordEvents: > ############################################################################### > > def OnDocumentChange(self): > self.seen_events["OnDocumentChange"] = None > print "OnDocumentChange" > > def OnWindowActivate(self, doc, wn): > self.seen_events["OnWindowActivate"] = None > print "OnWindowActivate" > > def OnQuit(self): > print "OnQuit" > self.seen_events["OnQuit"] = None > stopEvent.set() > > def OnStartup(self): > print "OnStartup" > self.seen_events["OnStartup"] = None > > def OnDocumentBeforeSave(self, Doc, SaveAsUI, Cancel): > print "OnDocumentBeforeSave" > print "SaveAsUI:", SaveAsUI > if SaveAsUI: > Cancel = True > return > self.seen_events["OnDocumentBeforeSave"] = None The reason Cancel = True is not working is that arguments to functions are passed by value, and seen as local variables. This assignment replaces the local Cancel; it does not affect the caller. I wonder if it might work to return False? > > def OnDocumentBeforeClose(self): > print "OnDocumentBeforeClose" > self.seen_events["OnDocumentBeforeClose"] = None > > ############################################################################### > class MyWord: > ############################################################################### > def __init__(self): > self.wordApp = None > self.wordDoc = None > > def __del__(self): > pythoncom.CoUninitialize() > > def Init(self): > self.wordApp = DispatchWithEvents('Word.Application', WordEvents) > self.wordApp.seen_events = {} > self.wordApp.Visible = 0 > self.wordDoc = self.wordApp.Documents.Add() > > def Start(self): > print "Start..." > s = self.wordDoc.Sentences(1) > s.Text = 'Hello world !' > self.wordDoc.Saved = 1 > self.wordApp.Visible = 1 > > def WaitForFinish(self): > while True: > pythoncom.PumpWaitingMessages() > try: > if not self.wordApp.Visible: # jesli zamkniecie worda to czas > wyjsc > return 0 > except pythoncom.com_error: > pass > return 1 > > def Wait(self): > return self.WaitForFinish() > > def Stop(self): > self.wordApp.Quit() > > > ############################################################################### > > word_ed = MyWord() > word_ed.Init() > word_ed.Start() > word_ed.Wait() > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From niki at vintech.bg Sat Dec 15 09:46:05 2007 From: niki at vintech.bg (niki) Date: Sat, 15 Dec 2007 10:46:05 +0200 Subject: [python-win32] python and Windows Resource Files. In-Reply-To: <354AE678C54C7540AF76CB09AAEF16EE0397DDC6@MLNYC724MB.amrs.win.ml.com> References: <354AE678C54C7540AF76CB09AAEF16EE0397DDC6@MLNYC724MB.amrs.win.ml.com> Message-ID: <4763944D.6050206@vintech.bg> I have small ctypes package for dynamic win32 dialogs (DialogBoxIndirectParam) which can be adapted for using resources. I will mail it on request. Niki Spahiev From bgailer at alum.rpi.edu Sat Dec 15 04:05:45 2007 From: bgailer at alum.rpi.edu (bob gailer) Date: Fri, 14 Dec 2007 22:05:45 -0500 Subject: [python-win32] python and Windows Resource Files. In-Reply-To: <354AE678C54C7540AF76CB09AAEF16EE0397DDC6@MLNYC724MB.amrs.win.ml.com> References: <354AE678C54C7540AF76CB09AAEF16EE0397DDC6@MLNYC724MB.amrs.win.ml.com> Message-ID: <47634489.7040409@alum.rpi.edu> Johri, Mayank (GTI) wrote: > Hello, > > I am writing a python program which uses Windows Resources for GUI > (i.e. Dialog boxes), does anyone know a good starting point > or tutorials to get & set values of common controls such as List view, > button, textBox etc for it. > > Thanks and Regards, > Mayank Johri > Ph: 212.647.3076 > ------------------------------------------------------------------------ > This message w/attachments (message) may be privileged, confidential > or proprietary, and if you are not an intended recipient, please > notify the sender, do not use or share it and delete it. Unless > specifically indicated, this message is not an offer to sell or a > solicitation of any investment products or other financial product or > service, an official confirmation of any transaction, or an official > statement of Merrill Lynch. Subject to applicable law, Merrill Lynch > may monitor, review and retain e-communications (EC) traveling through > its networks/systems. The laws of the country of each sender/recipient > may impact the handling of EC, and EC may be archived, supervised and > produced in countries other than the country in which you are located. > This message cannot be guaranteed to be secure or error-free. This > message is subject to terms available at the following link: > http://www.ml.com/e-communications_terms/. By messaging with Merrill > Lynch you consent to the foregoing. No I don't consent! And please don't presume that I do. Nor will I take the time to look up the terms. From mayank_johri at ml.com Mon Dec 17 16:07:54 2007 From: mayank_johri at ml.com (Johri, Mayank (GTI)) Date: Mon, 17 Dec 2007 10:07:54 -0500 Subject: [python-win32] python and Windows Resource Files. Message-ID: <354AE678C54C7540AF76CB09AAEF16EE0397DDCF@MLNYC724MB.amrs.win.ml.com> Tim, I am using the resource editor of Open Watcom. Thanks and Regards, Mayank Johri Merrill Lynch & Co. Ph: 212.647.3076 -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Roberts Sent: Friday, December 14, 2007 7:21 PM To: python-win32 at python.org Subject: Re: [python-win32] python and Windows Resource Files. Johri, Mayank (GTI) wrote: > > I am writing a python program which uses Windows Resources for GUI > (i.e. Dialog boxes), does anyone know a good starting point > or tutorials to get & set values of common controls such as List view, > button, textBox etc for it. How are you creating the dialog? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------------------------------------------------- This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing. -------------------------------------------------------- From timr at probo.com Mon Dec 17 18:58:36 2007 From: timr at probo.com (Tim Roberts) Date: Mon, 17 Dec 2007 09:58:36 -0800 Subject: [python-win32] python and Windows Resource Files. In-Reply-To: <354AE678C54C7540AF76CB09AAEF16EE0397DDD0@MLNYC724MB.amrs.win.ml.com> References: <354AE678C54C7540AF76CB09AAEF16EE0397DDD0@MLNYC724MB.amrs.win.ml.com> Message-ID: <4766B8CC.7040309@probo.com> Johri, Mayank (GTI) wrote: > Tim, > > I am using the win32rcparser and win32gui to display the dialog on the > screen. I have used the example win32rcparser.py for this. > Well, win32rcparser.py reads the RC file, but it doesn't display it on the screen. What you're doing is working at the lowest possible level. If you want to create a Windows GUI using the raw API, then you might as well write it in C++. You're just going to battle the Python/C boundary over and over. It is possible to call GetDlgItem to fetch window handles for the controls in your dialog, and then send Windows messages to fetch their contents, but it's a lot of work for no particularly good reason. It would be much better in the long term for you to investigate wxPython or tkinter or one of the other GUI wrappers, to let you create and manage your GUI with something approaching Python's class philosophy. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mayank_johri at ml.com Mon Dec 17 21:08:41 2007 From: mayank_johri at ml.com (Johri, Mayank (GTI)) Date: Mon, 17 Dec 2007 15:08:41 -0500 Subject: [python-win32] python and Windows Resource Files. Message-ID: <354AE678C54C7540AF76CB09AAEF16EE0397DDD1@MLNYC724MB.amrs.win.ml.com> Tim, Thanks for the information, I know the pain ;) it is causing me. The reason why I went to use RC was that the over head on my final package size was minimal. But now I think trying wxPython or Tkinker will be a better solution in long run. Thanks and Regards, Mayank Johri Merrill Lynch & Co. Ph: 212.647.3076 -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Roberts Sent: Monday, December 17, 2007 12:59 PM To: Python-Win32 List Subject: Re: [python-win32] python and Windows Resource Files. Johri, Mayank (GTI) wrote: > Tim, > > I am using the win32rcparser and win32gui to display the dialog on the > screen. I have used the example win32rcparser.py for this. > Well, win32rcparser.py reads the RC file, but it doesn't display it on the screen. What you're doing is working at the lowest possible level. If you want to create a Windows GUI using the raw API, then you might as well write it in C++. You're just going to battle the Python/C boundary over and over. It is possible to call GetDlgItem to fetch window handles for the controls in your dialog, and then send Windows messages to fetch their contents, but it's a lot of work for no particularly good reason. It would be much better in the long term for you to investigate wxPython or tkinter or one of the other GUI wrappers, to let you create and manage your GUI with something approaching Python's class philosophy. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------------------------------------------------- This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing. -------------------------------------------------------- From kevin.horn at gmail.com Mon Dec 17 21:28:43 2007 From: kevin.horn at gmail.com (Kevin Horn) Date: Mon, 17 Dec 2007 14:28:43 -0600 Subject: [python-win32] python and Windows Resource Files. In-Reply-To: <354AE678C54C7540AF76CB09AAEF16EE0397DDD1@MLNYC724MB.amrs.win.ml.com> References: <354AE678C54C7540AF76CB09AAEF16EE0397DDD1@MLNYC724MB.amrs.win.ml.com> Message-ID: <562bcc10712171228v6a1456c0k2612fcbe8d2381e0@mail.gmail.com> I would highly recommend wxPython over TkInter, especially if you are already familiar with Win32 GUI programs in general. reasons: - better supported on Win32 - better native look-n-feel - much more extensive (supports more types of controls, etc.) - more active community Of course this is just my opinion, and YMMV. Kevin Horn On Dec 17, 2007 2:08 PM, Johri, Mayank (GTI) wrote: > Tim, > > Thanks for the information, I know the pain ;) it is causing me. > The reason why I went to use RC was that the over head on my final > package size was minimal. But now I think trying wxPython or Tkinker > will be a better solution in long run. > > Thanks and Regards, > Mayank Johri > Merrill Lynch & Co. > Ph: 212.647.3076 > > > > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org] On Behalf Of Tim Roberts > Sent: Monday, December 17, 2007 12:59 PM > To: Python-Win32 List > Subject: Re: [python-win32] python and Windows Resource Files. > > > Johri, Mayank (GTI) wrote: > > Tim, > > > > I am using the win32rcparser and win32gui to display the dialog on the > > screen. I have used the example win32rcparser.py for this. > > > > Well, win32rcparser.py reads the RC file, but it doesn't display it on > the screen. > > What you're doing is working at the lowest possible level. If you want > to create a Windows GUI using the raw API, then you might as well write > it in C++. You're just going to battle the Python/C boundary over and > over. It is possible to call GetDlgItem to fetch window handles for the > controls in your dialog, and then send Windows messages to fetch their > contents, but it's a lot of work for no particularly good reason. > > It would be much better in the long term for you to investigate wxPython > or tkinter or one of the other GUI wrappers, to let you create and > manage your GUI with something approaching Python's class philosophy. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------------------------------------------------- > > This message w/attachments (message) may be privileged, confidential or > proprietary, and if you are not an intended recipient, please notify the > sender, do not use or share it and delete it. Unless specifically indicated, > this message is not an offer to sell or a solicitation of any investment > products or other financial product or service, an official confirmation of > any transaction, or an official statement of Merrill Lynch. Subject to > applicable law, Merrill Lynch may monitor, review and retain > e-communications (EC) traveling through its networks/systems. The laws of > the country of each sender/recipient may impact the handling of EC, and EC > may be archived, supervised and produced in countries other than the country > in which you are located. This message cannot be guaranteed to be secure or > error-free. This message is subject to terms available at the following > link: http://www.ml.com/e-communications_terms/. By messaging with Merrill > Lynch you consent to the foregoing. > -------------------------------------------------------- > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071217/2c8cea9f/attachment.htm From mayank_johri at ml.com Mon Dec 17 21:56:51 2007 From: mayank_johri at ml.com (Johri, Mayank (GTI)) Date: Mon, 17 Dec 2007 15:56:51 -0500 Subject: [python-win32] python and Windows Resource Files. Message-ID: <354AE678C54C7540AF76CB09AAEF16EE0397DDD3@MLNYC724MB.amrs.win.ml.com> Kevin, The only issue which I have with wx is the size of executable (I blame my size attitude to C & Linux for that. I started my carrier as C on Linux developer), but after your email I searched on internet and found that I can compress the size a lot on that front and thus some time tomorrow I will give it a try. Thanks and Regards, Mayank Johri Merrill Lynch & Co. Ph: 212.647.3076 -----Original Message----- From: python-win32-bounces+mayank_johri=ml.com at python.org [mailto:python-win32-bounces+mayank_johri=ml.com at python.org] On Behalf Of Kevin Horn Sent: Monday, December 17, 2007 3:29 PM To: python-win32 at python.org Subject: Re: [python-win32] python and Windows Resource Files. I would highly recommend wxPython over TkInter, especially if you are already familiar with Win32 GUI programs in general. reasons: - better supported on Win32 - better native look-n-feel - much more extensive (supports more types of controls, etc.) - more active community Of course this is just my opinion, and YMMV. Kevin Horn On Dec 17, 2007 2:08 PM, Johri, Mayank (GTI) < mayank_johri at ml.com > wrote: Tim, Thanks for the information, I know the pain ;) it is causing me. The reason why I went to use RC was that the over head on my final package size was minimal. But now I think trying wxPython or Tkinker will be a better solution in long run. Thanks and Regards, Mayank Johri Merrill Lynch & Co. Ph: 212.647.3076 -----Original Message----- From: python-win32-bounces at python.org [mailto: python-win32-bounces at python.org ] On Behalf Of Tim Roberts Sent: Monday, December 17, 2007 12:59 PM To: Python-Win32 List Subject: Re: [python-win32] python and Windows Resource Files. Johri, Mayank (GTI) wrote: > Tim, > > I am using the win32rcparser and win32gui to display the dialog on the > screen. I have used the example win32rcparser.py for this. > Well, win32rcparser.py reads the RC file, but it doesn't display it on the screen. What you're doing is working at the lowest possible level. If you want to create a Windows GUI using the raw API, then you might as well write it in C++. You're just going to battle the Python/C boundary over and over. It is possible to call GetDlgItem to fetch window handles for the controls in your dialog, and then send Windows messages to fetch their contents, but it's a lot of work for no particularly good reason. It would be much better in the long term for you to investigate wxPython or tkinter or one of the other GUI wrappers, to let you create and manage your GUI with something approaching Python's class philosophy. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------------------------------------------------- This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing. -------------------------------------------------------- _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071217/9d9ec158/attachment-0001.htm From timr at probo.com Mon Dec 17 22:48:28 2007 From: timr at probo.com (Tim Roberts) Date: Mon, 17 Dec 2007 13:48:28 -0800 Subject: [python-win32] python and Windows Resource Files. In-Reply-To: <354AE678C54C7540AF76CB09AAEF16EE0397DDD3@MLNYC724MB.amrs.win.ml.com> References: <354AE678C54C7540AF76CB09AAEF16EE0397DDD3@MLNYC724MB.amrs.win.ml.com> Message-ID: <4766EEAC.8050206@probo.com> Johri, Mayank (GTI) wrote: > Kevin, > > The only issue which I have with wx is the size of executable (I blame > my size attitude to C & Linux for that. I started my carrier as C on > Linux developer), but after your email I searched on internet and > found that I can compress the size a lot on that front and thus some > time tomorrow I will give it a try. Why would you spend any time at all thinking about this? I delivered a non-trivial wxPython-based application to a client last week. The (py2exe) setup utility was a single executable of less than 5 megabytes. Now, if you have to deliver complete releases over a dial-up telephone line, then it's quite likely that Python is a poor choice to begin with -- the basic python24.dll is almost 2 megabytes. If not, 5 megabytes is less than a third of a penny at today's disk prices. In a corporate environment, where you can guarantee (for example) that Python and wxPython are already configured, there's no delta at all. First, make it work. Only THEN should you worry about optimization. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From CAshurst at thig.com Wed Dec 19 15:01:24 2007 From: CAshurst at thig.com (Chris Ashurst) Date: Wed, 19 Dec 2007 09:01:24 -0500 Subject: [python-win32] Absence of PrintWindow? Message-ID: <5A7F36775DDD854CB1873E5F790C4D3701E0CC88@mailhost.thig.com> I'm in the process of writing a little screenshot utility, and I've hit a snag. I currently take a screenshot of a frame via the usual method of building the various DC's, BitBlt'ing and so on, but the problem I have is that I'm trying to grab screenshots of windows that are obscured by other windows (so as to not disturb the current z-index of all windows as they stand). I was beginning to feel that what I required would not be possible, until I found an article at CodeProject (http://www.codeproject.com/KB/cs/CapturingMinimizedWindow.aspx) that basically had what I needed (and was also for the most part all win32api calls, even though the author used C#). As far as I could tell, apart from some simple registry/bithacks, the author makes a call to PrintWindow(), and that's where my hunt went cold - I cannot find PrintWindow in the wrapped win32 stuff. This is all a really long-winded (my apologies) way of asking if PrintWindow *is* in Pythonwin, and if not, that's fine - I just need to save my sanity from hunting for something that isn't there :) (The only reference I could find to PrintWindow in regards to the win32 api being wrapped was from a mailing list thread for Tcl in 2006 - the author mentions it isn't wrapped due to CPU concerns). Thanks! :) Chris Ashurst ~Systems Production Support ~~Tower Hill Insurance Group CONFIDENTIAL NOTICE: This email including any attachments, contains confidential information belonging to the sender. It may also be privileged or otherwise protected by work product immunity or other legal rules. This information is intended only for the use of the individual or entity named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or the taking of any action in reliance on the contents of this emailed information is strictly prohibited. If you have received this email in error, please immediately notify us by reply email of the error and then delete this email immediately. From mail at timgolden.me.uk Wed Dec 19 15:32:06 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 19 Dec 2007 14:32:06 +0000 Subject: [python-win32] Absence of PrintWindow? In-Reply-To: <5A7F36775DDD854CB1873E5F790C4D3701E0CC88@mailhost.thig.com> References: <5A7F36775DDD854CB1873E5F790C4D3701E0CC88@mailhost.thig.com> Message-ID: <47692B66.7060009@timgolden.me.uk> Chris Ashurst wrote: > This is all a really long-winded (my apologies) way of asking if PrintWindow > *is* in Pythonwin, and if not, that's fine - I just need to save my sanity > from hunting for something that isn't there :) > > (The only reference I could find to PrintWindow in regards to the win32 api > being wrapped was from a mailing list thread for Tcl in 2006 - the author > mentions it isn't wrapped due to CPU concerns). I don't think it's wrapped by pywin32. You should be able to get to it with ctypes. TJG From CAshurst at thig.com Wed Dec 19 16:56:18 2007 From: CAshurst at thig.com (Chris Ashurst) Date: Wed, 19 Dec 2007 10:56:18 -0500 Subject: [python-win32] Absence of PrintWindow? Message-ID: <5A7F36775DDD854CB1873E5F790C4D3701E0CC89@mailhost.thig.com> Thank you, that's essentially what I've ended up doing :) Just in case anyone is attempting to do the whole "screenshot of hidden window" thing, this is my base code (Inside wx, but it could just have easily been straight win32api/gui): [--- snip---] import wx from ctypes import windll # Retrieved from a random window with win32gui.EnumChildWindows(...) hwnd = 2885072 # Window_FromHWND appears in wxPython 2.6.2.1+ window = wx.Window_FromHWND(None, hwnd) src_dc = wx.WindowDC(window) width, height = window.GetSize() mem_dc = wx.MemoryDC() bitmap = wx.EmptyBitmap(width, height) mem_dc.SelectObject(bitmap) windll.user32.PrintWindow(hwnd, mem_dc.GetHDC(), 0) mem_dc.SelectObject(wx.NullBitmap) image = bitmap.ConvertToImage() filename = "testsnap.png" image.SaveFile(filename, wx.BITMAP_TYPE_PNG) [---snip---] Again, thanks for pointing me at ctypes - I was beginning to go crazy at not finding a way around not having PrintWindow :D -----Original Message----- From: Tim Golden [mailto:mail at timgolden.me.uk] Sent: Wednesday, December 19, 2007 09:32 To: Chris Ashurst Cc: PyWin32 Users List (E-mail) Subject: Re: [python-win32] Absence of PrintWindow? Chris Ashurst wrote: > This is all a really long-winded (my apologies) way of asking if PrintWindow > *is* in Pythonwin, and if not, that's fine - I just need to save my sanity > from hunting for something that isn't there :) > > (The only reference I could find to PrintWindow in regards to the win32 api > being wrapped was from a mailing list thread for Tcl in 2006 - the author > mentions it isn't wrapped due to CPU concerns). I don't think it's wrapped by pywin32. You should be able to get to it with ctypes. TJG CONFIDENTIAL NOTICE: This email including any attachments, contains confidential information belonging to the sender. It may also be privileged or otherwise protected by work product immunity or other legal rules. This information is intended only for the use of the individual or entity named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or the taking of any action in reliance on the contents of this emailed information is strictly prohibited. If you have received this email in error, please immediately notify us by reply email of the error and then delete this email immediately. From timr at probo.com Wed Dec 19 19:08:14 2007 From: timr at probo.com (Tim Roberts) Date: Wed, 19 Dec 2007 10:08:14 -0800 Subject: [python-win32] Absence of PrintWindow? In-Reply-To: <5A7F36775DDD854CB1873E5F790C4D3701E0CC88@mailhost.thig.com> References: <5A7F36775DDD854CB1873E5F790C4D3701E0CC88@mailhost.thig.com> Message-ID: <47695E0E.1090506@probo.com> Chris Ashurst wrote: > I'm in the process of writing a little screenshot utility, and I've hit a > snag. I currently take a screenshot of a frame via the usual method of > building the various DC's, BitBlt'ing and so on, but the problem I have is > that I'm trying to grab screenshots of windows that are obscured by other > windows (so as to not disturb the current z-index of all windows as they > stand). > > I was beginning to feel that what I required would not be possible, until I > found an article at CodeProject > (http://www.codeproject.com/KB/cs/CapturingMinimizedWindow.aspx) that > basically had what I needed (and was also for the most part all win32api > calls, even though the author used C#). As far as I could tell, apart from > some simple registry/bithacks, the author makes a call to PrintWindow(), and > that's where my hunt went cold - I cannot find PrintWindow in the wrapped > win32 stuff. > > This is all a really long-winded (my apologies) way of asking if PrintWindow > *is* in Pythonwin, and if not, that's fine - I just need to save my sanity > from hunting for something that isn't there :) > I actually blogged about this issue two years ago: http://www.probo.com/timr/blog/pyblosxom.cgi/2005/Nov/08#WindowCapture The short answer is this: what you want is impossible in the general case. It works for some applications, but not the interesting ones. PrintWindow sends a WM_PRINT message to the app, and very few applications support WM_PRINT. It REQUIRES the cooperation of the application. This situation may improve in the future. Under Vista, with Aero, the full image of all windows is always available. The window images are drawn into offscreen textures, and the visible desktop is composited from those textures. The overlap happens during compositing. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From antonyjoseph89 at gmail.com Fri Dec 21 07:33:27 2007 From: antonyjoseph89 at gmail.com (Antony Joseph) Date: Fri, 21 Dec 2007 12:03:27 +0530 Subject: [python-win32] how to get mails from Outlook Message-ID: hi, I am trying to read all the mails in the Inbox from outlook and convert those mails into text format in my local path. Is there any tutorials or any links that can be usefull to me. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071221/516acd01/attachment.htm From mail at timgolden.me.uk Fri Dec 21 09:42:21 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 21 Dec 2007 08:42:21 +0000 Subject: [python-win32] how to get mails from Outlook In-Reply-To: References: Message-ID: <476B7C6D.2090400@timgolden.me.uk> Antony Joseph wrote: > hi, > > I am trying to read all the mails in the Inbox from outlook and convert > those mails into text format in my local path. > > Is there any tutorials or any links that can be usefull to me. Here's an absolutely Noddy example to get you going: # # inbox.py # test case for access to Exchange; run through the # hard-coded user's inbox and list the subjects of each email. # import win32com.client session = win32com.client.gencache.EnsureDispatch ("MAPI.Session") session.Logon () inbox = session.Inbox messages = inbox.Messages message = messages.GetFirst () while message: print "subject: ", message.Subject message = messages.GetNext () session.Logoff () and, aside from the MSDN docs on MAPI.Session, the keyword you're looking for is CDO. Here's a couple of useful sites: http://www.outlookcode.com/article.aspx?id=20 http://www.cdolive.com/default.htm BTW, this is all relatively old stuff (although it still works fine on my XP-Outlook2003-Exchangewhatever setup). There may well be some "preferred" MSActiveNETMailProvider [*] technique which is more future-proofed. If you need more info feel to come back and ask. TJG [*] Invented, obviously; don't go searching for it! From antonyjoseph89 at gmail.com Fri Dec 21 10:12:39 2007 From: antonyjoseph89 at gmail.com (Antony Joseph) Date: Fri, 21 Dec 2007 14:42:39 +0530 Subject: [python-win32] Operational errorr : Message-ID: I am getting Operational Error : when i try get my contacts . My code : import win32com.client oOutlook = win32com.client.gencache.EnsureDispatch("Outlook.Application") onMAPI = oOutlook.GetNamespace("MAPI") ofContacts = onMAPI.GetDefaultFolder(10) # 10=outlook contacts folder redemption = oOutlook.CreateObject('Redemption.SafeContactItem') for i in range(len(ofContacts.Items)): redemption.Item = ofContacts.Items.Item(i+1) print redemption.Subject can any one tell me , what i am doing error or please tell me to solve this problem. My Error: File "m1.py", line 5, in redemption = oOutlook.CreateObject('Redemption.SafeContactItem') File "C:\Python25\lib\site-packages\win32com\gen_py\00062FFF-0000-0000-C000-00 0000000046x0x9x3\_Application.py", line 82, in CreateObject ret = self._oleobj_.InvokeTypes(277, LCID, 1, (9, 0), ((8, 1),),ObjectName pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, 'Microsoft Off ice Outlook', 'The operation failed.', None, 0, -2147221005), None) Antony -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071221/c9e399c0/attachment.htm From mail at timgolden.me.uk Fri Dec 21 10:41:19 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 21 Dec 2007 09:41:19 +0000 Subject: [python-win32] Operational errorr : In-Reply-To: References: Message-ID: <476B8A3F.4090107@timgolden.me.uk> Antony Joseph wrote: > I am getting Operational Error : when i try get my contacts . > > My code : > import win32com.client > oOutlook = win32com.client.gencache.EnsureDispatch("Outlook.Application") > onMAPI = oOutlook.GetNamespace("MAPI") > ofContacts = onMAPI.GetDefaultFolder(10) # 10=outlook contacts folder > redemption = oOutlook.CreateObject('Redemption.SafeContactItem') Well your error's coming from this line, but for the life of me I can't work out what you're trying to do with it, since it's not used anywhere else. The MSDN help for Outlook _Application.CreateObject [1] suggests that it's a placeholder for other methods of creating objects. Maybe you're trying to use .CreateItem [2] which seems to be used for creating new contact items. > for i in range(len(ofContacts.Items)): > redemption.Item = ofContacts.Items.Item(i+1) > print redemption.Subject Ah, I think I see. You're trying to create a contact which then appears in the list this displays. I think you'll need to save it first with some details as per the Technet link below {[2]). TJG [1] http://msdn2.microsoft.com/en-us/library/microsoft.office.interop.outlook._application.createobject.aspx [2] http://www.microsoft.com/technet/scriptcenter/resources/officetips/apr05/tips0426.mspx From timr at probo.com Fri Dec 21 20:00:42 2007 From: timr at probo.com (Tim Roberts) Date: Fri, 21 Dec 2007 11:00:42 -0800 Subject: [python-win32] Operational errorr : In-Reply-To: References: Message-ID: <476C0D5A.9040905@probo.com> Antony Joseph wrote: > I am getting Operational Error : when i try get my contacts . > ... > My Error: > > File "m1.py", line 5, in > redemption = oOutlook.CreateObject('Redemption.SafeContactItem') > File > "C:\Python25\lib\site-packages\win32com\gen_py\00062FFF-0000-0000-C000-00 > 0000000046x0x9x3\_Application.py", line 82, in CreateObject > ret = self._oleobj_.InvokeTypes(277, LCID, 1, (9, 0), ((8, > 1),),ObjectName > pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, > 'Microsoft Off > ice Outlook', 'The operation failed.', None, 0, -2147221005), None) Tim G gave you the pointer on how to do this correctly, but I wanted to point out what the error meant. The COM error is the second large negative number here, -2147221005. Converting that to hex, we get 800401F3. Looking up that error, we find it is CO_E_CLASSSTRING, which means the COM class identifier is not valid. "Redemption.SafeContactItem" is part of a third-party product, not part of standard Outlook. Have you installed the Redemption objects? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mail at timgolden.me.uk Fri Dec 21 21:54:22 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 21 Dec 2007 20:54:22 -0000 (GMT) Subject: [python-win32] Operational errorr : In-Reply-To: <476C0D5A.9040905@probo.com> References: <476C0D5A.9040905@probo.com> Message-ID: <3370.82.31.131.116.1198270462.squirrel@82.31.131.116> > Antony Joseph wrote: >> I am getting Operational Error : when i try get my contacts . >> ... >> My Error: >> >> File "m1.py", line 5, in >> redemption = oOutlook.CreateObject('Redemption.SafeContactItem') >> File >> "C:\Python25\lib\site-packages\win32com\gen_py\00062FFF-0000-0000-C000-00 >> 0000000046x0x9x3\_Application.py", line 82, in CreateObject >> ret = self._oleobj_.InvokeTypes(277, LCID, 1, (9, 0), ((8, >> 1),),ObjectName >> pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, >> 'Microsoft Off >> ice Outlook', 'The operation failed.', None, 0, -2147221005), None) > > Tim G gave you the pointer on how to do this correctly, but I wanted to > point out what the error meant. The COM error is the second large > negative number here, -2147221005. Converting that to hex, we get > 800401F3. Looking up that error, we find it is CO_E_CLASSSTRING, which > means the COM class identifier is not valid. > > "Redemption.SafeContactItem" is part of a third-party product, not part > of standard Outlook. Have you installed the Redemption objects? Thanks for that, Tim. I hadn't really understood what he was trying to do with that Redemption.SafeContactItem thing! Whenever I try to look up MS numbers using the negative dec. version, I always forget that for Google, an unquoted -xxxxx means "don't include xxxxx in the search" and always wonder why it's unearthed this page which doesn't even include the error number anywhere! TJG From antonyjoseph89 at gmail.com Mon Dec 24 09:43:53 2007 From: antonyjoseph89 at gmail.com (Antony Joseph) Date: Mon, 24 Dec 2007 14:13:53 +0530 Subject: [python-win32] python-win32 Digest, Vol 57, Issue 22 In-Reply-To: References: Message-ID: Hi, I am try to print all the message in my mailbox . its not working inbox = session.Inbox i print the value of inbox its gives > I think its not getting the inbox ? # # inbox.py # test case for access to Exchange; run through the # hard-coded user's inbox and list the subjects of each email. # import win32com.client session = win32com.client.gencache > > .EnsureDispatch ("MAPI.Session") > session.Logon () > inbox = session.Inbox print inbox when I try to print the inbox : inbox = > can anybody tell whats wrong in Outlook.? > messages = inbox.Messages > message = messages.GetFirst () > while message: > print "subject: ", message.Subject > message = messages.GetNext () > > session.Logoff () > > On Dec 21, 2007 4:30 PM, wrote: > Send python-win32 mailing list submissions to > python-win32 at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-win32 > or, via email, send a message with subject or body 'help' to > python-win32-request at python.org > > You can reach the person managing the list at > python-win32-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of python-win32 digest..." > > > Today's Topics: > > 1. how to get mails from Outlook (Antony Joseph) > 2. Re: how to get mails from Outlook (Tim Golden) > 3. Operational errorr : (Antony Joseph) > 4. Re: Operational errorr : (Tim Golden) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Fri, 21 Dec 2007 12:03:27 +0530 > From: "Antony Joseph" > Subject: [python-win32] how to get mails from Outlook > To: python-win32 at python.org > Message-ID: > > Content-Type: text/plain; charset="iso-8859-1" > > hi, > > I am trying to read all the mails in the Inbox from outlook and convert > those mails into text format in my local path. > > Is there any tutorials or any links that can be usefull to me. > > Thanks > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > http://mail.python.org/pipermail/python-win32/attachments/20071221/516acd01/attachment-0001.htm > > ------------------------------ > > Message: 2 > Date: Fri, 21 Dec 2007 08:42:21 +0000 > From: Tim Golden > Subject: Re: [python-win32] how to get mails from Outlook > Cc: python-win32 at python.org > Message-ID: <476B7C6D.2090400 at timgolden.me.uk> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Antony Joseph wrote: > > hi, > > > > I am trying to read all the mails in the Inbox from outlook and convert > > those mails into text format in my local path. > > > > Is there any tutorials or any links that can be usefull to me. > > Here's an absolutely Noddy example to get you going: > > > # > # inbox.py > # test case for access to Exchange; run through the > # hard-coded user's inbox and list the subjects of each email. > # > > import win32com.client > > session = win32com.client.gencache.EnsureDispatch ("MAPI.Session") > session.Logon () > > inbox = session.Inbox > messages = inbox.Messages > message = messages.GetFirst () > while message: > print "subject: ", message.Subject > message = messages.GetNext () > > session.Logoff () > > > > and, aside from the MSDN docs on MAPI.Session, the keyword > you're looking for is CDO. Here's a couple of useful sites: > > http://www.outlookcode.com/article.aspx?id=20 > http://www.cdolive.com/default.htm > > BTW, this is all relatively old stuff (although it still works > fine on my XP-Outlook2003-Exchangewhatever setup). There may > well be some "preferred" MSActiveNETMailProvider [*] technique > which is more future-proofed. > > If you need more info feel to come back and ask. > > TJG > > [*] Invented, obviously; don't go searching for it! > > > ------------------------------ > > Message: 3 > Date: Fri, 21 Dec 2007 14:42:39 +0530 > From: "Antony Joseph" > Subject: [python-win32] Operational errorr : > To: python-win32 at python.org > Message-ID: > > Content-Type: text/plain; charset="iso-8859-1" > > I am getting Operational Error : when i try get my contacts . > > My code : > import win32com.client > oOutlook = win32com.client.gencache.EnsureDispatch("Outlook.Application") > onMAPI = oOutlook.GetNamespace("MAPI") > ofContacts = onMAPI.GetDefaultFolder(10) # 10=outlook contacts folder > redemption = oOutlook.CreateObject('Redemption.SafeContactItem') > for i in range(len(ofContacts.Items)): > redemption.Item = ofContacts.Items.Item(i+1) > print redemption.Subject > > can any one tell me , what i am doing error or please tell me to solve > this > problem. > > > My Error: > > File "m1.py", line 5, in > redemption = oOutlook.CreateObject('Redemption.SafeContactItem') > File > "C:\Python25\lib\site-packages\win32com\gen_py\00062FFF-0000-0000-C000-00 > 0000000046x0x9x3\_Application.py", line 82, in CreateObject > ret = self._oleobj_.InvokeTypes(277, LCID, 1, (9, 0), ((8, > 1),),ObjectName > pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, > 'Microsoft > Off > ice Outlook', 'The operation failed.', None, 0, -2147221005), None) > > > Antony > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > http://mail.python.org/pipermail/python-win32/attachments/20071221/c9e399c0/attachment-0001.htm > > ------------------------------ > > Message: 4 > Date: Fri, 21 Dec 2007 09:41:19 +0000 > From: Tim Golden > Subject: Re: [python-win32] Operational errorr : > Cc: python-win32 at python.org > Message-ID: <476B8A3F.4090107 at timgolden.me.uk> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Antony Joseph wrote: > > I am getting Operational Error : when i try get my contacts . > > > > My code : > > import win32com.client > > oOutlook = win32com.client.gencache.EnsureDispatch("Outlook.Application > ") > > onMAPI = oOutlook.GetNamespace("MAPI") > > ofContacts = onMAPI.GetDefaultFolder(10) # 10=outlook contacts folder > > redemption = oOutlook.CreateObject('Redemption.SafeContactItem') > > Well your error's coming from this line, but for the life > of me I can't work out what you're trying to do with it, > since it's not used anywhere else. The MSDN help for Outlook > _Application.CreateObject [1] suggests that it's a placeholder for > other methods of creating objects. Maybe you're trying to use > .CreateItem [2] which seems to be used for creating new contact > items. > > > for i in range(len(ofContacts.Items)): > > redemption.Item = ofContacts.Items.Item(i+1) > > print redemption.Subject > > Ah, I think I see. You're trying to create a contact which > then appears in the list this displays. I think you'll need > to save it first with some details as per the Technet link > below {[2]). > > TJG > > [1] > > http://msdn2.microsoft.com/en-us/library/microsoft.office.interop.outlook._application.createobject.aspx > [2] > > http://www.microsoft.com/technet/scriptcenter/resources/officetips/apr05/tips0426.mspx > > > > ------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > End of python-win32 Digest, Vol 57, Issue 22 > ******************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071224/96011e1b/attachment.htm From antonyjoseph89 at gmail.com Thu Dec 27 10:36:42 2007 From: antonyjoseph89 at gmail.com (Antony Joseph) Date: Thu, 27 Dec 2007 15:06:42 +0530 Subject: [python-win32] How to get mails from Exchange Server Message-ID: hi all, I can read my mails locally from my outlook, I want to read my mail directly from Exchange server , How can i do that? Any Help/link will be usefull to me . my code import win32com.client session = win32com.client.Dispatch("MAPI.Session") session.Logon() inbox = session.Inbox collmsg = inbox.Messages print collmsg msg = collmsg.GetFirst() while msg: print "subject: ", msg.subject msg = collmsg.GetNext() session.Logoff() Thanks Antony -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071227/c1155d81/attachment.htm From mail at timgolden.me.uk Thu Dec 27 11:28:44 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 27 Dec 2007 10:28:44 +0000 Subject: [python-win32] python-win32 Digest, Vol 57, Issue 22 In-Reply-To: References: Message-ID: <47737E5C.1050805@timgolden.me.uk> Antony Joseph wrote: > Hi, > > I am try to print all the message in my mailbox . its not working > inbox = session.Inbox > i print the value of inbox its gives > > I think its not getting the inbox ? > > > # > # inbox.py > # test case for access to Exchange; run through the > # hard-coded user's inbox and list the subjects of each email. > # > > import win32com.client > session = win32com.client.gencache >> .EnsureDispatch ("MAPI.Session") >> session.Logon () >> > inbox = session.Inbox > > print inbox > > when I try to print the inbox : > inbox = > > > can anybody tell whats wrong in Outlook.? I assume (from your later email) that you've realised that nothing's wrong here. By the way, it's better to cut-and-paste directly from your console than to retype: it's possible that any small differences may be vital! By now you'll have realised that ">" just means that the win32com.client libraries are doing dynamic dispatch and so have no particular knowledge about the COM object they're proxying, in particular its identifier. As to your later question: how to talk directly to Exchange. Well... there's several ways of answering this question. One is that, although you're talking in Outlook terms in the code above, you're not relying on Outlook as such. (There's an alternative "Outlook.Application" dispatch-based COM object which handles that specifically). So you *are* talking to Exchange as directly as you can, given that it's running on a server somewhere. That said, though, to bypass this model altogether, you could have Exchange expose its SMTP & IMAP interfaces and talk that way. I believe (from rude comments elsewhere) that the MS implementations of those protocols are less than 100%-RFC-compliant. But it should at least be possible to get something going that way. Obviously Python's stdlib email, smtplib and imaplib libraries will help you out there, along with other helpers such as Menno Smit's IMAPClient [1]. But do you have a particular reason for going that way? Rather than simple using the MAPI.Session (aka CDO) stuff? TJG [1] http://freshfoo.com/wiki/CodeIndex From timr at probo.com Thu Dec 27 19:03:04 2007 From: timr at probo.com (Tim Roberts) Date: Thu, 27 Dec 2007 10:03:04 -0800 Subject: [python-win32] How to get mails from Exchange Server In-Reply-To: References: Message-ID: <4773E8D8.7010505@probo.com> Antony Joseph wrote: > > I can read my mails locally from my outlook, > I want to read my mail directly from Exchange server , How can i do that? > Any Help/link will be usefull to me . Depending on how it is configured, your Exchange server might support POP3 or IMAP, just like a Real Mail Server. Those are easy to support in Python. If that doesn't work, then there are several other options available to you. Microsoft supplies an OLE DB driver for Exchange, so that you can access it just like a database server, using ADODB. Here are a couple of examples in VBScript: http://msdn2.microsoft.com/en-us/library/ms876220.aspx http://msdn2.microsoft.com/en-us/library/ms876220.aspx ADODB is pretty easy to use from Python. There are good samples on the web. If you don't like that, then you'll have to go fetch the Exchange Server SDK, but be prepared to invest some serious time. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mangoldproject at gmail.com Thu Dec 27 19:10:35 2007 From: mangoldproject at gmail.com (Assaf Tal) Date: Thu, 27 Dec 2007 20:10:35 +0200 Subject: [python-win32] How can I detect when a user switches between windows? Message-ID: Hi everybody, I hope I've come to the right place :). My name is Assaf, and I'm trying to write a small Python utility on a Win-XP platform. I'm not a beginning programmer (having experience mainly with scientific computations), but I'm pretty new to Python and Windows programming. The utility will execute a set of commands whenever the user switches his focus between different windows, including child windows in MDI applications (e.g. between two photos in Photoshop), based on the title of the window switched to. I've already figured how to retrieve an active window's title, by using win32gui's GetWindowText(GetForegroundWindow()). However, I'm still trying to figure out the best way of detecting whenever the focus shifts between windows. For my purposes, "shifting the focus" is equivalent to having the window's blue title bar become active. I've asked around and been given two ways of doing this, but both seem very unnatural: 1.) Using some timer, run a check every x seconds to see whether the window's title has changed, and act accordingly. This seems clumsy. 2.) Use PyHook and perhaps see when the keyboard focus has changed (not sure how to do that one yet, though). This seems like a decent solution (assuming I'll get it to work), but I can easily think of situations in which keyboard focus and window focus are not the same. For example, in many video and audio editing programs, one can switch between multiple open windows and still have his/her keyboard control the "mother application". So basically what I'm asking is: is there an elegant solution to this problem? Can I "bind" somehow a window-switching event, perhaps directly via the underlying windows API or some suitable wrapper? Your help is very much appreciated, and please let me know if I've picked the wrong group for this and there is some more suitable place to ask this question. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071227/e9b352ad/attachment.htm From timr at probo.com Thu Dec 27 20:17:06 2007 From: timr at probo.com (Tim Roberts) Date: Thu, 27 Dec 2007 11:17:06 -0800 Subject: [python-win32] How can I detect when a user switches between windows? In-Reply-To: References: Message-ID: <4773FA32.7090800@probo.com> Assaf Tal wrote: > > I hope I've come to the right place :). Didn't you ask this question on the newsgroup last night? I know I've read it recently. > The utility will execute a set of commands whenever the user switches > his focus between different windows, including child windows in MDI > applications (e.g. between two photos in Photoshop), based on the > title of the window switched to. > I've already figured how to retrieve an active window's title, by > using win32gui's GetWindowText(GetForegroundWindow()). However, I'm > still trying to figure out the best way of detecting whenever the > focus shifts between windows. For my purposes, "shifting the focus" is > equivalent to having the window's blue title bar become active. > I've asked around and been given two ways of doing this, but both seem > very unnatural: > 1.) Using some timer, run a check every x seconds to see whether the > window's title has changed, and act accordingly. This seems clumsy. > 2.) Use PyHook and perhaps see when the keyboard focus has changed > (not sure how to do that one yet, though). This seems like a decent > solution (assuming I'll get it to work), but I can easily think of > situations in which keyboard focus and window focus are not the same. > For example, in many video and audio editing programs, one can switch > between multiple open windows and still have his/her keyboard control > the "mother application". Windows doesn't really have the concept of "window focus". The focus window is the one receiving UI events. When you switch between multiple open windows as you describe, the messages all go to the message queue for the main UI thread of the owning application. That's why the "mother application" can still read them. It's up to the application to decide whether to handle the messages globally, or to let a separate window procedure handle them. > So basically what I'm asking is: is there an elegant solution to this > problem? Can I "bind" somehow a window-switching event, perhaps > directly via the underlying windows API or some suitable wrapper? > Your help is very much appreciated, and please let me know if I've > picked the wrong group for this and there is some more suitable place > to ask this question. There is no elegant solution. The way to do this is to install a Windows hook. The WH_CBT hook will allow you to intercept WM_ACTIVATE and WM_DEACTIVATE messages, which are the messages that get sent when a window receives or loses the focus. However, you probably won't want to do that in Python, because this involves injecting a DLL into every process in the system. You'll have to have some C code to make this work. I'm not sure why the hook method seems unnatural. Window messages are sent directly to the affected windows, which belong to a process. Windows does not have the concept of a "global event queue". If you want to see the messages being received by another process, you have to make yourself part of that process by using a hook. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From antonyjoseph89 at gmail.com Sat Dec 29 06:22:42 2007 From: antonyjoseph89 at gmail.com (Antony Joseph) Date: Sat, 29 Dec 2007 10:52:42 +0530 Subject: [python-win32] How to save the mails as it is in their own format Message-ID: Hi all, 1. I am working on a project , which i want to access the Microsoft outlook inbox, and get the mails and save it locally as it is. 2. This works to read the mails from Micrsoft outlook but its fails to get the mails from the outlook Express,. I run this code in windows machine , in that machine i hadn't install any microsoft product including Ms outlook. I am trying to get the mails from Outlook Express. import win32com.client session = win32com.client.Dispatch("MAPI.Session") session.Logon() inbox = session.Inbox collmsg = inbox.Messages print collmsg msg = collmsg.GetFirst() while msg: print "subject: ", msg.subject msg = collmsg.GetNext() session.Logoff() could anybody tell me what changes should i want to done , to run successfully? pls if there any links , which could more usefull to me pls forward to me. Thanks Antony -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20071229/38a44f66/attachment.htm From mc at mclaveau.com Sat Dec 29 08:36:29 2007 From: mc at mclaveau.com (Michel Claveau) Date: Sat, 29 Dec 2007 08:36:29 +0100 Subject: [python-win32] How to save the mails as it is in their own format In-Reply-To: References: Message-ID: <04F480AF6CBA4664AC625B7CC62E06F7@MCI1330> Hi! Not an answer, but... Change from Outlook-Express to Windows-Mail (no Windows-Mail-Live!). This software : - is native in Vista - run in XP - recover all informations from outlook-express - is the future - USES A FILE FOR EACH E-MAIL! (it is not necessary any more to save, it is already made!) @-salutations Michel Claveau From mc at mclaveau.com Sat Dec 29 12:11:35 2007 From: mc at mclaveau.com (Michel Claveau) Date: Sat, 29 Dec 2007 12:11:35 +0100 Subject: [python-win32] PyWin add-in for Excel-2007 and SP1+update Message-ID: Hi! For info. Since SP-1 of MS-Office-2007 (december), in Vista, the PyWin add-in for Excel crashs lamentably... But, today, a (windows)-update corrects the problem. (you must re-activate blocked add-ins) Joy: Youpi! @-salutations Michel Claveau From mail at timgolden.me.uk Mon Dec 31 12:05:27 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 31 Dec 2007 11:05:27 +0000 Subject: [python-win32] How to save the mails as it is in their own format In-Reply-To: References: Message-ID: <4778CCF7.5020300@timgolden.me.uk> Antony Joseph wrote: > 1. I am working on a project , which i want to access the Microsoft outlook > inbox, and get the mails and save it locally as it is. > > 2. This works to read the mails from Micrsoft outlook but its fails to get > the mails from the outlook Express,. I don't it's possible to get hold of the emails from Outlook Express this way (or any other way, for that matter). In spite of their similar names, the two products aren't really the same beast. You can hunt around for details of the OE mailbox format (DBX?) to see if that's parseable -- officially or otherwise -- but I'm fairly sure it changes from version to version so you'ld need to be sure which one you were looking at. TJG