From Andrew.MacIntyre at acma.gov.au Mon Dec 1 00:22:42 2008 From: Andrew.MacIntyre at acma.gov.au (Andrew MacIntyre) Date: Mon, 1 Dec 2008 10:22:42 +1100 Subject: [python-win32] Does Python need a native Windows GUI toolkit? [SEC=UNCLASSIFIED] In-Reply-To: References: Message-ID: <7B01D7143C4AD54899EA079D4557562AFEF553@ACT01EXC02.internal.govt> I've used Venster for my Windows apps, but admit to not really using all of its capabilities and to using archaic versions of Python and ctypes... Pity that it appears to have been abandoned by its original author, as it has worked wonderfully for me. -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre National Licensing and Allocations Branch tel: +61 2 6219 5356 Inputs to Industry Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: andrew.macintyre at acma.gov.au > -----Original Message----- > From: > python-win32-bounces+andrew.macintyre=acma.gov.au at python.org > [mailto:python-win32-bounces+andrew.macintyre=acma.gov.au at pyth on.org] On Behalf Of Thomas Heller > Sent: Saturday, 29 November 2008 7:46 AM > To: python-win32 at python.org > Subject: [python-win32] Does Python need a native Windows GUI toolkit? > > Does Python need a native, pure Python, Windows GUI toolkit, one that > uses > win32 api calls directly to use native windows controls? > > Or would that development be a waste of resources, in these days of of > Python.NET, Windows forms, IronPython, (and last, not least, wxPython > and all these other toolkits)? Or are desktop applications too rare > now? > > > Several years ago I started using wxPython (it is probably a lot more > mature now) to write some simple programs and was not really pleased. > It looked too much like MFC to me. I know that there are now several > wrappers over wxPython (althogh I have not used them) like Pythoncard > or newer ones like dabo (from what I hear). > There have also been other attempts to make nicer interfaces for > wxPython which have vanished nowadays. > Somehow I have the impression that the approach to put layer over > layer over layer is wrong (wxWindows C++ layer, wxPython SWIG layer, > Pythoncard/Dabo/whatever python layer). > > So, I started writing my own framework, also several years ago. I > used ctypes (early versions) to call the win32 api directly, and it > was fun and it worked out great. > I have my own form editor, I can also construct windows, dialogs, > menus, and so on with simple high level code. But also it is possible > even at the 'highest level' to directly reach out to the win32 api, or > to handle WM_xxx messages directly if the need arises. > > However, this framework is showing its age because during all this > time I developed some new approaches to make the work easier (for > example first I wrote the win32 plumbing code manually, now I have > tools that automatically generate the code to access constants, define > structure definitions, or generate function prototypes from the > windows header files. > Also the framework too much relies on manual conversions between byte > and unicode strings. > > So, the question is: Are there people that share these ideas? > Are they willing to join a coordinated effort to develop a framework > like this, using the current and future Python versions, and all the > fancy new features of Python? > > No promises, but I'm curious for the thoughts on this. > > -- > Thanks, > Thomas > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > If you have received this email in error, please notify the sender immediately and erase all copies of the email and any attachments to it. The information contained in this email and any attachments may be private, confidential and legally privileged or the subject of copyright. If you are not the addressee it may be illegal to review, disclose, use, forward, or distribute this email and/or its contents. Unless otherwise specified, the information in the email and any attachments is intended as a guide only and should not be relied upon as legal or technical advice or regarded as a substitute for legal or technical advice in individual cases. Opinions contained in this email or any of its attachments do not necessarily reflect the opinions of ACMA. From mail at microcorp.co.za Mon Dec 1 19:50:40 2008 From: mail at microcorp.co.za (Hendrik van Rooyen) Date: Mon, 1 Dec 2008 20:50:40 +0200 Subject: [python-win32] Does Python need a native Windows GUI toolkit? References: Message-ID: <000001c953e7$a37e8b60$0d00a8c0@hendrik> "Tony Cappellini" wrote: > First, I feel that Python already has too many GUI toolkits available, and > could stand to use some consolidation. Yes this is true 8<------------------------------------------- > I actually would rather see new any new GUI-related development efforts > going into a community-standardized RAD IDE (aka Delphi-like) environment, > as opposed to a seeing a new toolkit/framework come into existence. I have > been hoping a company like Microsoft or Google would get behind this effort, > more Google than Microsoft. > Since I am an advocate for wx, I would really prefer company-backed > resources put into a completed Delphi-like IDE for wxPython. > This is exacly what Boa is, and its already usable today. It takes care of all the sizer stuff too - you can merrily forget your hard won knowledge and get on with coding the app, instead of spending time hassling with arcane GUI rules and regulations. And the help works reasonably well, as it integrates the python and wxpython documentation. > > I applaud your efforts Thomas whatever the outcome. I know they will benefit > the Python community. +1 - where would we have been without ctypes? Back to this thread - has anybody used the new pythoncard stuff? I seem to remember a thread a while ago on clp about new wine in old bottles - I have never used pythoncard, but it sounded as if it could be a viable alternative for Boa - but it needs someone to comment who knows both the systems. - Hendrik From theller at ctypes.org Mon Dec 1 08:47:06 2008 From: theller at ctypes.org (Thomas Heller) Date: Mon, 01 Dec 2008 08:47:06 +0100 Subject: [python-win32] Does Python need a native Windows GUI toolkit? In-Reply-To: <57124720811281459w444540b0uc86d062d1ffc6e93@mail.gmail.com> References: <57124720811281459w444540b0uc86d062d1ffc6e93@mail.gmail.com> Message-ID: Simon Dahlbacka schrieb: > On Fri, Nov 28, 2008 at 10:46 PM, Thomas Heller wrote: >> Does Python need a native, pure Python, Windows GUI toolkit, one that uses >> win32 api calls directly to use native windows controls? > > How does it differ from http://venster.sourceforge.net/ ? The toolkit that I have written uses some good ideas (imo) from pythoncard; it was born approximately at the same time. Some examples: Named widgets: the container window has a .components collection which allows to access subwindows by name. Binding of event handlers by name: If a button is named OKButton for example then a 'on_OKButton_clicked(self, event)' method implemented in the container window is called when the button is clicked. If it is not defined, a 'on_clicked(self, event)' method is tried. Easy access to the raw windows events: The button window itself implements a '_BN_CLICKED(self, hwnd, msg, wParam, lParam)' method that can be overridden if needed. -- Thanks, Thomas From swalsh at impathnetworks.com Mon Dec 1 15:52:01 2008 From: swalsh at impathnetworks.com (Sandy Walsh) Date: Mon, 01 Dec 2008 10:52:01 -0400 Subject: [python-win32] win32com and extended error messages: IDL with [out, retval] long* error) Message-ID: <4933FA11.7010100@impathnetworks.com> Hi, I have a C++ COM Server with an IDL entry of: [ object, uuid(D989CB9A-0013-4E1A-BFB6-98A7946BD255), dual, helpstring("IFoo Interface"), pointer_default(unique) ] interface IFoo : IDispatch { [ id(1), helpstring("method Connect")] HRESULT Connect([in] BSTR x, [in] short y, [in] BSTR z, [out, retval] long* error); }; A call from Python to the C++ object works fine unless I return something other than S_OK for "error". If I return my own HResult error code an exception gets thrown: try: print "Trying to connect" self.assertEqual(0, self.control.Connect("10.0.0.0", "9999", "")) except pythoncom.com_error, (hr, msg, exc, arg): hr = 0xFFFFFFFF + hr + 1 print "The call failed with code %X: %s" % (hr, msg) if exc is None: print "There is no extended error information" else: wcode, source, text, helpFile, helpId, scode = exc if source: print "Source: ", source if text: print "Error: ", text if helpFile: print "More info can be found in %s (id=%d)" % (helpFile, helpId) The call failed with code 80020009: Exception occurred. The source of the error is None The error message is None More info can be found in None (id=0) Win32 exception occurred releasing IUnknown at 0x00e84c58 (where HR of 0x80020009 is DISP_E_EXCEPTION) I've traced the python side of the code and how it appears to me is the "error" out variable is not being created in the argument list. So it seems that during the unmarshalling something dies horribly because it doesn't know how to deal with the error message. The generated IFoo code looks like this: def Connect(self, x=defaultNamedNotOptArg, y=defaultNamedNotOptArg, z=defaultNamedNotOptArg): """method Connect""" return self._oleobj_.InvokeTypes(1, LCID, 1, (3, 0), ((8, 1), (2, 1), (8, 1)), x, y, z) I'm not sending extended error messages on the C++ side, just setting this error code out variable. I can only assume that the exception is being generated in the MS Com libraries when it tries to marshal the error variable into a non-existent spot? Is there something special I need to do to get win32com to handle this out variable properly? Thanks in advance! -Sandy -------------- next part -------------- A non-text attachment was scrubbed... Name: swalsh.vcf Type: text/x-vcard Size: 335 bytes Desc: not available URL: From niki at vintech.bg Mon Dec 1 17:21:31 2008 From: niki at vintech.bg (niki) Date: Mon, 01 Dec 2008 18:21:31 +0200 Subject: [python-win32] Does Python need a native Windows GUI toolkit? In-Reply-To: <3BC29EFDE22E42409C009054DCCCAC6F@MCI1330> References: <3BC29EFDE22E42409C009054DCCCAC6F@MCI1330> Message-ID: <49340F0B.5070606@vintech.bg> Michel Claveau wrote: > Hi! > > Perso, I use a HTML-GUI (with Python => PyWin32 => IE+Jscript library). > It is self-important for me, and enough fun... Have you tried pyjamas or pyjamas-desctop? HTH Niki From mc at mclaveau.com Mon Dec 1 17:48:09 2008 From: mc at mclaveau.com (Michel Claveau) Date: Mon, 1 Dec 2008 17:48:09 +0100 Subject: [python-win32] Does Python need a native Windows GUI toolkit? In-Reply-To: <49340F0B.5070606@vintech.bg> References: <3BC29EFDE22E42409C009054DCCCAC6F@MCI1330> <49340F0B.5070606@vintech.bg> Message-ID: Hi! >> Perso, I use a HTML-GUI (with Python=>PyWin32=>IE+Jscript library). >> It is self-important for me, and enough fun... > Have you tried pyjamas or pyjamas-desctop? No. But: - I believe than Pyjama run only on linux ; and, I run only on windows... - The next of Pyjama is Appcelerator, no? (http://community.appcelerator.org/index.jspa) @-salutations -- Michel Claveau From swalsh at impathnetworks.com Mon Dec 1 19:18:59 2008 From: swalsh at impathnetworks.com (Sandy Walsh) Date: Mon, 01 Dec 2008 14:18:59 -0400 Subject: [python-win32] win32com and extended error messages: IDL with [out, retval] long* error) In-Reply-To: <4933FA11.7010100@impathnetworks.com> References: <4933FA11.7010100@impathnetworks.com> Message-ID: <49342A93.4040500@impathnetworks.com> I should also mention that this happens with early or late bound dispatches. -S Sandy Walsh wrote: > I'm not sending extended error messages on the C++ side, just setting > this error code out variable. I can only assume that the exception is > being generated in the MS Com libraries when it tries to marshal the > error variable into a non-existent spot? > > Is there something special I need to do to get win32com to handle this > out variable properly? -------------- next part -------------- A non-text attachment was scrubbed... Name: swalsh.vcf Type: text/x-vcard Size: 335 bytes Desc: not available URL: From skippy.hammond at gmail.com Tue Dec 2 04:30:22 2008 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 02 Dec 2008 14:30:22 +1100 Subject: [python-win32] win32com and extended error messages: IDL with [out, retval] long* error) In-Reply-To: <4933FA11.7010100@impathnetworks.com> References: <4933FA11.7010100@impathnetworks.com> Message-ID: <4934ABCE.3080205@gmail.com> Sandy Walsh wrote: > Hi, > > I have a C++ COM Server with an IDL entry of: > > [ > object, > uuid(D989CB9A-0013-4E1A-BFB6-98A7946BD255), > dual, > helpstring("IFoo Interface"), > pointer_default(unique) > ] > interface IFoo : IDispatch > { > [ id(1), helpstring("method Connect")] > HRESULT Connect([in] BSTR x, [in] short y, [in] BSTR z, [out, > retval] long* error); > }; > > A call from Python to the C++ object works fine unless I return > something other than S_OK for "error". What does the C++ code look like? > self.assertEqual(0, self.control.Connect("10.0.0.0", "9999", > "")) That looks strange - your IDL says y is an integer, but you are passing a string. > The call failed with code 80020009: Exception occurred. > The source of the error is None > The error message is None > More info can be found in None (id=0) > Win32 exception occurred releasing IUnknown at 0x00e84c58 > > (where HR of 0x80020009 is DISP_E_EXCEPTION) So something is returning DISP_E_EXCEPTION as the HRESULT for the method (which is quite different than having a dispatch "return value" (which is passed as a param to the C++ implementation) named error. > I've traced the python side of the code and how it appears to me is the > "error" out variable is not being created in the argument list. No - it is a return value: it comes back in the VARIANT holding the result. Note we are going via IDispatch, so something, presumably ATL, is converting the IDispatch::Invoke call into a native vtable based call into your implementation. > I'm not sending extended error messages on the C++ side, just setting > this error code out variable. How are you setting it exactly? And what do you mean by "sending extended error messages" - how would they be sent? > I can only assume that the exception is > being generated in the MS Com libraries when it tries to marshal the > error variable into a non-existent spot? I don't think the COM libraries would throw that kind of exception. Is it possible that your C++ implementation is returning the error code instead of setting it? Your C++ method should always return S_OK, but set "error" via a pointer passed to your function. Cheers, Mark From cappy2112 at gmail.com Tue Dec 2 08:28:40 2008 From: cappy2112 at gmail.com (Tony Cappellini) Date: Mon, 1 Dec 2008 23:28:40 -0800 Subject: [python-win32] Does Python need a native Windows GUI toolkit? Message-ID: <8249c4ac0812012328oe74a89hb9dec7e9b92efc8d@mail.gmail.com> >>Back to this thread - has anybody used the new pythoncard stuff? What do you mean by the "new pythoncard stuff" ? Pythoncard has been around for a long time. I've used it- and it's one of the reasons I now use wxPython directly, without any wrappers. (I didn't like Boa - but it's been a long time since I've tried it) -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at microcorp.co.za Tue Dec 2 20:44:41 2008 From: mail at microcorp.co.za (Hendrik van Rooyen) Date: Tue, 2 Dec 2008 21:44:41 +0200 Subject: [python-win32] Does Python need a native Windows GUI toolkit? References: <8249c4ac0812012328oe74a89hb9dec7e9b92efc8d@mail.gmail.com> Message-ID: <004a01c954b6$6ee8c760$0d00a8c0@hendrik> Tony Cappellini wrote: >What do you mean by the "new pythoncard stuff" ? >Pythoncard has been around for a long time. > Like I said - there was a thread on clp not so long ago. If I remember correctly, the title was: "new wine in old bottles". I am under the impression it was started by the original author of pythoncard, and he was sort of discussing changes he had made. I did not pay much attention at the time, I just remember the occurrence. - Hendrik From werner.bruhin at free.fr Tue Dec 2 12:22:14 2008 From: werner.bruhin at free.fr (Werner F. Bruhin) Date: Tue, 02 Dec 2008 12:22:14 +0100 Subject: [python-win32] Does Python need a native Windows GUI toolkit? In-Reply-To: References: Message-ID: Thomas Heller wrote: > Does Python need a native, pure Python, Windows GUI toolkit, one that uses > win32 api calls directly to use native windows controls? > > Or would that development be a waste of resources, in these days of > of Python.NET, Windows forms, IronPython, (and last, not least, wxPython > and all these other toolkits)? Or are desktop applications too rare now? I would consider it a waste of resources. I use wxPython and if I would change today to something else it would probably be a web/html based tool kit. Why, the only issue I have found with wxPython is that it is too large for devices such as Palm/iPhone/WinMobile. Unless one invests in some professional tools (I am only aware of WinDev, but there must be others) one can not develop one app which runs on these mobile devices and on desktops. > > > Several years ago I started using wxPython (it is probably a lot more > mature now) to write some simple programs and was not really pleased. > It looked too much like MFC to me. I know that there are now several > wrappers over wxPython (althogh I have not used them) like Pythoncard > or newer ones like dabo (from what I hear). There have also been other > attempts to make nicer interfaces for wxPython which have vanished nowadays. > Somehow I have the impression that the approach to put layer over layer over layer > is wrong (wxWindows C++ layer, wxPython SWIG layer, Pythoncard/Dabo/whatever > python layer). I think that wxPython is doing a very good job for desktop apps, while I see your argument about too many layers I do not think this is that big an issue today. It is much more important to be productive - i.e. to be able to generate a good looking GUI as quickly and easily as possible. Dabo might be a contender for a desktop app, also I have the impression that they are trying to do everything themselves instead of re-using available tools (db layer instead of e.g. sqlalchemy, report designer instead of e.g. Report Manager, logging instead of Python logging, screen designer instead of e.g. XRCed). > > So, I started writing my own framework, also several years ago. I used > ctypes (early versions) to call the win32 api directly, and it was fun > and it worked out great. > I have my own form editor, I can also construct windows, dialogs, > menus, and so on with simple high level code. But also it is possible > even at the 'highest level' to directly reach out to the win32 api, or > to handle WM_xxx messages directly if the need arises. > > However, this framework is showing its age because during all this time > I developed some new approaches to make the work easier (for example first > I wrote the win32 plumbing code manually, now I have tools that automatically > generate the code to access constants, define structure definitions, or generate > function prototypes from the windows header files. Also the framework too much > relies on manual conversions between byte and unicode strings. > > So, the question is: Are there people that share these ideas? > Are they willing to join a coordinated effort to develop a framework > like this, using the current and future Python versions, and all the fancy > new features of Python? I hope you will find something which will be fun for you and which will improve an existing project. Anyhow, thank you for all the things you have already done for the community like ctypes, py2exe and probably other things I am not aware off! Werner From werner.bruhin at free.fr Tue Dec 2 12:32:36 2008 From: werner.bruhin at free.fr (Werner F. Bruhin) Date: Tue, 02 Dec 2008 12:32:36 +0100 Subject: [python-win32] Does Python need a native Windows GUI toolkit? In-Reply-To: <8249c4ac0812012328oe74a89hb9dec7e9b92efc8d@mail.gmail.com> References: <8249c4ac0812012328oe74a89hb9dec7e9b92efc8d@mail.gmail.com> Message-ID: Tony Cappellini wrote: > > >>Back to this thread - has anybody used the new pythoncard stuff? > > What do you mean by the "new pythoncard stuff" ? > Pythoncard has been around for a long time. There seems also be a fork or at least a discussion about doing one. https://sourceforge.net/mailarchive/forum.php?thread_name=20081112123302.GA4443%40dedalo.nexlab.thc&forum_name=pythoncard-users > > I've used it- and it's one of the reasons I now use wxPython directly, > without any wrappers. > (I didn't like Boa - but it's been a long time since I've tried it) Can only see a question about getting CVS on the Boa list from you (but then my archive might not have everything). Pity that at the time you tried it you did not comment to the Boa or wxPython list of what you did not like about Boa. I am sure Riaan would like to hear about dislikes as that is the only way they might get fixed/changed at some point in the future - unless one provides a patch which is even faster:). Werner From swalsh at impathnetworks.com Tue Dec 2 13:30:09 2008 From: swalsh at impathnetworks.com (Sandy Walsh) Date: Tue, 02 Dec 2008 08:30:09 -0400 Subject: [python-win32] win32com and extended error messages: IDL with [out, retval] long* error) In-Reply-To: <4934ABCE.3080205@gmail.com> References: <4933FA11.7010100@impathnetworks.com> <4934ABCE.3080205@gmail.com> Message-ID: <49352A51.1010701@impathnetworks.com> Thanks for the prompt reply Mark. That was it ... the C++ was returning the error code and not S_OK. Everything is cool now. Also the "9999" string for int was a problem as well ... good catch. Keep up the great work and thanks again! -Sandy Mark Hammond wrote: > Sandy Walsh wrote: >> Hi, >> >> I have a C++ COM Server with an IDL entry of: >> >> [ >> object, >> uuid(D989CB9A-0013-4E1A-BFB6-98A7946BD255), >> dual, >> helpstring("IFoo Interface"), >> pointer_default(unique) >> ] >> interface IFoo : IDispatch >> { >> [ id(1), helpstring("method Connect")] >> HRESULT Connect([in] BSTR x, [in] short y, [in] BSTR z, [out, >> retval] long* error); >> }; >> >> A call from Python to the C++ object works fine unless I return >> something other than S_OK for "error". > > What does the C++ code look like? > >> self.assertEqual(0, self.control.Connect("10.0.0.0", >> "9999", "")) > > That looks strange - your IDL says y is an integer, but you are > passing a string. > >> The call failed with code 80020009: Exception occurred. >> The source of the error is None >> The error message is None >> More info can be found in None (id=0) >> Win32 exception occurred releasing IUnknown at 0x00e84c58 >> >> (where HR of 0x80020009 is DISP_E_EXCEPTION) > > So something is returning DISP_E_EXCEPTION as the HRESULT for the > method (which is quite different than having a dispatch "return value" > (which is passed as a param to the C++ implementation) named error. > >> I've traced the python side of the code and how it appears to me is >> the "error" out variable is not being created in the argument list. > > No - it is a return value: it comes back in the VARIANT holding the > result. Note we are going via IDispatch, so something, presumably > ATL, is converting the IDispatch::Invoke call into a native vtable > based call into your implementation. > >> I'm not sending extended error messages on the C++ side, just setting >> this error code out variable. > > How are you setting it exactly? And what do you mean by "sending > extended error messages" - how would they be sent? > > > I can only assume that the exception is >> being generated in the MS Com libraries when it tries to marshal the >> error variable into a non-existent spot? > > I don't think the COM libraries would throw that kind of exception. > > Is it possible that your C++ implementation is returning the error > code instead of setting it? Your C++ method should always return > S_OK, but set "error" via a pointer passed to your function. > > Cheers, > > Mark > > > -------------- next part -------------- A non-text attachment was scrubbed... Name: swalsh.vcf Type: text/x-vcard Size: 335 bytes Desc: not available URL: From venutaurus539 at gmail.com Wed Dec 3 11:25:01 2008 From: venutaurus539 at gmail.com (venu madhav) Date: Wed, 3 Dec 2008 15:55:01 +0530 Subject: [python-win32] Problem in accessing the Sender and Receiver addresses of an outlook mail Message-ID: Hi all, I am trying to use python for extracting contents of an outlook email. For extracting the list of Recipients addresses I tried using the "MAPI.message.Recipients.Address" property, but the problem I am facing is that it is giving the complete DN name which is putting me in further complications. Is there any way to obtain the actual SMTP mail address ( username at domain.com) of both sender and receiver from the above object? I searched for it in the MSDN help but couldn't succeed. Thanks in advance, Venu -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Dec 3 19:00:06 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 03 Dec 2008 10:00:06 -0800 Subject: [python-win32] Problem in accessing the Sender and Receiver addresses of an outlook mail In-Reply-To: References: Message-ID: <4936C926.2090209@probo.com> venu madhav wrote: > > I am trying to use python for extracting contents of an > outlook email. For extracting the list of Recipients addresses I tried > using > the "MAPI.message.Recipients.Address" property, but the problem I > am facing is that it is giving the complete DN name which is putting > me in further complications. Is there any way to obtain the actual > SMTP mail address (username at domain.com ) > of both sender and receiver from the above object? I searched for it > in the MSDN help but couldn't succeed. This depends on your mail server. If you are using Exchange, and are looking at an internal message, it's not using SMTP, and might be configured to deliver only to DN names. The "Type" property of the address tells you which address type it is. http://www.ssuet.edu.pk/taimoor/books/0-672-30928-9/ch4.htm -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From stef.mientki at gmail.com Wed Dec 3 19:05:49 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Wed, 03 Dec 2008 19:05:49 +0100 Subject: [python-win32] Does Python need a native Windows GUI toolkit? In-Reply-To: References: Message-ID: <4936CA7D.2080802@gmail.com> Werner F. Bruhin wrote: > Thomas Heller wrote: >> Does Python need a native, pure Python, Windows GUI toolkit, one that >> uses >> win32 api calls directly to use native windows controls? >> >> Or would that development be a waste of resources, in these days of >> of Python.NET, Windows forms, IronPython, (and last, not least, wxPython >> and all these other toolkits)? Or are desktop applications too rare >> now? > > I would consider it a waste of resources. > > I use wxPython and if I would change today to something else it would > probably be a web/html based tool kit. Why, the only issue I have > found with wxPython is that it is too large for devices such as > Palm/iPhone/WinMobile. Unless one invests in some professional tools > (I am only aware of WinDev, but there must be others) one can not > develop one app which runs on these mobile devices and on desktops. try PocketPyGui for mobile devices, works great. cheers, Stef From venutaurus539 at gmail.com Thu Dec 4 05:57:41 2008 From: venutaurus539 at gmail.com (venu madhav) Date: Thu, 4 Dec 2008 10:27:41 +0530 Subject: [python-win32] Problem in accessing the Sender and Receiver addresses of an outlook mail In-Reply-To: <4936C926.2090209@probo.com> References: <4936C926.2090209@probo.com> Message-ID: On Wed, Dec 3, 2008 at 11:30 PM, Tim Roberts wrote: > venu madhav wrote: > > > > I am trying to use python for extracting contents of an > > outlook email. For extracting the list of Recipients addresses I tried > > using > > the "MAPI.message.Recipients.Address" property, but the problem I > > am facing is that it is giving the complete DN name which is putting > > me in further complications. Is there any way to obtain the actual > > SMTP mail address (username at domain.com ) > > of both sender and receiver from the above object? I searched for it > > in the MSDN help but couldn't succeed. > > This depends on your mail server. If you are using Exchange, and are > looking at an internal message, it's not using SMTP, and might be > configured to deliver only to DN names. The "Type" property of the > address tells you which address type it is. > > http://www.ssuet.edu.pk/taimoor/books/0-672-30928-9/ch4.htm > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > ************************************************************************* I am using Exchange server and partial code is given below message = inbox.Messages.Item(11) objRecip = message.Recipients.Item(1) typ = objRecip.AddressEntry.Type print " the type of address " print typ Its output is ************************************************************************** the type of address EX ******************************************************************* Please let me know if I can provide you any other information. Thanks in advance, Venu -------------- next part -------------- An HTML attachment was scrubbed... URL: From theller at ctypes.org Thu Dec 4 08:17:28 2008 From: theller at ctypes.org (Thomas Heller) Date: Thu, 04 Dec 2008 08:17:28 +0100 Subject: [python-win32] Does Python need a native Windows GUI toolkit? In-Reply-To: References: Message-ID: Thomas Heller schrieb: > Does Python need a native, pure Python, Windows GUI toolkit, one that uses > win32 api calls directly to use native windows controls? Ok, the answer to this question, for the 'community', is a clear No! Understood, Thomas From theller at ctypes.org Thu Dec 4 08:18:20 2008 From: theller at ctypes.org (Thomas Heller) Date: Thu, 04 Dec 2008 08:18:20 +0100 Subject: [python-win32] Does Python need a native Windows GUI toolkit? In-Reply-To: <4930EFE6.5020507@canterbury.ac.nz> References: <4930EFE6.5020507@canterbury.ac.nz> Message-ID: Greg Ewing schrieb: > Thomas Heller wrote: >> Does Python need a native, pure Python, Windows GUI toolkit, one that uses >> win32 api calls directly to use native windows controls? > > I believe so. One of the long-term goals for PyGUI is to > give it a native Windows backend. I share your dislike of > layers on layers. > >> Are there people that share these ideas? >> Are they willing to join a coordinated effort to develop a framework >> like this, > > Would you be willing to work on a Windows implementation > of PyGUI? > > http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ > Yes, I'll look into it. Is there a null-implementation that makes it easier to get started? -- Thanks, Thomas From whatyoulookin at yahoo.com Thu Dec 4 10:24:46 2008 From: whatyoulookin at yahoo.com (Alec Bennett) Date: Thu, 4 Dec 2008 01:24:46 -0800 (PST) Subject: [python-win32] turning monitors off from Python? Message-ID: <689506.34103.qm@web54601.mail.re2.yahoo.com> I'm trying to turn a monitor off from a Python script. I can do this using the program "wizmo", so its possible from Windows. I found this script which describes a method using SendMessage: http://fci-h.blogspot.com/2007/03/turn-off-your-monitor-via-code-c.html Translated to Python, here's what I have so far: SC_MONITORPOWER = 0xF170 win32gui.SendMessage(handle, WM_SYSCOMMAND, SC_MONITORPOWER, 2) That follows this general structure: SendMessage(Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal MONITOR_OFF) My problem is getting the handle. I'm used to getting the handles of windows, but in this case I'm sending the command to the operating system itself. I'm guessing its a DLL call? There's a link to a working C example here: http://www.4shared.com/file/11593987/2d23f157/Turn_Your_Monitor_BY_Essawy.html Does anyone have any tips? From mail at timgolden.me.uk Thu Dec 4 11:09:35 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 04 Dec 2008 10:09:35 +0000 Subject: [python-win32] turning monitors off from Python? In-Reply-To: <689506.34103.qm@web54601.mail.re2.yahoo.com> References: <689506.34103.qm@web54601.mail.re2.yahoo.com> Message-ID: <4937AC5F.4090306@timgolden.me.uk> Alec Bennett wrote: > I'm trying to turn a monitor off from a Python script. I can do this using the program "wizmo", so its possible from Windows. I found this script which describes a method using SendMessage: > > http://fci-h.blogspot.com/2007/03/turn-off-your-monitor-via-code-c.html > > Translated to Python, here's what I have so far: > > SC_MONITORPOWER = 0xF170 > win32gui.SendMessage(handle, WM_SYSCOMMAND, SC_MONITORPOWER, 2) > > That follows this general structure: > SendMessage(Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal MONITOR_OFF) > > My problem is getting the handle. The article you mention suggests using the desktop window handle -- available via GetDesktopWindow (). You might try that? TJG From whatyoulookin at yahoo.com Thu Dec 4 12:01:14 2008 From: whatyoulookin at yahoo.com (Alec Bennett) Date: Thu, 4 Dec 2008 03:01:14 -0800 (PST) Subject: [python-win32] turning monitors off from Python? In-Reply-To: <4937AC5F.4090306@timgolden.me.uk> Message-ID: <372258.9304.qm@web54606.mail.re2.yahoo.com> > The article you mention suggests using the desktop window > handle -- available via GetDesktopWindow (). You might try that? I have a feeling that was progress, but still no reaction on my monitors. Here's the code including the new clue: SC_MONITORPOWER = 0xF170 handle = win32gui.GetDesktopWindow() win32gui.SendMessage(handle, win32con.WM_SYSCOMMAND, SC_MONITORPOWER, 2) From whatyoulookin at yahoo.com Thu Dec 4 12:17:40 2008 From: whatyoulookin at yahoo.com (Alec Bennett) Date: Thu, 4 Dec 2008 03:17:40 -0800 (PST) Subject: [python-win32] turning monitors off from Python? In-Reply-To: <372258.9304.qm@web54606.mail.re2.yahoo.com> Message-ID: <711605.55850.qm@web54605.mail.re2.yahoo.com> Eureka! In case anyone else comes down this path, the trick is to use HWND_BROADCAST to send the message to all windows. So the code to turn off all monitors: SC_MONITORPOWER = 0xF170 win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND, SC_MONITORPOWER, 2) According to the documentation, that last parameter (the 2) could be a 1 for low power (not sure if any Windows computers support this?), or a -1 to turn the monitor back on. Of course you can always turn the monitor back on by moving the mouse or hitting a key. From mc at mclaveau.com Thu Dec 4 15:02:41 2008 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 4 Dec 2008 15:02:41 +0100 Subject: [python-win32] turning monitors off from Python? In-Reply-To: <711605.55850.qm@web54605.mail.re2.yahoo.com> References: <711605.55850.qm@web54605.mail.re2.yahoo.com> Message-ID: Hi! > Eureka! Thanks for your /fun/shared/ code-source. @-salutations -- Michel Claveau From timr at probo.com Thu Dec 4 19:15:19 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 04 Dec 2008 10:15:19 -0800 Subject: [python-win32] Problem in accessing the Sender and Receiver addresses of an outlook mail In-Reply-To: References: <4936C926.2090209@probo.com> Message-ID: <49381E37.6080909@probo.com> venu madhav wrote: > > I am using Exchange server and partial code is given below > message = inbox.Messages.Item(11) > objRecip = message.Recipients.Item(1) > typ = objRecip.AddressEntry.Type > print " the type of address " > print typ > > Its output is > ************************************************************************** > the type of address > EX > ******************************************************************* > Please let me know if I can provide you any other information. Yep, you have a native Exchange address. The message does not contain the SMTP address, because Exchange doesn't use that for delivery. If you really need the SMTP address for this person, you will have to go look it up in the Exchange address book using the address you got. Here's an article from microsoft.public.platformsdk.mapi that talks a little about this: *http://tinyurl.com/6mfqqo* -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From whatyoulookin at yahoo.com Thu Dec 4 21:04:05 2008 From: whatyoulookin at yahoo.com (Alec Bennett) Date: Thu, 4 Dec 2008 12:04:05 -0800 (PST) Subject: [python-win32] rebooting windows from Python? Message-ID: <183192.14416.qm@web54607.mail.re2.yahoo.com> I'm wondering if there's some way to reboot or shutdown Windows from within Python? I can log out like this: win32api.ExitWindowsEx(4) And according to the documentation, I should be able to shutdown like this: win32api.ExitWindowsEx(2) But that returns the following error: 'A required privilege is not held by the client.' Is there some way to do this? Currently I'm running shutdown.exe, which works, but I'd rather do it directly if possible. Thanks for any help. From timr at probo.com Thu Dec 4 21:16:21 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 04 Dec 2008 12:16:21 -0800 Subject: [python-win32] rebooting windows from Python? In-Reply-To: <183192.14416.qm@web54607.mail.re2.yahoo.com> References: <183192.14416.qm@web54607.mail.re2.yahoo.com> Message-ID: <49383A95.9000603@probo.com> Alec Bennett wrote: > I'm wondering if there's some way to reboot or shutdown Windows from within Python? > > I can log out like this: > > win32api.ExitWindowsEx(4) > > And according to the documentation, I should be able to shutdown like this: > > win32api.ExitWindowsEx(2) > > But that returns the following error: > > 'A required privilege is not held by the client.' > > Is there some way to do this? Currently I'm running shutdown.exe, which works, but I'd rather do it directly if possible. > Yes -- you have to acquire the required privilege. ;) The mechanism to do so is tedious, and involves fetching your current privilege token, then adjusting it in place. You can read about it in the MSDN page on ExitWindowsEx: http://msdn.microsoft.com/en-us/library/aa376868.aspx Personally, and it really is a personal preference, I think it's a lot less trouble, and a lot easier to understand, just to use the tools at my disposal: subprocess.call( "shutdown", "-r" ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From wesbrooks at gmail.com Thu Dec 4 21:16:57 2008 From: wesbrooks at gmail.com (Wesley Brooks) Date: Thu, 4 Dec 2008 20:16:57 +0000 Subject: [python-win32] rebooting windows from Python? In-Reply-To: <183192.14416.qm@web54607.mail.re2.yahoo.com> References: <183192.14416.qm@web54607.mail.re2.yahoo.com> Message-ID: To restart I use: outFileObject = os.popen("shutdown -r -t 05", 'r') To shutdown swap -r for -s. This is the same as running the "shutdown -r -t 05" on the command prompt. The number is the delay and the outFileObject catches any messages that would be printed out to the command prompt window. Wes. 2008/12/4 Alec Bennett > I'm wondering if there's some way to reboot or shutdown Windows from within > Python? > > I can log out like this: > > win32api.ExitWindowsEx(4) > > And according to the documentation, I should be able to shutdown like this: > > win32api.ExitWindowsEx(2) > > But that returns the following error: > > 'A required privilege is not held by the client.' > > Is there some way to do this? Currently I'm running shutdown.exe, which > works, but I'd rather do it directly if possible. > > Thanks for any help. > > > > > > > _______________________________________________ > 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: From mdriscoll at co.marshall.ia.us Thu Dec 4 23:32:32 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Thu, 04 Dec 2008 16:32:32 -0600 Subject: [python-win32] Walking the registry and creating reg files Message-ID: <49385A80.9000603@co.marshall.ia.us> Hi, We're doing what amounts to a registry session audit here at work, so I need to walk a specific set of subfolders in our registry and get the contents thereof. The subfolders will vary from user to user. I found Tim Golden's excellent registry walking script on his website here: http://timgolden.me.uk/python-on-windows/programming-areas/registry/walk-the-registry.html My problem is that I need to output the data into *.reg files. Is there a builtin way to do that with _winreg or PyWin32 or do I just need to roll my own? I'm using Python 2.5.2 on Windows XP. Thanks, Mike From timr at probo.com Fri Dec 5 00:13:48 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 04 Dec 2008 15:13:48 -0800 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <49385A80.9000603@co.marshall.ia.us> References: <49385A80.9000603@co.marshall.ia.us> Message-ID: <4938642C.2080205@probo.com> Mike Driscoll wrote: > > We're doing what amounts to a registry session audit here at work, so > I need to walk a specific set of subfolders in our registry and get > the contents thereof. The subfolders will vary from user to user. I > found Tim Golden's excellent registry walking script on his website here: > > http://timgolden.me.uk/python-on-windows/programming-areas/registry/walk-the-registry.html > > > My problem is that I need to output the data into *.reg files. Is > there a builtin way to do that with _winreg or PyWin32 or do I just > need to roll my own? I'm not answering the question you asked, but are you aware of the very handy "reg" tool included with XP? "reg export" can export a full key in a format that is compatible with regedit. reg export HKLM\system\CurrentControlSet\Services\vgasave xxx.reg -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From whatyoulookin at yahoo.com Fri Dec 5 02:13:29 2008 From: whatyoulookin at yahoo.com (Alec Bennett) Date: Thu, 4 Dec 2008 17:13:29 -0800 (PST) Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <4938642C.2080205@probo.com> Message-ID: <129882.26950.qm@web54603.mail.re2.yahoo.com> Reg files are just text files, so why not just create the text files yourself? Here's a reg file for example: REGEDIT4 [HKEY_LOCAL_MACHINE\SOFTWARE\Gizmoware\Whatever] "Name"="Yada" "Number"="something" --- On Thu, 12/4/08, Tim Roberts wrote: > From: Tim Roberts > Subject: Re: [python-win32] Walking the registry and creating reg files > To: "Python-Win32 List" > Date: Thursday, December 4, 2008, 6:13 PM > Mike Driscoll wrote: > > > > We're doing what amounts to a registry session > audit here at work, so > > I need to walk a specific set of subfolders in our > registry and get > > the contents thereof. The subfolders will vary from > user to user. I > > found Tim Golden's excellent registry walking > script on his website here: > > > > > http://timgolden.me.uk/python-on-windows/programming-areas/registry/walk-the-registry.html > > > > > > My problem is that I need to output the data into > *.reg files. Is > > there a builtin way to do that with _winreg or PyWin32 > or do I just > > need to roll my own? > > I'm not answering the question you asked, but are you > aware of the very > handy "reg" tool included with XP? "reg > export" can export a full key > in a format that is compatible with regedit. > reg export > HKLM\system\CurrentControlSet\Services\vgasave > xxx.reg > > -- > 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 From timr at probo.com Fri Dec 5 02:24:12 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 04 Dec 2008 17:24:12 -0800 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <129882.26950.qm@web54603.mail.re2.yahoo.com> References: <129882.26950.qm@web54603.mail.re2.yahoo.com> Message-ID: <493882BC.1010501@probo.com> Alec Bennett wrote: > Reg files are just text files, so why not just create the text files yourself? > > Here's a reg file for example: > > REGEDIT4 > > [HKEY_LOCAL_MACHINE\SOFTWARE\Gizmoware\Whatever] > > "Name"="Yada" > "Number"="something" > Because Mike said he needed to extract sections from the existing registry for audit purposes. It's up to him to decide whether that's easier by writing Python or by using "reg export". Is "something" a number? ;) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mail at timgolden.me.uk Fri Dec 5 10:02:10 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 05 Dec 2008 09:02:10 +0000 Subject: [python-win32] rebooting windows from Python? In-Reply-To: <49383A95.9000603@probo.com> References: <183192.14416.qm@web54607.mail.re2.yahoo.com> <49383A95.9000603@probo.com> Message-ID: <4938EE12.6080608@timgolden.me.uk> Tim Roberts wrote: > Alec Bennett wrote: >> I'm wondering if there's some way to reboot or shutdown Windows from within Python? >> >> I can log out like this: >> >> win32api.ExitWindowsEx(4) >> >> And according to the documentation, I should be able to shutdown like this: >> >> win32api.ExitWindowsEx(2) >> >> But that returns the following error: >> >> 'A required privilege is not held by the client.' >> >> Is there some way to do this? Currently I'm running shutdown.exe, which works, but I'd rather do it directly if possible. >> > > Yes -- you have to acquire the required privilege. ;) The mechanism to > do so is tedious, and involves fetching your current privilege token, > then adjusting it in place. You can read about it in the MSDN page on > ExitWindowsEx: > http://msdn.microsoft.com/en-us/library/aa376868.aspx > > Personally, and it really is a personal preference, I think it's a lot > less trouble, and a lot easier to understand, just to use the tools at > my disposal: > subprocess.call( "shutdown", "-r" ) > Or... WMI makes this one slightly easier. This example: http://timgolden.me.uk/python/wmi_cookbook.html#reboot_remote_machine comes close. You don't -- probably -- need the remote machine bit, and the privilege you need is Shutdown, not RemoteShutdown. Oh, sod it; here's the code: import wmi wmi.WMI (privileges=["Shutdown"]).Win32_OperatingSystem ()[0].Shutdown () TJG From mail at timgolden.me.uk Fri Dec 5 10:18:16 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 05 Dec 2008 09:18:16 +0000 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <49385A80.9000603@co.marshall.ia.us> References: <49385A80.9000603@co.marshall.ia.us> Message-ID: <4938F1D8.2000402@timgolden.me.uk> Mike Driscoll wrote: > We're doing what amounts to a registry session audit here at work, so I > need to walk a specific set of subfolders in our registry and get the > contents thereof. The subfolders will vary from user to user. I found > Tim Golden's excellent registry walking script on his website here: > > http://timgolden.me.uk/python-on-windows/programming-areas/registry/walk-the-registry.html > > > My problem is that I need to output the data into *.reg files. Is there > a builtin way to do that with _winreg or PyWin32 or do I just need to > roll my own? Try as I might, I was unable to discover an API to do this. The backup/restore APIs create opaque binaries. Shouldn't be too hard to get a simple version up-and-running, but picking up all the nuances of different data types might be a bit tedious[*]. If you decide to do something and get it running, please do post it back. I have a long-in-gestation winsys package: http://winsys.googlecode.com/svn/trunk which has a registry module which could do with such a routine. I had thought about writing it myself but considered it low priority. I'm hoping that once I get this -- frankly enormous -- package out with docs & tests I'll be able to feed the best bits of it, and of my own experience, back into the docs you reference above which have been sadly neglected. TJG [*} One note which I remember: the .reg files are usually UTF16LE; not sure if that's important or not. From whatyoulookin at yahoo.com Fri Dec 5 10:35:48 2008 From: whatyoulookin at yahoo.com (Alec Bennett) Date: Fri, 5 Dec 2008 01:35:48 -0800 (PST) Subject: [python-win32] rebooting windows from Python? In-Reply-To: <4938EE12.6080608@timgolden.me.uk> Message-ID: <283415.37492.qm@web54607.mail.re2.yahoo.com> > > import wmi > > wmi.WMI(privileges=["Shutdown"]).Win32_OperatingSystem()[0].Shutdown () > > Stylin, works. The only thing it doesn't do that I personally need it to do is the "force shutdown". In other words "shutdown.exe -f". I found this page with some hints but couldn't get it to work: http://www.freevbcode.com/ShowCode.asp?ID=7693 I tried: nForcePowerDown=12 wmi.WMI(privileges=["Shutdown"]).Win32_OperatingSystem()[0].Shutdown (nForcePowerDown) But no joy. It looks like that code sample is referring to a function called Win32Shutdown(), which appears to be part of the WMI, but I couldn't get it to work. Here's the docs: http://msdn.microsoft.com/en-us/library/aa394058(VS.85).aspx I tried: nForcePowerDown=12 wmi.WMI(privileges=["Shutdown"]).Win32_OperatingSystem()[0].Win32Shutdown(nForcePowerDown) Interestingly that errors out with "_call__() takes exactly 1 argument (2 given)", meaning I think that the Win32Shutdown function doesn't take a parameter, even though the docs say it does. From mail at timgolden.me.uk Fri Dec 5 11:00:19 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 05 Dec 2008 10:00:19 +0000 Subject: [python-win32] rebooting windows from Python? In-Reply-To: <283415.37492.qm@web54607.mail.re2.yahoo.com> References: <283415.37492.qm@web54607.mail.re2.yahoo.com> Message-ID: <4938FBB3.9010802@timgolden.me.uk> Alec Bennett wrote: >> >> import wmi >> >> wmi.WMI(privileges=["Shutdown"]).Win32_OperatingSystem()[0].Shutdown () >> >> > > Stylin, works. The only thing it doesn't do that I personally need > it to do is the "force shutdown". In other words "shutdown.exe -f". > I found this page with some hints but couldn't get it to work: > > http://www.freevbcode.com/ShowCode.asp?ID=7693 Well I'm slightly surprised. The MS docs for this method: http://msdn.microsoft.com/en-us/library/aa393627(VS.85).aspx state that there are no params. And, on my XP SP3 box, introspection says the same: >>> import wmi >>> c = wmi.WMI () >>> c.Win32_OperatingSystem.Shutdown (ReturnValue uint32) | Needs: SeShutdownPrivilege> >>> Ah. I remember. You need the *Win32Shutdown* method, not the *Shutdown* method. Sorry. Try this (untested because I can't be fagged to power my machine down just to test an email :) ): import wmi nForcePowerDown=12 wmi.WMI(privileges=["Shutdown"]).Win32_OperatingSystem()[0].Win32Shutdown (Flags=nForcePowerDown) Earlier versions of the WMI module had a bug/feature which only allowed named params in method calls. Can't remember whether the current release version has it fixed. Certainly my dev version does. TJG From whatyoulookin at yahoo.com Fri Dec 5 11:48:00 2008 From: whatyoulookin at yahoo.com (Alec Bennett) Date: Fri, 5 Dec 2008 02:48:00 -0800 (PST) Subject: [python-win32] rebooting windows from Python? In-Reply-To: <4938FBB3.9010802@timgolden.me.uk> Message-ID: <317019.56572.qm@web54603.mail.re2.yahoo.com> And thus I say for the second time in 24 hours: Eureka! For anyone else coming down this path, here's how to shutdown, reboot or logoff Windows, each with the option to force the action. In other words, you can force Windows to reboot even if its asking if you want to save a document. nLogOff=0 nReboot=2 nForceLogOff=4 nForceReboot=6 nPowerDown=8 nForcePowerDown=12 import wmi wmi.WMI(privileges=["Shutdown"]).Win32_OperatingSystem()[0].Win32Shutdown (Flags=nForceReboot) As is probably pretty obvious, change the "Flags" parameter to whatever you want from the list of options above. On the off chance anyone's curious what my questions have been about, its a sleep timer to shutdown winamp, itunes, vlc, etc., or shutdown windows after a period of time. So now I can be a total slacker and fall asleep to a DVD and not have the menu music playing all night long. http://gizmoware.net/sleeper From mdriscoll at co.marshall.ia.us Fri Dec 5 15:22:12 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Fri, 05 Dec 2008 08:22:12 -0600 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <4938642C.2080205@probo.com> References: <49385A80.9000603@co.marshall.ia.us> <4938642C.2080205@probo.com> Message-ID: <49393914.1000705@co.marshall.ia.us> Tim Roberts wrote: > Mike Driscoll wrote: > >> We're doing what amounts to a registry session audit here at work, so >> I need to walk a specific set of subfolders in our registry and get >> the contents thereof. The subfolders will vary from user to user. I >> found Tim Golden's excellent registry walking script on his website here: >> >> http://timgolden.me.uk/python-on-windows/programming-areas/registry/walk-the-registry.html >> >> >> My problem is that I need to output the data into *.reg files. Is >> there a builtin way to do that with _winreg or PyWin32 or do I just >> need to roll my own? >> > > I'm not answering the question you asked, but are you aware of the very > handy "reg" tool included with XP? "reg export" can export a full key > in a format that is compatible with regedit. > reg export HKLM\system\CurrentControlSet\Services\vgasave xxx.reg > > I suppose I should have completely explained the project, but I didn't think the other details mattered. I will be running this as part of my login script, and writing each subfolder to a directory tree on a per user basis. We are trying to figure out which users have which sessions of a certain program and how to best manage said sessions and their respective configurations, hence the audit. I wasn't aware of this function but I don't know if it will run on every XP machine I touch. I keep running into screwy oddities on our machines where stuff that I thought should be standard isn't actually there. I'll look into your suggestion and see if it's viable though. Thanks for the info. Mike From mail at timgolden.me.uk Fri Dec 5 15:40:34 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 05 Dec 2008 14:40:34 +0000 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <49393914.1000705@co.marshall.ia.us> References: <49385A80.9000603@co.marshall.ia.us> <4938642C.2080205@probo.com> <49393914.1000705@co.marshall.ia.us> Message-ID: <49393D62.7030506@timgolden.me.uk> Mike Driscoll wrote: > Tim Roberts wrote: >> Mike Driscoll wrote: >> >>> We're doing what amounts to a registry session audit here at work, so >>> I need to walk a specific set of subfolders in our registry and get >>> the contents thereof. The subfolders will vary from user to user. I >>> found Tim Golden's excellent registry walking script on his website >>> here: >>> >>> http://timgolden.me.uk/python-on-windows/programming-areas/registry/walk-the-registry.html >>> >>> >>> >>> My problem is that I need to output the data into *.reg files. Is >>> there a builtin way to do that with _winreg or PyWin32 or do I just >>> need to roll my own? >>> >> >> I'm not answering the question you asked, but are you aware of the very >> handy "reg" tool included with XP? "reg export" can export a full key >> in a format that is compatible with regedit. >> reg export HKLM\system\CurrentControlSet\Services\vgasave xxx.reg >> >> > > I suppose I should have completely explained the project, but I didn't > think the other details mattered. I will be running this as part of my > login script, and writing each subfolder to a directory tree on a per > user basis. We are trying to figure out which users have which sessions > of a certain program and how to best manage said sessions and their > respective configurations, hence the audit. As far as I can see, Mike, there's nothing in your description which prevents you from using the registry's save/restore functionality: http://timgolden.me.uk/python-on-windows/programming-areas/registry/save-and-restore-the-registry.html There are bits in there which are a little out-of-date since pywin32 212 which added stuff, but basically the approach should work. You can save the user's folder tree and then -- if you need -- pull the file to some other machine and load it into a different tree. The user running the save operation will need backup privs, however. Might be a showstopper. TJG From mdriscoll at co.marshall.ia.us Fri Dec 5 15:40:32 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Fri, 05 Dec 2008 08:40:32 -0600 Subject: [python-win32] rebooting windows from Python? In-Reply-To: <317019.56572.qm@web54603.mail.re2.yahoo.com> References: <317019.56572.qm@web54603.mail.re2.yahoo.com> Message-ID: <49393D60.3030802@co.marshall.ia.us> Alec, > And thus I say for the second time in 24 hours: Eureka! > > For anyone else coming down this path, here's how to shutdown, reboot or logoff Windows, each with the option to force the action. In other words, you can force Windows to reboot even if its asking if you want to save a document. > > > > nLogOff=0 > nReboot=2 > nForceLogOff=4 > nForceReboot=6 > nPowerDown=8 > nForcePowerDown=12 > > import wmi > wmi.WMI(privileges=["Shutdown"]).Win32_OperatingSystem()[0].Win32Shutdown (Flags=nForceReboot) > > > > As is probably pretty obvious, change the "Flags" parameter to whatever you want from the list of options above. > > On the off chance anyone's curious what my questions have been about, its a sleep timer to shutdown winamp, itunes, vlc, etc., or shutdown windows after a period of time. So now I can be a total slacker and fall asleep to a DVD and not have the menu music playing all night long. > > http://gizmoware.net/sleeper > > I've been using the following method that I found on ActiveState's Cookbook, which I modified a little (http://code.activestate.com/recipes/360649/): import win32security import win32api import sys import time from ntsecuritycon import * def AdjustPrivilege(priv, enable=1): # Get the process token flags = TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY htoken = win32security.OpenProcessToken(win32api.GetCurrentProcess(), flags) # Get the ID for the system shutdown privilege. idd = win32security.LookupPrivilegeValue(None, priv) # Now obtain the privilege for this process. # Create a list of the privileges to be added. if enable: newPrivileges = [(idd, SE_PRIVILEGE_ENABLED)] else: newPrivileges = [(idd, 0)] # and make the adjustment win32security.AdjustTokenPrivileges(htoken, 0, newPrivileges) def RebootServer(message='Rebooting', timeout=30, bForce=0, bReboot=1): AdjustPrivilege(SE_SHUTDOWN_NAME) try: win32api.InitiateSystemShutdown(None, message, timeout, bForce, bReboot) finally: # Now we remove the privilege we just added. AdjustPrivilege(SE_SHUTDOWN_NAME, 0) def AbortReboot(): AdjustPrivilege(SE_SHUTDOWN_NAME) try: win32api.AbortSystemShotdown(None) finally: AdjustPrivilege(SE_SHUTDOWN_NAME, 0) if __name__ == '__main__': RebootServer() time.sleep(10) print 'Aborting shutdown' AbortReboot() Tim Roberts mentioned it, but didn't give any code. I use it for some of my unattended installs where I need to reboot the PC at certain points to continue the installation. Golden's method is definitely shorter and clearer though. Mike From rdahlstrom at directedge.com Fri Dec 5 15:41:36 2008 From: rdahlstrom at directedge.com (Dahlstrom, Roger) Date: Fri, 5 Dec 2008 09:41:36 -0500 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <49393D62.7030506@timgolden.me.uk> References: <49385A80.9000603@co.marshall.ia.us> <4938642C.2080205@probo.com> <49393914.1000705@co.marshall.ia.us> <49393D62.7030506@timgolden.me.uk> Message-ID: <70D9B06B9E99EE4E98E4893703ADA1410E47E37E5B@EXCHANGE1.global.knight.com> If you can read the registry, you can save it without any other special permissions. It is just text. Just export a branch of your own registry and open it with notepad to see the format. I do it all the time, it works fine. -----Original Message----- From: python-win32-bounces+rdahlstrom=directedge.com at python.org [mailto:python-win32-bounces+rdahlstrom=directedge.com at python.org] On Behalf Of Tim Golden Sent: Friday, December 05, 2008 9:41 AM Cc: python-win32 at python.org Subject: Re: [python-win32] Walking the registry and creating reg files Mike Driscoll wrote: > Tim Roberts wrote: >> Mike Driscoll wrote: >> >>> We're doing what amounts to a registry session audit here at work, so >>> I need to walk a specific set of subfolders in our registry and get >>> the contents thereof. The subfolders will vary from user to user. I >>> found Tim Golden's excellent registry walking script on his website >>> here: >>> >>> http://timgolden.me.uk/python-on-windows/programming-areas/registry/walk-the-registry.html >>> >>> >>> >>> My problem is that I need to output the data into *.reg files. Is >>> there a builtin way to do that with _winreg or PyWin32 or do I just >>> need to roll my own? >>> >> >> I'm not answering the question you asked, but are you aware of the very >> handy "reg" tool included with XP? "reg export" can export a full key >> in a format that is compatible with regedit. >> reg export HKLM\system\CurrentControlSet\Services\vgasave xxx.reg >> >> > > I suppose I should have completely explained the project, but I didn't > think the other details mattered. I will be running this as part of my > login script, and writing each subfolder to a directory tree on a per > user basis. We are trying to figure out which users have which sessions > of a certain program and how to best manage said sessions and their > respective configurations, hence the audit. As far as I can see, Mike, there's nothing in your description which prevents you from using the registry's save/restore functionality: http://timgolden.me.uk/python-on-windows/programming-areas/registry/save-and-restore-the-registry.html There are bits in there which are a little out-of-date since pywin32 212 which added stuff, but basically the approach should work. You can save the user's folder tree and then -- if you need -- pull the file to some other machine and load it into a different tree. The user running the save operation will need backup privs, however. Might be a showstopper. TJG _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 DISCLAIMER: This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. NOTICE REGARDING PRIVACY AND CONFIDENTIALITY Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications. www.directedge.com From mail at timgolden.me.uk Fri Dec 5 16:02:10 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 05 Dec 2008 15:02:10 +0000 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <70D9B06B9E99EE4E98E4893703ADA1410E47E37E5B@EXCHANGE1.global.knight.com> References: <49385A80.9000603@co.marshall.ia.us> <4938642C.2080205@probo.com> <49393914.1000705@co.marshall.ia.us> <49393D62.7030506@timgolden.me.uk> <70D9B06B9E99EE4E98E4893703ADA1410E47E37E5B@EXCHANGE1.global.knight.com> Message-ID: <49394272.1040507@timgolden.me.uk> Dahlstrom, Roger wrote: > If you can read the registry, you can save it without any other > special permissions. It is just text. > > Just export a branch of your own registry and open it with notepad > to see the format. I do it all the time, it works fine. You're quite right, Roger, and other people earlier in the thread have more-or-less suggested this approach. I think Mike was looking for something programmatic and there doesn't seem to be anything in the API which offers the same output as the Export action gives you from the menu. My point about the backup (and later restore) privs refers to the specific API calls RegSaveKey and RegRestoreKey. These produce an opaque binary format which doesn't look quite so good in notepad. :) TJG From mdriscoll at co.marshall.ia.us Fri Dec 5 17:15:05 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Fri, 05 Dec 2008 10:15:05 -0600 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <49394272.1040507@timgolden.me.uk> References: <49385A80.9000603@co.marshall.ia.us> <4938642C.2080205@probo.com> <49393914.1000705@co.marshall.ia.us> <49393D62.7030506@timgolden.me.uk> <70D9B06B9E99EE4E98E4893703ADA1410E47E37E5B@EXCHANGE1.global.knight.com> <49394272.1040507@timgolden.me.uk> Message-ID: <49395389.3050102@co.marshall.ia.us> Tim Golden wrote: >
Dahlstrom, Roger wrote: >> If you can read the registry, you can save it without any other >> special permissions. It is just text. >> >> Just export a branch of your own registry and open it with notepad to >> see the format. I do it all the time, it works fine. > > You're quite right, Roger, and other people earlier in the thread > have more-or-less suggested this approach. I think Mike was looking > for something programmatic and there doesn't seem to be anything in > the API which offers the same output as the Export action gives you > from the menu. Yeah, that's what I was looking for. I apologize for not making that clearer. Thanks for reading my mind, Tim! > > My point about the backup (and later restore) privs refers to the > specific API calls RegSaveKey and RegRestoreKey. These produce > an opaque binary format which doesn't look quite so good in notepad. :) > > TJG As I said before, I'll give the export method a try since that's what most of the guys have suggested. Then I'll look at writing something myself that uses Python rather than subprocess if I can find a moment... Mike From timr at probo.com Fri Dec 5 18:35:50 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 05 Dec 2008 09:35:50 -0800 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <4938F1D8.2000402@timgolden.me.uk> References: <49385A80.9000603@co.marshall.ia.us> <4938F1D8.2000402@timgolden.me.uk> Message-ID: <49396676.4060909@probo.com> Tim Golden wrote: > > [*} One note which I remember: the .reg files are usually UTF16LE; > not sure if that's important or not. Regedit and "reg export" create UTF16 files, but regedit and "reg import" are perfectly happy to read 8-bit .reg files. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Dec 5 18:44:23 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 05 Dec 2008 09:44:23 -0800 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <70D9B06B9E99EE4E98E4893703ADA1410E47E37E5B@EXCHANGE1.global.knight.com> References: <49385A80.9000603@co.marshall.ia.us> <4938642C.2080205@probo.com> <49393914.1000705@co.marshall.ia.us> <49393D62.7030506@timgolden.me.uk> <70D9B06B9E99EE4E98E4893703ADA1410E47E37E5B@EXCHANGE1.global.knight.com> Message-ID: <49396877.8090200@probo.com> Dahlstrom, Roger wrote: > If you can read the registry, you can save it without any other special permissions. It is just text. > > Just export a branch of your own registry and open it with notepad to see the format. I do it all the time, it works fine. > Well, you are simplifying things a bit too much. The registry itself is NOT, in fact, text. It is an indexed, hierarchical database. You can certainly use regedit to export a key to text, but the question here was about doing it programmatically, without regedit. Regedit supports the backup/restore function that Tim mentioned, but to do so, it has to acquire backup privileges. If you want to use the same functions from your own program, YOU have to acquire the backup privileges. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rdahlstrom at directedge.com Fri Dec 5 18:51:23 2008 From: rdahlstrom at directedge.com (Dahlstrom, Roger) Date: Fri, 5 Dec 2008 12:51:23 -0500 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <49396877.8090200@probo.com> References: <49385A80.9000603@co.marshall.ia.us><4938642C.2080205@probo.com> <49393914.1000705@co.marshall.ia.us><49393D62.7030506@timgolden.me.uk><70D9B06B9E99EE4E98E4893703ADA1410E47E37E5B@EXCHANGE1.global.knight.com> <49396877.8090200@probo.com> Message-ID: <70D9B06B9E99EE4E98E4893703ADA1410E47E37E6F@EXCHANGE1.global.knight.com> Well, sure the registry itself is not text, but the keynames contained within it are, and so are the values, once you've read them. Basically what I'm saying is not that you need *no* permissions, just that you don't need any *special* permissions - if you have permission to read it and enumerate the subkeys, that is (at least in my experience, maybe I'm not doing exactly what the request is) sufficient. Regedit is not needed, as regedit is not what is being used, whatever program you are running is being used. -----Original Message----- From: python-win32-bounces+rdahlstrom=directedge.com at python.org [mailto:python-win32-bounces+rdahlstrom=directedge.com at python.org] On Behalf Of Tim Roberts Sent: Friday, December 05, 2008 12:44 PM To: Python-Win32 List Subject: Re: [python-win32] Walking the registry and creating reg files Dahlstrom, Roger wrote: > If you can read the registry, you can save it without any other special permissions. It is just text. > > Just export a branch of your own registry and open it with notepad to see the format. I do it all the time, it works fine. > Well, you are simplifying things a bit too much. The registry itself is NOT, in fact, text. It is an indexed, hierarchical database. You can certainly use regedit to export a key to text, but the question here was about doing it programmatically, without regedit. Regedit supports the backup/restore function that Tim mentioned, but to do so, it has to acquire backup privileges. If you want to use the same functions from your own program, YOU have to acquire the backup privileges. -- 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 DISCLAIMER: This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. NOTICE REGARDING PRIVACY AND CONFIDENTIALITY Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications. www.directedge.com From timr at probo.com Fri Dec 5 19:20:07 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 05 Dec 2008 10:20:07 -0800 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <70D9B06B9E99EE4E98E4893703ADA1410E47E37E6F@EXCHANGE1.global.knight.com> References: <49385A80.9000603@co.marshall.ia.us><4938642C.2080205@probo.com> <49393914.1000705@co.marshall.ia.us><49393D62.7030506@timgolden.me.uk><70D9B06B9E99EE4E98E4893703ADA1410E47E37E5B@EXCHANGE1.global.knight.com> <49396877.8090200@probo.com> <70D9B06B9E99EE4E98E4893703ADA1410E47E37E6F@EXCHANGE1.global.knight.com> Message-ID: <493970D7.5060207@probo.com> Dahlstrom, Roger wrote: > ... Basically what I'm saying is not that you need *no* permissions, just that you don't need any *special* permissions - if you have permission to read it and enumerate the subkeys, that is (at least in my experience, maybe I'm not doing exactly what the request is) sufficient. Almost. The RegSaveKey and RegRestoreKey functions, which export and import entire subtrees, need the SE_BACKUP_NAME privilege. The administrator account can get that privilege, but you have to use APIs to ask for it. http://msdn.microsoft.com/en-us/library/ms724917.aspx -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From whatyoulookin at yahoo.com Fri Dec 5 19:21:20 2008 From: whatyoulookin at yahoo.com (Alec Bennett) Date: Fri, 5 Dec 2008 10:21:20 -0800 (PST) Subject: [python-win32] rebooting windows from Python? In-Reply-To: <49393D60.3030802@co.marshall.ia.us> Message-ID: <118904.94270.qm@web54605.mail.re2.yahoo.com> > I've been using the following method that I found on > ActiveState's Cookbook, which I modified a little > (http://code.activestate.com/recipes/360649/): Does that method ever hang during shutdown? I've tested the WMI method a few times and got one hang, where it was asking me to terminate a process during logout. This even though I'm specifying the force shutdown flag. From mdriscoll at co.marshall.ia.us Fri Dec 5 19:25:26 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Fri, 05 Dec 2008 12:25:26 -0600 Subject: [python-win32] rebooting windows from Python? In-Reply-To: <118904.94270.qm@web54605.mail.re2.yahoo.com> References: <118904.94270.qm@web54605.mail.re2.yahoo.com> Message-ID: <49397216.9090201@co.marshall.ia.us> Alec, >> I've been using the following method that I found on >> ActiveState's Cookbook, which I modified a little >> (http://code.activestate.com/recipes/360649/): >> > > Does that method ever hang during shutdown? I've tested the WMI method a few times and got one hang, where it was asking me to terminate a process during logout. This even though I'm specifying the force shutdown flag. > > I haven't had it hang yet, but I'm using it for installing updates on freshly configured PCs, so theoretically, there's not much cruft running on the PCs I'm doing this to. We've had some McAfee and Nero related hangups when the user's restart their PCs, so it's possible that some poorly coded programs could hang it up... All I can say is give it a shot and find out. Mike From rdahlstrom at directedge.com Fri Dec 5 19:31:43 2008 From: rdahlstrom at directedge.com (Dahlstrom, Roger) Date: Fri, 5 Dec 2008 13:31:43 -0500 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <493970D7.5060207@probo.com> References: <49385A80.9000603@co.marshall.ia.us><4938642C.2080205@probo.com><49393914.1000705@co.marshall.ia.us><49393D62.7030506@timgolden.me.uk><70D9B06B9E99EE4E98E4893703ADA1410E47E37E5B@EXCHANGE1.global.knight.com><49396877.8090200@probo.com><70D9B06B9E99EE4E98E4893703ADA1410E47E37E6F@EXCHANGE1.global.knight.com> <493970D7.5060207@probo.com> Message-ID: <70D9B06B9E99EE4E98E4893703ADA1410E47E37E75@EXCHANGE1.global.knight.com> Well, like I said, I've never done it in Python, and this is going back a bit, so some things might be different, but I'm not talking about RegSaveKey or RegRestoreKey, I'm talking about using EnumKey and CreateKey. As far as I can remember, I didn't have any special permissions for that. -----Original Message----- From: python-win32-bounces+rdahlstrom=directedge.com at python.org [mailto:python-win32-bounces+rdahlstrom=directedge.com at python.org] On Behalf Of Tim Roberts Sent: Friday, December 05, 2008 1:20 PM To: Python-Win32 List Subject: Re: [python-win32] Walking the registry and creating reg files Dahlstrom, Roger wrote: > ... Basically what I'm saying is not that you need *no* permissions, just that you don't need any *special* permissions - if you have permission to read it and enumerate the subkeys, that is (at least in my experience, maybe I'm not doing exactly what the request is) sufficient. Almost. The RegSaveKey and RegRestoreKey functions, which export and import entire subtrees, need the SE_BACKUP_NAME privilege. The administrator account can get that privilege, but you have to use APIs to ask for it. http://msdn.microsoft.com/en-us/library/ms724917.aspx -- 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 DISCLAIMER: This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. NOTICE REGARDING PRIVACY AND CONFIDENTIALITY Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications. www.directedge.com From timr at probo.com Fri Dec 5 19:43:11 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 05 Dec 2008 10:43:11 -0800 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <70D9B06B9E99EE4E98E4893703ADA1410E47E37E75@EXCHANGE1.global.knight.com> References: <49385A80.9000603@co.marshall.ia.us><4938642C.2080205@probo.com><49393914.1000705@co.marshall.ia.us><49393D62.7030506@timgolden.me.uk><70D9B06B9E99EE4E98E4893703ADA1410E47E37E5B@EXCHANGE1.global.knight.com><49396877.8090200@probo.com><70D9B06B9E99EE4E98E4893703ADA1410E47E37E6F@EXCHANGE1.global.knight.com> <493970D7.5060207@probo.com> <70D9B06B9E99EE4E98E4893703ADA1410E47E37E75@EXCHANGE1.global.knight.com> Message-ID: <4939763F.4000406@probo.com> Dahlstrom, Roger wrote: > Well, like I said, I've never done it in Python, and this is going back a bit, so some things might be different, but I'm not talking about RegSaveKey or RegRestoreKey, I'm talking about using EnumKey and CreateKey. As far as I can remember, I didn't have any special permissions for that. > You are quite correct. It's only those two specific functions (RegSaveKey and RegRestoreKey) that need special privileges. It just so happens that's what Tim G was talking about. So, we're all in violent agreement... -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rdahlstrom at directedge.com Fri Dec 5 19:55:59 2008 From: rdahlstrom at directedge.com (Dahlstrom, Roger) Date: Fri, 5 Dec 2008 13:55:59 -0500 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <4939763F.4000406@probo.com> References: <49385A80.9000603@co.marshall.ia.us><4938642C.2080205@probo.com><49393914.1000705@co.marshall.ia.us><49393D62.7030506@timgolden.me.uk><70D9B06B9E99EE4E98E4893703ADA1410E47E37E5B@EXCHANGE1.global.knight.com><49396877.8090200@probo.com><70D9B06B9E99EE4E98E4893703ADA1410E47E37E6F@EXCHANGE1.global.knight.com><493970D7.5060207@probo.com><70D9B06B9E99EE4E98E4893703ADA1410E47E37E75@EXCHANGE1.global.knight.com> <4939763F.4000406@probo.com> Message-ID: <70D9B06B9E99EE4E98E4893703ADA1410E47E37E76@EXCHANGE1.global.knight.com> I think my mistake was assuming that reading the values was going to be sufficient. For all the purposes I've used, it was. For my edification, what's the functional difference? I mean, what I was doing was able to walk the registry, extract information, save it for later, modify it, then re-insert it in to the registry. What's different with saving and restoring, or is it just the neater API? -----Original Message----- From: python-win32-bounces+rdahlstrom=directedge.com at python.org [mailto:python-win32-bounces+rdahlstrom=directedge.com at python.org] On Behalf Of Tim Roberts Sent: Friday, December 05, 2008 1:43 PM To: 'Python-Win32 List' Subject: Re: [python-win32] Walking the registry and creating reg files Dahlstrom, Roger wrote: > Well, like I said, I've never done it in Python, and this is going back a bit, so some things might be different, but I'm not talking about RegSaveKey or RegRestoreKey, I'm talking about using EnumKey and CreateKey. As far as I can remember, I didn't have any special permissions for that. > You are quite correct. It's only those two specific functions (RegSaveKey and RegRestoreKey) that need special privileges. It just so happens that's what Tim G was talking about. So, we're all in violent agreement... -- 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 DISCLAIMER: This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. NOTICE REGARDING PRIVACY AND CONFIDENTIALITY Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications. www.directedge.com From cappy2112 at gmail.com Fri Dec 5 20:52:35 2008 From: cappy2112 at gmail.com (Tony Cappellini) Date: Fri, 5 Dec 2008 11:52:35 -0800 Subject: [python-win32] rebooting windows from Python Message-ID: <8249c4ac0812051152g64f06dcfgab5a6c893040c098@mail.gmail.com> Message: 3 Date: Fri, 05 Dec 2008 08:40:32 -0600 From: Mike Driscoll Subject: Re: [python-win32] rebooting windows from Python? To: whatyoulookin at yahoo.com Cc: Python-Win32 List Message-ID: <49393D60.3030802 at co.marshall.ia.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed > On the off chance anyone's curious what my questions have been about, its a sleep >>timer >>to shutdown winamp, itunes, vlc, etc., or shutdown windows after a period of >>time. So now >>I can be a total slacker and fall asleep to a DVD and not have the menu >>music playing all >>night long. Is this capability not already part of XP? I've got my machines set to go to sleep after 1 hour, no programming needed. Right click on the Desktop, Properties, ScreenSaver, Power. There are options to shut the system down, standby or hibernate between 1 minute and 5 hours. From Kyle.Rickey at bakerhughes.com Fri Dec 5 21:43:14 2008 From: Kyle.Rickey at bakerhughes.com (Rickey, Kyle W) Date: Fri, 5 Dec 2008 14:43:14 -0600 Subject: [python-win32] Simulating a mouse click - lParam Message-ID: <59FACAE10BA736419936C90B4E60D459FFF24A@MSGHOUMBX07.ent.bhicorp.com> Let's say I've got a window for which I want to simulate a mouse click at a specific x, y coordinate. I already have the hwnd but I'm not sure how to construct the lParam. I've used SendMessage in the past to click on buttons, etc., but I knew their hwnds. How do I construct the lParam. Per the MSDN docs: http://msdn.microsoft.com/en-us/library/ms645607(VS.85).aspx lParam The low-order word specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area. The high-order word specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area. lParam = ??? win32gui.SendMessage(hwnd, win32con.WM_LBUTTONDOWN, 0, lParam) win32gui.SendMessage(hwnd, win32con.WM_LBUTTONUP, 0, lParam) Any help would be greatly appreciated. I also can't help but wonder if I'm going about this the wrong way. My end goal is clicking on a certain Tab in a TabCtrl (in this case _wx_SysTabCtl32). I used EnumChildWindows to find all the main window's children, but couldn't find the tabs. So figured I would try to 'click' on the tab. -Kyle Rickey -------------- next part -------------- An HTML attachment was scrubbed... URL: From whatyoulookin at yahoo.com Fri Dec 5 22:11:02 2008 From: whatyoulookin at yahoo.com (Alec Bennett) Date: Fri, 5 Dec 2008 13:11:02 -0800 (PST) Subject: [python-win32] rebooting windows from Python In-Reply-To: <8249c4ac0812051152g64f06dcfgab5a6c893040c098@mail.gmail.com> Message-ID: <805584.75756.qm@web54607.mail.re2.yahoo.com> > Is this capability not already part of XP? > I've got my machines set to go to sleep after 1 hour, > no programming needed. > Right click on the Desktop, Properties, ScreenSaver, Power. A couple of problems with doing it like that: 1) if you set your computer to go to sleep after X minutes, you'll have to unset it next time or it'll go to sleep when you didn't mean it to. In other words that method isn't good for a one time thing. 2) I don't think there's a control panel method for shutting down or rebooting, but I could be wrong. And if there is, it'll probably hang on the question "would you like to save your work?" if you had any documents open or a stubborn application that won't close. 3) you can't pause Winamp, which is the main thing I made this for. To me the bigger criticism is that there are probably 600 other programs that do the same thing, but what fun would it be for me to use someone else's program... From cappy2112 at gmail.com Fri Dec 5 22:46:04 2008 From: cappy2112 at gmail.com (Tony Cappellini) Date: Fri, 5 Dec 2008 13:46:04 -0800 Subject: [python-win32] rebooting windows from Python In-Reply-To: <805584.75756.qm@web54607.mail.re2.yahoo.com> References: <8249c4ac0812051152g64f06dcfgab5a6c893040c098@mail.gmail.com> <805584.75756.qm@web54607.mail.re2.yahoo.com> Message-ID: <8249c4ac0812051346x2dbcc2ben8a16f1aa2a52fd2b@mail.gmail.com> > To me the bigger criticism is that there are probably 600 other programs that do the same > thing, but what fun would it be for me to use someone else's program... got it. I'll take a look at your program. From timr at probo.com Fri Dec 5 23:24:36 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 05 Dec 2008 14:24:36 -0800 Subject: [python-win32] Simulating a mouse click - lParam In-Reply-To: <59FACAE10BA736419936C90B4E60D459FFF24A@MSGHOUMBX07.ent.bhicorp.com> References: <59FACAE10BA736419936C90B4E60D459FFF24A@MSGHOUMBX07.ent.bhicorp.com> Message-ID: <4939AA24.4020904@probo.com> Rickey, Kyle W wrote: > > Let?s say I?ve got a window for which I want to simulate a mouse click > at a specific x, y coordinate. I already have the hwnd but I?m not > sure how to construct the lParam. I?ve used SendMessage in the past to > click on buttons, etc., but I knew their hwnds. How do I construct the > lParam. Per the MSDN docs: > > > > http://msdn.microsoft.com/en-us/library/ms645607(VS.85).aspx > > > /lParam/ > > The low-order word specifies the x-coordinate of the cursor. The > coordinate is relative to the upper-left corner of the client area. > > The high-order word specifies the y-coordinate of the cursor. The > coordinate is relative to the upper-left corner of the client area. > > lParam = ??? > > win32gui.SendMessage(hwnd, win32con.WM_LBUTTONDOWN, 0, lParam) > > win32gui.SendMessage(hwnd, win32con.WM_LBUTTONUP, 0, lParam) > > > > Any help would be greatly appreciated. I also can?t help but wonder if > I?m going about this the wrong way. My end goal is clicking on a > certain Tab in a TabCtrl (in this case _/wx/_SysTabCtl32). I used > EnumChildWindows to find all the main window?s children, but couldn?t > find the tabs. So figured I would try to ?click? on the tab. > Two ways. This works as long as both coordinates are positive: lParam = (y << 16) | x The more robust way is like this: lParam = struct.unpack( 'L', struct.unpack( 'hh', x, y ) )[0] However, it would be much better to talk to the tab control directly. Are you doing this from inside the owning wx application? If so, you should be able to get the tab control object and call the methods directly. Even if you can only get the handle, you can use TCM_SETCURSEL. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Dec 5 23:30:16 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 05 Dec 2008 14:30:16 -0800 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <70D9B06B9E99EE4E98E4893703ADA1410E47E37E76@EXCHANGE1.global.knight.com> References: <49385A80.9000603@co.marshall.ia.us><4938642C.2080205@probo.com><49393914.1000705@co.marshall.ia.us><49393D62.7030506@timgolden.me.uk><70D9B06B9E99EE4E98E4893703ADA1410E47E37E5B@EXCHANGE1.global.knight.com><49396877.8090200@probo.com><70D9B06B9E99EE4E98E4893703ADA1410E47E37E6F@EXCHANGE1.global.knight.com><493970D7.5060207@probo.com><70D9B06B9E99EE4E98E4893703ADA1410E47E37E75@EXCHANGE1.global.knight.com> <4939763F.4000406@probo.com> <70D9B06B9E99EE4E98E4893703ADA1410E47E37E76@EXCHANGE1.global.knight.com> Message-ID: <4939AB78.1030000@probo.com> Dahlstrom, Roger wrote: > I think my mistake was assuming that reading the values was going to be sufficient. For all the purposes I've used, it was. For my edification, what's the functional difference? I mean, what I was doing was able to walk the registry, extract information, save it for later, modify it, then re-insert it in to the registry. What's different with saving and restoring, or is it just the neater API? > RegSaveKey and RegRestoreKey use a binary format. It's a direct copy of the database nodes from the registry file itself. RegRestoreKey doesn't merge the new information with the existing information, like the text APIs do. Instead, it completely replaces the entire tree being restored. It's really a backup operation. Thus, these are considered more dangerous APIs, and that's why these need special privileges. At least, that's my story, and I'm sticking to it. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Kyle.Rickey at bakerhughes.com Fri Dec 5 23:52:19 2008 From: Kyle.Rickey at bakerhughes.com (Rickey, Kyle W) Date: Fri, 5 Dec 2008 16:52:19 -0600 Subject: [python-win32] Simulating a mouse click - lParam In-Reply-To: <4939AA24.4020904@probo.com> References: <59FACAE10BA736419936C90B4E60D459FFF24A@MSGHOUMBX07.ent.bhicorp.com> <4939AA24.4020904@probo.com> Message-ID: <59FACAE10BA736419936C90B4E60D459FFF2F6@MSGHOUMBX07.ent.bhicorp.com> Thanks Tim. I used the following to select my tab of interest: TCM_SETCURSEL = 0x130C win32gui.SendMessage(hwnd, TCM_SETCURSEL, 3, 0) However, according to MSDN: http://msdn.microsoft.com/en-us/library/bb760612(VS.85).aspx "Remarks A tab control does not send a TCN_SELCHANGING or TCN_SELCHANGE notification message when a tab is selected using this message." So of course nothing happens after the tab is selected. Ie, the window is not updated to show the different controls etc. And unfortunately, the window of interest is a 3rd party app, so I don't have direct access to the controls and their methods :( Also using: x = 212 y = 66 lParam = (y << 16) | x win32gui.SendMessage(top_hwnd, win32con.WM_LBUTTONDOWN, 0, lParam) win32gui.SendMessage(top_hwnd, win32con.WM_LBUTTONUP, 0, lParam) Selects the tab (albeit not as "elegantly"), but again, the window does not update. Any ideas? -Kyle Rickey -----Original Message----- From: python-win32-bounces+kyle.rickey=bakerhughes.com at python.org [mailto:python-win32-bounces+kyle.rickey=bakerhughes.com at python.org] On Behalf Of Tim Roberts Sent: Friday, December 05, 2008 4:25 PM To: Python-Win32 List Subject: Re: [python-win32] Simulating a mouse click - lParam Rickey, Kyle W wrote: > > Let's say I've got a window for which I want to simulate a mouse click > at a specific x, y coordinate. I already have the hwnd but I'm not > sure how to construct the lParam. I've used SendMessage in the past to > click on buttons, etc., but I knew their hwnds. How do I construct the > lParam. Per the MSDN docs: > > > > http://msdn.microsoft.com/en-us/library/ms645607(VS.85).aspx > > > /lParam/ > > The low-order word specifies the x-coordinate of the cursor. The > coordinate is relative to the upper-left corner of the client area. > > The high-order word specifies the y-coordinate of the cursor. The > coordinate is relative to the upper-left corner of the client area. > > lParam = ??? > > win32gui.SendMessage(hwnd, win32con.WM_LBUTTONDOWN, 0, lParam) > > win32gui.SendMessage(hwnd, win32con.WM_LBUTTONUP, 0, lParam) > > > > Any help would be greatly appreciated. I also can't help but wonder if > I'm going about this the wrong way. My end goal is clicking on a > certain Tab in a TabCtrl (in this case _/wx/_SysTabCtl32). I used > EnumChildWindows to find all the main window's children, but couldn't > find the tabs. So figured I would try to 'click' on the tab. > Two ways. This works as long as both coordinates are positive: lParam = (y << 16) | x The more robust way is like this: lParam = struct.unpack( 'L', struct.unpack( 'hh', x, y ) )[0] However, it would be much better to talk to the tab control directly. Are you doing this from inside the owning wx application? If so, you should be able to get the tab control object and call the methods directly. Even if you can only get the handle, you can use TCM_SETCURSEL. -- 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 From Kyle.Rickey at bakerhughes.com Fri Dec 5 23:56:09 2008 From: Kyle.Rickey at bakerhughes.com (Rickey, Kyle W) Date: Fri, 5 Dec 2008 16:56:09 -0600 Subject: [python-win32] Simulating a mouse click - lParam In-Reply-To: <59FACAE10BA736419936C90B4E60D459FFF2F6@MSGHOUMBX07.ent.bhicorp.com> References: <59FACAE10BA736419936C90B4E60D459FFF24A@MSGHOUMBX07.ent.bhicorp.com><4939AA24.4020904@probo.com> <59FACAE10BA736419936C90B4E60D459FFF2F6@MSGHOUMBX07.ent.bhicorp.com> Message-ID: <59FACAE10BA736419936C90B4E60D459FFF2F8@MSGHOUMBX07.ent.bhicorp.com> Apparently I jumped the gun. I tried: lParam = (y << 16) | x win32gui.SendMessage(top_hwnd, win32con.WM_LBUTTONDOWN, 0, lParam) win32gui.SendMessage(top_hwnd, win32con.WM_LBUTTONUP, 0, lParam) with x and y 1st being on-screen coordinates, and 2nd with x and y being referenced from the corner of my window. I left the TCM_SETCURSEL code un-commented when I ran it the first time. -Kyle Rickey -----Original Message----- From: python-win32-bounces+kyle.rickey=bakerhughes.com at python.org [mailto:python-win32-bounces+kyle.rickey=bakerhughes.com at python.org] On Behalf Of Rickey, Kyle W Sent: Friday, December 05, 2008 4:52 PM To: python-win32 at python.org Subject: Re: [python-win32] Simulating a mouse click - lParam Thanks Tim. I used the following to select my tab of interest: TCM_SETCURSEL = 0x130C win32gui.SendMessage(hwnd, TCM_SETCURSEL, 3, 0) However, according to MSDN: http://msdn.microsoft.com/en-us/library/bb760612(VS.85).aspx "Remarks A tab control does not send a TCN_SELCHANGING or TCN_SELCHANGE notification message when a tab is selected using this message." So of course nothing happens after the tab is selected. Ie, the window is not updated to show the different controls etc. And unfortunately, the window of interest is a 3rd party app, so I don't have direct access to the controls and their methods :( Also using: x = 212 y = 66 lParam = (y << 16) | x win32gui.SendMessage(top_hwnd, win32con.WM_LBUTTONDOWN, 0, lParam) win32gui.SendMessage(top_hwnd, win32con.WM_LBUTTONUP, 0, lParam) Selects the tab (albeit not as "elegantly"), but again, the window does not update. Any ideas? -Kyle Rickey -----Original Message----- From: python-win32-bounces+kyle.rickey=bakerhughes.com at python.org [mailto:python-win32-bounces+kyle.rickey=bakerhughes.com at python.org] On Behalf Of Tim Roberts Sent: Friday, December 05, 2008 4:25 PM To: Python-Win32 List Subject: Re: [python-win32] Simulating a mouse click - lParam Rickey, Kyle W wrote: > > Let's say I've got a window for which I want to simulate a mouse click > at a specific x, y coordinate. I already have the hwnd but I'm not > sure how to construct the lParam. I've used SendMessage in the past to > click on buttons, etc., but I knew their hwnds. How do I construct the > lParam. Per the MSDN docs: > > > > http://msdn.microsoft.com/en-us/library/ms645607(VS.85).aspx > > > /lParam/ > > The low-order word specifies the x-coordinate of the cursor. The > coordinate is relative to the upper-left corner of the client area. > > The high-order word specifies the y-coordinate of the cursor. The > coordinate is relative to the upper-left corner of the client area. > > lParam = ??? > > win32gui.SendMessage(hwnd, win32con.WM_LBUTTONDOWN, 0, lParam) > > win32gui.SendMessage(hwnd, win32con.WM_LBUTTONUP, 0, lParam) > > > > Any help would be greatly appreciated. I also can't help but wonder if > I'm going about this the wrong way. My end goal is clicking on a > certain Tab in a TabCtrl (in this case _/wx/_SysTabCtl32). I used > EnumChildWindows to find all the main window's children, but couldn't > find the tabs. So figured I would try to 'click' on the tab. > Two ways. This works as long as both coordinates are positive: lParam = (y << 16) | x The more robust way is like this: lParam = struct.unpack( 'L', struct.unpack( 'hh', x, y ) )[0] However, it would be much better to talk to the tab control directly. Are you doing this from inside the owning wx application? If so, you should be able to get the tab control object and call the methods directly. Even if you can only get the handle, you can use TCM_SETCURSEL. -- 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 _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From timr at probo.com Sat Dec 6 01:33:44 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 05 Dec 2008 16:33:44 -0800 Subject: [python-win32] Simulating a mouse click - lParam In-Reply-To: <59FACAE10BA736419936C90B4E60D459FFF2F6@MSGHOUMBX07.ent.bhicorp.com> References: <59FACAE10BA736419936C90B4E60D459FFF24A@MSGHOUMBX07.ent.bhicorp.com> <4939AA24.4020904@probo.com> <59FACAE10BA736419936C90B4E60D459FFF2F6@MSGHOUMBX07.ent.bhicorp.com> Message-ID: <4939C868.4080101@probo.com> Rickey, Kyle W wrote: > Thanks Tim. I used the following to select my tab of interest: > > TCM_SETCURSEL = 0x130C > win32gui.SendMessage(hwnd, TCM_SETCURSEL, 3, 0) > > However, according to MSDN: > http://msdn.microsoft.com/en-us/library/bb760612(VS.85).aspx > "Remarks > > A tab control does not send a TCN_SELCHANGING or TCN_SELCHANGE > notification message when a tab is selected using this message." > > So of course nothing happens after the tab is selected. Ie, the window > is not updated to show the different controls etc. And unfortunately, > the window of interest is a 3rd party app, so I don't have direct access > to the controls and their methods :( > Assuming you have the top-most window of the app, you should be able to use FindWindowEx to find the tab control by class name; you shouldn't have to enumerate for it. After you send TCM_SETCURSEL, you should be able to call InvalidateRect to force the window to redraw. Do you have the Windows SDK installed? You can use the "spyxx" tool to explore the window configuration of the app you're examining. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rdahlstrom at directedge.com Sat Dec 6 03:43:36 2008 From: rdahlstrom at directedge.com (Dahlstrom, Roger) Date: Fri, 5 Dec 2008 21:43:36 -0500 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <4939AB78.1030000@probo.com> References: <49385A80.9000603@co.marshall.ia.us><4938642C.2080205@probo.com><49393914.1000705@co.marshall.ia.us><49393D62.7030506@timgolden.me.uk><70D9B06B9E99EE4E98E4893703ADA1410E47E37E5B@EXCHANGE1.global.knight.com><49396877.8090200@probo.com><70D9B06B9E99EE4E98E4893703ADA1410E47E37E6F@EXCHANGE1.global.knight.com><493970D7.5060207@probo.com><70D9B06B9E99EE4E98E4893703ADA1410E47E37E75@EXCHANGE1.global.knight.com><4939763F.4000406@probo.com><70D9B06B9E99EE4E98E4893703ADA1410E47E37E76@EXCHANGE1.global.knight.com> <4939AB78.1030000@probo.com> Message-ID: <70D9B06B9E99EE4E98E4893703ADA1410E47E37E7E@EXCHANGE1.global.knight.com> OK - so if I'm correct in understanding this, let's say hypothetically, I have something like so... HKLM... something something else something else something else If I were to use my operation, and export the entire tree, I would get a copy of the above, but then if someone modified it such that there were four "something else"s, and I merged my copy back in, the end result would be the same four "something else"s, while with your method, I would end up with the original three? Is that right? -----Original Message----- From: python-win32-bounces+rdahlstrom=directedge.com at python.org [mailto:python-win32-bounces+rdahlstrom=directedge.com at python.org] On Behalf Of Tim Roberts Sent: Friday, December 05, 2008 5:30 PM To: Python-Win32 List Subject: Re: [python-win32] Walking the registry and creating reg files Dahlstrom, Roger wrote: > I think my mistake was assuming that reading the values was going to be sufficient. For all the purposes I've used, it was. For my edification, what's the functional difference? I mean, what I was doing was able to walk the registry, extract information, save it for later, modify it, then re-insert it in to the registry. What's different with saving and restoring, or is it just the neater API? > RegSaveKey and RegRestoreKey use a binary format. It's a direct copy of the database nodes from the registry file itself. RegRestoreKey doesn't merge the new information with the existing information, like the text APIs do. Instead, it completely replaces the entire tree being restored. It's really a backup operation. Thus, these are considered more dangerous APIs, and that's why these need special privileges. At least, that's my story, and I'm sticking to it. -- 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 DISCLAIMER: This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. NOTICE REGARDING PRIVACY AND CONFIDENTIALITY Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications. www.directedge.com From venutaurus539 at gmail.com Mon Dec 8 14:48:29 2008 From: venutaurus539 at gmail.com (venu madhav) Date: Mon, 8 Dec 2008 19:18:29 +0530 Subject: [python-win32] Obtaining SMTP address of a sender and receiver of an outlook mail In-Reply-To: References: Message-ID: Sir, I am a beginner in Python and I tried a lot but couldn't make it work. Can I get a code snippet some where giving me the Sender and Recipient addresses using LDAP as you have said. I have already a MAPI session opened for reading the mails. Is it possible to access LDAP object through this MAPI. Any code snippets or references are highly appreciated. Thank you, Venu. On Sat, Dec 6, 2008 at 7:52 AM, BJ Swope wrote: > If you are logged into a windows pc on the domain, you can read query AD > using ldap. By access I meant you can hit the AD server, not that you can > control the server. > > I've not monkeyed with the MAPI tools enough to know. > > > On Wed, Dec 3, 2008 at 11:43 PM, venu madhav wrote: > >> Hi, >> I don't have access to the AD server because only the >> administrators here have those rights. Aren't there any MAPI Sender and >> Recipient object properties which satisfies my need? >> >> Thank you, >> Venu. >> >> On Thu, Dec 4, 2008 at 9:00 AM, BJ Swope wrote: >> >>> If you have access to the AD server that hosts those DNs you can use >>> python's ldap module to retrieve the smtp attribute for the DN you've just >>> parsed from the message. >>> >>> On Wed, Dec 3, 2008 at 2:06 AM, venutaurus539 at gmail.com < >>> venutaurus539 at gmail.com> wrote: >>> >>>> Hi all, >>>> I am trying to use python for extracting contents of an outlook >>>> email. For extracting the list of Recipients addresses I tried using >>>> the "MAPI.message.Recipients.Address" property, but the problem I am >>>> facing is that it is giving the complete DN name which is putting me >>>> in further complications. Is there any way to obtain the actual SMTP >>>> mail address (username at domain.com) from the above object? I searched >>>> for it in the MSDN help but couldn't succeed. >>>> >>>> Thanks in advance, >>>> Venu >>>> -- >>>> http://mail.python.org/mailman/listinfo/python-list >>>> >>> >>> >> > > > -- > We are all slave to our own paradigm. -- Joshua Williams > > If the letters PhD appear after a person's name, that person will remain > outdoors even after it's started raining. -- Jeff Kay > > Fascism is a term used to describe authoritarian nationalist political > ideologies or mass movements that are concerned with notions of cultural > decline or decadence and seek to achieve a millenarian national rebirth by > exalting the nation or race, and promoting cults of unity, strength and > purity. - Wikipedia > -------------- next part -------------- An HTML attachment was scrubbed... URL: From haraldarminmassa at gmail.com Mon Dec 8 14:53:43 2008 From: haraldarminmassa at gmail.com (Harald Armin Massa) Date: Mon, 8 Dec 2008 14:53:43 +0100 Subject: [python-win32] Obtaining SMTP address of a sender and receiver of an outlook mail In-Reply-To: References: Message-ID: <7be3f35d0812080553r7d375702k9cdb9732ed8b5a7d@mail.gmail.com> Venu, if Karma forces you to deal with Outlook and Exchange, you can ease your burden with http://www.dimastr.com/redemption/ The redemption library makes it much easier to deal with outlook. Your challenges are not Python ones, so your salvation most likely will not be findable by conquering da Snake. Harald On Mon, Dec 8, 2008 at 14:48, venu madhav wrote: > Sir, > I am a beginner in Python and I tried a lot but couldn't make it > work. Can I get a code snippet some where giving me the Sender and Recipient > addresses using LDAP as you have said. I have already a MAPI session opened > for reading the mails. Is it possible to access LDAP object through this > MAPI. > Any code snippets or references are highly appreciated. > Thank you, > Venu. > > On Sat, Dec 6, 2008 at 7:52 AM, BJ Swope wrote: >> >> If you are logged into a windows pc on the domain, you can read query AD >> using ldap. By access I meant you can hit the AD server, not that you can >> control the server. >> >> I've not monkeyed with the MAPI tools enough to know. >> >> On Wed, Dec 3, 2008 at 11:43 PM, venu madhav >> wrote: >>> >>> Hi, >>> I don't have access to the AD server because only the >>> administrators here have those rights. Aren't there any MAPI Sender and >>> Recipient object properties which satisfies my need? >>> Thank you, >>> Venu. >>> On Thu, Dec 4, 2008 at 9:00 AM, BJ Swope wrote: >>>> >>>> If you have access to the AD server that hosts those DNs you can use >>>> python's ldap module to retrieve the smtp attribute for the DN you've just >>>> parsed from the message. >>>> >>>> On Wed, Dec 3, 2008 at 2:06 AM, venutaurus539 at gmail.com >>>> wrote: >>>>> >>>>> Hi all, >>>>> I am trying to use python for extracting contents of an outlook >>>>> email. For extracting the list of Recipients addresses I tried using >>>>> the "MAPI.message.Recipients.Address" property, but the problem I am >>>>> facing is that it is giving the complete DN name which is putting me >>>>> in further complications. Is there any way to obtain the actual SMTP >>>>> mail address (username at domain.com) from the above object? I searched >>>>> for it in the MSDN help but couldn't succeed. >>>>> >>>>> Thanks in advance, >>>>> Venu >>>>> -- >>>>> http://mail.python.org/mailman/listinfo/python-list >>>> >>> >> >> >> >> -- >> We are all slave to our own paradigm. -- Joshua Williams >> >> If the letters PhD appear after a person's name, that person will remain >> outdoors even after it's started raining. -- Jeff Kay >> >> Fascism is a term used to describe authoritarian nationalist political >> ideologies or mass movements that are concerned with notions of cultural >> decline or decadence and seek to achieve a millenarian national rebirth by >> exalting the nation or race, and promoting cults of unity, strength and >> purity. - Wikipedia > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 no fx, no carrier pigeon - EuroPython 2009 will take place in Birmingham - Stay tuned! From Kyle.Rickey at bakerhughes.com Mon Dec 8 18:28:07 2008 From: Kyle.Rickey at bakerhughes.com (Rickey, Kyle W) Date: Mon, 8 Dec 2008 11:28:07 -0600 Subject: [python-win32] Simulating a mouse click - lParam In-Reply-To: <4939C868.4080101@probo.com> References: <59FACAE10BA736419936C90B4E60D459FFF24A@MSGHOUMBX07.ent.bhicorp.com> <4939AA24.4020904@probo.com><59FACAE10BA736419936C90B4E60D459FFF2F6@MSGHOUMBX07.ent.bhicorp.com> <4939C868.4080101@probo.com> Message-ID: <59FACAE10BA736419936C90B4E60D459FFF53C@MSGHOUMBX07.ent.bhicorp.com> I tried using the InvalidateRect but it had not effect. Below is the code I used. TCM_SETCURSEL = 0x130C win32gui.SendMessage(hwnd, TCM_SETCURSEL, 3, 0) win32gui.InvalidateRect(hwnd, None, True) I'm thinking I need to send the TCN_SELCHANGE message to the window, but I don't know how to do that. From googling I find out I need to use WM_NOTIFY and here's what I've got so far: win32gui.SendMessage(hwnd, win32con.WM_NOTIFY, I'm having trouble finding the value for TCN_SELCHANGE as it's not wrapped in win32con nor is it defined on the msdn website. How frustrating... http://msdn.microsoft.com/en-us/library/bb760569(VS.85).aspx I also don't understand how to construct the final parameter for TCN_SELCHANGE. Thanks again for the help. -Kyle Rickey -----Original Message----- From: python-win32-bounces+kyle.rickey=bakerhughes.com at python.org [mailto:python-win32-bounces+kyle.rickey=bakerhughes.com at python.org] On Behalf Of Tim Roberts Sent: Friday, December 05, 2008 6:34 PM To: Python-Win32 List Subject: Re: [python-win32] Simulating a mouse click - lParam Rickey, Kyle W wrote: > Thanks Tim. I used the following to select my tab of interest: > > TCM_SETCURSEL = 0x130C > win32gui.SendMessage(hwnd, TCM_SETCURSEL, 3, 0) > > However, according to MSDN: > http://msdn.microsoft.com/en-us/library/bb760612(VS.85).aspx > "Remarks > > A tab control does not send a TCN_SELCHANGING or TCN_SELCHANGE > notification message when a tab is selected using this message." > > So of course nothing happens after the tab is selected. Ie, the window > is not updated to show the different controls etc. And unfortunately, > the window of interest is a 3rd party app, so I don't have direct access > to the controls and their methods :( > Assuming you have the top-most window of the app, you should be able to use FindWindowEx to find the tab control by class name; you shouldn't have to enumerate for it. After you send TCM_SETCURSEL, you should be able to call InvalidateRect to force the window to redraw. Do you have the Windows SDK installed? You can use the "spyxx" tool to explore the window configuration of the app you're examining. -- 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 From timr at probo.com Mon Dec 8 19:17:35 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 08 Dec 2008 10:17:35 -0800 Subject: [python-win32] Walking the registry and creating reg files In-Reply-To: <70D9B06B9E99EE4E98E4893703ADA1410E47E37E7E@EXCHANGE1.global.knight.com> References: <49385A80.9000603@co.marshall.ia.us><4938642C.2080205@probo.com><49393914.1000705@co.marshall.ia.us><49393D62.7030506@timgolden.me.uk><70D9B06B9E99EE4E98E4893703ADA1410E47E37E5B@EXCHANGE1.global.knight.com><49396877.8090200@probo.com><70D9B06B9E99EE4E98E4893703ADA1410E47E37E6F@EXCHANGE1.global.knight.com><493970D7.5060207@probo.com><70D9B06B9E99EE4E98E4893703ADA1410E47E37E75@EXCHANGE1.global.knight.com><4939763F.4000406@probo.com><70D9B06B9E99EE4E98E4893703ADA1410E47E37E76@EXCHANGE1.global.knight.com> <4939AB78.1030000@probo.com> <70D9B06B9E99EE4E98E4893703ADA1410E47E37E7E@EXCHANGE1.global.knight.com> Message-ID: <493D64BF.9040209@probo.com> Dahlstrom, Roger wrote: > OK - so if I'm correct in understanding this, let's say hypothetically, I have something like so... > > HKLM... > something > something else > something else > something else > > If I were to use my operation, and export the entire tree, I would get a copy of the above, but then if someone modified it such that there were four "something else"s, and I merged my copy back in, the end result would be the same four "something else"s, while with your method, I would end up with the original three? Is that right? > Yes, but remember that RegSaveKey uses an undocumented binary format that matches the internal registry database format. Joe User isn't going to go in and modify the saved file. It was really designed for backup and restore. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Jim.Vickroy at noaa.gov Tue Dec 9 18:26:00 2008 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue, 09 Dec 2008 10:26:00 -0700 Subject: [python-win32] how to determine the version of pywin programmatically ? Message-ID: <493EAA28.2080702@noaa.gov> Hello all, I'm writing a script to determine the versions of various installed software packages. How do I access the pywin32 build number from within a script? For example: * for the numpy package, it is: numpy.__version__ * for the PIL package, PIL.Image.VERSION seems to work I notice that the build number appears in: * pywin32.version.txt but I was hoping for something similar to numpy or PIL. Thanks in advance for your feedback, -- jv -------------- next part -------------- An HTML attachment was scrubbed... URL: From bp.tralfamadore at gmail.com Tue Dec 9 19:49:56 2008 From: bp.tralfamadore at gmail.com (Billy Pilgrim) Date: Tue, 9 Dec 2008 13:49:56 -0500 Subject: [python-win32] get window title Message-ID: Hi all, I am rather new to python and haven't been able to find a solution to this (in python or in any other language). The problem: I am trying to find a way to iterate over the set of open windows, and retrieve/extract the window title. The real project, stupid as it is, is to find the 'Freecell' window and extract the game number -- which is part of the title. Thanks for your help! -bp. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Dec 9 20:41:10 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 09 Dec 2008 11:41:10 -0800 Subject: [python-win32] get window title In-Reply-To: References: Message-ID: <493EC9D6.8080300@probo.com> Billy Pilgrim wrote: > > I am rather new to python and haven't been able to find a solution to > this (in python or in any other language). > > The problem: I am trying to find a way to iterate over the set of > open windows, and retrieve/extract the window title. > > The real project, stupid as it is, is to find the 'Freecell' window > and extract the game number -- which is part of the title. I hesitate to turn on my sarcasm generator, but I find it hard to believe that you actually looked for a solution to this. Any number of good Google phrases should have brought you the pieces you need to make this happen. import win32gui def winEnumHandler( hwnd, ctx ): if win32gui.IsWindowVisible( hwnd ): print hex(hwnd), win32gui.GetWindowText( hwnd ) win32gui.EnumWindows( winEnumHandler, None ); -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Tue Dec 9 21:23:43 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 09 Dec 2008 12:23:43 -0800 Subject: [python-win32] get window title In-Reply-To: References: <493EC9D6.8080300@probo.com> Message-ID: <493ED3CF.8000407@probo.com> Billy Pilgrim wrote: > So I presume that window text and title are the same? > (text, IMHO, implies contents of window). That's actually a reasonable question, so I'll turn off the sarcasm engine. ;) The "GetWindowText" and "SetWindowText" APIs are generic, and can be used with almost any kind of window. The definition of what "window text" means depends on the type of the window. Remember that almost everything you see on your screen is a window; there are typically thousands of windows on your desktop at any given time, contained within one another. For dialogs and top-level windows, it means the title bar text. For edit boxes, it means the contents. For static text, it means the text. For buttons, it means the button caption. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skippy.hammond at gmail.com Tue Dec 9 23:55:26 2008 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 10 Dec 2008 09:55:26 +1100 Subject: [python-win32] how to determine the version of pywin programmatically ? In-Reply-To: <493EAA28.2080702@noaa.gov> References: <493EAA28.2080702@noaa.gov> Message-ID: <493EF75E.2070103@gmail.com> Jim Vickroy wrote: > I notice that the build number appears in: > > * pywin32.version.txt > > but I was hoping for something similar to numpy or PIL. I can't see a huge gain in pywin32 opening that file just to make it available in __version__, and having it manually maintained in a .py file other than 'setup.py' doesn't appeal either - so I'm afraid you need to open that file yourself. This is what pythonwin does for its about box. A longer winded alternative is to read the version resources from any of the .dll files - the version number is embedded there - but getting the version string out without win32api is painful. Mark From Jim.Vickroy at noaa.gov Wed Dec 10 00:03:40 2008 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue, 09 Dec 2008 16:03:40 -0700 Subject: [python-win32] how to determine the version of pywin programmatically ? In-Reply-To: <493EF75E.2070103@gmail.com> References: <493EAA28.2080702@noaa.gov> <493EF75E.2070103@gmail.com> Message-ID: <493EF94C.808@noaa.gov> Mark Hammond wrote: > Jim Vickroy wrote: > >> I notice that the build number appears in: >> >> * pywin32.version.txt >> >> but I was hoping for something similar to numpy or PIL. > > I can't see a huge gain in pywin32 opening that file just to make it > available in __version__, and having it manually maintained in a .py > file other than 'setup.py' doesn't appeal either - so I'm afraid you > need to open that file yourself. This is what pythonwin does for its > about box. > > A longer winded alternative is to read the version resources from any > of the .dll files - the version number is embedded there - but getting > the version string out without win32api is painful. > > Mark > OK, thanks Mark. I wanted to be sure I had not missed something obvious and it appears (for once) I had not ;-) From Dominick.Lauzon at MSCsoftware.com Wed Dec 10 14:23:01 2008 From: Dominick.Lauzon at MSCsoftware.com (Dominick Lauzon) Date: Wed, 10 Dec 2008 08:23:01 -0500 Subject: [python-win32] Getting active SMTP servers via python. Message-ID: <589DC3F5067BDD479AAAE54CE398166D640417@NAAAEX01.na.mscsoftware.com> I am attempting to determine the accessible SMTP servers on a given desktop to avoir various users for having to predefine in a given script to facilitate distribution. Is this possible ? Dominick Lauzon ing. Ing?nieur d'application Sr / Sr Application Engineer -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Wed Dec 10 15:06:45 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 10 Dec 2008 14:06:45 +0000 Subject: [python-win32] Getting active SMTP servers via python. In-Reply-To: <589DC3F5067BDD479AAAE54CE398166D640417@NAAAEX01.na.mscsoftware.com> References: <589DC3F5067BDD479AAAE54CE398166D640417@NAAAEX01.na.mscsoftware.com> Message-ID: <493FCCF5.7070202@timgolden.me.uk> Dominick Lauzon wrote: > I am attempting to determine the accessible SMTP servers > on a given desktop to avoir various users for having to > predefine in a given script to facilitate distribution. Can you clarify what you mean by "the accessible SMTP servers"? If you're connected to the internet, that list will potentially be very long :) TJG From mail at timgolden.me.uk Wed Dec 10 16:56:17 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 10 Dec 2008 15:56:17 +0000 Subject: [python-win32] Passing data in a windows message Message-ID: <493FE6A1.2060600@timgolden.me.uk> I'm using win32gui.PyGetBufferAddressAndLen to pass the address & length of a marshalled object as the wparam / lparam of a windows message. Something like this: address, length = \ win32gui.PyGetBufferAddressAndLen (buffer (marshal.dumps (message))) PostMessage (self.hwnd, self.WM_PROGRESS_MESSAGE, length, address) where "message" here is actually a unicode object. At the other end, I'm unpacking the message with PyGetString: message = marshal.loads (win32gui.PyGetString (lparam, wparam)) Obviously, these two code fragments occur in two completely different places. (In two separate threads, in fact). What I'm entirely unsure about is the safety of this from the point of view of the object references. I'm fairly shaky on the Python C-API so altho' I've looked at the implementation of those functions I can't make out whether any references to the data in the buffer is being held. The symptom is that, sometimes, I get garbage out when unmarshalling from the message, which suggests to me that the memory *is* being reallocated. Can anyone enlighten me? Thanks TJG From timr at probo.com Wed Dec 10 19:05:22 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 10 Dec 2008 10:05:22 -0800 Subject: [python-win32] Passing data in a windows message In-Reply-To: <493FE6A1.2060600@timgolden.me.uk> References: <493FE6A1.2060600@timgolden.me.uk> Message-ID: <494004E2.3020408@probo.com> Tim Golden wrote: > I'm using win32gui.PyGetBufferAddressAndLen to pass the address & > length of a marshalled object as the wparam / lparam of a windows > message. Something like this: > > address, length = \ > win32gui.PyGetBufferAddressAndLen (buffer (marshal.dumps (message))) > PostMessage (self.hwnd, self.WM_PROGRESS_MESSAGE, length, address) > > where "message" here is actually a unicode object. But, "marshal.dumps" creates a temporary object, "buffer" creates another temporary to wrap it, but when that statement ends, both temporary objects no longer have any references, so they will get garbage collected. Won't they? Now, if you had written it this way: hold_me = marshal.dumps( message ) address, length = win32gui.PyGetBufferAddressandLen( buffer(hold_me) ) then I think it would work, because the marshaled buffer still has a reference. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Dec 10 19:06:02 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 10 Dec 2008 10:06:02 -0800 Subject: [python-win32] Getting active SMTP servers via python. In-Reply-To: <589DC3F5067BDD479AAAE54CE398166D640417@NAAAEX01.na.mscsoftware.com> References: <589DC3F5067BDD479AAAE54CE398166D640417@NAAAEX01.na.mscsoftware.com> Message-ID: <4940050A.1010407@probo.com> Dominick Lauzon wrote: > > I am attempting to determine the accessible SMTP servers on a given > desktop to avoir various users for having to predefine in a given > script to facilitate distribution. > > > > Is this possible ? > No. There is no way to determine this a priori, and many commercial environments do not have SMTP servers at all (Exchange clients, for example). You must ask the user to configure this. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From theller at ctypes.org Wed Dec 10 19:05:55 2008 From: theller at ctypes.org (Thomas Heller) Date: Wed, 10 Dec 2008 19:05:55 +0100 Subject: [python-win32] Passing data in a windows message In-Reply-To: <493FE6A1.2060600@timgolden.me.uk> References: <493FE6A1.2060600@timgolden.me.uk> Message-ID: Tim Golden schrieb: > I'm using win32gui.PyGetBufferAddressAndLen to pass the address & length > of a marshalled object as the wparam / lparam of a windows message. > Something like this: > > address, length = \ > win32gui.PyGetBufferAddressAndLen (buffer (marshal.dumps (message))) I guess that the argument to PyGetBufferAddressAndLen() go out of scope here, so they may already be invalid BEFORE you call PostMessage. > PostMessage (self.hwnd, self.WM_PROGRESS_MESSAGE, length, address) > > where "message" here is actually a unicode object. At the other end, I'm > unpacking the message with PyGetString: > > message = marshal.loads (win32gui.PyGetString (lparam, wparam)) > Since you used PostMessage, the message is simply posted to the thread's message queue. You have no control when it is processed; so I fear you must keep the posted 'object' alive even longer. From timr at probo.com Wed Dec 10 19:41:23 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 10 Dec 2008 10:41:23 -0800 Subject: [python-win32] Passing data in a windows message In-Reply-To: References: <493FE6A1.2060600@timgolden.me.uk> Message-ID: <49400D53.9010909@probo.com> Thomas Heller wrote: > Since you used PostMessage, the message is simply posted to the thread's > message queue. You have no control when it is processed; so I fear you > must keep the posted 'object' alive even longer. > This is a good point that I overlooked. If you used SendMessage, it would block until the other end acknowledged it. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mail at timgolden.me.uk Wed Dec 10 20:58:22 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 10 Dec 2008 19:58:22 +0000 Subject: [python-win32] Passing data in a windows message In-Reply-To: <49400D53.9010909@probo.com> References: <493FE6A1.2060600@timgolden.me.uk> <49400D53.9010909@probo.com> Message-ID: <49401F5E.9090404@timgolden.me.uk> Tim Roberts wrote: > Thomas Heller wrote: >> Since you used PostMessage, the message is simply posted to the thread's >> message queue. You have no control when it is processed; so I fear you >> must keep the posted 'object' alive even longer. >> > > This is a good point that I overlooked. If you used SendMessage, it > would block until the other end acknowledged it. > Thanks, Tim & Thomas. Pretty much what I thought was happening, but good to get confirmation from more authoritative sources. For some reason which now escapes me, I had tried to avoid using the SendMessage route but it seems like the cleanest way out. (I think I was trying to avoid a circular message path, but that doesn't seem to apply now if it ever did). Thanks for you input. TJG From john_nowlan at carleton.ca Thu Dec 11 17:24:55 2008 From: john_nowlan at carleton.ca (John_Nowlan) Date: Thu, 11 Dec 2008 11:24:55 -0500 Subject: [python-win32] Pythonwin starts, displays main window, interactive window 'frame', then exits Message-ID: <53C341FE4EA0B744B5BB64CA5C708C8C0C2398@CCSEXB10.CUNET.CARLETON.CA> Sorry to intrude, but I'm hoping this is something stupid. Has anyone seen this behaviour and know of a fix? I've searched hi & low, but its hard to find specific info on pythonwin. The only things that have changed are I installed some oracle software and ran some of the samples. Could that have led to something that is causing this? Everything was working fine before. The docs do mention dll problems, could there be a dll 'clash' Windows 2000 sp4 Python 2.6 Pythonwin 212 Btw, I love the simplicity of this ide. Simple but powerful. From whatyoulookin at yahoo.com Fri Dec 12 11:10:52 2008 From: whatyoulookin at yahoo.com (Alec Bennett) Date: Fri, 12 Dec 2008 02:10:52 -0800 (PST) Subject: [python-win32] Pythonwin starts, displays main window, interactive window 'frame', then exits In-Reply-To: <53C341FE4EA0B744B5BB64CA5C708C8C0C2398@CCSEXB10.CUNET.CARLETON.CA> Message-ID: <108233.95563.qm@web54604.mail.re2.yahoo.com> Run it from commandline and see if an error message is printed the console? --- On Thu, 12/11/08, John_Nowlan wrote: > From: John_Nowlan > Subject: [python-win32] Pythonwin starts, displays main window, interactive window 'frame', then exits > To: python-win32 at python.org > Date: Thursday, December 11, 2008, 11:24 AM > Sorry to intrude, but I'm hoping this is something > stupid. Has anyone > seen this behaviour and know of a fix? > > I've searched hi & low, but its hard to find > specific info on pythonwin. > > The only things that have changed are I installed some > oracle software > and ran some of the samples. Could that have led to > something that is > causing this? Everything was working fine before. > > The docs do mention dll problems, could there be a dll > 'clash' > > Windows 2000 sp4 > Python 2.6 > Pythonwin 212 > > Btw, I love the simplicity of this ide. Simple but > powerful. > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From Dominick.Lauzon at MSCsoftware.com Fri Dec 12 15:54:27 2008 From: Dominick.Lauzon at MSCsoftware.com (Dominick Lauzon) Date: Fri, 12 Dec 2008 09:54:27 -0500 Subject: [python-win32] Writing to Excel performance Message-ID: <589DC3F5067BDD479AAAE54CE398166D64070D@NAAAEX01.na.mscsoftware.com> Hi, I have large matrices of data to push to excel and I find the writing of data to excel to be excessively slow (cell by cell method) even if the Visible is to False. Right now I reverted back to a 2 step CSV - Import to Excel but it is far from ideal. Is there any trick to accumulate the data and push it to Excel all at once or any other way to improve performance altogether ? Any guidance would be appreciated. Domnick Lauzon -------------- next part -------------- An HTML attachment was scrubbed... URL: From rdahlstrom at directedge.com Fri Dec 12 15:58:26 2008 From: rdahlstrom at directedge.com (Dahlstrom, Roger) Date: Fri, 12 Dec 2008 09:58:26 -0500 Subject: [python-win32] Writing to Excel performance In-Reply-To: <589DC3F5067BDD479AAAE54CE398166D64070D@NAAAEX01.na.mscsoftware.com> References: <589DC3F5067BDD479AAAE54CE398166D64070D@NAAAEX01.na.mscsoftware.com> Message-ID: <70D9B06B9E99EE4E98E4893703ADA1410E47E37EEC@EXCHANGE1.global.knight.com> Couple of tricks I've used with some success... 1. If this is data only, and not formulas, you can write the data as an html table, but name the file something.xls - Excel will open it natively. 2. If you need special formatting or formulas, you can write the data as Excel's HTML templates (make a sample file in Excel, save it as html, then you can see how to do it) I believe #1 to be a security flaw in windows - that you can just name a file anything, and the application will open it, but anyway, it works, and is fairly fast. ________________________________ From: python-win32-bounces+rdahlstrom=directedge.com at python.org [mailto:python-win32-bounces+rdahlstrom=directedge.com at python.org] On Behalf Of Dominick Lauzon Sent: Friday, December 12, 2008 9:54 AM To: python-win32 at python.org Subject: [python-win32] Writing to Excel performance Hi, I have large matrices of data to push to excel and I find the writing of data to excel to be excessively slow (cell by cell method) even if the Visible is to False. Right now I reverted back to a 2 step CSV - Import to Excel but it is far from ideal. Is there any trick to accumulate the data and push it to Excel all at once or any other way to improve performance altogether ? Any guidance would be appreciated. Domnick Lauzon DISCLAIMER: This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. NOTICE REGARDING PRIVACY AND CONFIDENTIALITY Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications. www.directedge.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Fri Dec 12 16:07:02 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 12 Dec 2008 15:07:02 +0000 Subject: [python-win32] Writing to Excel performance In-Reply-To: <589DC3F5067BDD479AAAE54CE398166D64070D@NAAAEX01.na.mscsoftware.com> References: <589DC3F5067BDD479AAAE54CE398166D64070D@NAAAEX01.na.mscsoftware.com> Message-ID: <49427E16.6060802@timgolden.me.uk> Dominick Lauzon wrote: > I have large matrices of data to push to excel and I find the writing of > data to excel to be excessively slow (cell by cell method) even if the > Visible is to False. > > Right now I reverted back to a 2 step CSV - Import to Excel but it is > far from ideal. > > Is there any trick to accumulate the data and push it to Excel all at > once or any other way to improve performance altogether ? Using COM (which I assume you are from the reference to Visible) you can add a range at a time as a Python list or list of lists: import win32com.client xl = win32com.client.gencache.EnsureDispatch ("Excel.Application") xl.Visible = True sheet = xl.Workbooks.Add ().ActiveSheet sheet.Range (sheet.Cells (1, 1), sheet.Cells (10, 10)).Value = \ [range (10) for i in range (10)] I suspect -- tho' I've never tried to find out -- that using something like xlwt (and when I say "something like xlwt" I really mean "xlwt") might be faster since it doesn't have to manipulate the interface at the same time: http://pypi.python.org/pypi/xlwt Lastly there is a Google Group set up for Python-Excel issues and you might want to lurk or ask there: http://groups.google.com.au/group/python-excel TJG From Kyle.Rickey at bakerhughes.com Fri Dec 12 17:19:42 2008 From: Kyle.Rickey at bakerhughes.com (Rickey, Kyle W) Date: Fri, 12 Dec 2008 10:19:42 -0600 Subject: [python-win32] Simulating a mouse click - lParam In-Reply-To: <59FACAE10BA736419936C90B4E60D459FFF53C@MSGHOUMBX07.ent.bhicorp.com> References: <59FACAE10BA736419936C90B4E60D459FFF24A@MSGHOUMBX07.ent.bhicorp.com> <4939AA24.4020904@probo.com><59FACAE10BA736419936C90B4E60D459FFF2F6@MSGHOUMBX07.ent.bhicorp.com><4939C868.4080101@probo.com> <59FACAE10BA736419936C90B4E60D459FFF53C@MSGHOUMBX07.ent.bhicorp.com> Message-ID: <59FACAE10BA736419936C90B4E60D4590107DB6A@MSGHOUMBX07.ent.bhicorp.com> Ok, I did some more googling and found a solution to this problem. http://www.codeguru.com/forum/showthread.php?t=229822 Suggest using TCM_SETCURFOCUS instead of TCM_SETCURSEL. So here's the code that works to change to a given tab. TCM_SETCURFOCUS = 0x1330 win32gui.SendMessage(hwnd, TCM_SETCURFOCUS, 3, 0) where hwnd is the window handle of the tab control. -Kyle Rickey -----Original Message----- From: python-win32-bounces+kyle.rickey=bakerhughes.com at python.org [mailto:python-win32-bounces+kyle.rickey=bakerhughes.com at python.org] On Behalf Of Rickey, Kyle W Sent: Monday, December 08, 2008 11:28 AM To: python-win32 at python.org Subject: Re: [python-win32] Simulating a mouse click - lParam I tried using the InvalidateRect but it had not effect. Below is the code I used. TCM_SETCURSEL = 0x130C win32gui.SendMessage(hwnd, TCM_SETCURSEL, 3, 0) win32gui.InvalidateRect(hwnd, None, True) I'm thinking I need to send the TCN_SELCHANGE message to the window, but I don't know how to do that. From googling I find out I need to use WM_NOTIFY and here's what I've got so far: win32gui.SendMessage(hwnd, win32con.WM_NOTIFY, I'm having trouble finding the value for TCN_SELCHANGE as it's not wrapped in win32con nor is it defined on the msdn website. How frustrating... http://msdn.microsoft.com/en-us/library/bb760569(VS.85).aspx I also don't understand how to construct the final parameter for TCN_SELCHANGE. Thanks again for the help. -Kyle Rickey -----Original Message----- From: python-win32-bounces+kyle.rickey=bakerhughes.com at python.org [mailto:python-win32-bounces+kyle.rickey=bakerhughes.com at python.org] On Behalf Of Tim Roberts Sent: Friday, December 05, 2008 6:34 PM To: Python-Win32 List Subject: Re: [python-win32] Simulating a mouse click - lParam Rickey, Kyle W wrote: > Thanks Tim. I used the following to select my tab of interest: > > TCM_SETCURSEL = 0x130C > win32gui.SendMessage(hwnd, TCM_SETCURSEL, 3, 0) > > However, according to MSDN: > http://msdn.microsoft.com/en-us/library/bb760612(VS.85).aspx > "Remarks > > A tab control does not send a TCN_SELCHANGING or TCN_SELCHANGE > notification message when a tab is selected using this message." > > So of course nothing happens after the tab is selected. Ie, the window > is not updated to show the different controls etc. And unfortunately, > the window of interest is a 3rd party app, so I don't have direct access > to the controls and their methods :( > Assuming you have the top-most window of the app, you should be able to use FindWindowEx to find the tab control by class name; you shouldn't have to enumerate for it. After you send TCM_SETCURSEL, you should be able to call InvalidateRect to force the window to redraw. Do you have the Windows SDK installed? You can use the "spyxx" tool to explore the window configuration of the app you're examining. -- 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 _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From timr at probo.com Fri Dec 12 19:23:51 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 12 Dec 2008 10:23:51 -0800 Subject: [python-win32] Writing to Excel performance In-Reply-To: <70D9B06B9E99EE4E98E4893703ADA1410E47E37EEC@EXCHANGE1.global.knight.com> References: <589DC3F5067BDD479AAAE54CE398166D64070D@NAAAEX01.na.mscsoftware.com> <70D9B06B9E99EE4E98E4893703ADA1410E47E37EEC@EXCHANGE1.global.knight.com> Message-ID: <4942AC37.5080903@probo.com> Dahlstrom, Roger wrote: > Couple of tricks I've used with some success... > > 1. If this is data only, and not formulas, you can write the data as > an html table, but name the file something.xls - Excel will open it > natively. > 2. If you need special formatting or formulas, you can write the data > as Excel's HTML templates (make a sample file in Excel, save it as > html, then you can see how to do it) > > I believe #1 to be a security flaw in windows - that you can just name > a file anything, and the application will open it, No, it's not a security flaw. The file still has to be in a format that Excel knows how to import. Excel just happens to understand a lot of formats, and it reads the file to figure out what the format really is. It doesn't trust the extension. Internet Explorer uses the same tactic. When a web page sends an attachment, it doesn't trust the MIME type. It reads the file to detect the file type. If you rename an executable to xxx.xls and try to open it within it Excel, it will complain about the format. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rdahlstrom at directedge.com Fri Dec 12 19:28:10 2008 From: rdahlstrom at directedge.com (Dahlstrom, Roger) Date: Fri, 12 Dec 2008 13:28:10 -0500 Subject: [python-win32] Writing to Excel performance In-Reply-To: <4942AC37.5080903@probo.com> References: <589DC3F5067BDD479AAAE54CE398166D64070D@NAAAEX01.na.mscsoftware.com><70D9B06B9E99EE4E98E4893703ADA1410E47E37EEC@EXCHANGE1.global.knight.com> <4942AC37.5080903@probo.com> Message-ID: <70D9B06B9E99EE4E98E4893703ADA1410E47E37EF7@EXCHANGE1.global.knight.com> I understand where you're coming from, I just don't like how Windows handles such things. My opinion is that determining file type by extension (arbitrary at that) is a bad thing to begin with. -----Original Message----- From: python-win32-bounces+rdahlstrom=directedge.com at python.org [mailto:python-win32-bounces+rdahlstrom=directedge.com at python.org] On Behalf Of Tim Roberts Sent: Friday, December 12, 2008 1:24 PM To: Python-Win32 List Subject: Re: [python-win32] Writing to Excel performance Dahlstrom, Roger wrote: > Couple of tricks I've used with some success... > > 1. If this is data only, and not formulas, you can write the data as > an html table, but name the file something.xls - Excel will open it > natively. > 2. If you need special formatting or formulas, you can write the data > as Excel's HTML templates (make a sample file in Excel, save it as > html, then you can see how to do it) > > I believe #1 to be a security flaw in windows - that you can just name > a file anything, and the application will open it, No, it's not a security flaw. The file still has to be in a format that Excel knows how to import. Excel just happens to understand a lot of formats, and it reads the file to figure out what the format really is. It doesn't trust the extension. Internet Explorer uses the same tactic. When a web page sends an attachment, it doesn't trust the MIME type. It reads the file to detect the file type. If you rename an executable to xxx.xls and try to open it within it Excel, it will complain about the format. -- 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 DISCLAIMER: This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. NOTICE REGARDING PRIVACY AND CONFIDENTIALITY Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications. www.directedge.com From timr at probo.com Fri Dec 12 19:44:23 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 12 Dec 2008 10:44:23 -0800 Subject: [python-win32] Writing to Excel performance In-Reply-To: <70D9B06B9E99EE4E98E4893703ADA1410E47E37EF7@EXCHANGE1.global.knight.com> References: <589DC3F5067BDD479AAAE54CE398166D64070D@NAAAEX01.na.mscsoftware.com><70D9B06B9E99EE4E98E4893703ADA1410E47E37EEC@EXCHANGE1.global.knight.com> <4942AC37.5080903@probo.com> <70D9B06B9E99EE4E98E4893703ADA1410E47E37EF7@EXCHANGE1.global.knight.com> Message-ID: <4942B107.7000209@probo.com> Dahlstrom, Roger wrote: > I understand where you're coming from, I just don't like how Windows handles such things. My opinion is that determining file type by extension (arbitrary at that) is a bad thing to begin with. > This is veering a bit off-topic for this mailing list, but I'd be curious to hear what alternatives you would suggest. It's a difficult problem to solve generically, but if you've brainstormed about it, I'd like to hear your thoughts. The extension scheme has always seemed quite sensible to me. Windows, for the most part, uses the extension to look up a handler in the registry. The old Mac OS used a fourcc scheme, where you embedded a code identifier in the resource fork of the file itself. That makes many things unnecessarily hard. Linux uses the "shebang" technique, where the first line of a file (#!) identifies the handler. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From theller at ctypes.org Fri Dec 12 21:30:38 2008 From: theller at ctypes.org (Thomas Heller) Date: Fri, 12 Dec 2008 21:30:38 +0100 Subject: [python-win32] comtypes 0.5.3 released Message-ID: <4942C9EE.2060905@ctypes.org> I just released comtypes-0.5.3. comtypes is a lightweight Python COM package, based on the ctypes FFI library, in less than 10000 lines of code (not counting the tests). comtypes allows to define, call, and implement custom and dispatch-based COM interfaces in pure Python. It works on Windows, 64-bit Windows, and Windows CE. Download location: http://sourceforge.net/project/showfiles.php?group_id=115265 Homepage: http://starship.python.net/crew/theller/comtypes/ This is a maintainance release of the current repository state, before I merged the dynamic-dispatch branch (which will be released as comtypes-0.6.0 within the next few days). Summary of important changes: - Compatible with Python 3.0 - Added comtypes.shelllink module; this allows to manage shortcuts - Various smaller improvements Detailed changes since version 0.5.2: 2008-12-12 Thomas Heller * Bumped version number to 0.5.3. * Added VARIANT support for VT_I8 and VT_UI8 typecodes. 2008-12-11 Thomas Heller * Workaround for Python bug: Python 3 cannot handle a distutils installscript in the setup script * Merged the py3-branch: Various changes for py3 compatibility. The setup script now uses distutils.command.build_py.build_py_2to3 when run with Python 3.x, and converts the sources into py3 syntax on the fly (in the build directory). 2008-11-26 Thomas Heller * Added untested code to comtypes.server: RegisterActiveObject() and RevokeActiveObject(), plus some flags. * Applied a patch from Torbj?rn Tyridal. This allows to high-level implement methods in COM servers, and event handler methods that have [in] and [out] arguments in mixed order. 2008-11-05 Thomas Heller * Add the IPersistFile interface to the comtypes.persist module. Add comtypes.shelllink module which contains IShellLinkA and IShellLinkW interfaces, plus the ShellLink coclass. 2008-10-29 Thomas Heller * Handle coclass pointers as arguments in com interface methods correctly. Method calls will now accept pointers to the default interface of this coclass. * The Fire_Event() method in comtypes.server.connectionpoints now returns a list of results. 2008-10-10 Thomas Heller * Import cStringIO, which should always be available on Windows, instead of first trying cStringIO and then StringIO. * Python 2.6 compatibility: use 'types.MethodType' instead of 'new.instancemethod' to fix a -3 warning. Use 'raise Exception(details)' instead of 'raise Exception, details'. Don't use tuple unpacking in exception handlers: 'except COMError, err: (hresult, text, details) = err' instead of 'except COMError, (hresult, text, details)' * Python 2.4 compatibility: os.stat() raises OSError instead of WindowsError when a file is not found. -- Thanks, Thomas From greg.ewing at canterbury.ac.nz Sat Dec 13 01:02:30 2008 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sat, 13 Dec 2008 13:02:30 +1300 Subject: [python-win32] Writing to Excel performance In-Reply-To: <4942B107.7000209@probo.com> References: <589DC3F5067BDD479AAAE54CE398166D64070D@NAAAEX01.na.mscsoftware.com> <70D9B06B9E99EE4E98E4893703ADA1410E47E37EEC@EXCHANGE1.global.knight.com> <4942AC37.5080903@probo.com> <70D9B06B9E99EE4E98E4893703ADA1410E47E37EF7@EXCHANGE1.global.knight.com> <4942B107.7000209@probo.com> Message-ID: <4942FB96.7000707@canterbury.ac.nz> Tim Roberts wrote: > Dahlstrom, Roger wrote: > >> My opinion is that determining file type by extension (arbitrary at that) >> is a bad thing to begin with. > > This is veering a bit off-topic for this mailing list, but I'd be > curious to hear what alternatives you would suggest. The way classic MacOS handled it was much better. The file type was a separate piece of metadata that the user never normally saw or changed. The file type info is still available in MacOSX, but Apple seems to be discouraging its use, which is disappointing. -- Greg From unkwntech at unkwndesign.com Sat Dec 13 13:37:41 2008 From: unkwntech at unkwndesign.com (Arron Chapman - UnkwnDesign.Com) Date: Sat, 13 Dec 2008 04:37:41 -0800 Subject: [python-win32] Detecting fast user switching Message-ID: <4943AC95.6060205@unkwndesign.com> I found Tim Golden's artical "See if my workstation is locked" http://timgolden.me.uk/python/win32_how_do_i/see_if_my_workstation_is_locked.html which got me most of the way to where I need to be, I want to detect both logout and login events, with some changes to the script provided above I ended up with 2 problems 1) I was able to detect the logout but not the login 2) it was a resource hog at 50% cpu usage (presumably because of the while 1:) here is what I have now: import time, ctypes, Skype4Py skype = Skype4Py.Skype() def restoreMessages(messages): #for now lets just deal with skype, we'll add the others later skype.Profile('MOOD_TEXT', messages['skype']) def setMessages(message): #for now lets just deal with skype, we'll add the others later skype.Profile('MOOD_TEXT', message) user32 = ctypes.windll.User32 OpenDesktop = user32.OpenDesktopA SwitchDesktop = user32.SwitchDesktop DESKTOP_SWITCHDESKTOP = 0x0100 locked = False try: while 1: hDesktop = OpenDesktop ("default", 0, False, DESKTOP_SWITCHDESKTOP) result = SwitchDesktop (hDesktop) if result: if locked: locked = False restoreMessages(messages) else: locked = True messages = {'skype':skype.Profile('MOOD_TEXT')} setMessages('AFK - Away From Keyboard') time.sleep(2) except: pass From skippy.hammond at gmail.com Sun Dec 14 05:18:59 2008 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sun, 14 Dec 2008 15:18:59 +1100 Subject: [python-win32] Pythonwin starts, displays main window, interactive window 'frame', then exits In-Reply-To: <53C341FE4EA0B744B5BB64CA5C708C8C0C2398@CCSEXB10.CUNET.CARLETON.CA> References: <53C341FE4EA0B744B5BB64CA5C708C8C0C2398@CCSEXB10.CUNET.CARLETON.CA> Message-ID: <49448933.70400@gmail.com> John_Nowlan wrote: > Sorry to intrude, but I'm hoping this is something stupid. Has anyone > seen this behaviour and know of a fix? > > I've searched hi & low, but its hard to find specific info on pythonwin. Try deleting your "HKEY_CURRENT_USER\Software\Python 2.5" (using whatever version of Python you are using) key - this may have garbage which causes MFC to get upset as it starts. Cheers, Mark From ckkart at hoc.net Sun Dec 14 20:41:43 2008 From: ckkart at hoc.net (Christian K.) Date: Sun, 14 Dec 2008 19:41:43 +0000 (UTC) Subject: [python-win32] SOLVED: force outlook ui update Message-ID: Hi, a couple of weeks ago I asked how to refresh the outlook view after having modified a mail's properties directly using the extended MAPI. At least for the subject of the mail there is an easy workaround: mailitem.Subject = mailitem.Subject will trigger a refresh of all views of the mailitem. Christian From qinwyo2008 at yahoo.com Mon Dec 15 09:17:21 2008 From: qinwyo2008 at yahoo.com (Wang Yongqing) Date: Mon, 15 Dec 2008 00:17:21 -0800 (PST) Subject: [python-win32] Transmit HID device with python on Windows Message-ID: <380845.29428.qm@web56503.mail.re3.yahoo.com> Hi All, I have a USB hid device, and I want to use the python to communicate with it on the Windows. My question is whether there is a python module which could be used to this program. Best regards Yongqing -------------- next part -------------- An HTML attachment was scrubbed... URL: From ferdinandsousa at gmail.com Mon Dec 15 14:37:59 2008 From: ferdinandsousa at gmail.com (Ferdinand Sousa) Date: Mon, 15 Dec 2008 19:07:59 +0530 Subject: [python-win32] Post Message Message-ID: Greetings everyone, My config is: python 2.5.1 pywin32 build 212 Win Xp I have written a small script to automate a process. The issue is that a "Save As" pops up at the end. Using Winspector, I could come up with this: win32gui.PostMessage(win_hdl,con.WM_COMMAND,1,0) # handle to the "Save As" window, message type, Control ID of the "Save" button This works perfectly. However, now I would like to modify the "File name" field so that I can change the default save location. It is a combo box and has a control ID 1148. Using intuition, I tried WM_SETTEXT, but no luck. Any pointers? If possible, could any one point out any general, simple-to-use help on the PostMessage function? Best regards, Ferdi -------------- next part -------------- An HTML attachment was scrubbed... URL: From enricjaen at yahoo.es Mon Dec 15 14:55:04 2008 From: enricjaen at yahoo.es (Enric Jaen) Date: Mon, 15 Dec 2008 13:55:04 +0000 (GMT) Subject: [python-win32] no array returned in output parameter Message-ID: <964605.10949.qm@web23606.mail.ird.yahoo.com> Hi, ** Situation ** Using python 2.6.1. I have the following method generated by makepy.py: def GetFilters(self, pvarFilterArray=defaultNamedNotOptArg, pnArraySize=defaultNamedNotOptArg): """method GetFilters""" return self._oleobj_.InvokeTypes(68, LCID, 1, (24, 0), ((16396, 0), (16387, 0)),pvarFilterArray , pnArraySize) As you see, the method has two output params: The first is of type pointer to a Variant (which the COM object should fill with an array) and the second a pointer to a type long. But when I invoke that method it returns a tuple as if there were no data: >>> r.GetFilters() (None, 0) i.e array is Null with size is 0. The same is happening with other methods that have an output array. - Which type represents 16396 ? - What win32com does when it receives a Variant containing an array? - Has someone faced the same problem? Where else can I have a look? I will appreciate any help as I am stacked. /Enric From timr at probo.com Mon Dec 15 19:03:17 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 15 Dec 2008 10:03:17 -0800 Subject: [python-win32] Post Message In-Reply-To: References: Message-ID: <49469BE5.6000809@probo.com> Ferdinand Sousa wrote: > > I have written a small script to automate a process. The issue is that > a "Save As" pops up at the end. Using Winspector, I could come up with > this: > win32gui.PostMessage(win_hdl,con.WM_COMMAND,1,0) # handle to the "Save > As" window, message type, Control ID of the "Save" > button > This works perfectly. However, now I would like to modify the "File > name" field so that I can change the default save location. It is a > combo box and has a control ID 1148. Using intuition, I tried > WM_SETTEXT, but no luck. Any pointers? > If possible, could any one point out any general, simple-to-use help > on the PostMessage function? What process are you automating? Many big applications today can be controlled by COM, which is a much more reliable and predictable method of control than hacking window messages. Remember that the "Save As" dialog is in a separate top-level window, and because it is modal, it has its own message loop. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon Dec 15 19:11:42 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 15 Dec 2008 10:11:42 -0800 Subject: [python-win32] no array returned in output parameter In-Reply-To: <964605.10949.qm@web23606.mail.ird.yahoo.com> References: <964605.10949.qm@web23606.mail.ird.yahoo.com> Message-ID: <49469DDE.3060304@probo.com> Enric Jaen wrote: > I have the following method generated by makepy.py: > > def GetFilters(self, pvarFilterArray=defaultNamedNotOptArg, pnArraySize=defaultNamedNotOptArg): > """method GetFilters""" > return self._oleobj_.InvokeTypes(68, LCID, 1, (24, 0), ((16396, 0), (16387, 0)),pvarFilterArray > , pnArraySize) > > > As you see, the method has two output params: The first is of type pointer to a Variant (which the COM object should fill with an array) and the second a pointer to a type long. > > But when I invoke that method it returns a tuple as if there were no data: > >>>> r.GetFilters() >>>> > (None, 0) > > i.e array is Null with size is 0. > > The same is happening with other methods that have an output array. > > > - Which type represents 16396 ? > That's 12 + 0x4000, so it's VT_VARIANT + VT_BYREF. That is, a variant output parameter. 16387 is VT_I4 + VT_BYREF, or a long integer output parameter. Are you 100% convinced that the object has an array of filters to return? How do you know? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon Dec 15 19:19:19 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 15 Dec 2008 10:19:19 -0800 Subject: [python-win32] Transmit HID device with python on Windows In-Reply-To: <380845.29428.qm@web56503.mail.re3.yahoo.com> References: <380845.29428.qm@web56503.mail.re3.yahoo.com> Message-ID: <49469FA7.7020901@probo.com> Wang Yongqing wrote: > > I have a USB hid device, and I want to use the python to communicate > with it on the Windows. > > My question is whether there is a python module which could be used to > this program. The "libhid" project has a Windows version and includes a Python binding. http://libhid.alioth.debian.org/ -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From enricjaen at yahoo.es Mon Dec 15 20:57:01 2008 From: enricjaen at yahoo.es (Enric Jaen) Date: Mon, 15 Dec 2008 19:57:01 +0000 (GMT) Subject: [python-win32] no array returned in output parameter References: <964605.10949.qm@web23606.mail.ird.yahoo.com> <49469DDE.3060304@probo.com> Message-ID: <54549.38612.qm@web23604.mail.ird.yahoo.com> Thanks for the explanation, Tim. I am 100 % sure because I have tested it with a VB program and it returns data. As I have seen from previous posts in this mailinglist, the memory is allocated at the COM side. This also returns a null array: a,b = r.getFilters() /Enric ----- Mensaje original ---- De: Tim Roberts Para: Python-Win32 List Enviado: lunes, 15 de diciembre, 2008 19:11:42 Asunto: Re: [python-win32] no array returned in output parameter Enric Jaen wrote: > I have the following method generated by makepy.py: > > def GetFilters(self, pvarFilterArray=defaultNamedNotOptArg, pnArraySize=defaultNamedNotOptArg): > """method GetFilters""" > return self._oleobj_.InvokeTypes(68, LCID, 1, (24, 0), ((16396, 0), (16387, 0)),pvarFilterArray > , pnArraySize) > > > As you see, the method has two output params: The first is of type pointer to a Variant (which the COM object should fill with an array) and the second a pointer to a type long. > > But when I invoke that method it returns a tuple as if there were no data: > >>>> r.GetFilters() >>>> > (None, 0) > > i.e array is Null with size is 0. > > The same is happening with other methods that have an output array. > > > - Which type represents 16396 ? > That's 12 + 0x4000, so it's VT_VARIANT + VT_BYREF. That is, a variant output parameter. 16387 is VT_I4 + VT_BYREF, or a long integer output parameter. Are you 100% convinced that the object has an array of filters to return? How do you know? -- 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 From timr at probo.com Mon Dec 15 21:42:05 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 15 Dec 2008 12:42:05 -0800 Subject: [python-win32] no array returned in output parameter In-Reply-To: <54549.38612.qm@web23604.mail.ird.yahoo.com> References: <964605.10949.qm@web23606.mail.ird.yahoo.com> <49469DDE.3060304@probo.com> <54549.38612.qm@web23604.mail.ird.yahoo.com> Message-ID: <4946C11D.2020405@probo.com> Enric Jaen wrote: > I am 100 % sure because I have tested it with a VB program and it returns data. > What are you controlling here? Is this Flash? > As I have seen from previous posts in this mailinglist, the memory is allocated at the COM side. > Yes, but that should be irrelevant. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From enricjaen at yahoo.es Tue Dec 16 12:50:24 2008 From: enricjaen at yahoo.es (Enric Jaen) Date: Tue, 16 Dec 2008 11:50:24 +0000 (GMT) Subject: [python-win32] no array returned in output parameter Message-ID: <333412.65821.qm@web23608.mail.ird.yahoo.com> It's the library of the Xcalibur, a propietary program used in proteomics. to read spectra. They provide an API, and VB examples to access it. The problem is happening with those methods that return and array, as the others work fine. I am using defaultNamedNotOptArg= pythoncom.Missing Is there something else I should check? In a try to workaround this, let me explain that this Xcalibur program comes with another COM library that does the same but with a different API. In this case, makepy.py accesses Filters is a class and its accessed as an attribute of this class: class IXDetectorRead(DispatchBaseClass): """IXDetectorRead Interface""" CLSID = IID('{88536044-BF39-11D2-BD97-0060978EEB9C}') coclass_clsid = IID('{88536045-BF39-11D2-BD97-0060978EEB9C}') ... _prop_map_get_ = { ... "Filters": (1, 2, (9, 0), (), "Filters", None), It works fine in VB, but in Python I get an exception: Traceback (most recent call last): File "", line 1, in File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 455, in __getattr__ return self._ApplyTypes_(*args) File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 448, in _ApplyTypes_ dispid, 0, wFlags, retType, argTypes, *args), com_error: (-2147352567, 'Ocurri\xf3 una excepci\xf3n.', (0, None, None, None, 0, -2147473634), None) I have identified -2147352567 = 0x80020009 = DISP_E_EXCEPTION but -2147473634 = 0x8000271C which I don't know what this code means. Is this an Xcalibur-specific error code? In a previous mail I found that one guy solved a similar problem replacing the None of: "Filters": (1, 2, (9, 0), (), "Filters", None), by the CLSID of the Filter's class. So I tried: "Filters": (1, 2, (9, 0), (), "Filters", '{8E2D2225-C0BE-11D2-BD99-0060978EEB9C}'), but the exception is the same. So, I have two libraries to access the data but both crashes for different reasons. I'd appreacite any glue that I could follow. /Enric ----- Mensaje original ---- De: Tim Roberts Para: Python-Win32 List Enviado: lunes, 15 de diciembre, 2008 21:42:05 Asunto: Re: [python-win32] no array returned in output parameter Enric Jaen wrote: > I am 100 % sure because I have tested it with a VB program and it returns data. > What are you controlling here? Is this Flash? > As I have seen from previous posts in this mailinglist, the memory is allocated at the COM side. > Yes, but that should be irrelevant. -- 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 From ferdinandsousa at gmail.com Tue Dec 16 12:53:32 2008 From: ferdinandsousa at gmail.com (Ferdinand Sousa) Date: Tue, 16 Dec 2008 17:23:32 +0530 Subject: [python-win32] python-win32 Digest, Vol 69, Issue 23 In-Reply-To: References: Message-ID: ---------- Forwarded message ---------- > From: Tim Roberts > To: Python-Win32 List > Date: Mon, 15 Dec 2008 10:03:17 -0800 > Subject: Re: [python-win32] Post Message > Ferdinand Sousa wrote: > > > > I have written a small script to automate a process. The issue is that > > a "Save As" pops up at the end. Using Winspector, I could come up with > > this: > > win32gui.PostMessage(win_hdl,con.WM_COMMAND,1,0) # handle to the "Save > > As" window, message type, Control ID of the "Save" > > button > > This works perfectly. However, now I would like to modify the "File > > name" field so that I can change the default save location. It is a > > combo box and has a control ID 1148. Using intuition, I tried > > WM_SETTEXT, but no luck. Any pointers? > > If possible, could any one point out any general, simple-to-use help > > on the PostMessage function? > > What process are you automating? Many big applications today can be > controlled by COM, which is a much more reliable and predictable method > of control than hacking window messages. > > Remember that the "Save As" dialog is in a separate top-level window, > and because it is modal, it has its own message loop. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > Actually, I am using COM to control Adobe Acrobat 7. I searched high and low for methods to enable pdfs for commenting in Adobe Reader, and the only method I could find was to execute the appropriate menu item in Acrobat. I did all this in COM. The problem is that once that option is executed, the Save As dialog pops up. Now, I am able to click the Save button (as mentioned in my previous mail). Between yesterday and now, I have got this: gui.PostMessage(combo_hwnd,con.WM_SETFOCUS,0,0) gui.SendMessage(combo_hwnd,con.WM_SETTEXT,0,'F:\Sample File.pdf' ) I am now able to set the text in the combo box. How ever this requires the handle of the combo box. I can obtained the handles to the owner of Save As and Save As itself. w_hwnd=1573334 >>> gui.GetWindowText(w_hwnd) 'Save As' >>> child=gui.GetWindow(w_hwnd, con.GW_CHILD) >>> >>> for i in range (20): child=gui.GetWindow(child, con.GW_HWNDNEXT) print b,'=',gui.GetWindowText(child) 3342844 = 459416 = 2031970 = 655960 = 917912 = 1114744 = 1573478 = File &name: 1442168 = #### this is the handle of the combo box 787024 = Save as &type: 852368 = 1114516 = Open as &read-only 1049194 = &Save 1900908 = Cancel 1442464 = &Help 1180026 = 1442306 = 0 = Traceback (most recent call last): File "", line 2, in child=gui.GetWindow(child, con.GW_HWNDNEXT) error: (1400, 'GetWindow', 'Invalid window handle.') >>> I feel this is not the correct way to get the handle of the combo. Any ideas? The WM_COMMAND is sent to the Save As window with control ID = 1 (Referencing the Save button). Is there any way I can modify the filename by sending messages to the Save As window using the control ID of the combo as a parameter? Thanks for taking the trouble to read! Ferdi -------------- next part -------------- An HTML attachment was scrubbed... URL: From rwupole at msn.com Tue Dec 16 14:30:30 2008 From: rwupole at msn.com (Roger Upole) Date: Tue, 16 Dec 2008 08:30:30 -0500 Subject: [python-win32] Re: no array returned in output parameter Message-ID: Enric Jaen wrote: > > > It's the library of the Xcalibur, a propietary program used in proteomics. > to read spectra. They provide an API, and VB examples to access it. > > The problem is happening with those methods that return and array, as the > others work fine. > > I am using defaultNamedNotOptArg= pythoncom.Missing > > Is there something else I should check? > > Try using pythoncom.Empty instead of Missing. Missing can be interpreted as the end of the argument list, so the app sees no arguments at all. Roger From john_nowlan at carleton.ca Tue Dec 16 15:48:17 2008 From: john_nowlan at carleton.ca (John_Nowlan) Date: Tue, 16 Dec 2008 09:48:17 -0500 Subject: [python-win32] Pythonwin starts, displays main window, interactive window 'frame', then exits In-Reply-To: <49448933.70400@gmail.com> References: <53C341FE4EA0B744B5BB64CA5C708C8C0C2398@CCSEXB10.CUNET.CARLETON.CA> <49448933.70400@gmail.com> Message-ID: <53C341FE4EA0B744B5BB64CA5C708C8C0C23AF@CCSEXB10.CUNET.CARLETON.CA> Thanks for the suggestion. Will have to remember. But I had already gone for the brute force approach and uninstalled python 2.6 and went to 2.5. That worked. It hadn't worked when I had just uninstalled pythonwin and reinstalled. > -----Original Message----- > From: Mark Hammond [mailto:skippy.hammond at gmail.com] > Sent: Saturday, December 13, 2008 11:19 PM > To: John_Nowlan > Cc: python-win32 at python.org > Subject: Re: [python-win32] Pythonwin starts, displays main window, > interactive window 'frame', then exits > > John_Nowlan wrote: > > Sorry to intrude, but I'm hoping this is something stupid. Has anyone > > seen this behaviour and know of a fix? > > > > I've searched hi & low, but its hard to find specific info on pythonwin. > > Try deleting your "HKEY_CURRENT_USER\Software\Python 2.5" (using > whatever version of Python you are using) key - this may have garbage > which causes MFC to get upset as it starts. > > Cheers, > > Mark From mail at timgolden.me.uk Tue Dec 16 17:20:14 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 16 Dec 2008 16:20:14 +0000 Subject: [python-win32] Detecting fast user switching In-Reply-To: <4943AC95.6060205@unkwndesign.com> References: <4943AC95.6060205@unkwndesign.com> Message-ID: <4947D53E.2090200@timgolden.me.uk> Arron Chapman - UnkwnDesign.Com wrote: > I found Tim Golden's artical "See if my workstation is locked" > http://timgolden.me.uk/python/win32_how_do_i/see_if_my_workstation_is_locked.html > which got me most of the way to where I need to be, I want to detect > both logout and login events I haven't gone down this route, but I imagine it's worth looking at the win32ts module which exposes Terminal Services functionality. Altho' you don't think of yourself as running Terminal Services it basically operates on WinStations which is more or less what the fast user switch is doing. Might be worth a browse to see if it takes you anywhere. TJG From skippy.hammond at gmail.com Wed Dec 17 00:00:32 2008 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 17 Dec 2008 10:00:32 +1100 Subject: [python-win32] no array returned in output parameter In-Reply-To: References: Message-ID: <49483310.3030000@gmail.com> On 17/12/2008 12:30 AM, Roger Upole wrote: > Enric Jaen wrote: >> >> >> It's the library of the Xcalibur, a propietary program used in >> proteomics. to read spectra. They provide an API, and VB examples to >> access it. >> >> The problem is happening with those methods that return and array, as >> the others work fine. >> >> I am using defaultNamedNotOptArg= pythoncom.Missing >> >> Is there something else I should check? >> >> > > Try using pythoncom.Empty instead of Missing. Missing can be interpreted > as the end of > the argument list, so the app sees no arguments at all. It would be very interesting if that was the problem. Empty makes most sense for "out" args, but it is impossible/pointless to have Empty specified after Missing - and many common objects work much better with Missing. I wish I knew exactly what VB did (and I suppose some reverse-engineering could probably tell us), but that will need a round-tuit too... Mark From skippy.hammond at gmail.com Wed Dec 17 00:01:51 2008 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 17 Dec 2008 10:01:51 +1100 Subject: [python-win32] Pythonwin starts, displays main window, interactive window 'frame', then exits In-Reply-To: <53C341FE4EA0B744B5BB64CA5C708C8C0C23AF@CCSEXB10.CUNET.CARLETON.CA> References: <53C341FE4EA0B744B5BB64CA5C708C8C0C2398@CCSEXB10.CUNET.CARLETON.CA> <49448933.70400@gmail.com> <53C341FE4EA0B744B5BB64CA5C708C8C0C23AF@CCSEXB10.CUNET.CARLETON.CA> Message-ID: <4948335F.7090207@gmail.com> On 17/12/2008 1:48 AM, John_Nowlan wrote: > Thanks for the suggestion. Will have to remember. > > But I had already gone for the brute force approach and uninstalled > python 2.6 and went to 2.5. That worked. > It hadn't worked when I had just uninstalled pythonwin and reinstalled. Yeah - uninstalling doesn't remove that key. It is where pythonwin's preference information is stored - python itself doesn't know about it at all! Mark From rwupole at msn.com Wed Dec 17 04:54:41 2008 From: rwupole at msn.com (Roger Upole) Date: Tue, 16 Dec 2008 22:54:41 -0500 Subject: [python-win32] no array returned in output parameter Message-ID: Mark Hammond wrote: > On 17/12/2008 12:30 AM, Roger Upole wrote: >> Enric Jaen wrote: >>> >>> >>> It's the library of the Xcalibur, a propietary program used in >>> proteomics. to read spectra. They provide an API, and VB examples to >>> access it. >>> >>> The problem is happening with those methods that return and array, as >>> the others work fine. >>> >>> I am using defaultNamedNotOptArg= pythoncom.Missing >>> >>> Is there something else I should check? >>> >>> >> >> Try using pythoncom.Empty instead of Missing. Missing can be interpreted >> as the end of >> the argument list, so the app sees no arguments at all. > > It would be very interesting if that was the problem. Empty makes most > sense for "out" args, but it is impossible/pointless to have Empty > specified after Missing - and many common objects work much better with > Missing. I wish I knew exactly what VB did (and I suppose some > reverse-engineering could probably tell us), but that will need a > round-tuit too... > > Mark It make perfect sense to have a real arg after Missing when there are optional args. Say you have a method that takes 3 optional args, and makepy generates something like def somemeth(self, arg1 = pythoncom.Missing, arg2 = pythoncom.Missing, arg3 = Pythoncom.missing): ... You may want to call it with just arg3 like so: somemeth(arg3='something') However, you *can't*. As soon as pythoncom sees Missing for arg1, the rest of the arguments are silently ignored. Roger From romain.gilles at gmail.com Wed Dec 17 09:10:50 2008 From: romain.gilles at gmail.com (Romain Gilles) Date: Wed, 17 Dec 2008 09:10:50 +0100 Subject: [python-win32] Internet Explorer Session independent Creation Message-ID: Hi, I'm new in python and I would like to know how I can create 2 (and more) session independent Internet Explorer. This is my actual code: ie1 = Dispatch("InternetExplorer.Application") ie1.Navigate(url) login(ie1) ie2 = Dispatch("InternetExplorer.Application") ie2.Navigate(url) ... In this example when the 'ie2' instance navigate to the url it is automatically authenticated as if ie1 and ie2 shared the same credential. But what I want is truly independent internet explorer instance. Somebody can help me? Thanks, Romain -------------- next part -------------- An HTML attachment was scrubbed... URL: From siddhartha.veedaluru at gmail.com Wed Dec 17 15:23:19 2008 From: siddhartha.veedaluru at gmail.com (siddhartha veedaluru) Date: Wed, 17 Dec 2008 19:53:19 +0530 Subject: [python-win32] python.exe crashes while connecting to MSSQL Database using pyodbc.connect In-Reply-To: <424b71ec0812170618r19db91fch8ef70804fc3b4ce6@mail.gmail.com> References: <424b71ec0812170618r19db91fch8ef70804fc3b4ce6@mail.gmail.com> Message-ID: <424b71ec0812170623x6b35c531p8f37b0cb7969724a@mail.gmail.com> Hi, > Summary-: python.exe crashes while connecting to the MSSQL Database on > remote machine using pyodbc module > OS-: win 2003 server, 32bit > Installed python products: python 2.5,pyodbc-2.0.52,pywin32-211 > > Problem Description & Steps followed: > i have MSSQL Database on a remote machine > i have created a System DSN in my local machine using python script which > uses ctypes module > using pyodbc module i'm trying to connect to remote database. > > sometimes python.exe crashes in the connect function > > if i reboot the machine, i can connect it,but next try to connect crashes > python.exe > > **Following is the code snippet of my script that are used to do the above > tasks > > Script to Create a System DSN > ---------------------------------------------- > def create_sys_dsn(driver, **kw): > "Create a system DSN" > ODBC_ADD_SYS_DSN = 4 > nul = chr(0) > attributes = [] > for attr in kw.keys(): > atrbStr = "%s=%s" % (attr, kw[attr]) > #print atrbStr > attributes.append(atrbStr) > #print driver > return ctypes.windll.ODBCCP32.SQLConfigDataSource(0, ODBC_ADD_SYS_DSN, > driver, nul.join(attributes)) > > retCode = create_sys_dsn("SQL Server", SERVER=server, DESCRIPTION="TestDB > DSN", DSN="TestDB", Database="testDB") > if retCode != 1: > mesg = "Cannot Create TestDB DSN" > print mesg > sys.exit(1) > else: > mesg = "TestDB DSN Created" > print mesg > sys.exit(0) > --------------------------------------------------------------------------- > > Script to connect to database > --------------------------------------------------------------------------- > import pyodbc > try: > DBCon = pyodbc.connect("DSN=TestDB;UID=tester;PWD=tester") > except pyodbc.Error, erno: > mesg = "Unable to connect testDB Database check the UserID and > Password" > print mesg,erno > return 1 > return 0 > : > : > : > : > DBCon.close() > > Please Help me out > take a look or forward to concerned developers > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Wed Dec 17 15:45:17 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 17 Dec 2008 14:45:17 +0000 Subject: [python-win32] python.exe crashes while connecting to MSSQL Database using pyodbc.connect In-Reply-To: <424b71ec0812170623x6b35c531p8f37b0cb7969724a@mail.gmail.com> References: <424b71ec0812170618r19db91fch8ef70804fc3b4ce6@mail.gmail.com> <424b71ec0812170623x6b35c531p8f37b0cb7969724a@mail.gmail.com> Message-ID: <4949107D.6030007@timgolden.me.uk> siddhartha veedaluru wrote: >> i have created a System DSN in my local machine using python script which >> uses ctypes module >> using pyodbc module i'm trying to connect to remote database. >> >> sometimes python.exe crashes in the connect function Not answering your question directly but... did you know that you don't need to create a DSN just to connect via ODBC? This kind of thing will do it just as well: import pyodbc connection = "Driver={SQL Server};Server=SVR;Database=DB;TrustedConnection=Yes" db = pyodbc.connect (connection) TJG From vernondcole at gmail.com Wed Dec 17 16:45:06 2008 From: vernondcole at gmail.com (Vernon Cole) Date: Wed, 17 Dec 2008 08:45:06 -0700 Subject: [python-win32] python.exe crashes while connecting to MSSQL Database using pyodbc.connect In-Reply-To: <4949107D.6030007@timgolden.me.uk> References: <424b71ec0812170618r19db91fch8ef70804fc3b4ce6@mail.gmail.com> <424b71ec0812170623x6b35c531p8f37b0cb7969724a@mail.gmail.com> <4949107D.6030007@timgolden.me.uk> Message-ID: Do you have some special reason for using pyodbc, such as higher performance? If not, you might try replacing pyodbc with adodbapi. import adodbapi try: DBCon = adodbapi.connect("DSN=TestDB;UID=tester;PWD=tester") except adodbapi.Error, erno: mesg = "Unable to connect testDB Database check the UserID and Password" print mesg,erno return 1 return 0 adodbapi (using dbapi version 2.0) and odbc (using dbapi version 1.0) are both included in pywin32. (upgrade your version of pywin32 to get bug fixes to both packages.) Tim is also correct about not needing a DSN (unless other code is using it elsewhere) so you may be able to discard all that. In your situation, I would try something like: adodbapi.connect("Provider=sqloledb; Data Source=server; Initial Catalog =testDB; User Id=tester;Password=tester") Connection string examples for many other situations can be found at www.connectionstrings.com On Wed, Dec 17, 2008 at 7:45 AM, Tim Golden wrote: > siddhartha veedaluru wrote: > >> i have created a System DSN in my local machine using python script which >>> uses ctypes module >>> using pyodbc module i'm trying to connect to remote database. >>> >>> sometimes python.exe crashes in the connect function >>> >> > > Not answering your question directly but... did you know > that you don't need to create a DSN just to connect via > ODBC? This kind of thing will do it just as well: > > > > import pyodbc > > connection = "Driver={SQL > Server};Server=SVR;Database=DB;TrustedConnection=Yes" > db = pyodbc.connect (connection) > > > > TJG > _______________________________________________ > 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: From siddhartha.veedaluru at gmail.com Wed Dec 17 17:31:11 2008 From: siddhartha.veedaluru at gmail.com (siddhartha veedaluru) Date: Wed, 17 Dec 2008 22:01:11 +0530 Subject: [python-win32] python.exe crashes while connecting to the MSSQL Database on remote machine using pyodbc module Message-ID: <424b71ec0812170831i26c06e4br384033ae7e1502d@mail.gmail.com> Hi, Summary-: python.exe crashes while connecting to the MSSQL Database on remote machine using pyodbc module OS-: win 2003 server, 32bit Installed python products: python 2.5,pyodbc-2.0.52,pywin32-211 Problem Description & Steps followed: i have MSSQL Database on a remote machine i have created a System DSN in my local machine using python script which uses ctypes module using pyodbc module i'm trying to connect to remote database. sometimes python.exe crashes in the connect function if i reboot the machine, i can connect it,but next try to connect crashes python.exe Attached are the dmp files of the crash. Following is the code snippet of my script that are used to do the above tasks Script to Create a System DSN ---------------------------------------------- def create_sys_dsn(driver, **kw): "Create a system DSN" ODBC_ADD_SYS_DSN = 4 nul = chr(0) attributes = [] for attr in kw.keys(): atrbStr = "%s=%s" % (attr, kw[attr]) #print atrbStr attributes.append(atrbStr) #print driver return ctypes.windll.ODBCCP32.SQLConfigDataSource(0, ODBC_ADD_SYS_DSN, driver, nul.join(attributes)) retCode = create_sys_dsn("SQL Server", SERVER=server, DESCRIPTION="TestDB DSN", DSN="TestDB", Database="testDB") if retCode != 1: mesg = "Cannot Create TestDB DSN" print mesg sys.exit(1) else: mesg = "TestDB DSN Created" print mesg sys.exit(0) --------------------------------------------------------------------------- Script to connect to database --------------------------------------------------------------------------- import pyodbc try: DBCon = pyodbc.connect("DSN=TestDB;UID=tester;PWD=tester") except pyodbc.Error, erno: mesg = "Unable to connect testDB Database check the UserID and Password" print mesg,erno return 1 return 0 : : : : DBCon.close() Please Help me out take a look or forward to concerned developers -------------- next part -------------- An HTML attachment was scrubbed... URL: From siddhartha.veedaluru at gmail.com Wed Dec 17 19:32:35 2008 From: siddhartha.veedaluru at gmail.com (siddhartha veedaluru) Date: Thu, 18 Dec 2008 00:02:35 +0530 Subject: [python-win32] python.exe crashes while connecting to MSSQL Database using pyodbc.connect In-Reply-To: References: <424b71ec0812170618r19db91fch8ef70804fc3b4ce6@mail.gmail.com> Message-ID: <424b71ec0812171032s478c8272ub8e9a6a8a6f91e20@mail.gmail.com> Hi, Thank you Everybody who vested their valuable time in replying me. Thanks Vernon Cole Thanks Michael. Michael, As you said,i have downloaded the latest version of pyodbc and tested with it. same issue comes up again. Other facts i noticed while testing : 1) The script just exists with return code 128. 2) Sometime after(approx 20-30 mins) if i run the scripts,i was able to connect and no crash found. 3)After establishing the connection,if we terminate (Keyboard Interrupt)the script without closing the connection and once again try to connect,python.exe crashes The scripts terminates abnormally and doesnt give any traceback. i can see the dumps only when i reboot the machine. Please let me know if you need some more information. Thanks and Regards, Siddhartha On Wed, Dec 17, 2008 at 10:20 PM, Michael Kleehammer wrote: > I am the correct developer, so we'll get started. > > The first thing we should do is try the latest pyodbc: > http://code.google.com/p/pyodbc > > There are a number of fixes in this new version, so it might be what > you need. (If so, let me know, though.) > > If the crash occurs in the new version, we'll also want to open a bug > report since it might help others. > > Next, we'd want to do 2 things: > > 1) Get an ODBC trace, which will tell us if one of the ODBC calls > failed and pyodbc crashed trying to cleanup the connection. > 2) Try the same test with a Unicode connection string: cnxn = > pyodbc.connect(u"..."). The first thing pyodbc does is convert the > string to Unicode and try the Unicode connect function, so perhaps > there is an error there. > > Thanks for the report and sorry for the trouble, > Michael Kleehammer > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Dec 17 20:05:13 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 17 Dec 2008 11:05:13 -0800 Subject: [python-win32] Internet Explorer Session independent Creation In-Reply-To: References: Message-ID: <49494D69.7080509@probo.com> Romain Gilles wrote: > > I'm new in python and I would like to know how I can create 2 (and > more) session independent Internet Explorer. > > This is my actual code: > > > > ie1 = Dispatch("InternetExplorer.Application") > > ie1.Navigate(url) > > login(ie1) > > > > ie2 = Dispatch("InternetExplorer.Application") > > ie2.Navigate(url) > > ... > > > > In this example when the 'ie2' instance navigate to the url it is > automatically authenticated as if ie1 and ie2 shared the same credential. > > But what I want is truly independent internet explorer instance. > > > > Somebody can help me? > I'm not convinced this is possible. When you run several instances of IE via COM, they all try to route to the same process, which means they will share credentials. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Dec 17 22:17:41 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 17 Dec 2008 13:17:41 -0800 Subject: [python-win32] Post Message In-Reply-To: References: Message-ID: <49496C75.8000603@probo.com> Ferdinand Sousa wrote: > > Actually, I am using COM to control Adobe Acrobat 7. I searched high > and low for methods to enable pdfs for commenting in Adobe Reader, and > the only method I could find was to execute the appropriate menu item > in Acrobat. I did all this in COM. The problem is that once that > option is executed, the Save As dialog pops up. Now, I am able to > click the Save button (as mentioned in my previous mail). Have you downloaded the Adobe "Interapplication Communication API Reference" document that describes the COM interface to Acrobat? The AcroExch.PDDoc interface includes a "Save" method to save the file. I don't immediately see how annotations are enabled; is that one of the keys in the "Info" dictionary? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mc at mclaveau.com Wed Dec 17 23:24:34 2008 From: mc at mclaveau.com (Michel Claveau) Date: Wed, 17 Dec 2008 23:24:34 +0100 Subject: [python-win32] python.exe crashes while connecting to the MSSQLDatabase on remote machine using pyodbc module In-Reply-To: <424b71ec0812170831i26c06e4br384033ae7e1502d@mail.gmail.com> References: <424b71ec0812170831i26c06e4br384033ae7e1502d@mail.gmail.com> Message-ID: <657705DA022446BFACBC2777B8366421@MCI1330> Hi! Several solution are given. Another (example) : import win32com.client from win32com.client import Dispatch connexion = Dispatch('ADODB.Connection') connexion.ConnectionString = "Provider=SQLOLEDB.1; Data Source=192.168.10.10; uid=username; pwd=password; database=baseSQLdata" connexion.Open() if connexion.State == 1: print "connected." recordset = Dispatch('ADODB.RecordSet') recordset.ActiveConnection = connexion recordset.Open("tablexample") while not recordset.EOF: print recordset.Fields.Item("mail").Value, recordset.Fields(2).Value recordset.Close() recordset = None connexion.Close() connexion = None @-salutations -- Michel Claveau From skippy.hammond at gmail.com Wed Dec 17 23:41:53 2008 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 18 Dec 2008 09:41:53 +1100 Subject: [python-win32] no array returned in output parameter In-Reply-To: References: Message-ID: <49498031.4060703@gmail.com> On 17/12/2008 2:54 PM, Roger Upole wrote: > Mark Hammond wrote: >> On 17/12/2008 12:30 AM, Roger Upole wrote: >>> Enric Jaen wrote: >>>> >>>> >>>> It's the library of the Xcalibur, a propietary program used in >>>> proteomics. to read spectra. They provide an API, and VB examples to >>>> access it. >>>> >>>> The problem is happening with those methods that return and array, as >>>> the others work fine. >>>> >>>> I am using defaultNamedNotOptArg= pythoncom.Missing >>>> >>>> Is there something else I should check? >>>> >>>> >>> >>> Try using pythoncom.Empty instead of Missing. Missing can be interpreted >>> as the end of >>> the argument list, so the app sees no arguments at all. >> >> It would be very interesting if that was the problem. Empty makes most >> sense for "out" args, but it is impossible/pointless to have Empty >> specified after Missing - and many common objects work much better with >> Missing. I wish I knew exactly what VB did (and I suppose some >> reverse-engineering could probably tell us), but that will need a >> round-tuit too... >> >> Mark > > It make perfect sense to have a real arg after Missing when there are > optional args. Say you have a method that takes 3 optional args, and > makepy generates something like > > def somemeth(self, arg1 = pythoncom.Missing, arg2 = pythoncom.Missing, > arg3 = Pythoncom.missing): > ... > > You may want to call it with just arg3 like so: > somemeth(arg3='something') > However, you *can't*. As soon as pythoncom sees Missing for arg1, > the rest of the arguments are silently ignored. But unless I'm missing your point, that is exactly the purpose of pythoncom.Empty? Further, in the example above, the call is probably best made with no positional args at all, using only the "named args" feature of IDispatch - however, pythoncom has zero support for making such calls :( Cheers, Mark From mc at mclaveau.com Thu Dec 18 00:40:11 2008 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 18 Dec 2008 00:40:11 +0100 Subject: [python-win32] Internet Explorer Session independent Creation In-Reply-To: <49494D69.7080509@probo.com> References: <49494D69.7080509@probo.com> Message-ID: <9E5FF2306A4048ACBF3609A8EDFE8414@MCI1330> Hi! A way is to launch separate instance, then connect to instances. Example: import os,time,win32com.client def finstance(url): for instance in win32com.client.Dispatch('{9BA05972-F6A8-11CF-A442-00A0C90A8F39}'): if instance.LocationURL.find(url)>-1: return instance os.startfile('http://www.google.fr') time.sleep(2) os.system('start "" "C:\\Program Files\\Internet Explorer\\iexplore.exe" http://www.mclaveau.com/batch') time.sleep(3) ie1 = finstance('http://www.google.fr') ie1.Left=10 ie1.Top=10 ie1.Width=600 ie1.Height=700 ie2 = finstance('http://www.mclaveau.com/batch') ie2.Left=610 ie2.Top=10 ie2.Width=600 ie2.Height=700 time.sleep(2) @-salutations -- Michel Claveau From redrackem at yahoo.com Thu Dec 18 07:49:50 2008 From: redrackem at yahoo.com (Red Rackham) Date: Wed, 17 Dec 2008 22:49:50 -0800 (PST) Subject: [python-win32] kernal32.DeviceIoControl Operation Aborted Message-ID: <240192.68421.qm@web30008.mail.mud.yahoo.com> Hi.? I'm a bit of a novice with ctypes and this is my first post here so please forgive any detected newbiness.? After trying and searching I hereby give up and appeal to the pros out there who may be more intimately familiar with DeviceIoControl usage.? ? I'm trying use Python?to access a USB device based on Cypress FX2 (EZ-USB) type part.? The first operation I'm attempting is to access a command that is supposed to return the microcontroller's PORTA value.? Here's a minimal amount of code: ? ??retCode = k32.DeviceIoControl( ???dev.deviceHandle, ???IOCTL_EZUSB_VENDOR_OR_CLASS_REQUEST, ???byref(vrControl), ???sizeof(VENDOR_OR_CLASS_REQUEST_CONTROL), ???pBuffer, ???c_ushort(255), # READ_LENGTH, ???byref(retBytes), ???None) ? Where the vrControl is a struct like this: ??vrControl = VENDOR_OR_CLASS_REQUEST_CONTROL() ??vrControl.direction = VENDOR_REQUEST_DIRECTION_DEVICE2HOST ??vrControl.requestType = VENDOR_REQUEST_REQUESTTYPE_VENDOR ??vrControl.recipient = VENDOR_REQUEST_RECIPIENT_ENDPOINT ??vrControl.reqTypeResdBits = 0 ??vrControl.request = VR_PORTS ??vrControl.value = VR_PORTS_READ << 8 | value ??vrControl.index = port ? kernal32.DeviceIoControl returns a 0, and kernal32.GetLastError() is returning a 995, which is,?"ERROR_OPERATION_ABORTED.? The I/O operation has been aborted because of either a thread exit or an application request" according to: http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx ? The reason for the abort does not make sense to me.? Anyone know what would most commonly cause this?? What should be my next step?? ? Thanks in advance, Mark ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From enricjaen at yahoo.es Thu Dec 18 14:07:42 2008 From: enricjaen at yahoo.es (Enric Jaen) Date: Thu, 18 Dec 2008 13:07:42 +0000 (GMT) Subject: [python-win32] no array returned in output parameter References: <49498031.4060703@gmail.com> Message-ID: <925927.74929.qm@web23602.mail.ird.yahoo.com> in my case the call getFilters() has no input params and 2 output params. Either if I use Empty or Missing the result is a null array. I put below the description that comes with the GetFilters() API, in case this gives you any idea about what is going on. Thanks, /Enric ps: GeFilters API: long GetFilters(VARIANT FAR* pvarFilterArray, long FAR* pnArraySize); Return Value 1 if successful; otherwise, see Error Codes. Parameters pvarFilterArray A valid pointer to a variable of type VARIANT. This variable must exist and be initialized to VT_EMPTY. pnArraySize A valid pointer to a variable of type long. This variable must exist. Remarks Returns the list of unique scan filters for the raw file. This function is only supported for MS device controllers. If the function succeeds, pvarFilterArray will point to an array of BSTR fields each containing a unique scan filter and pnArraySize will contain the number of scan filters in the pvarFilterArray. Example // example for GetFilters VARIANT varFilters; VariantInit(&varFilters); long nArraySize = 0; long nRet = XRawfileCtrl.GetFilters ( & varFilters, &nArraySize ); if( nRet != 1 ) { ::MessageBox( NULL, _T(?Error getting array of scan filters?), _T(?Error?), MB_OK ); return } ----- Mensaje original ---- De: Mark Hammond CC: python-win32 at python.org Enviado: mi?rcoles, 17 de diciembre, 2008 23:41:53 Asunto: Re: [python-win32] no array returned in output parameter On 17/12/2008 2:54 PM, Roger Upole wrote: > Mark Hammond wrote: >> On 17/12/2008 12:30 AM, Roger Upole wrote: >>> Enric Jaen wrote: >>>> >>>> >>>> It's the library of the Xcalibur, a propietary program used in >>>> proteomics. to read spectra. They provide an API, and VB examples to >>>> access it. >>>> >>>> The problem is happening with those methods that return and array, as >>>> the others work fine. >>>> >>>> I am using defaultNamedNotOptArg= pythoncom.Missing >>>> >>>> Is there something else I should check? >>>> >>>> >>> >>> Try using pythoncom.Empty instead of Missing. Missing can be interpreted >>> as the end of >>> the argument list, so the app sees no arguments at all. >> >> It would be very interesting if that was the problem. Empty makes most >> sense for "out" args, but it is impossible/pointless to have Empty >> specified after Missing - and many common objects work much better with >> Missing. I wish I knew exactly what VB did (and I suppose some >> reverse-engineering could probably tell us), but that will need a >> round-tuit too... >> >> Mark > > It make perfect sense to have a real arg after Missing when there are > optional args. Say you have a method that takes 3 optional args, and > makepy generates something like > > def somemeth(self, arg1 = pythoncom.Missing, arg2 = pythoncom.Missing, > arg3 = Pythoncom.missing): > ... > > You may want to call it with just arg3 like so: > somemeth(arg3='something') > However, you *can't*. As soon as pythoncom sees Missing for arg1, > the rest of the arguments are silently ignored. But unless I'm missing your point, that is exactly the purpose of pythoncom.Empty? Further, in the example above, the call is probably best made with no positional args at all, using only the "named args" feature of IDispatch - however, pythoncom has zero support for making such calls :( Cheers, Mark _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From romain.gilles at gmail.com Thu Dec 18 15:31:56 2008 From: romain.gilles at gmail.com (Romain Gilles) Date: Thu, 18 Dec 2008 15:31:56 +0100 Subject: [python-win32] Internet Explorer Session independent Creation In-Reply-To: <9E5FF2306A4048ACBF3609A8EDFE8414@MCI1330> References: <49494D69.7080509@probo.com> <9E5FF2306A4048ACBF3609A8EDFE8414@MCI1330> Message-ID: I have exactly the same idea. But I was not able to retrieve the IE instance. So I will try your solution. Thanks, Romain. 2008/12/18 Michel Claveau > Hi! > > A way is to launch separate instance, then connect to instances. > Example: > > > import os,time,win32com.client > > def finstance(url): > for instance in > win32com.client.Dispatch('{9BA05972-F6A8-11CF-A442-00A0C90A8F39}'): > if instance.LocationURL.find(url)>-1: > return instance > > os.startfile('http://www.google.fr') > time.sleep(2) > os.system('start "" "C:\\Program Files\\Internet Explorer\\iexplore.exe" > http://www.mclaveau.com/batch') > time.sleep(3) > > ie1 = finstance('http://www.google.fr') > ie1.Left=10 > ie1.Top=10 > ie1.Width=600 > ie1.Height=700 > > ie2 = finstance('http://www.mclaveau.com/batch') > ie2.Left=610 > ie2.Top=10 > ie2.Width=600 > ie2.Height=700 > > time.sleep(2) > > > > > @-salutations > -- > Michel Claveau > _______________________________________________ > 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: From timr at probo.com Thu Dec 18 19:31:43 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 18 Dec 2008 10:31:43 -0800 Subject: [python-win32] kernal32.DeviceIoControl Operation Aborted In-Reply-To: <240192.68421.qm@web30008.mail.mud.yahoo.com> References: <240192.68421.qm@web30008.mail.mud.yahoo.com> Message-ID: <494A970F.2010506@probo.com> Red Rackham wrote: > Hi. I'm a bit of a novice with ctypes and this is my first post here > so please forgive any detected newbiness. After trying and searching > I hereby give up and appeal to the pros out there who may be more > intimately familiar with DeviceIoControl usage. > > I'm trying use Python to access a USB device based on Cypress FX2 > (EZ-USB) type part. > First, are you using a driver that supports the Cypress standard ioctls? If you are using one of the standard Cypress drivers, then you are, but if this is a device that has its own driver, you might not. > The first operation I'm attempting is to access a command that is > supposed to return the microcontroller's PORTA value. Here's a > minimal amount of code: > > retCode = k32.DeviceIoControl( > dev.deviceHandle, > IOCTL_EZUSB_VENDOR_OR_CLASS_REQUEST, > byref(vrControl), > sizeof(VENDOR_OR_CLASS_REQUEST_CONTROL), > pBuffer, > c_ushort(255), # READ_LENGTH, > byref(retBytes), > None) > > Where the vrControl is a struct like this: > vrControl = VENDOR_OR_CLASS_REQUEST_CONTROL() > vrControl.direction = VENDOR_REQUEST_DIRECTION_DEVICE2HOST > vrControl.requestType = VENDOR_REQUEST_REQUESTTYPE_VENDOR > vrControl.recipient = VENDOR_REQUEST_RECIPIENT_ENDPOINT > vrControl.reqTypeResdBits = 0 > vrControl.request = VR_PORTS > vrControl.value = VR_PORTS_READ << 8 | value > vrControl.index = port > Are you sure your firmware supports the VR_PORTS request? Is this something you added to your firmware? What does your CreateFile call look like? Technically, this request violates the USB spec. You should be using VENDOR_REQUEST_RECIPIENT_DEVICE; you can't use an endpoint request unless the wIndex value specifies an endpoint number that is currently configured. Before changing that, you'd have to make sure the firmware was also set up for that. I almost hate to suggest it, but you might try writing this same sequence as a short, standalone C program, just to make sure that the Python wrapper isn't interfering. I don't see any reason why it should, but it's one less variable. > kernal32.DeviceIoControl returns a 0, and kernal32.GetLastError() is > returning a 995, which is, "ERROR_OPERATION_ABORTED. The I/O > operation has been aborted because of either a thread exit or an > application request" ... > > The reason for the abort does not make sense to me. Anyone know what > would most commonly cause this? What should be my next step? > ERROR_OPERATION_ABORTED maps to STATUS_CANCELED in the driver world. That's a very specific error, which happens only when a driver has requested that your I/O request be canceled. That can happen if you hit Ctrl-C, or if you unplugged the device. However, it shouldn't happen with ordinary requests, unless your driver is enforcing some kind of a timeout. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From redrackem at yahoo.com Fri Dec 19 19:38:58 2008 From: redrackem at yahoo.com (Red Rackham) Date: Fri, 19 Dec 2008 10:38:58 -0800 (PST) Subject: [python-win32] kernal32.DeviceIoControl Operation Aborted In-Reply-To: <494A970F.2010506@probo.com> Message-ID: <986249.8554.qm@web30007.mail.mud.yahoo.com> I think I have finally figured it out.? Thanks for the suggestion, I ran the executable (compiled C code) and it worked, and it returned 0x8B. ? Previously I saw this?value and?thought was bunkum.? I thought it was incorrect because of the way ctypes encodes a string buffer: ('value', '\x8b|').? I was probably thrown off by the '|' in the string.? Not sure why that gets returned.? I guess to get a real value out of that buffer you have to use the 're' module or something. ? So I reasoned that I must be using the wrong direction.? I had at that point changed from ...HOST2DEVICE to ...DEVICE2HOST, reasoning that a read op is going to result in data going from the device to the host.? However the way I had it before (HOST2DEVICE) was actually correct (for some reason. ? Thanks, Mark ? ? ? ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From redrackem at yahoo.com Fri Dec 19 19:57:08 2008 From: redrackem at yahoo.com (Red Rackham) Date: Fri, 19 Dec 2008 10:57:08 -0800 (PST) Subject: [python-win32] kernal32.DeviceIoControl Operation Aborted In-Reply-To: <986249.8554.qm@web30007.mail.mud.yahoo.com> Message-ID: <250505.55204.qm@web30001.mail.mud.yahoo.com> Except that now I'm trying to read PORTD which is also returning the same value (0x8B) but I'm expecting a different value.? So either it's just a coincidence that I read 0x8B, or I have my data aligned wrong and it's getting a '0' in the field where it's expecting a 7 for PORTD. ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Dec 19 20:31:49 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 19 Dec 2008 11:31:49 -0800 Subject: [python-win32] kernal32.DeviceIoControl Operation Aborted In-Reply-To: <986249.8554.qm@web30007.mail.mud.yahoo.com> References: <986249.8554.qm@web30007.mail.mud.yahoo.com> Message-ID: <494BF6A5.9030600@probo.com> Red Rackham wrote: > > I think I have finally figured it out. Thanks for the suggestion, I > ran the executable (compiled C code) and it worked, and it returned 0x8B. > > Previously I saw this value and thought was bunkum. I thought it was > incorrect because of the way ctypes encodes a string buffer: ('value', > '\x8b|'). I was probably thrown off by the '|' in the string. Not > sure why that gets returned. I guess to get a real value out of that > buffer you have to use the 're' module or something. > You need to use your head to figure this out, and thinking of the "re" module is not using your head. The only way to pass buffers around in Python 2 is as strings. The answer is that your ioctl is returning TWO bytes: 8B and 7C. It is not uncommon practice in FX2 firmware to return an error code in the first byte, so perhaps the port value is actually the second byte: 7C. You can tell this for sure by checking the firmware source code. If you really want to handle the result as hex byte values, you can use struct or array: import struct s = '\x8b|' t = struct.unpack('BB', s ) print [hex(i) for i in t] import array x = array('B') x.fromstring( s ) t = x.tolist() print [hex(i) for i in t] > Except that now I'm trying to read PORTD which is also returning the > same value (0x8B) but I'm expecting a different value. So either it's > just a coincidence that I read 0x8B, or I have my data aligned wrong > and it's getting a '0' in the field where it's expecting a 7 for PORTD. Are you getting two bytes here as well? What's the second byte? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From redrackem at yahoo.com Fri Dec 19 21:11:23 2008 From: redrackem at yahoo.com (Red Rackham) Date: Fri, 19 Dec 2008 12:11:23 -0800 (PST) Subject: [python-win32] kernal32.DeviceIoControl Operation Aborted In-Reply-To: <494BF6A5.9030600@probo.com> Message-ID: <706122.99335.qm@web30001.mail.mud.yahoo.com> Eureka!? After the function returned I did a print on getmembers(buffer) and I found the data (except for the pipe character). ? If the function had returned all port values I would expect it to return: OEA, IOA, OEB, IOB, OEC, IOC, OED, IOD, OEE, IOE which I expected to look like: 0x8B, 0x09, 0x00, 0x00, 0xFF, 0x00, 0xFE, 0xB1, 0xFF, 0x00 what I got back was "('raw', '\x8b|\x00\x00\xff\x00\xfe\xb1\xff\x00\x00\x00\x00..." I find the suggestion below very relevant, since I would rather not pass a string buffer to get a byte array back.? So I will need to pass a different arg when I want to get back say, a string descriptor or something. If you really want to handle the result as hex byte values, you can use struct or array: import struct s = '\x8b|' t = struct.unpack('BB', s ) print [hex(i) for i in t] import array x = array('B') x.fromstring( s ) t = x.tolist() print [hex(i) for i in t] ? ? ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From redrackem at yahoo.com Fri Dec 19 21:48:28 2008 From: redrackem at yahoo.com (Red Rackham) Date: Fri, 19 Dec 2008 12:48:28 -0800 (PST) Subject: [python-win32] kernal32.DeviceIoControl Operation Aborted In-Reply-To: <706122.99335.qm@web30001.mail.mud.yahoo.com> Message-ID: <457484.6265.qm@web30008.mail.mud.yahoo.com> Mystery?solved.? The value on the port had changed from 0x09 to 0x76 from the time I used the c-based program to the time I came along and red it in Python.? Went back and used the c-based program and found the port was indeed 0x76. ? I used your "array" example: ??? x = array.array('B') ??? x.fromstring( buffer ) ??? t = x.tolist() ??? print [hex(i) for i in t] ? and got back "['0x8b', '0x7c', '0x0', '0x0', '0xff', '0x0', '0xfe', '0xb1', '0xff', '0x0', '0x0', '0x0',". ? Woo hoo!!!!??I didn't know that the "array" class was capable of this, which is why I was considering the "re" module. ? Thanks for helping me resolve the string conversion.? Mark ? ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Dec 19 23:12:39 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 19 Dec 2008 14:12:39 -0800 Subject: [python-win32] kernal32.DeviceIoControl Operation Aborted In-Reply-To: <457484.6265.qm@web30008.mail.mud.yahoo.com> References: <457484.6265.qm@web30008.mail.mud.yahoo.com> Message-ID: <494C1C57.3040507@probo.com> Red Rackham wrote: > Mystery solved. The value on the port had changed from 0x09 to 0x76 > from the time I used the c-based program to the time I came along and > red it in Python. Went back and used the c-based program and found > the port was indeed 0x76. > > I used your "array" example: > x = array.array('B') > x.fromstring( buffer ) > t = x.tolist() > print [hex(i) for i in t] > > and got back "['0x8b', '0x7c', '0x0', '0x0', '0xff', '0x0', '0xfe', > '0xb1', '0xff', '0x0', '0x0', '0x0',". > > Woo hoo!!!! I didn't know that the "array" class was capable of this, > which is why I was considering the "re" module. > Python is an excellent language for dealing with hardware, but if you do very much of it, you'll find that the "array" and "struct" modules become indispensable parts of your daily toolkit. I write drivers for a living, both Windows and Linux. My debug and diagnostic tools are almost always written in Python, because it's so easy to experiment. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From romain.gilles at gmail.com Sat Dec 20 15:29:55 2008 From: romain.gilles at gmail.com (Romain Gilles) Date: Sat, 20 Dec 2008 15:29:55 +0100 Subject: [python-win32] IEControler and Navigate method Message-ID: Hi, I do not understand why when I call the Navigate method on a IEControler a new instance of IE is created. This is occuring on vista but not on XP. does Somebody know why ? Romain. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mc at mclaveau.com Sat Dec 20 23:49:45 2008 From: mc at mclaveau.com (Michel Claveau) Date: Sat, 20 Dec 2008 23:49:45 +0100 Subject: [python-win32] IEControler and Navigate method In-Reply-To: References: Message-ID: <44DE235A3DC34A2BA285F6F7FD2832BA@MCI1330> Hi! > when I call the Navigate method on a IEControler a new instance of IE is > created Not for me (Vista / XP / 2000). Perhaps your code is special? Perhaps a parameter on your IE? @-salutations -- Michel Claveau From fuffa2k5 at gmail.com Mon Dec 22 14:58:55 2008 From: fuffa2k5 at gmail.com (Andrea) Date: Mon, 22 Dec 2008 14:58:55 +0100 Subject: [python-win32] Hello and first question Message-ID: Hi folks, I'm new to the list and also to the python word! I want to write a script to exchange messages with a win32 application. I have a sample code in VB but I want to do it using python. The problem is that I have no experience on comunication between application in win. Here there is the code in vb Dim L32hWnd as long L32hWnd = FindWindow(vbNullString, "appham32") Dim L32Msg as long L32Msg = RegisterWindowMessage("appham32 1"). PostMessage L32hWnd, L32Msg, 1, GhW How do I translate it in python. Many Thanks. Andrea. Andrea. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Mon Dec 22 15:37:40 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 22 Dec 2008 14:37:40 +0000 Subject: [python-win32] Hello and first question In-Reply-To: References: Message-ID: <494FA634.1060503@timgolden.me.uk> Andrea wrote: > Hi folks, > I'm new to the list and also to the python word! > I want to write a script to exchange messages with a win32 application. > I have a sample code in VB but I want to do it using python. > The problem is that I have no experience on comunication between application > in win. Look at the win32gui module from the pywin32 extensions: http://sourceforge.net/projects/pywin32/ TJG From romain.gilles at gmail.com Mon Dec 22 23:12:21 2008 From: romain.gilles at gmail.com (Romain Gilles) Date: Mon, 22 Dec 2008 23:12:21 +0100 Subject: [python-win32] IEControler and Navigate method In-Reply-To: <44DE235A3DC34A2BA285F6F7FD2832BA@MCI1330> References: <44DE235A3DC34A2BA285F6F7FD2832BA@MCI1330> Message-ID: No I have found something but I don't know if it is the reason ;) When I'm opening a IE with the classique dispatch technique : ie = Dispatch("InternetExplorer.Application") ie.Navigate("http://www.google.fr") A new IE is created but if I do it like this: ie = Dispatch("InternetExplorer.Application") ie.Navigate('file:///C:/PathToAnExistingFile') In this case it works. When I create the IE within a subprocess and give him a default target URL and them go to google it does not create a new window: subprocess.call(['C:\Program Files\Internet Explorer\iexplore.exe', ' http://toto']) ie = lookup('http://toto') ie.Navigate('http://www.google.fr') In this case it works also. It is look like if the Initial IE creation needs to have the same scheme... ??? Any Ideas ? Thanks, Romain. 2008/12/20 Michel Claveau > Hi! > > when I call the Navigate method on a IEControler a new instance of IE is >> created >> > > Not for me (Vista / XP / 2000). > Perhaps your code is special? > Perhaps a parameter on your IE? > > @-salutations > -- > Michel Claveau > > > > _______________________________________________ > 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: From david.h.haas at gmail.com Thu Dec 25 02:28:18 2008 From: david.h.haas at gmail.com (David Haas) Date: Wed, 24 Dec 2008 17:28:18 -0800 Subject: [python-win32] DDE: python server/excel client - pass array? Message-ID: <29e0499c0812241728t6bb869day64f8dc5ee814bb1b@mail.gmail.com> I've run into a problem with DDE which, after much googling and trial & error, I managed to work around, but I'm pretty sure there's a better solution. I think the problem is this: there's currently no way for a python DDE server to pass an array back as a response from a DDE Request - it's either a string, or nothing. Since Excel expects the response it receives from a DDE Request that it makes to be an array, it dies (with what I believe is an Error 2042) when communicating with a Python DDE server. If someone could give me some idea how to fix what I think is broken in python's DDE module, I'd greatly appreciate it. Even better, if someone knows an easy way to do this which has totally escaped me, I'd greatly appreciate knowing how to do it. And if nothing else, someone else may google this response and save themselves some hassle. Details of my setup & what I've tried is below: I'm running Win XP, Python 2.6.1, pywin32 build 212 from Sourceforge, MS Excel from Office 2000. My python DDE server: basically taken verbatim from win32/demos/dde/ddeserver.py I think the key piece of code is in the "MyRequestTopic" class - namely, the call to CreateStringItem: class MyRequestTopic(object.Object): def __init__(self, topicName): topic = dde.CreateTopic(topicName) topic.AddItem(dde.CreateStringItem("")) <- this line object.Object.__init__(self, topic) My Excel client is using a little bit of VBA to query the python DDE server: dim chan as long dim resp as variant chan = DDEInitiate("pyserver","request") resp = DDERequest(chan, "Hello") DDETerminate chan If I start my python DDE server, and use a python DDE client, passing the above request will return a valid response from the system (right now, it just echos back whatever it receives, so we'd get a response of "Hello"). If I plug the above VBA code into Microsoft Word, the variable "resp" in VBA gets set to "Hello", which is the appropriate response. Word's documentation says it expects a String as a response when it makes a DDERequest. However, running the above VBA code in Microsoft Excel will set the variable "resp" to "Error 2042". Actually, passing any valid request will give me a response of "Error 2042" in Excel. Interestingly enough, the documentation for Excel says it expects an Array as a response when it makes a DDERequest. I've tried changing the response from the DDE server into (for example) a list and/or a tuple, but that still gave me the same error in Excel. Interestingly enough, it also would then break in Word. My workaround in Excel is to make a Word object, and then use the Word object to handle all the requests from my python DDE server. It works, but it's not elegant. Looking through the code of ddemodule.cpp, I see a method for "CreateStringItem", but nothing like "CreateArrayItem", or "CreateGenericItem" . Looking at the documentation for TCL's DDE implementation, it looks like it can pass back either a string or a binary array. Any ideas on either of the following two questions would be greatly appreciated: a) how I could use the current dde module to pass in something Excel could read; b) what extra code would need to be added to the dde module to pass back arrays; Thanks . . . - David From bgailer at gmail.com Thu Dec 25 03:56:39 2008 From: bgailer at gmail.com (bob gailer) Date: Wed, 24 Dec 2008 21:56:39 -0500 Subject: [python-win32] DDE: python server/excel client - pass array? In-Reply-To: <29e0499c0812241728t6bb869day64f8dc5ee814bb1b@mail.gmail.com> References: <29e0499c0812241728t6bb869day64f8dc5ee814bb1b@mail.gmail.com> Message-ID: <4952F667.6050406@gmail.com> David Haas wrote: > I've run into a problem with DDE Why use DDE when COM is available? > which, after much googling and trial > & error, I managed to work around, but I'm pretty sure there's a > better solution. > > I think the problem is this: there's currently no way for a python DDE > server to pass an array back as a response from a DDE Request - it's > either a string, or nothing. Since Excel expects the response it > receives from a DDE Request that it makes to be an array, it dies > (with what I believe is an Error 2042) when communicating with a > Python DDE server. > > If someone could give me some idea how to fix what I think is broken > in python's DDE module, I'd greatly appreciate it. Even better, if > someone knows an easy way to do this which has totally escaped me, I'd > greatly appreciate knowing how to do it. And if nothing else, someone > else may google this response and save themselves some hassle. > Details of my setup & what I've tried is below: > > I'm running Win XP, Python 2.6.1, pywin32 build 212 from Sourceforge, > MS Excel from Office 2000. > > My python DDE server: basically taken verbatim from win32/demos/dde/ddeserver.py > I think the key piece of code is in the "MyRequestTopic" class - > namely, the call to CreateStringItem: > > class MyRequestTopic(object.Object): > def __init__(self, topicName): > topic = dde.CreateTopic(topicName) > topic.AddItem(dde.CreateStringItem("")) <- this line > object.Object.__init__(self, topic) > > My Excel client is using a little bit of VBA to query the python DDE server: > > dim chan as long > dim resp as variant > > chan = DDEInitiate("pyserver","request") > resp = DDERequest(chan, "Hello") > DDETerminate chan > > If I start my python DDE server, and use a python DDE client, passing > the above request will return a valid response from the system (right > now, it just echos back whatever it receives, so we'd get a response > of "Hello"). > If I plug the above VBA code into Microsoft Word, the variable "resp" > in VBA gets set to "Hello", which is the appropriate response. Word's > documentation says it expects a String as a response when it makes a > DDERequest. > However, running the above VBA code in Microsoft Excel will set the > variable "resp" to "Error 2042". Actually, passing any valid request > will give me a response of "Error 2042" in Excel. Interestingly > enough, the documentation for Excel says it expects an Array as a > response when it makes a DDERequest. > > I've tried changing the response from the DDE server into (for > example) a list and/or a tuple, but that still gave me the same error > in Excel. Interestingly enough, it also would then break in Word. > > My workaround in Excel is to make a Word object, and then use the Word > object to handle all the requests from my python DDE server. It > works, but it's not elegant. > > Looking through the code of ddemodule.cpp, I see a method for > "CreateStringItem", but nothing like "CreateArrayItem", or > "CreateGenericItem" . Looking at the documentation for TCL's DDE > implementation, it looks like it can pass back either a string or a > binary array. > > Any ideas on either of the following two questions would be greatly appreciated: > > a) how I could use the current dde module to pass in something Excel could read; > b) what extra code would need to be added to the dde module to pass back arrays; > > > Thanks . . . > > - David > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -- Bob Gailer Chapel Hill NC 919-636-4239 From timr at probo.com Fri Dec 26 19:49:12 2008 From: timr at probo.com (timr at probo.com) Date: Fri, 26 Dec 2008 10:49:12 -0800 Subject: [python-win32] DDE: python server/excel client - pass array? In-Reply-To: <29e0499c0812241728t6bb869day64f8dc5ee814bb1b@mail.gmail.com>; from David Haas on Wed, Dec 24, 2008 at 05:28:18PM -0800 References: <29e0499c0812241728t6bb869day64f8dc5ee814bb1b@mail.gmail.com> Message-ID: <20081226104912.C5304@probo.com> On Wed, Dec 24, 2008 at 05:28:18PM -0800, David Haas wrote: > > I've run into a problem with DDE which, after much googling and trial > & error, I managed to work around, but I'm pretty sure there's a > better solution. > > I think the problem is this: there's currently no way for a python DDE > server to pass an array back as a response from a DDE Request - it's > either a string, or nothing. Since Excel expects the response it > receives from a DDE Request that it makes to be an array, it dies > (with what I believe is an Error 2042) when communicating with a > Python DDE server. DDE works exclusively in strings. So, the key is to figure out how to encode the array as a string in order to satisfy Excel. I've been searching for an Excel DDE reference guide without success, although I'm certain there must be one. -- Tim Roberts, timr at probo.com Providenza & Boeklheide, Inc. From joshua__lim at hotmail.com Sat Dec 27 20:36:01 2008 From: joshua__lim at hotmail.com (Joshua Lim) Date: Sat, 27 Dec 2008 19:36:01 +0000 Subject: [python-win32] Welcome to the "python-win32" mailing list In-Reply-To: References: Message-ID: Hi everyone, I'm new to python or C. I've been trying to get open source pyrad, a socket radius python app, to work on win32, and encountered an error: Traceback (most recent call last): File "C:\Python25\pyrad\example\server.py", line 36, in srv.Run() File "C:\Python25\pyrad\example\server.py", line 256, in Run AttributeError: 'module' object has no attribute 'poll' A quick Google revealed that the error has something to do with Linux poll not working under windows. I searched Pyrad code, server.py, line 256, and this brought up the following: def Run(self): """Main loop. This method is the main loop for a RADIUS server. It waits for packets to arrive via the network and calls other methods to process them. """ self._poll=select.poll() self._fdmap={} self._PrepareSockets() while 1: for (fd, event) in self._poll.poll(): if event==select.POLLIN: try: fdo=self._fdmap[fd] self._ProcessInput(fdo) except ServerPacketError, err: logger.info("Dropping packet: " + str(err)) except packet.PacketError, err: logger.info("Received a broken packet: " + str(err)) else: logger.error("Unexpected event in server main loop") As i understand, i need to change the code to use select.select(). I tried replacing "select.poll()" with "select.select()" but got a new error: TypeError: select expected at least 3 arguments, got 0 What should i do? Would appreciate any tip. :) Rgds, Joshua _________________________________________________________________ NEW! Get Windows Live FREE. http://www.get.live.com/wl/all -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias.ekman at googlemail.com Sun Dec 28 19:50:03 2008 From: matthias.ekman at googlemail.com (Matthias Ekman) Date: Sun, 28 Dec 2008 19:50:03 +0100 Subject: [python-win32] Pythonwin starts, displays main window, interactive window 'frame', then exits In-Reply-To: <49448933.70400@gmail.com> References: <49448933.70400@gmail.com> Message-ID: <4957CA5B.7080903@googlemail.com> > Try deleting your "HKEY_CURRENT_USER\Software\Python 2.5" (using > whatever version of Python you are using) key - this may have garbage > which causes MFC to get upset as it starts. deleting "HKEY_CURRENT_USER\Software\Python 2.5" (Python 2.6 in my case) works fine for me ... BUT ... on next start up of pythonwin editor a new entry is created. So do I have to deleate "HKEY_CURRENT_USER\Software\Python 2.5" *everytime* I use pythonwin? There might be a better solution? Best regards, Matthias From skippy.hammond at gmail.com Sun Dec 28 22:39:40 2008 From: skippy.hammond at gmail.com (Mark Hammond) Date: Mon, 29 Dec 2008 08:39:40 +1100 Subject: [python-win32] Pythonwin starts, displays main window, interactive window 'frame', then exits In-Reply-To: <4957CA5B.7080903@googlemail.com> References: <49448933.70400@gmail.com> <4957CA5B.7080903@googlemail.com> Message-ID: <4957F21C.2000004@gmail.com> On 29/12/2008 5:50 AM, Matthias Ekman wrote: > > Try deleting your "HKEY_CURRENT_USER\Software\Python 2.5" (using > > whatever version of Python you are using) key - this may have garbage > > which causes MFC to get upset as it starts. > > deleting "HKEY_CURRENT_USER\Software\Python 2.5" (Python 2.6 in my case) > works fine for me ... BUT ... on next start up of pythonwin editor a new > entry is created. So do I have to deleate > "HKEY_CURRENT_USER\Software\Python 2.5" *everytime* I use pythonwin? > There might be a better solution? Do you have build 212? If so, it is expected the key will be re-created, but it should *not* fill with the garbage that caused the original problem. Can you tell us what is in that key? Cheers, Mark From matthias.ekman at googlemail.com Mon Dec 29 01:01:01 2008 From: matthias.ekman at googlemail.com (Matthias Ekman) Date: Mon, 29 Dec 2008 01:01:01 +0100 Subject: [python-win32] Pythonwin starts, displays main window, interactive window 'frame', then exits In-Reply-To: <4957F21C.2000004@gmail.com> References: <49448933.70400@gmail.com> <4957CA5B.7080903@googlemail.com> <4957F21C.2000004@gmail.com> Message-ID: <4958133D.3060004@googlemail.com> Mark Hammond schrieb: > On 29/12/2008 5:50 AM, Matthias Ekman wrote: >> > Try deleting your "HKEY_CURRENT_USER\Software\Python 2.5" (using >> > whatever version of Python you are using) key - this may have garbage >> > which causes MFC to get upset as it starts. >> >> deleting "HKEY_CURRENT_USER\Software\Python 2.5" (Python 2.6 in my case) >> works fine for me ... BUT ... on next start up of pythonwin editor a new >> entry is created. So do I have to deleate >> "HKEY_CURRENT_USER\Software\Python 2.5" *everytime* I use pythonwin? >> There might be a better solution? > > Do you have build 212? If so, it is expected the key will be > re-created, but it should *not* fill with the garbage that caused the > original problem. Can you tell us what is in that key? > > Cheers, > > Mark Hi Mark! I have built 211.1. I figured out, that the problem is caused by the DWORD called "bars" in "HKEY_CURRENT_USER\Software\Python 2.6\Python for Win32\ToolbarDefault-Summary". The default value of "bars" is 9 (decimal). Using "Tools --> Browse Path" in PythonWin changes the value to 10 (decimal) and PythonWin won't start up. Setting the value back to 9 .. and everything works fine again. BUT ... the value is re-created every time. cheers, Matthias From timr at probo.com Mon Dec 29 19:23:09 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 29 Dec 2008 10:23:09 -0800 Subject: [python-win32] Welcome to the "python-win32" mailing list In-Reply-To: References: Message-ID: <4959158D.2050002@probo.com> Joshua Lim wrote: > Hi everyone, > > I'm new to python or C. I've been trying to get open source pyrad, a > socket radius python app, to work on win32, and encountered an error: > > Traceback (most recent call last): > File "C:\Python25\pyrad\example\server.py", line 36, in > srv.Run() > File "C:\Python25\pyrad\example\server.py", line 256, in Run > > AttributeError: 'module' object has no attribute 'poll' > > A quick Google revealed that the error has something to do with Linux > poll not working under windows. I searched Pyrad code, server.py, > line 256, and this brought up the following: > > def Run(self): > """Main loop. > > This method is the main loop for a RADIUS server. It waits > for packets to arrive via the network and calls other methods > &nbs p; to process them. > """ > self._poll=select.poll() > self._fdmap={} > self._PrepareSockets() > > while 1: > for (fd, event) in self._poll.poll(): > if event==select.POLLIN: > try: > fdo=self._fdmap[fd] > self._ProcessInput(fdo) > exc ept ServerPacketError, err: > logger.info("Dropping > packet: " + str(err)) > except packet.PacketError, err: > logger.info("Received a broken packet: " + > str(err)) > else: > logger.e rror("Unexpected > event in server main loop") > > > > As i understand, i need to change the code to use select.select(). I > tried replacing "select.poll()" with "select.select()" but got a new > error: > > TypeError: select expected at least 3 arguments, got 0 > > What should i do? Would appreciate any tip. :) Well, "select" is not just a drop-in replacement for "poll", although it can serve the same function. Without looking at the rest of the source, you probably want something like this: def Run( self ): self._fdmap = {} self._PrepareSockets() while 1: fdi = select.select( self._fdmap, [], [] )[0] if fdi: self._ProcessInput( fdi[0] ) else: logger.error( "select returned empty." ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon Dec 29 19:47:15 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 29 Dec 2008 10:47:15 -0800 Subject: [python-win32] Welcome to the "python-win32" mailing list In-Reply-To: <4959158D.2050002@probo.com> References: <4959158D.2050002@probo.com> Message-ID: <49591B33.5030107@probo.com> Tim Roberts wrote: > Well, "select" is not just a drop-in replacement for "poll", although it > can serve the same function. Without looking at the rest of the source, > you probably want something like this: > > def Run( self ): > self._fdmap = {} > self._PrepareSockets() > while 1: > fdi = select.select( self._fdmap, [], [] )[0] > I just realized this is not correct. _fdmap is a dictionary, and it needs to be a list of FDs. _fdmap probably contains the list of read FDs, write FDs, and other FDs -- exactly the way select.select wants them -- but you'll have to look inside _PrepareSockets to know how to pull out the three individual lists. OK, after looking at the source, I think the list of fds is actually the keys of the dictionary, so we need two small changes: def Run( self ): self._fdmap = {} self._PrepareSockets() while 1: fdi = select.select( self._fdmap.keys(), [], [] )[0] if fdi: self._ProcessInput( self._fdmap[fdi[0]] ) else: logger.error( "select returned empty." ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From joshua__lim at hotmail.com Mon Dec 29 20:00:32 2008 From: joshua__lim at hotmail.com (Joshua Lim) Date: Mon, 29 Dec 2008 19:00:32 +0000 Subject: [python-win32] Welcome to the "python-win32" mailing list In-Reply-To: <49591B33.5030107@probo.com> References: <4959158D.2050002@probo.com> <49591B33.5030107@probo.com> Message-ID: Hi Tim, Thanks for helping. I replaced your code from def Run( self ): onwards, but got an error: C:\Python25\pyrad\example>c:\python25\python server.pyTraceback (most recent call last): File "server.py", line 3, in from pyrad import dictionary, packet, server File "c:\python25\lib\site-packages\pyrad-1.1-py2.5.egg\pyrad\server.py", line 259 fdi = select.select( self._fdmap.keys(), [], [] )[0] ^IndentationError: expected an indented block Rgds, Joshua > Date: Mon, 29 Dec 2008 10:47:15 -0800> From: timr at probo.com> To: python-win32 at python.org> Subject: Re: [python-win32] Welcome to the "python-win32" mailing list> > Tim Roberts wrote:> > Well, "select" is not just a drop-in replacement for "poll", although it> > can serve the same function. Without looking at the rest of the source,> > you probably want something like this:> >> > def Run( self ):> > self._fdmap = {}> > self._PrepareSockets()> > while 1:> > fdi = select.select( self._fdmap, [], [] )[0]> > > > I just realized this is not correct. _fdmap is a dictionary, and it> needs to be a list of FDs. _fdmap probably contains the list of read> FDs, write FDs, and other FDs -- exactly the way select.select wants> them -- but you'll have to look inside _PrepareSockets to know how to> pull out the three individual lists.> > OK, after looking at the source, I think the list of fds is actually the> keys of the dictionary, so we need two small changes:> > def Run( self ):> self._fdmap = {}> self._PrepareSockets()> while 1:> fdi = select.select( self._fdmap.keys(), [], [] )[0]> if fdi:> self._ProcessInput( self._fdmap[fdi[0]] )> else:> logger.error( "select returned empty." )> > -- > 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 _________________________________________________________________ NEW! Get Windows Live FREE. http://www.get.live.com/wl/all -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.h.haas at gmail.com Tue Dec 30 05:24:02 2008 From: david.h.haas at gmail.com (David Haas) Date: Mon, 29 Dec 2008 20:24:02 -0800 Subject: [python-win32] DDE: python server/excel client - pass array? In-Reply-To: <20081226104912.C5304@probo.com> References: <29e0499c0812241728t6bb869day64f8dc5ee814bb1b@mail.gmail.com> <20081226104912.C5304@probo.com> Message-ID: <29e0499c0812292024l71bc20cdq5d59bc7e68222616@mail.gmail.com> Tim: Thanks for the reply. It's made me go back to look for some way to send Excel what it wants, which led to some other ideas. First: I found on google a MS Word document from NI about the DDE formats Excel supports - in particular, the "xlTable" format: http://forums.ni.com/ni/attachments/ni/170/113711/1/dde.doc (see also this C++ code: http://support.microsoft.com/kb/238133) I also stumbled across a mention somewhere in Google that Excel will request data using the clipboard format in the order listed in the above NI doc, and if you're not returning data with that format, your application should spit back a "false", or "not supported", or something to that effect, at which point Excel will make another request using the next format on the list, and so on and so forth until you get to something you both agree on or until you run out of formats. I purposely did something bad in my server response which generated an exception (ie, return hex('164116259')) - when I call this from Excel, I get 9 exception reports on the console. If I call it from Word, I only get 1 exception report. Perhaps that's a sign that Excel is making multiple requests with different format types, until it hits the CF_TEXT we actually send back? Reading through the code in stddde.cpp, it seems like it might not be handling checks for that correctly. In CDDEServer::DoCallback, it gets a wFmt passed in, which then gets passed along to CDDEServer::Request. CDDEServer::Request passes the wFmt to the request method of whatever CDDETopic matches. In CDDETopic, if m_strName is blank, it gets passed to NSRequest(pszItem, ppData, pdwSize) <- which doesn't list anything at all about the wFmt command. That looks like it gets passed into Python, which ultimately gets passed back up to CDDEServer::DoCallback, which returns data using the wFmt that was passed in. But if Excel was expecting this xlTable format, maybe that's why this error 2042 shows up? It looks like if you name the string topic, then it will get passed to CDDEStringTopic, which ASSERTS wFmt is CF_TEXT. I tried to pass back a string like "16411625", hoping I'd get "5" returned, but it didn't work. Anyway, do you think adding in a check to the NSRequest function that wFmt is really CF_TEXT might fix this issue? Thanks for whatever help you can provide. On Fri, Dec 26, 2008 at 10:49 AM, wrote: > On Wed, Dec 24, 2008 at 05:28:18PM -0800, David Haas wrote: >> >> I've run into a problem with DDE which, after much googling and trial >> & error, I managed to work around, but I'm pretty sure there's a >> better solution. >> >> I think the problem is this: there's currently no way for a python DDE >> server to pass an array back as a response from a DDE Request - it's >> either a string, or nothing. Since Excel expects the response it >> receives from a DDE Request that it makes to be an array, it dies >> (with what I believe is an Error 2042) when communicating with a >> Python DDE server. > > DDE works exclusively in strings. So, the key is to figure out how > to encode the array as a string in order to satisfy Excel. I've been > searching for an Excel DDE reference guide without success, although > I'm certain there must be one. > -- > Tim Roberts, timr at probo.com > Providenza & Boeklheide, Inc. > From matthias.ekman at googlemail.com Tue Dec 30 12:03:08 2008 From: matthias.ekman at googlemail.com (Matthias Ekman) Date: Tue, 30 Dec 2008 12:03:08 +0100 Subject: [python-win32] Pythonwin starts, displays main window, interactive window 'frame', then exits In-Reply-To: <4958133D.3060004@googlemail.com> References: <4958133D.3060004@googlemail.com> Message-ID: <4959FFEC.3080201@googlemail.com> do you suggest to update to build 212? From bgailer at gmail.com Tue Dec 30 17:05:15 2008 From: bgailer at gmail.com (bob gailer) Date: Tue, 30 Dec 2008 11:05:15 -0500 Subject: [python-win32] DDE: python server/excel client - pass array? In-Reply-To: <29e0499c0812292024l71bc20cdq5d59bc7e68222616@mail.gmail.com> References: <29e0499c0812241728t6bb869day64f8dc5ee814bb1b@mail.gmail.com> <20081226104912.C5304@probo.com> <29e0499c0812292024l71bc20cdq5d59bc7e68222616@mail.gmail.com> Message-ID: <495A46BB.7060507@gmail.com> Why oh why are you using DDE when there are newer and better ways??? -- Bob Gailer Chapel Hill NC 919-636-4239 From joshua__lim at hotmail.com Tue Dec 30 17:46:40 2008 From: joshua__lim at hotmail.com (Joshua Lim) Date: Tue, 30 Dec 2008 16:46:40 +0000 Subject: [python-win32] Welcome to the "python-win32" mailing list In-Reply-To: <495A2C92.9090503@pythonlibrary.org> References: <4959158D.2050002@probo.com> <49591B33.5030107@probo.com> <495A2C92.9090503@pythonlibrary.org> Message-ID: Thanks Mike, it didn't occur to me that indentations are required. :o C:\Python25\pyrad\example>c:\python25\python server.pyTraceback (most recent call last): File "server.py", line 3, in from pyrad import dictionary, packet, server File "C:\Python25\pyrad\example\server.py", line 259, in NameError: name 'self' is not defined Now a new error. Line 259 refers to "fdi = select.select( self._fdmap.keys(), [], [] )[0]" > Date: Tue, 30 Dec 2008 08:13:38 -0600> From: mike at pythonlibrary.org> To: joshua__lim at hotmail.com; python-win32 at python.org> Subject: Re: [python-win32] Welcome to the "python-win32" mailing list> > Joshua Lim wrote:> > Hi Tim,> >> > Thanks for helping.> >> > I replaced your code from def Run( self ): onwards, but got an error:> >> > C:\Python25\pyrad\example>c:\python25\python server.py> > Traceback (most recent call last):> > File "server.py", line 3, in > > from pyrad import dictionary, packet, server> > File> > "c:\python25\lib\site-packages\pyrad-1.1-py2.5.egg\pyrad\server.py", line> > 259> > fdi = select.select( self._fdmap.keys(), [], [] )[0]> > ^> > IndentationError: expected an indented block> >> > Rgds,> > Joshua> >> > > When copying and pasting code from a mail reader, the indents can get> messed up. Just fix them yourself.> > Mike> > > > > >> > > Date: Mon, 29 Dec 2008 10:47:15 -0800> > > From: timr at probo.com> > > To: python-win32 at python.org> > > Subject: Re: [python-win32] Welcome to the "python-win32" mailing list> > >> > > Tim Roberts wrote:> > > > Well, "select" is not just a drop-in replacement for "poll",> > although it> > > > can serve the same function. Without looking at the rest of the> > source,> > > > you probably want something like this:> > > >> > > > def Run( self ):> > > > self._fdmap = {}> > > > self._PrepareSockets()> > > > while 1:> > > > fdi = select.select( self._fdmap, [], [] )[0]> > > >> > >> > > I just realized this is not correct. _fdmap is a dictionary, and it> > > needs to be a list of FDs. _fdmap probably contains the list of read> > > FDs, write FDs, and other FDs -- exactly the way select.select wants> > > them -- but you'll have to look inside _PrepareSockets to know how to> > > pull ou t the three individual lists.> > >> > > OK, after looking at the source, I think the list of fds is actually the> > > keys of the dictionary, so we need two small changes:> > >> > > def Run( self ):> > > self._fdmap = {}> > > self._PrepareSockets()> > > while 1:> > > fdi = select.select( self._fdmap.keys(), [], [] )[0]> > > if fdi:> > > self._ProcessInput( self._fdmap[fdi[0]] )> > > else:> > > logger.error( "select returned empty." )> > >> > > --> > > 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> >> >> > ------------------------------------------------------------------------> > Make the most of what you can do on your PC and the Web, just the way> > you want. Windows Live > _________________________________________________________________ NEW! Get Windows Live FREE. http://www.get.live.com/wl/all -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Dec 30 18:38:49 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 30 Dec 2008 09:38:49 -0800 Subject: [python-win32] Welcome to the "python-win32" mailing list In-Reply-To: References: <4959158D.2050002@probo.com> <49591B33.5030107@probo.com> <495A2C92.9090503@pythonlibrary.org> Message-ID: <495A5CA9.2030006@probo.com> Joshua Lim wrote: > Thanks Mike, it didn't occur to me that indentations are required. :o You may want to take some time to get comfortable with Python before making a change like this. Indentation is a fundamental part of Python syntax, replacing the { curly braces of C } and the begin/end of Pascal. It is NOT optional. It must look exactly like my example. Further, you should configure your editor so that you always use spaces for indentation, or always use tabs. Mixing spaces and tabs will get you into trouble. > C:\Python25\pyrad\example>c:\python25\python server.py > Traceback (most recent call last): > File "server.py", line 3, in > from pyrad import dictionary, packet, server > File "C:\Python25\pyrad\example\server.py", line 259, in > NameError: name 'self' is not defined > > Now a new error. Line 259 refers to "fdi = select.select( > self._fdmap.keys(), [], [] )[0]" You still have an indentation problem. This line should be part of the Run function, which includes "self" as a parameter. That line must be indented from the "while" statement, which is indented from the "def" statement. If you had that line at the same indentation as the "def", you'd see this error, because it would not be part of the function. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gagsl-py2 at yahoo.com.ar Tue Dec 30 19:20:04 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 30 Dec 2008 16:20:04 -0200 Subject: [python-win32] service support in 2.6 isn't working Message-ID: Hello I had some problems writting a service using Python 2.6 and pywin32 Build 212, and I eventually found that even the pipeTestService.py demo program doesn't work either. The service apparently installs fine, but refuses to start: C:\APPS\Python26\Lib\site-packages\win32\Demos\service>python26 pipeTestService. py install Installing service PyPipeTestService Service installed C:\APPS\Python26\Lib\site-packages\win32\Demos\service>python26 pipeTestService. py start Starting service PyPipeTestService Error starting service: El servicio no ha respondido a la petici?n o inicio del control en un tiempo adecuado. (in english: "The service did not answer the start request in adequate time") The error comes immediately, without any delay, so I guess a timeout somewhere is set too small. If I uninstall the demo service, and reinstall using Python 2.5 and pywin32 Build 210, it works fine. -- Gabriel Genellina