From rwupole at msn.com Wed Aug 1 02:38:48 2007 From: rwupole at msn.com (Roger Upole) Date: Tue, 31 Jul 2007 20:38:48 -0400 Subject: [python-win32] Re: Utilizing a raw IDispatch Pointer from Python Message-ID: <000b01c7d3d4$55a5df90$0100a8c0@rupole> Brad Johnson wrote: >I have a C++ application that creates a collection of COM objects. I am > embedding a Python interpreter that will have access to Automation objects > written in C++. > > I would like to give the Python interpreter access to the IDispatch interface on > these objects. > > Stated another way, how can I have Python consume a IDispatch pointer from C++ > and wrap it with one of those nice Python classes (IPyDispatch?) automatically? > > Thanks in advance. PyCom_PyObjectFromIUnknown can be used to wrap an IDispatch pointer in a PyIDispatch object. Roger From crown.hg at gmail.com Wed Aug 1 07:50:45 2007 From: crown.hg at gmail.com (Huang Guan) Date: Wed, 1 Aug 2007 13:50:45 +0800 Subject: [python-win32] Fwd: pywin32 bugs feedback from learner In-Reply-To: <2d8a7c070707310925n4138711dr44f318403d251c5b@mail.gmail.com> References: <2d8a7c070707310925n4138711dr44f318403d251c5b@mail.gmail.com> Message-ID: <2d8a7c070707312250v5e787735wf99afe79a3044e4a@mail.gmail.com> From: Huang Guan Date: 2007-8-1 ????12:25 Subject: pywin32 bugs feedback from learner To: mhammond at skippinet.com.au Dear pywin32 team, First I want to express my appreciation to pywin32, who developed the excellent extend utility package, which push python of win32 develop so quickly. I am a learner of pywin32, and I have some queries during my study. May I draw your kindly attention to the following problem and have some nice directions about that? 1). While using pythoncom develop com+ serivce, executed triumphantly. But why the pythonservice appear in windows process administer always? Is there any method to let pythonservice disappear from windows process administer? 2). While using pythoncom develop com+ sever, below variable have been set: _svc_name_='myservice' _svc_display_name_='myservice display name' _svc_description_='myservice description' Why it can't display server manufacture in the msconfig of windows xp? How can I have the result as follow: eg: service name:VMware DHCP Service, service manufacture:VMware,Inc. 3). while using pywin32 to control IE, make sure spring OnDocumentComplete affair already, thance, to load local HTML file to IE, code as below: v_s=v_iexplore.Document._oleobj_.QueryInterface(\ win32com.client.pythoncom.IID_IPersistStreamInit) if v_s: print 'Exists pythoncom.IID_IPersistStreamInit ' v_s.InitNew() Now it's sure that it initializtion the DHTML controller of IE successful, and return a PyIPersistStreamInit object, but according to the help from pywin32, there is only one initNew()method in PyIPersistStreamInit object. So What's the method load(),Save(),Release() for PyIPersistStreamInit? How to find it? How to carry out the similar VC code function as below: hr = pPersistStreamInit->InitNew(); if ( SUCCEEDED(hr) ) { // Load the contents of the stream. hr = pPersistStreamInit->Load( pStream ); } pPersistStreamInit->Release(); 4). While using pywin32 to control IE, It's certain that using win32com.client.Dispatch return IE object. It can execute the JavaScript method of current transfer page, the following code has been execute and come through: v_iexplore=win32com.client.Dispatch('InternetExplorer.Application') v_iexplore.Navigate(' http://www.cpplab.com/Articles/JSCalls/TestPage/JSCallTestPage.htm' ) v_id=v_iexplore.Document.Script._oleobj_.GetIDsOfNames('Welcome') v_iexplore.Document.Script._oleobj_.Invoke(\ v_id, 0, win32com.client.pythoncom.DISPATCH_METHOD, True,\ 'HuanGuan') But: It can't execute the above code exactly In the win32com.client.DispatchWithEvents return IE object. How to solve this problem ? Would you pls kindly to show me some examples? Anxiously awaiting your kindly comments. Thanks and best regards! crown.hg -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070801/16776e56/attachment.html From rbell01824 at earthlink.net Wed Aug 1 15:39:25 2007 From: rbell01824 at earthlink.net (Richard Bell) Date: Wed, 1 Aug 2007 08:39:25 -0500 Subject: [python-win32] python com error - 'module' object has no attribute 'CLSIDToClassMap' strangeness Message-ID: <000001c7d441$648132e0$6701a8c0@rjbmain> I've a COM application that automated IE that I've been working on for some months. This mourning I get the following error message when I run a test that ran successfully last night: === H2 tag in IFRAME but is NOT visible when the frame is visible, need to scroll -- flashTag H2 -- tagScreenCord H2 Traceback (most recent call last): File "C:\rbell\Bell Curve Group\IE Testing\t070731a.py", line 382, in flashTag(tag) File "C:\rbell\Bell Curve Group\IE Testing\t070731a.py", line 299, in flashTag tagL, tagT, tagW, tagH = _tagScreenCord(tag) File "C:\rbell\Bell Curve Group\IE Testing\t070731a.py", line 192, in _tagScreenCord winL, winT, winW, winH, winscrollL, winscrollT = _winLTWHSLT(_iewin(tag)) File "C:\rbell\Bell Curve Group\IE Testing\t070731a.py", line 263, in _winLTWHSLT win3 = win32com.client.CastTo(win, 'IHTMLWindow3') # cast to get screen... File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line 132, in CastTo ob = gencache.EnsureDispatch(ob) File "C:\Python25\Lib\site-packages\win32com\client\gencache.py", line 536, in EnsureDispatch mod = EnsureModule(tla[0], tla[1], tla[3], tla[4], bForDemand=bForDemand) File "C:\Python25\Lib\site-packages\win32com\client\gencache.py", line 393, in EnsureModule module = GetModuleForTypelib(typelibCLSID, lcid, major, minor) File "C:\Python25\Lib\site-packages\win32com\client\gencache.py", line 262, in GetModuleForTypelib AddModuleToCache(typelibCLSID, lcid, major, minor) File "C:\Python25\Lib\site-packages\win32com\client\gencache.py", line 554, in AddModuleToCache dict = mod.CLSIDToClassMap AttributeError: 'module' object has no attribute 'CLSIDToClassMap' An attempt to run makePY on the 'HTML Object Library' yielded the following error: Generating to C:\DOCUME~1\rbell\LOCALS~1\Temp\gen_py\2.5\3050F1C5-98B5-11CF-BB82-00AA00BDC E0Bx0x4x0.py Building definitions from type library... Generating... Importing module Failed to execute command: from win32com.client import makepy;makepy.main() Traceback (most recent call last): File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\toolmenu.py", line 103, in HandleToolCommand exec "%s\n" % pyCmd File "", line 1, in File "C:\Python25\lib\site-packages\win32com\client\makepy.py", line 363, in main GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, bForDemand = bForDemand, bBuildHidden = hiddenSpec) File "C:\Python25\lib\site-packages\win32com\client\makepy.py", line 271, in GenerateFromTypeLibSpec gencache.AddModuleToCache(info.clsid, info.lcid, info.major, info.minor) File "C:\Python25\Lib\site-packages\win32com\client\gencache.py", line 554, in AddModuleToCache dict = mod.CLSIDToClassMap AttributeError: 'module' object has no attribute 'CLSIDToClassMap' Deleting the gen_py output directory and re-running makepy SUCCEEDS and subsequently the test application runs OK again. So the symptom is resolved, but any clues as to how this could have happened. This is a VERY long running application (think 24x7 for years) and I'm concerned that whatever caused this might occur again. Thanks for any clues. Regards, Richard From rasjidw at gmail.com Wed Aug 1 15:53:31 2007 From: rasjidw at gmail.com (Rasjid Wilcox) Date: Wed, 1 Aug 2007 23:53:31 +1000 Subject: [python-win32] Registering a Server COM to make it visible in thereference list In-Reply-To: <006d01c7d254$b9ecd3e0$1c0a0a0a@enfoldsystems.local> References: <006d01c7d254$b9ecd3e0$1c0a0a0a@enfoldsystems.local> Message-ID: On 7/30/07, Mark Hammond wrote: > There should be no need to create an IDL file - enough interfaces are > exposed so that we can create the typelib directly. Ah, after some looking around, I see that there is pythoncom.CreateTypeLib and CreateTypeLib2. Is this what you mean? > The problem I see is how to infer the intent of the Python programmer, who > probably does *not* want to author the interfaces externally. In other > words, the typelib should be able to be created only from information inside > the .py file. > > class MyCOMObject: > ... > def Foo(self, bar): > return "foo" > > Somehow we need to allow this to be annotated so that the programmer can say > "bar must be a string, and the result must be a string". > > Last I thought about this, Python 'decorators' were just a gleam in > someone's eye, so they may offer a solution. Ideally, we would look at > tools like pyrex which may already have grown ways to annotate types of > things it deals with. I was assuming the use of decorators, but it also may be possible to just extend the current class variable syntax. > Another (easier) issue is to decide on the semantics for creation of the > typelib - eg, do we force the programmer to nominate the typelib GUID, and > any version annotations necessary? How hard do we try to stop them shooting > themselves in the foot by, for example, changing method signatures without > chaning the version or GUID? etc. The other idea I had was to use something like zope.interface where one defines the interfaces in a separate class. This sits half way between using something like IDL where the interfaces are in a separate file (and different language) and using decorators / class variables where your class has all the information. The advantage that I can see is that it makes it clearer to the programmer when they need to change the version number / GUID of the typelib. If they change the interface class, they need to change the version number. If they just change the implementation class, they do not. It may also make it easier to write unit tests to check that the implementation class complies with the interface. Thoughts? Cheers, Rasjid. From niki at vintech.bg Wed Aug 1 14:42:07 2007 From: niki at vintech.bg (niki) Date: Wed, 01 Aug 2007 15:42:07 +0300 Subject: [python-win32] Have IHTMLWindow2 objectneed correspondingIHTMLWindow3 object and flash box In-Reply-To: <46AF6FBB.5090405@probo.com> References: <002901c7d071$091c7410$6701a8c0@rjbmain> <003601c7d09f$51b6a410$6701a8c0@rjbmain><46AA7B94.6060909@probo.com><46AA8192.8020409@probo.com> <008301c7d302$6bad8e00$6701a8c0@rjbmain> <003901c7d371$68003e00$6701a8c0@rjbmain> <46AF6FBB.5090405@probo.com> Message-ID: <46B07F9F.10802@vintech.bg> > As I understand it, win32gui exposes the raw GDI APIs and deals with raw > GDI handles as plain integers. win32ui is an attempt to wrap the raw > GDI interfaces with Pythonic wrapper objects. IIRC win32ui is MFC based and better avoided. Niki Spahiev From timr at probo.com Wed Aug 1 18:20:13 2007 From: timr at probo.com (Tim Roberts) Date: Wed, 01 Aug 2007 09:20:13 -0700 Subject: [python-win32] Have IHTMLWindow2 objectneed correspondingIHTMLWindow3 object and flash box In-Reply-To: <46B07F9F.10802@vintech.bg> References: <002901c7d071$091c7410$6701a8c0@rjbmain> <003601c7d09f$51b6a410$6701a8c0@rjbmain><46AA7B94.6060909@probo.com><46AA8192.8020409@probo.com> <008301c7d302$6bad8e00$6701a8c0@rjbmain> <003901c7d371$68003e00$6701a8c0@rjbmain> <46AF6FBB.5090405@probo.com> <46B07F9F.10802@vintech.bg> Message-ID: <46B0B2BD.3060700@probo.com> niki wrote: >> As I understand it, win32gui exposes the raw GDI APIs and deals with raw >> GDI handles as plain integers. win32ui is an attempt to wrap the raw >> GDI interfaces with Pythonic wrapper objects. > > IIRC win32ui is MFC based and better avoided. Why? Just personal bias? There is nothing inherently wrong with MFC. The overhead it adds in this situation is relatively benign, compared to the overhead of Python, and the win32ui objects are more convenient to work with. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Aug 1 18:42:46 2007 From: timr at probo.com (Tim Roberts) Date: Wed, 01 Aug 2007 09:42:46 -0700 Subject: [python-win32] Fwd: pywin32 bugs feedback from learner In-Reply-To: <2d8a7c070707312250v5e787735wf99afe79a3044e4a@mail.gmail.com> References: <2d8a7c070707310925n4138711dr44f318403d251c5b@mail.gmail.com> <2d8a7c070707312250v5e787735wf99afe79a3044e4a@mail.gmail.com> Message-ID: <46B0B806.2020600@probo.com> Huang Guan wrote: > > 1). While using pythoncom develop com+ serivce, executed triumphantly. > But why the pythonservice appear in windows process administer always? > Is there any method to let pythonservice disappear from windows > process administer? Do you mean Task Manager? I don't want you to hide your service from me. It's my computer, and I want to know exactly what's running. > 2). While using pythoncom develop com+ sever, below variable have been > set: > _svc_name_='myservice' > _svc_display_name_='myservice display name' > _svc_description_='myservice description' > Why it can't display server manufacture in the msconfig of windows xp? > How can I have the result as follow: > eg: service name:VMware DHCP Service, service manufacture:VMware,Inc. Msconfig gets this information by reading the "version" resource from the service executable. The executable in your case is "pythonservice.exe" which does not have a "version" resource. It is possible to modify the resources of an executable, and there are tools to do so. Thus, you may be able to insert a version resource into "pythonservice.exe," but I would suggest that it is too much trouble. > 3). while using pywin32 to control IE, make sure spring > OnDocumentComplete affair already, thance, to load local HTML file to > > IE, code as below: > v_s=v_iexplore.Document._oleobj_.QueryInterface(\ > win32com.client.pythoncom.IID_IPersistStreamInit) > if v_s: > print 'Exists pythoncom.IID_IPersistStreamInit ' > v_s.InitNew() > Now it's sure that it initializtion the DHTML controller of IE > successful, and return a PyIPersistStreamInit object, but according to > the help from pywin32, there is only one initNew()method in > PyIPersistStreamInit object. Unless you have used "makepy", the Python "help" doesn't know all of the available properties and methods. In this case, it knows about "InitNew" because you called it. > So What's the method load(),Save(),Release() for PyIPersistStreamInit? > How to find it? How to carry out the similar VC code function as below: > hr = pPersistStreamInit->InitNew(); > if ( SUCCEEDED(hr) ) > { > // Load the contents of the stream. > hr = pPersistStreamInit->Load( pStream ); > } > pPersistStreamInit->Release(); You should be able to use "v_s.Load( pStream )". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Brad.Johnson at ballardtech.com Wed Aug 1 19:14:12 2007 From: Brad.Johnson at ballardtech.com (Brad Johnson) Date: Wed, 1 Aug 2007 17:14:12 +0000 (UTC) Subject: [python-win32] Utilizing a raw IDispatch Pointer from Python References: <000b01c7d3d4$55a5df90$0100a8c0@rupole> Message-ID: > > PyCom_PyObjectFromIUnknown can be used to wrap an IDispatch pointer in a > PyIDispatch object. > > Roger > Thanks a ton, Roger! I spend a good amount of time trying to find an answer to my question, but now that I have that function name there is a bunch of info through Google to get me going! I wish I had known Mark had created this really nice helper library for just such applications... From niki at vintech.bg Thu Aug 2 09:25:09 2007 From: niki at vintech.bg (niki) Date: Thu, 02 Aug 2007 10:25:09 +0300 Subject: [python-win32] Have IHTMLWindow2 objectneed correspondingIHTMLWindow3 object and flash box In-Reply-To: <46B0B2BD.3060700@probo.com> References: <002901c7d071$091c7410$6701a8c0@rjbmain> <003601c7d09f$51b6a410$6701a8c0@rjbmain><46AA7B94.6060909@probo.com><46AA8192.8020409@probo.com> <008301c7d302$6bad8e00$6701a8c0@rjbmain> <003901c7d371$68003e00$6701a8c0@rjbmain> <46AF6FBB.5090405@probo.com> <46B07F9F.10802@vintech.bg> <46B0B2BD.3060700@probo.com> Message-ID: <46B186D5.8000603@vintech.bg> Tim Roberts wrote: > niki wrote: >>> As I understand it, win32gui exposes the raw GDI APIs and deals with raw >>> GDI handles as plain integers. win32ui is an attempt to wrap the raw >>> GDI interfaces with Pythonic wrapper objects. >> IIRC win32ui is MFC based and better avoided. > > Why? Just personal bias? There is nothing inherently wrong with MFC. > The overhead it adds in this situation is relatively benign, compared to > the overhead of Python, and the win32ui objects are more convenient to > work with. Nothing personal, just business. :) E.g. size events works properly only in pythonwin, not in python.exe or COM server. Recompilation with special define can fix this but requires some changes in code. HTH Niki Spahiev From crown.hg at gmail.com Thu Aug 2 09:28:41 2007 From: crown.hg at gmail.com (Huang Guan) Date: Thu, 2 Aug 2007 15:28:41 +0800 Subject: [python-win32] Fwd: pywin32 bugs feedback from learner In-Reply-To: <003601c7d42b$1fb02bf0$6801a8c0@homeoffice.benchmarkinternational.com> References: <2d8a7c070707310925n4138711dr44f318403d251c5b@mail.gmail.com> <2d8a7c070707312250v5e787735wf99afe79a3044e4a@mail.gmail.com> <003601c7d42b$1fb02bf0$6801a8c0@homeoffice.benchmarkinternational.com> Message-ID: <2d8a7c070708020028g5a85603aqfe83b50d14221ad2@mail.gmail.com> Dear Richard, Thank you very much for your quick response. As brief view of PAMIE source code, PAMIE realization is a very special ideas. But it can only be used by Dispatch approaches, it does not use the method DispatchWithEvents; I can't load "Loading HTML content from a Stream" function. Pls see the functional description: http://msdn2.microsoft.com/en-us/library/aa752047.aspx. ONDocumentComplete fire event with win32com.client confirmed, and can with PyIPersistStreamInit.InitNew () to initialize the DHTML Object, Why there aren't load (), Save (), Release () method to perfect PyIPersistStreamInit object? How can I achieve "Loading HTML content from a Stream" function? Ctypes module to be used? How should we use? I sincere hope would have more support from Mr. Mhammond, Mr.Richard and member of pywin32 team. Anxiously awaiting your guidance. Thanks and best regards! Crown.hg 2007/8/1, Richard Bell : > > Concerning questions 3 and 4 ?? > > If part of your work involves controlling IE you may want to study > PAMIE. It provides considerable insight into how to automate IE, navigate > within the DOM, etc. While PAMIE uses late binding, from personnel > experience I've found that early binding of IE's com interface simplifies > development as you can refer to the makepy files. > > Regards, > Richard > > > > ________________________________________ > From: python-win32-bounces at python.org [mailto: > python-win32-bounces at python.org] On Behalf Of Huang Guan > Sent: Wednesday, August 01, 2007 1:51 AM > To: python-win32 at python.org > Subject: [python-win32] Fwd: pywin32 bugs feedback from learner > > From: Huang Guan > Date: 2007-8-1 ????12:25 > Subject: pywin32 bugs feedback from learner > To: mhammond at skippinet.com.au > > Dear pywin32 team, > > First I want to express my appreciation to pywin32, who developed the > excellent extend utility package, which push python of > > win32 develop so quickly. > > I am a learner of pywin32, and I have some queries during my study. May I > draw your kindly attention to the following problem > > and have some nice directions about that? > > 1). While using pythoncom develop com+ serivce, executed triumphantly. But > why the pythonservice appear in windows process > > administer always? Is there any method to let pythonservice disappear from > windows process administer? > > 2). While using pythoncom develop com+ sever, below variable have been > set: > _svc_name_='myservice' > _svc_display_name_='myservice display name' > _svc_description_='myservice description' > Why it can't display server manufacture in the msconfig of windows xp? > How can I have the result as follow: > eg: service name:VMware DHCP Service, service manufacture:VMware,Inc. > > 3). while using pywin32 to control IE, make sure spring OnDocumentComplete > affair already, thance, to load local HTML file to > > IE, code as below: > v_s=v_iexplore.Document._oleobj_.QueryInterface(\ > win32com.client.pythoncom.IID_IPersistStreamInit) > if v_s: > print 'Exists pythoncom.IID_IPersistStreamInit ' > v_s.InitNew() > Now it's sure that it initializtion the DHTML controller of IE successful, > and return a PyIPersistStreamInit object, but > > according to the help from pywin32, there is only one initNew()method in > PyIPersistStreamInit object. So What's the method > > load(),Save(),Release() for PyIPersistStreamInit? How to find it? How to > carry out the similar VC code function as below: > hr = pPersistStreamInit->InitNew(); > if ( SUCCEEDED(hr) ) > { > // Load the contents of the stream. > hr = pPersistStreamInit->Load( pStream ); > } > pPersistStreamInit->Release(); > > 4). While using pywin32 to control IE, > It's certain that using win32com.client.Dispatch return IE object. > It can execute the JavaScript method of current transfer page, > the following code has been execute and come through: > v_iexplore=win32com.client.Dispatch('InternetExplorer.Application') > v_iexplore.Navigate(' > http://www.cpplab.com/Articles/JSCalls/TestPage/JSCallTestPage.htm' ) > v_id=v_iexplore.Document.Script._oleobj_.GetIDsOfNames('Welcome') > v_iexplore.Document.Script._oleobj_.Invoke(\ > v_id, 0, win32com.client.pythoncom.DISPATCH_METHOD, True,\ > 'HuanGuan') > But: It can't execute the above code exactly In the > win32com.client.DispatchWithEvents return IE object. > How to solve this problem ? Would you pls kindly to show me some examples? > > Anxiously awaiting your kindly comments. > > Thanks and best regards! > crown.hg > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070802/7de8c0a3/attachment-0001.htm From rwupole at msn.com Thu Aug 2 10:37:34 2007 From: rwupole at msn.com (Roger Upole) Date: Thu, 2 Aug 2007 04:37:34 -0400 Subject: [python-win32] Fwd: pywin32 bugs feedback from learner Message-ID: <002501c7d4e0$624154c0$0100a8c0@rupole> Huang Guan wrote: > Thank you very much for your quick response. > As brief view of PAMIE source code, PAMIE realization is a very special ideas. > But it can only be used by Dispatch approaches, it does not use the > method DispatchWithEvents; > I can't load "Loading HTML content from a Stream" function. > Pls see the functional description: > http://msdn2.microsoft.com/en-us/library/aa752047.aspx. import win32com.client, pythoncom class IE_Events: def OnNavigateComplete2(self, pDisp, URL): print 'OnNavigateComplete2:', URL ie=win32com.client.DispatchWithEvents('internetexplorer.application', IE_Events) ie.Visible=1 ie.Navigate('about:blank') p=ie.Document._oleobj_.QueryInterface(pythoncom.IID_IPersistStreamInit) p.Load() Roger From zorg724 at yahoo.fr Thu Aug 2 12:46:37 2007 From: zorg724 at yahoo.fr (sccs cscs) Date: Thu, 2 Aug 2007 12:46:37 +0200 (CEST) Subject: [python-win32] Problem with Rhapsody automation: It is Impossible? Message-ID: <539521.62067.qm@web90509.mail.mud.yahoo.com> Hello, Our team uses Visual Basic for Rhapsody Automation, but we now would like to use Python. But it seems to be IMPOSSIBLE. Indeed, it seems that there is no Polymorphism in Python so that when i get back a daughter instance Class, it does not not work, i continue to have the corresponding Mother Class. Exemple: Here is my code: The Application used is "Rhapsody" import pythoncom # Window word wrapper for Rhapsody import win32com.client # Window word wrapper for Rhapsody import sys class TestRhapsody(object): def connectRhapsody(self): print "connecting to Rhapsody.." self.rhapsody = win32com.client.gencache.EnsureDispatch("Rhapsody.Application") self.project = self.rhapsody.activeProject() if self.project == None : raise Exception("Load a Rhapsody project!") print "OK" def listAllLanguageTypes(self): theIRPModelElement = self.project.findNestedElementRecursive("T_Boolean", "Type") print theIRPModelElement.getFullPathName() print theIRPModelElement.name # HERE IS THE ERROR: The theIRPModelElement is a "IRPType" which is # a specialization of a IRPModelElement, but Python continue to see it like an IRPModelElement print "Declaration : %s\n" % (theIRPModelElement.declaration) def test(): try: thePatch = TestRhapsody() thePatch.connectRhapsody() thePatch.listAllLanguageTypes() except Exception ,err: print "ERROR ! \n %s"%( str (err)) if __name__ == '__main__': test() I got the following message: '' object has no attribute 'declaration' >>> Here is the Py32Com Wrapper extract: class IRPModelElement(DispatchBaseClass): """IRPModelElement Interface""" CLSID = IID('{57DBF9EF-F318-11D2-B825-00104B3E6572}') coclass_clsid = IID('{57DBF9F0-F318-11D2-B825-00104B3E6572}') class IRPType(DispatchBaseClass): """IRPType Interface""" CLSID = IID('{EB754AE3-0D76-11D3-8E4D-0060080B70BC}') coclass_clsid = IID('{EB754AE4-0D76-11D3-8E4D-0060080B70BC}') # Result is of type IRPFlowchart def addActivityDiagram(self): """method addActivi _prop_map_get_ = { ... "currentDirectory": (110, 2, (8, 0), (), "currentDirectory", None), "declaration": (803, 2, (8, 0), (), "declaration", None), ... --------------------------------- Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070802/fedd0fbc/attachment.html From torriem at chem.byu.edu Thu Aug 2 16:59:11 2007 From: torriem at chem.byu.edu (Michael L Torrie) Date: Thu, 02 Aug 2007 08:59:11 -0600 Subject: [python-win32] Problem with Rhapsody automation: It is Impossible? In-Reply-To: <539521.62067.qm@web90509.mail.mud.yahoo.com> References: <539521.62067.qm@web90509.mail.mud.yahoo.com> Message-ID: <46B1F13F.9000200@chem.byu.edu> sccs cscs wrote: > Hello, Our team uses Visual Basic for Rhapsody Automation, > but we now would like to use Python. But it seems to be IMPOSSIBLE. > Indeed, it seems that there is no Polymorphism in Python so that when i get back > a daughter instance Class, it does not not work, i continue to have the corresponding Mother Class. > Exemple: Python does have polymorphism, but it's very different from how VB or C++ thinks of polymorphism. It's a purer form of polymorphism, in my opinion. More smalltalk-like. Python instances are all first-class objects. So Python implements a protocol-based polymorphism. In other words, rather than say I want an object of type foo or a descendant class, we just say, we want an object foo that implements a method bar. It doesn't matter what class that object is, so long as it implements something we want. In the long run, this gives consistent behavior that's very flexible and extensible. None of that solves your problem though. For those of us not familiar with driving an application through COM, can you explain how how the polymorphism worked in your VB code? Perhaps there's a pythonic way of doing this. > > Here is my code: > > The Application used is "Rhapsody" > > import pythoncom # Window word wrapper for Rhapsody > import win32com.client # Window word wrapper for Rhapsody > import sys > > class TestRhapsody(object): > def connectRhapsody(self): > print "connecting to Rhapsody.." > self.rhapsody = win32com.client.gencache.EnsureDispatch("Rhapsody.Application") > self.project = self.rhapsody.activeProject() > if self.project == None : > raise Exception("Load a Rhapsody project!") > print "OK" > def listAllLanguageTypes(self): > theIRPModelElement = self.project.findNestedElementRecursive("T_Boolean", "Type") > print theIRPModelElement.getFullPathName() > print theIRPModelElement.name > # HERE IS THE ERROR: The theIRPModelElement is a "IRPType" which is > # a specialization of a IRPModelElement, but Python continue to see it like an IRPModelElement > > print "Declaration : %s\n" % (theIRPModelElement.declaration) > > def test(): > try: > thePatch = TestRhapsody() > thePatch.connectRhapsody() > thePatch.listAllLanguageTypes() > except Exception ,err: > print "ERROR ! \n %s"%( str (err)) > if __name__ == '__main__': > test() > > I got the following message: > '' > object has no attribute 'declaration' > > Here is the Py32Com Wrapper extract: > class IRPModelElement(DispatchBaseClass): > """IRPModelElement Interface""" > CLSID = IID('{57DBF9EF-F318-11D2-B825-00104B3E6572}') > coclass_clsid = IID('{57DBF9F0-F318-11D2-B825-00104B3E6572}') > > class IRPType(DispatchBaseClass): > """IRPType Interface""" > CLSID = IID('{EB754AE3-0D76-11D3-8E4D-0060080B70BC}') > coclass_clsid = IID('{EB754AE4-0D76-11D3-8E4D-0060080B70BC}') > # Result is of type IRPFlowchart > def addActivityDiagram(self): > """method addActivi > > > _prop_map_get_ = { > ... > "currentDirectory": (110, 2, (8, 0), (), "currentDirectory", None), > "declaration": (803, 2, (8, 0), (), "declaration", None), > ... > > > > > --------------------------------- > Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail > > > ------------------------------------------------------------------------ > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From malaclypse2 at gmail.com Thu Aug 2 20:17:15 2007 From: malaclypse2 at gmail.com (Jerry Hill) Date: Thu, 2 Aug 2007 14:17:15 -0400 Subject: [python-win32] Problem with Rhapsody automation: It is Impossible? In-Reply-To: <539521.62067.qm@web90509.mail.mud.yahoo.com> References: <539521.62067.qm@web90509.mail.mud.yahoo.com> Message-ID: <16651e80708021117r390fb6p299203af322948fb@mail.gmail.com> On 8/2/07, sccs cscs wrote: > # HERE IS THE ERROR: The theIRPModelElement is a "IRPType" which is > # a specialization of a IRPModelElement, but Python continue to see > it like an IRPModelElement Take a look at the win32com.client.CastTo() function. You probably want something like: theIRPModelElement = win32com.client.CastTo(theIRPModelElement, 'IRPType') I'm not sure how you would do it if you don't know ahead of time what subclass you're going to get back. -- Jerry From timr at probo.com Thu Aug 2 20:18:01 2007 From: timr at probo.com (Tim Roberts) Date: Thu, 02 Aug 2007 11:18:01 -0700 Subject: [python-win32] Problem with Rhapsody automation: It is Impossible? In-Reply-To: <539521.62067.qm@web90509.mail.mud.yahoo.com> References: <539521.62067.qm@web90509.mail.mud.yahoo.com> Message-ID: <46B21FD9.4080708@probo.com> sccs cscs wrote: > Hello, Our team uses Visual Basic for Rhapsody Automation, > but we now would like to use Python. But it seems to be IMPOSSIBLE. > Indeed, it seems that there is no Polymorphism in Python so that when > i get back > a daughter instance Class, it does not not work, i continue to have > the corresponding Mother Class. This kind of interface inheritance is not commonly used in COM, precisely because it is almost impossible to use in a dispatch-based interface like what Python uses. If Python believes that findNestedElementRecursive returns an IRPModelElement, there's no good way for it to know any differently. If you know the object also implements IRPType, you can cast it: theIrpType = win32com.client.CastTo(theIRPModelElement, 'IRPType') -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From crown.hg at gmail.com Fri Aug 3 16:30:06 2007 From: crown.hg at gmail.com (Huang Guan) Date: Fri, 3 Aug 2007 22:30:06 +0800 Subject: [python-win32] Python-win32 Digest, Vol 53, Issue 2 In-Reply-To: <001c01c7d5da$720d9cb0$7001a8c0@kwfiona> References: <001c01c7d5da$720d9cb0$7001a8c0@kwfiona> Message-ID: <2d8a7c070708030730r1663ee98w22d2e6766dca322b@mail.gmail.com> Dear Tim Roberts, Thanks for your kindly comments. Pls see my question as below letter in blue and give me some suggestion accordingly. Huang Guan wrote: > > 1). While using pythoncom develop com+ serivce, executed triumphantly. > But why the pythonservice appear in windows process administer always? > Is there any method to let pythonservice disappear from windows > process administer? Do you mean Task Manager? I don't want you to hide your service from me. It's my computer, and I want to know exactly what's running. {Yes, I am writting a similar module. An general user of windows user group could shut pythonservice.exe in the task manager, and my python service would be shutdown in the same time.Is there any good ways except hide pythonservice.exe process?} > > 2). While using pythoncom develop com+ sever, below variable have been > > set: > > _svc_name_='myservice' > > _svc_display_name_='myservice display name' > > _svc_description_='myservice description' > > Why it can't display server manufacture in the msconfig of windows xp? > > How can I have the result as follow: > > eg: service name:VMware DHCP Service, service manufacture:VMware,Inc. > > Msconfig gets this information by reading the "version" resource from > the service executable. The executable in your case is > "pythonservice.exe" which does not have a "version" resource. > > It is possible to modify the resources of an executable, and there are > tools to do so. Thus, you may be able to insert a version resource into > "pythonservice.exe," but I would suggest that it is too much trouble. {I use ResHacker tool to change the Version info of vmnetdhcp.exe file, change 'VALUE "CompanyName", "VMware, inc."' to be 'VALUE "CompanyName", "VMware,Crop."',then??show "VMware.Inc" in Msconfig successfully, as" Vmware.Crop."??But I use the same method on pythonservice.exe??it doesn't work? How can I do for it?} > 3). while using pywin32 to control IE, make sure spring > > OnDocumentComplete affair already, thance, to load local HTML file to > > > > IE, code as below: > > v_s=v_iexplore.Document._oleobj_.QueryInterface(\ > > win32com.client.pythoncom.IID_IPersistStreamInit) > > if v_s: > > print 'Exists pythoncom.IID_IPersistStreamInit ' > > v_s.InitNew() > > Now it's sure that it initializtion the DHTML controller of IE > > successful, and return a PyIPersistStreamInit object, but according to > > the help from pywin32, there is only one initNew()method in > > PyIPersistStreamInit object. > > Unless you have used "makepy", the Python "help" doesn't know all of the > available properties and methods. In this case, it knows about "InitNew" > because you called it. > > > > So What's the method load(),Save(),Release() for PyIPersistStreamInit? > > How to find it? How to carry out the similar VC code function as below: > > hr = pPersistStreamInit->InitNew(); > > if ( SUCCEEDED(hr) ) > > { > > // Load the contents of the stream. > > hr = pPersistStreamInit->Load( pStream ); > > } > > pPersistStreamInit->Release(); > > You should be able to use "v_s.Load( pStream )". {without using makepy, according to below suggestion by Mr.Roger: ie.Navigate('about:blank') p=ie.Document._oleobj_.QueryInterface( pythoncom.IID_IPersistStreamInit ) p.Load() in existence p.Load() method confirmed??but how to do could use P.Save() save PyISteram to a string variable(include Html header info????How to do could load to ie.document via p.Load() from HTML SOURCE string variable? This is my greatest concern problem.I re-sent this question to Roger and pywin32 mail list, pls do me the favor on these problem. Thank you. } additional attached(?? 4). While using pywin32 to control IE, It's certain that using win32com.client.Dispatch return IE object. It can execute the JavaScript method of current transfer page, the following code has been execute and come through: v_iexplore=win32com.client.Dispatch('InternetExplorer.Application') v_iexplore.Navigate(' http://www.cpplab.com/Articles/JSCalls/TestPage/JSCallTestPage.htm' ) v_id=v_iexplore.Document .Script._oleobj_.GetIDsOfNames('Welcome') v_iexplore.Document.Script._oleobj_.Invoke(\ v_id, 0, win32com.client.pythoncom.DISPATCH_METHOD, True,\ 'HuanGuan') But: It can't execute the above code exactly In the win32com.client.DispatchWithEvents return IE object. How to solve this problem ? Would you pls kindly to show me some examples? -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070803/6bd4b9b8/attachment.html From crown.hg at gmail.com Fri Aug 3 16:33:44 2007 From: crown.hg at gmail.com (Huang Guan) Date: Fri, 3 Aug 2007 22:33:44 +0800 Subject: [python-win32] Python-win32 Digest, Vol 53, Issue 3 In-Reply-To: References: Message-ID: <2d8a7c070708030733s1f750adfua717fbacef94c079@mail.gmail.com> Dear Roger, Thanks for your comments, according the code suggestion you gave: ie.Navigate('about:blank') p=ie.Document._oleobj_.QueryInterface(pythoncom.IID_IPersistStreamInit) p.Load(), confirm Load() metchod in existence. Could you give some examples on how to use PyISteream for my reference? It's very difficult to find use paradigm in pywin32.chm. 1.) How can we use p.Save() method, save html source and html header into a string variant? 2.) same as part 1,how to use a string variant ??string=html source??,load into ie.Document control? 3) If execute p.Save (), and p.Load () successfully, as initialize ie.Document control with ie.Navigate ( 'about : blank') before, will the IE original URL address bar become "about : blank"? I want to keep the original IE address bar URL unchanged. Is it possible? Would you pls show me some example, roger? Anxiously awaiting your further comments. Thanks & best regards! Crown.hg 2007/8/2, python-win32-request at python.org : > > Send Python-win32 mailing list submissions to > python-win32 at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-win32 > or, via email, send a message with subject or body 'help' to > python-win32-request at python.org > > You can reach the person managing the list at > python-win32-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Python-win32 digest..." > > > Today's Topics: > > 1. Fwd: pywin32 bugs feedback from learner (Roger Upole) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 2 Aug 2007 04:37:34 -0400 > From: "Roger Upole" > Subject: [python-win32] Fwd: pywin32 bugs feedback from learner > To: > Message-ID: <002501c7d4e0$624154c0$0100a8c0 at rupole> > Content-Type: text/plain; format=flowed; charset="iso-8859-1"; > reply-type=original > > Huang Guan wrote: > > Thank you very much for your quick response. > > As brief view of PAMIE source code, PAMIE realization is a very special > ideas. > > But it can only be used by Dispatch approaches, it does not use the > > method DispatchWithEvents; > > I can't load "Loading HTML content from a Stream" function. > > Pls see the functional description: > > http://msdn2.microsoft.com/en-us/library/aa752047.aspx. > > > import win32com.client, pythoncom > class IE_Events: > def OnNavigateComplete2(self, pDisp, URL): > print 'OnNavigateComplete2:', URL > > ie=win32com.client.DispatchWithEvents('internetexplorer.application', > IE_Events) > ie.Visible=1 > ie.Navigate('about:blank') > p=ie.Document._oleobj_.QueryInterface(pythoncom.IID_IPersistStreamInit) > p.Load() > > Roger > > > > ------------------------------ > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > End of Python-win32 Digest, Vol 53, Issue 3 > ******************************************* > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070803/cd0ab9f3/attachment.htm From scripteaze at gmail.com Fri Aug 3 16:47:37 2007 From: scripteaze at gmail.com (scripteaze) Date: Fri, 3 Aug 2007 09:47:37 -0500 Subject: [python-win32] [ looking for beginer python newsgroups ] Message-ID: <3ab717830708030747x2affdce9q4dbb028acc4a7687@mail.gmail.com> Hello all, im new to the python scene and was wondering if there were any beginer python newsgroups similar to this. I did look in the python.org list or newsgroups and did not see one avail. THnX -- -=scripteaze=- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070803/1f6a5165/attachment.html From graemeglass at gmail.com Fri Aug 3 17:14:08 2007 From: graemeglass at gmail.com (Graeme Glass) Date: Fri, 3 Aug 2007 17:14:08 +0200 Subject: [python-win32] [ looking for beginer python newsgroups ] In-Reply-To: <3ab717830708030747x2affdce9q4dbb028acc4a7687@mail.gmail.com> References: <3ab717830708030747x2affdce9q4dbb028acc4a7687@mail.gmail.com> Message-ID: On 8/3/07, scripteaze wrote: > > Hello all, im new to the python scene and was wondering if there were any > beginer python newsgroups similar to this. I did look in the python.orglist or newsgroups and did not see one avail. > > THnX > > -- > > > > > -=scripteaze=- > For general python related questions: comp.lang.python at googlegroups.com is a good list For win32 related python question, this list is the place to be. For getting started with python take a look here: http://docs.python.org/tut/tut.html -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070803/77f8d15a/attachment.htm From rbell01824 at earthlink.net Fri Aug 3 18:39:18 2007 From: rbell01824 at earthlink.net (Richard Bell) Date: Fri, 3 Aug 2007 11:39:18 -0500 Subject: [python-win32] Have IHTMLWindow2 objectneed correspondingIHTMLWindow3 object and flash box In-Reply-To: <008301c7d302$6bad8e00$6701a8c0@rjbmain> References: <002901c7d071$091c7410$6701a8c0@rjbmain> <003601c7d09f$51b6a410$6701a8c0@rjbmain><46AA7B94.6060909@probo.com><46AA8192.8020409@probo.com> <008301c7d302$6bad8e00$6701a8c0@rjbmain> Message-ID: <007001c7d5ec$d6a69cf0$6701a8c0@rjbmain> I've cleaned up the flash code and am posting it as possibly helpful to others. Interestingly, I'm unable to find a way to SetROP2 in win32gui! So the side discussion about win32gui v. win32ui may be a bit moot. If there is a way I'd be curious to know what it is as it appears to me that there is a SetROP2 method that is part of window's basic GDI library (but since I'm definitely not a window's GDI programmer I could well be entirely wrong). Thanks again for the help. Regards, Richard BTW, the issue of finding the screen coordinates of the HTML tag turns out to be VERY tricky. I'm still working on a solution having discovered that it depends on (among lord knows what other things) the presence of a DOCTYPE declaration in the page source and nesting of scrollable windows within the page. If anyone is interested I'll post a solution when I find one that actually works. --- code --- def flash2(left, top, width, height ): """ put a flashing box at cordinates """ # try to use only win32gui from win32con import PS_SOLID, HOLLOW_BRUSH, R2_XORPEN # win32gui source http://pywin32.cvs.sourceforge.net/pywin32/pywin32/win32/src/?pathrev=b208 hdc = win32gui.GetDC(0) # int handle of DC for screen hpen = win32gui.CreatePen( PS_SOLID, 3, 0x00ff00) hbrush = win32gui.GetStockObject( HOLLOW_BRUSH ) hpenOld = win32gui.SelectObject(hdc, hpen) hbrushOld = win32gui.SelectObject(hdc, hbrush) #win32gui.SetROP2(hdc, R2_XORPEN) # apparently not implemented in win32gui pycdc = win32ui.CreateDCFromHandle(hdc) # PyCDC object pycdc.SetROP2(R2_XORPEN) # R2_XOR for i in range(0,5): # 5 flashes win32gui.Rectangle(hdc, left, top, left+width, top + height) # draw it time.sleep(.250) # hang out win32gui.Rectangle(hdc, left, top, left+width, top + height) # again time.sleep(.250) # hang out win32gui.SelectObject(hdc, hpenOld) # put back old pen win32gui.DeleteObject(hpen) win32gui.SelectObject(hdc, hbrushOld) # put back old brush win32gui.DeleteObject(hbrush) win32gui.ReleaseDC(hdc,0) # release the DC --- end code --- From timr at probo.com Fri Aug 3 18:48:33 2007 From: timr at probo.com (Tim Roberts) Date: Fri, 03 Aug 2007 09:48:33 -0700 Subject: [python-win32] pywin32 bugs feedback from learner In-Reply-To: <2d8a7c070708030730r1663ee98w22d2e6766dca322b@mail.gmail.com> References: <001c01c7d5da$720d9cb0$7001a8c0@kwfiona> <2d8a7c070708030730r1663ee98w22d2e6766dca322b@mail.gmail.com> Message-ID: <46B35C61.9020204@probo.com> Huang Guan wrote: > Dear Tim Roberts, > > Do you mean Task Manager? I don't want you to hide your service from me. > It's my computer, and I want to know exactly what's running. > {Yes, I am writting a similar module. An general user of windows user > group could shut pythonservice.exe in the task manager, and my python > service would be shutdown in the same time.Is there any good ways > except hide pythonservice.exe process?} No legitimate process should be able to hide from me. It's MY computer, and I have every right to know exactly what is running on it. And if I decide I don't want your process to run, it's not up to you to stop me. Don't do this. If you do, pythonservice.exe will get a reputation as being "malware", and all Python users will suffer. > {I use ResHacker tool to change the Version info of vmnetdhcp.exe > file, change 'VALUE "CompanyName", "VMware, inc."' to be 'VALUE > "CompanyName", "VMware,Crop."',then??show "VMware.Inc" in Msconfig > successfully, as"Vmware.Crop."??But I use the same method on > pythonservice.exe??it doesn't work? How can I do for it?} PythonService.exe does not seem to have a version resource at all. I don't know if ResHacker has the ability to insert a version resource into a file that does not have one. And even if it could, I'm not convinced that it is ethical. PythonService.exe was not created by you. Why should you have the right to claim it? > {without using makepy, according to below suggestion by Mr.Roger: > ie.Navigate('about:blank') > p=ie.Document._oleobj_.QueryInterface(pythoncom.IID_IPersistStreamInit ) > p.Load() > in existence p.Load() method confirmed??but how to do could use > P.Save() save PyISteram to a string variable(include Html header > info????How to do could load to ie.document via p.Load() from HTML > SOURCE string variable? This is my greatest concern problem.I re-sent > this question to Roger and pywin32 mail list, pls do me the favor on > these problem. Thank you. } To do this, you will somehow have to create a PyIStream object that saves to a string. I Googled for "using istream python" and did find one or two examples of people doing this. > 4). While using pywin32 to control IE, > It's certain that using win32com.client.Dispatch return IE object. > It can execute the JavaScript method of current transfer page, > the following code has been execute and come through: > v_iexplore=win32com.client.Dispatch('InternetExplorer.Application') > v_iexplore.Navigate(' > http://www.cpplab.com/Articles/JSCalls/TestPage/JSCallTestPage.htm' > ) > v_id=v_iexplore.Document > .Script._oleobj_.GetIDsOfNames('Welcome') > v_iexplore.Document.Script._oleobj_.Invoke(\ > v_id, 0, win32com.client.pythoncom.DISPATCH_METHOD, True,\ > 'HuanGuan') > But: It can't execute the above code exactly In the > win32com.client.DispatchWithEvents return IE object. > How to solve this problem ? Would you pls kindly to show me some examples? It's interesting that you showed us the code that worked, but not the code that didn't work. That's what you need to fix, right? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rwupole at msn.com Sat Aug 4 01:09:48 2007 From: rwupole at msn.com (Roger Upole) Date: Fri, 3 Aug 2007 19:09:48 -0400 Subject: [python-win32] Re: Python-win32 Digest, Vol 53, Issue 3 Message-ID: <000201c7d623$665f4eb0$0100a8c0@rupole> Huang Guan wrote: > Thanks for your comments, according the code suggestion you gave: > ie.Navigate('about:blank') > p=ie.Document._oleobj_.QueryInterface(pythoncom.IID_IPersistStreamInit) > p.Load(), > confirm Load() metchod in existence. > > Could you give some examples on how to use PyISteream for my > reference? It's very difficult to find use paradigm in pywin32.chm. > > 1.) How can we use p.Save() method, > save html source and html header into a string variant? > 2.) same as part 1,how to use a string variant ??string=html > source??,load into ie.Document control? > 3) If execute p.Save (), and p.Load () successfully, as initialize > ie.Document control with ie.Navigate ( 'about : blank') before, will > the IE original URL address bar become "about : blank"? I want to keep > the original IE address bar URL unchanged. Is it possible? There are a couple of IStream implementations included in the Pywin32 distribution. Take a look at win32com.server.util.FileStream for file operations, and \win32com\test\testStreams.py for a string based approach. Here's an example of creating an IStream suitable for loading content from a file: import pythoncom from win32com.server import util f=open('somepage.html','r') fs=util.FileStream(f) istream=util.wrap(fs, pythoncom.IID_IStream) If you already have a document loaded, you can omit the Navigate part, and the URL remains as it was. Roger From mc at mclaveau.com Sat Aug 4 16:31:34 2007 From: mc at mclaveau.com (Michel Claveau) Date: Sat, 4 Aug 2007 16:31:34 +0200 Subject: [python-win32] pywin32 bugs feedback from learner References: <001c01c7d5da$720d9cb0$7001a8c0@kwfiona><2d8a7c070708030730r1663ee98w22d2e6766dca322b@mail.gmail.com> <46B35C61.9020204@probo.com> Message-ID: <000e01c7d6a4$2ee30900$0601a8c0@PORTABLES> Hello! > v_id=v_iexplore.Document.Script._oleobj_.GetIDsOfNames('Welcome') > v_iexplore.Document.Script._oleobj_.Invoke(v_id, 0, > win32com.client.pythoncom.DISPATCH_METHOD, True,'HuanGuan') Ppffffuuuiiiitttt !!! These lines are very too complex for my little brain. Try this : v_iexplore.Document.parentWindow.Welcome() (more easy, more nice, and most of all, more fun) @-salutations Michel Claveau From lucemia51 at hotmail.com Sat Aug 4 20:14:51 2007 From: lucemia51 at hotmail.com (lucemia) Date: Sun, 5 Aug 2007 02:14:51 +0800 Subject: [python-win32] COM object Dispatch Error Message-ID: Hi: I have a problem about using win32com in python. I am using a software called CSTStudio to do my project. CSTStudiod could be used in VBA Script currectly to start or execute program via COM interface, but it crashed in python win32com. > h = win32com.client.Dispatch('CSTStudio.Application') <--- it is ok! > mws = h.OpenFile('C:\\CSTProject\\ga2layer_v1.psf') <--- the CSTStudio will open the file currectly but failed to retrun mws. What should i do to solve this problem? Thanks lucemia Error Message: Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. **************************************************************** Personal firewall software may warn about the connection IDLE makes to its subprocess using this computer's internal loopback interface. This connection is not visible on any external interface and no data is sent to or received from the Internet. **************************************************************** IDLE 1.2 >>> import win32com >>> import win32com.client >>> win32com.client.Dispatch('CSTStudio.Application') >>> h = win32com.client.Dispatch('CSTStudio.Application') >>> mws = h.OpenFile('C:\\CSTProject\\ga2layer_v1.psf') Traceback (most recent call last): File "", line 1, in mws = h.OpenFile('C:\\CSTProject\\ga2layer_v1.psf') File "", line 2, in OpenFile File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 290, in _get_good_object_ return self._get_good_single_object_(ob) File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 275, in _get_good_single_object_ return self._wrap_dispatch_(ob, userName, ReturnCLSID) File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line 123, in _wrap_dispatch_ return Dispatch(ob, userName, returnCLSID,None,UnicodeToString) File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line 96, in Dispatch return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx) File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line 44, in __WrapDispatch return dynamic.Dispatch(dispatch, userName, WrapperClass, typeinfo, UnicodeToString=UnicodeToString,clsctx=clsctx) File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 114, in Dispatch typecomp = typeinfo.GetTypeComp() AttributeError: 'NoneType' object has no attribute 'GetTypeComp' >>> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070805/5c7e5aaa/attachment.html From crown.hg at gmail.com Tue Aug 7 02:23:41 2007 From: crown.hg at gmail.com (Huang Guan) Date: Tue, 7 Aug 2007 08:23:41 +0800 Subject: [python-win32] Python-win32 Digest, Vol 53, Issue 6 In-Reply-To: <2d8a7c070708060900y392e4980p812b9794f312da28@mail.gmail.com> References: <2d8a7c070708060900y392e4980p812b9794f312da28@mail.gmail.com> Message-ID: <2d8a7c070708061723j328db9f7n566fa66403c7dc15@mail.gmail.com> Dear Sirs, Thanks for the detail comments from Tim Roberts,Roger and Michel Claveau, question 1, 2, 4 have been finished. I am doing a anti pornography and violence software, which face to the youngers. Convenience to distribute the software and restrictc some mischievous youngsters to shut down this program, that's why I need to settel the problem 1. Regarding to the problem 2, I found it and major in reserching technic, not mean others. Now we could reolve the problem 1 and 2, it's unneccessary to discut it any more. Thanks for the Michel Claveau's suggestion help me settled problem 4. question 1, 2, 4 have been finished. I need your help on question 3 still: import pythoncom from win32com.server import util f=open('somepage.html','r') fs=util.FileStream(f) istream=util.wrap(fs, pythoncom.IID_IStream ) p=ie.Document._oleobj_.QueryInterface (pythoncom.IID_IPersistStreamInit) p.Load(istream) p.Load(istream)tested and excuted successful, thank you. f=open('somepage.html','w+') fs=util.FileStream (f) istream=util.wrap(fs, pythoncom.IID_IStream) p=ie.Document._oleobj_.QueryInterface(pythoncom.IID_IPersistStreamInit) p.Save(istream,True) Why p.Save(istream,True) can excuted, but error massage as below: pythoncom error: Unexpected gateway error : an integer is required check somepage.html file current dir,is exists,size:5kb, but the file is not complete html source. How to resolve the p.Save() problem? v_StringIO=StringIO.StringIO() v_f_object=open(' somepage.html','r') v_StringIO.write(v_f_object.read()) v_f_object.close() fs=util.FileStream(StringIO) istream=util.wrap(fs, pythoncom.IID_IStream) p=ie.Document._oleobj_.QueryInterface (pythoncom.IID_IPersistStreamInit) p.Load(istream) p.Load(istream) excuted successfully, but do not get values from v_StringIO, why? Thanks & best regards! Crown.hg > Message: 4 > Date: Fri, 03 Aug 2007 09:48:33 -0700 > From: Tim Roberts < timr at probo.com> > Subject: Re: [python-win32] pywin32 bugs feedback from learner > To: python-win32 at python.org > Message-ID: < 46B35C61.9020204 at probo.com> > Content-Type: text/plain; charset=GB2312 > > Huang Guan wrote: > > Dear Tim Roberts, > > > > Do you mean Task Manager? I don't want you to hide your service from me. > > It's my computer, and I want to know exactly what's running. > > {Yes, I am writting a similar module. An general user of windows user > > group could shut pythonservice.exe in the task manager, and my python > > service would be shutdown in the same time.Is there any good ways > > except hide pythonservice.exe process?} > > No legitimate process should be able to hide from me. It's MY computer, > and I have every right to know exactly what is running on it. And if I > decide I don't want your process to run, it's not up to you to stop me. > > Don't do this. If you do, pythonservice.exe will get a reputation as > being "malware", and all Python users will suffer. > > > > {I use ResHacker tool to change the Version info of vmnetdhcp.exe > > file, change 'VALUE "CompanyName", "VMware, inc."' to be 'VALUE > > "CompanyName", "VMware,Crop."',then??show "VMware.Inc" in Msconfig > > successfully, as" Vmware.Crop."??But I use the same method on > > pythonservice.exe??it doesn't work? How can I do for it?} > > PythonService.exe does not seem to have a version resource at all. I > don't know if ResHacker has the ability to insert a version resource > into a file that does not have one. > > And even if it could, I'm not convinced that it is ethical. > PythonService.exe was not created by you. Why should you have the right > to claim it? > > > > {without using makepy, according to below suggestion by Mr.Roger: > > ie.Navigate('about:blank') > > p=ie.Document._oleobj_.QueryInterface(pythoncom.IID_IPersistStreamInit ) > > p.Load() > > in existence p.Load() method confirmed??but how to do could use > > P.Save() save PyISteram to a string variable(include Html header > > info????How to do could load to ie.document via p.Load() from HTML > > SOURCE string variable? This is my greatest concern problem.I re-sent > > this question to Roger and pywin32 mail list, pls do me the favor on > > these problem. Thank you. } > > To do this, you will somehow have to create a PyIStream object that > saves to a string. I Googled for "using istream python" and did find one > or two examples of people doing this. > > > > 4). While using pywin32 to control IE, > > It's certain that using win32com.client.Dispatch return IE object. > > It can execute the JavaScript method of current transfer page, > > the following code has been execute and come through: > > v_iexplore=win32com.client.Dispatch('InternetExplorer.Application') > > v_iexplore.Navigate(' > > http://www.cpplab.com/Articles/JSCalls/TestPage/JSCallTestPage.htm' > > < http://www.cpplab.com/Articles/JSCalls/TestPage/JSCallTestPage.htm%27 > >) > > v_id=v_iexplore.Document > > .Script._oleobj_.GetIDsOfNames('Welcome') > > v_iexplore.Document.Script._oleobj_.Invoke(\ > > v_id, 0, win32com.client.pythoncom.DISPATCH_METHOD, True,\ > > 'HuanGuan') > > But: It can't execute the above code exactly In the > > win32com.client.DispatchWithEvents return IE object. > > How to solve this problem ? Would you pls kindly to show me some > examples? > > It's interesting that you showed us the code that worked, but not the > code that didn't work. That's what you need to fix, right? > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > > > ------------------------------ > > Message: 5 > Date: Fri, 3 Aug 2007 19:09:48 -0400 > From: "Roger Upole" < rwupole at msn.com > > Subject: [python-win32] Re: Python-win32 Digest, Vol 53, Issue 3 > To: > Message-ID: <000201c7d623$665f4eb0$0100a8c0 at rupole> > Content-Type: text/plain; format=flowed; charset="iso-8859-1"; > reply-type=original > > Huang Guan wrote: > > Thanks for your comments, according the code suggestion you gave: > > ie.Navigate('about:blank') > > p=ie.Document._oleobj_.QueryInterface(pythoncom.IID_IPersistStreamInit) > > p.Load(), > > confirm Load() metchod in existence. > > > > Could you give some examples on how to use PyISteream for my > > reference? It's very difficult to find use paradigm in pywin32.chm. > > > > 1.) How can we use p.Save() method, > > save html source and html header into a string variant? > > 2.) same as part 1,how to use a string variant ??string=html > > source??,load into ie.Document control? > > 3) If execute p.Save (), and p.Load () successfully, as initialize > > ie.Document control with ie.Navigate ( 'about : blank') before, will > > the IE original URL address bar become "about : blank"? I want to keep > > the original IE address bar URL unchanged. Is it possible? > > > There are a couple of IStream implementations included in the Pywin32 > distribution. Take a look at win32com.server.util.FileStream for file > operations, and \win32com\test\testStreams.py for a string based > approach. > > Here's an example of creating an IStream suitable for loading content from > a file: > import pythoncom > from win32com.server import util > f=open('somepage.html','r') > fs=util.FileStream (f) > istream=util.wrap(fs, pythoncom.IID_IStream) > > If you already have a document loaded, you can omit the Navigate > part, and the URL remains as it was. > > Roger > > > > ------------------------------ > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > End of Python-win32 Digest, Vol 53, Issue 6 > ******************************************* > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070807/0212e19d/attachment.htm From rwupole at msn.com Tue Aug 7 09:26:24 2007 From: rwupole at msn.com (Roger Upole) Date: Tue, 7 Aug 2007 03:26:24 -0400 Subject: [python-win32] Re: Python-win32 Digest, Vol 53, Issue 6 Message-ID: <000201c7d8c4$44f8bc90$0100a8c0@rupole> Huang Guan wrote: > I need your help on question 3 still: > > import pythoncom > from win32com.server import util > f=open('somepage.html','r') > fs=util.FileStream(f) > istream=util.wrap(fs, pythoncom.IID_IStream ) > p=ie.Document._oleobj_.QueryInterface (pythoncom.IID_IPersistStreamInit) > p.Load(istream) > > p.Load(istream)tested and excuted successful, thank you. > > f=open('somepage.html','w+') > fs=util.FileStream (f) > istream=util.wrap(fs, pythoncom.IID_IStream) > p=ie.Document._oleobj_.QueryInterface(pythoncom.IID_IPersistStreamInit) > p.Save(istream,True) > > Why p.Save(istream,True) can excuted, but error massage as below: > pythoncom error: Unexpected gateway error > : an integer is required > check somepage.html file current dir,is exists,size:5kb, > but the file is not complete html source. > How to resolve the p.Save() problem? FileStream's Write method wasn't returning the length as expected. I just checked in a fix: http://pywin32.cvs.sourceforge.net/pywin32/pywin32/com/win32com/server/util.py?view=log > v_StringIO=StringIO.StringIO() > v_f_object=open(' somepage.html','r') > v_StringIO.write(v_f_object.read()) > v_f_object.close() > fs=util.FileStream(v_StringIO) > istream=util.wrap(fs, pythoncom.IID_IStream) > p=ie.Document._oleobj_.QueryInterface (pythoncom.IID_IPersistStreamInit) > p.Load(istream) > > p.Load(istream) excuted successfully, but do not get values from v_StringIO, > why? > You need to seek the input stream to the beginning before loading from it. Roger From shaileshk at gmail.com Tue Aug 7 16:50:55 2007 From: shaileshk at gmail.com (Shailesh Kumar) Date: Tue, 7 Aug 2007 20:20:55 +0530 Subject: [python-win32] problem with UNICODE network paths and WNetAddConnection2 Message-ID: <92e4c3710708070750nb02d171naaf138636ce637ba@mail.gmail.com> Hi, I am facing a problem with network paths which contain non-ascii characters when trying to map them. More precisely, the location contains Korean characters. location = ur'\\baton1\TestStreams\shailesh\?????;??;?' WNetAddConnection2 function expects string type as remoteName argument. A simple call certainly fails: win32wnet.WNetAddConnection2( win32netcon.RESOURCETYPE_DISK, None, location, None, None, None) Traceback (most recent call last): File "D:\eclipseworkspaces\training\pytraining\win32networkstuff\unc.py", line 66, in ? None, None) UnicodeEncodeError: 'ascii' codec can't encode characters in position 30-44: ordinal not in range(128) I couldn't figure out the right encoding for the UNICODE string. I tried both 'utf8' and 'mbcs' encodings, something like: win32wnet.WNetAddConnection2( win32netcon.RESOURCETYPE_DISK, None, location.encode('utf8'), None, None, None) Traceback (most recent call last): File "D:\eclipseworkspaces\training\pytraining\win32networkstuff\unc.py", line 66, in ? None, None) pywintypes.error: (53, 'WNetAddConnection2', 'The network path was not found.') Sometimes 'Access is Denied' string is also reported. What is the right way to handle this case? Your help is highly appreciated. I am running Python 2.4.4 on Win XP Pro with pywin32-209 revision. With regards, -Shailesh From larry.bates at websafe.com Tue Aug 7 16:55:43 2007 From: larry.bates at websafe.com (Larry Bates) Date: Tue, 07 Aug 2007 09:55:43 -0500 Subject: [python-win32] COM object Dispatch Error In-Reply-To: References: Message-ID: lucemia wrote: > Hi: > > I have a problem about using win32com in python. > > I am using a software called CSTStudio to do my project. > CSTStudiod could be used in VBA Script currectly to start or execute > program via COM interface, > but it crashed in python win32com. > >> h = win32com.client.Dispatch('CSTStudio.Application') <--- it is ok! >> mws = h.OpenFile('C:\\CSTProject\\ga2layer_v1.psf') <--- the > CSTStudio will open the file currectly but failed to retrun mws. > > What should i do to solve this problem? > > Thanks > lucemia > > Error Message: > > Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit > (Intel)] on win32 > Type "copyright", "credits" or "license()" for more information. > > **************************************************************** > Personal firewall software may warn about the connection IDLE > makes to its subprocess using this computer's internal loopback > interface. This connection is not visible on any external > interface and no data is sent to or received from the Internet. > **************************************************************** > > IDLE 1.2 >>>> import win32com >>>> import win32com.client >>>> win32com.client.Dispatch('CSTStudio.Application') > >>>> h = win32com.client.Dispatch('CSTStudio.Application') >>>> mws = h.OpenFile('C:\\CSTProject\\ga2layer_v1.psf') > > Traceback (most recent call last): > File "", line 1, in > mws = h.OpenFile('C:\\CSTProject\\ga2layer_v1.psf') > File "", line 2, in OpenFile > File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line > 290, in _get_good_object_ > return self._get_good_single_object_(ob) > File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line > 275, in _get_good_single_object_ > return self._wrap_dispatch_(ob, userName, ReturnCLSID) > File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line > 123, in _wrap_dispatch_ > return Dispatch(ob, userName, returnCLSID,None,UnicodeToString) > File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line > 96, in Dispatch > return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, > UnicodeToString, clsctx) > File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line > 44, in __WrapDispatch > return dynamic.Dispatch(dispatch, userName, WrapperClass, typeinfo, > UnicodeToString=UnicodeToString,clsctx=clsctx) > File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line > 114, in Dispatch > typecomp = typeinfo.GetTypeComp() > AttributeError: 'NoneType' object has no attribute 'GetTypeComp' >>>> > > > ------------------------------------------------------------------------ > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 Google on CSTStudiod didn't turn up anything so there's no way to know the correct calling sequence for the OpenFile method. There is a reference to userName in the traceback. Did you forget to supply a userName argument? -Larry From mark at enfoldsystems.com Thu Aug 2 17:18:50 2007 From: mark at enfoldsystems.com (Mark Hammond) Date: Fri, 3 Aug 2007 01:18:50 +1000 Subject: [python-win32] Registering a Server COM to make it visible in thereference list In-Reply-To: Message-ID: > On 7/30/07, Mark Hammond wrote: > > There should be no need to create an IDL file - enough interfaces are > > exposed so that we can create the typelib directly. > > Ah, after some looking around, I see that there is > pythoncom.CreateTypeLib and CreateTypeLib2. Is this what you mean? Yep. > I was assuming the use of decorators, but it also may be possible to > just extend the current class variable syntax. > The other idea I had was to use something like zope.interface where > one defines the interfaces in a separate class. This sits half way > between using something like IDL where the interfaces are in a > separate file (and different language) and using decorators / class > variables where your class has all the information. The advantage > that I can see is that it makes it clearer to the programmer when they > need to change the version number / GUID of the typelib. If they > change the interface class, they need to change the version number. > If they just change the implementation class, they do not. It may > also make it easier to write unit tests to check that the > implementation class complies with the interface. I think that is getting a bit too heavy-weight - if people really want formal interface definitions, then they can stick with the IDL and having their Python code reference the typelib. I'm more interested in an "informal" approach where people can create a typelib for the benefit of other languages but without adding too much overhead. Cheers, Mark From mhammond at skippinet.com.au Tue Aug 7 20:21:39 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 7 Aug 2007 13:21:39 -0500 Subject: [python-win32] win32com does not recognise an Interface for events In-Reply-To: <46A76479.6020102@revolutioncontrols.com> References: <46A76479.6020102@revolutioncontrols.com> Message-ID: <035001c7d91f$cc25a060$6c01a8c0@bobcat> > OLE Viewer finds a second interface IS7ProSimEvents that is > made the default source makepy does not recognise > IS7ProSimEvents as an interface at all. That seems strange - for events, even non-dual interfaces should be supported. > gencache.GetClassForCLSID(clsid) returns the class with > docstring """IS7ProSim Interface for S7ProSim COM Object""" > This is correct. > This class has no sources, as can be seen in the OLE Viewer > output, and the AttributError is thrown. OK. > klass.coclass_clsid is '{83CC0D83-FEDA-11D1-BE76-0060B06816CF}'. OK. > gencache.GetClassForCLSID(klass.coclass_clsid) returns a > class with the following properties: > base class : CoClassBaseClass > coclass_interface : [ win32com.gen_py.83CC0D80-FEDA-11D1-BE76-0060B06816CFx0x1x0.IS7 > ProSim at > 0x00E4DCF0>] > coclass_sources : [] > clsid : {83CC0D83-FEDA-11D1-BE76-0060B06816CF} > There is no attribute default_source, so the AttributeError > is thrown again. > > This is correct with respect to the makepy output, but not > with repsect to the actual OLE object. > IMHO the makepy output should have included IS7PrSomEvents as > an interface and declared it as default_source within CoClass > S7SimPro. Right? Yep - so presumably this is the same problem as above. > So how come it does not? No idea. > Tracking the makepy actions: > ---------------------------- > A convenient break point location is makepy.py line 263: > gen.generate(....) Walking on till genpy.py line 737 > self.CollectOleItemInfosFromType() > returned a (correct) list > of all OleItem information headers: > infotype doc[0] > doc[1] > TKIND_INTERFACE, 'IS7ProSimEvents', 'Event interface for > S7ProSim COM Object' > TKIND_COCLASS, 'S7ProSim', 'S7ProSim Class' > TKIND_DISPATCH, 'IS7ProSim', 'IS7ProSim > Interface > for S7ProSim COM Object' > a number of (infotype 0 and 6) entries for the constant > enumerations This list is run through to colelct and build > all oleItems, enumItems, recordItems and vtableItems > pass 0: TKIND_INTERFACE, 'IS7ProSimEvents', 'Event interface > for S7ProSim COM Object' > oleItem, vtableItem = > self._Build_Interface(type_info_tuple) > returns (None, ) > returns (None, ). This will lead to > the exclusion of this interface later on. > > So how does this happen? It would appear that makepy is excluding non-dual interfaces, and that the integration with the 'universal' support for vtable interfaces isn't complete. > Did I stumble on a bug here or am I completely missing a > point? Please help out. I think you struck a bug - we should be able to support incoming interfaces (ie, events) using only vtables. Mark From theller at ctypes.org Tue Aug 7 21:39:00 2007 From: theller at ctypes.org (Thomas Heller) Date: Tue, 07 Aug 2007 21:39:00 +0200 Subject: [python-win32] win32com does not recognise an Interface for events In-Reply-To: <035001c7d91f$cc25a060$6c01a8c0@bobcat> References: <46A76479.6020102@revolutioncontrols.com> <035001c7d91f$cc25a060$6c01a8c0@bobcat> Message-ID: >> OLE Viewer finds a second interface IS7ProSimEvents that is >> made the default source makepy does not recognise >> IS7ProSimEvents as an interface at all. > > > It would appear that makepy is excluding non-dual interfaces, and that the > integration with the 'universal' support for vtable interfaces isn't > complete. You could try comtypes: it should support custom interfaces and custom event interfaces. 'easy_install comtypes==dev' to get the SVN version. Thomas From theller at ctypes.org Tue Aug 7 21:43:37 2007 From: theller at ctypes.org (Thomas Heller) Date: Tue, 07 Aug 2007 21:43:37 +0200 Subject: [python-win32] comtypes mailing list Message-ID: <46B8CB69.8020509@ctypes.org> Since the number of comtypes users seems to be growing slowly, I have created a comtypes mailing list. The mailing list interface is here: http://lists.sourceforge.net/lists/listinfo/comtypes-users comtypes "homepage": http://cheeseshop.python.org/pypi/comtypes Thomas From meledictas at gmail.com Wed Aug 8 05:23:44 2007 From: meledictas at gmail.com (Chatchai Neanudorn) Date: Wed, 8 Aug 2007 10:23:44 +0700 Subject: [python-win32] Two perfmon objects for two services running on single machine. Message-ID: <6f10a16a0708072023h5be768f4k77a78b88a6175cfc@mail.gmail.com> Hi, I have two python services running on single machine. Each service has performance object. The problem is, when I apply user to own service and try to start a service. A service that start first can be started successfully but for a subsequence service, it cannot start because a perfmon dll is already in used by the first service. The solution I can think is complie new perfmon dll. The question is how? Any idea is welcomed. Thank Chatchai. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070808/e81d1f04/attachment.htm From rwupole at msn.com Wed Aug 8 13:46:31 2007 From: rwupole at msn.com (Roger Upole) Date: Wed, 8 Aug 2007 07:46:31 -0400 Subject: [python-win32] Re: problem with UNICODE network paths and Message-ID: <000c01c7d9b1$c618c7a0$0100a8c0@rupole> Shailesh Kumar wrote: > Hi, > I am facing a problem with network paths which contain non-ascii > characters when trying to map them. > > More precisely, the location contains Korean characters. > location = ur'\\baton1\TestStreams\shailesh\?????;??;?' > > WNetAddConnection2 function expects string type as remoteName argument. > > A simple call certainly fails: > win32wnet.WNetAddConnection2( > win32netcon.RESOURCETYPE_DISK, > None, location, None, > None, None) > Traceback (most recent call last): > File "D:\eclipseworkspaces\training\pytraining\win32networkstuff\unc.py", > line 66, in ? > None, None) > UnicodeEncodeError: 'ascii' codec can't encode characters in position > 30-44: ordinal not in range(128) > > > I couldn't figure out the right encoding for the UNICODE string. I tried both > 'utf8' and 'mbcs' encodings, something like: > > win32wnet.WNetAddConnection2( > win32netcon.RESOURCETYPE_DISK, > None, location.encode('utf8'), None, > None, None) > > Traceback (most recent call last): > File "D:\eclipseworkspaces\training\pytraining\win32networkstuff\unc.py", > line 66, in ? > None, None) > pywintypes.error: (53, 'WNetAddConnection2', 'The network path was not found.') > > > Sometimes 'Access is Denied' string is also reported. > > What is the right way to handle this case? > Your help is highly appreciated. > > I am running Python 2.4.4 on Win XP Pro with pywin32-209 revision. > > With regards, > -Shailesh The win32wnet functions use plain strings for compatibility with Win98. You should be able to use win32net.NetUseAdd instead, which uses unicode. Roger From crown.hg at gmail.com Wed Aug 8 16:58:05 2007 From: crown.hg at gmail.com (Huang Guan) Date: Wed, 8 Aug 2007 22:58:05 +0800 Subject: [python-win32] Python-win32 Digest, Vol 53, Issue 8 In-Reply-To: References: Message-ID: <2d8a7c070708080758u364e43dbsb6d2d2c815c26081@mail.gmail.com> Dear All, Roger, thanks for your patch, I have settled the fourth question successfully. Thanks Tim Roberts,Michel Clveau and Richard Bell gave much good suggestions, which elicitation to resolve this question better. Mhammond, thank you for leading to subscribe to python mail list, which is a very good space for discussion. I have to give my high honor to everyone of pywin32 team, it's you who create the excellent win32 extend. I hope would have more communion and direction in python mail list in the future. Thanks and best regards! Crown.hg 2007/8/7, python-win32-request at python.org : > > Today's Topics: > > 1. Re: Python-win32 Digest, Vol 53, Issue 6 (Huang Guan) > 2. Re: Python-win32 Digest, Vol 53, Issue 6 (Roger Upole) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Tue, 7 Aug 2007 08:23:41 +0800 > From: "Huang Guan" > Subject: Re: [python-win32] Python-win32 Digest, Vol 53, Issue 6 > To: python-win32 at python.org > Message-ID: > <2d8a7c070708061723j328db9f7n566fa66403c7dc15 at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > Dear Sirs, > > Thanks for the detail comments from Tim Roberts,Roger and Michel Claveau, > question 1, 2, 4 have been finished. > > I am doing a anti pornography and violence software, which face to the > youngers. > > Convenience to distribute the software and restrictc some mischievous > youngsters to shut down this program, that's why I need to settel the > problem 1. > > Regarding to the problem 2, I found it and major in reserching technic, > not > mean others. > Now we could reolve the problem 1 and 2, it's unneccessary to discut it > any > more. > > Thanks for the Michel Claveau's suggestion help me settled problem 4. > > question 1, 2, 4 have been finished. > > > I need your help on question 3 still: > > import pythoncom > from win32com.server import util > f=open('somepage.html','r') > fs=util.FileStream(f) > istream=util.wrap(fs, pythoncom.IID_IStream ) > p=ie.Document._oleobj_.QueryInterface (pythoncom.IID_IPersistStreamInit) > p.Load(istream) > > p.Load(istream)tested and excuted successful, thank you. > > f=open('somepage.html','w+') > fs=util.FileStream (f) > istream=util.wrap(fs, pythoncom.IID_IStream) > p=ie.Document._oleobj_.QueryInterface(pythoncom.IID_IPersistStreamInit) > p.Save(istream,True) > > Why p.Save(istream,True) can excuted, but error massage as below: > pythoncom error: Unexpected gateway error > : an integer is required > check somepage.html file current dir,is exists,size:5kb, > but the file is not complete html source. > How to resolve the p.Save() problem? > > v_StringIO=StringIO.StringIO() > v_f_object=open(' somepage.html','r') > v_StringIO.write(v_f_object.read()) > v_f_object.close() > fs=util.FileStream(StringIO) > istream=util.wrap(fs, pythoncom.IID_IStream) > p=ie.Document._oleobj_.QueryInterface (pythoncom.IID_IPersistStreamInit) > p.Load(istream) > > p.Load(istream) excuted successfully, but do not get values from > v_StringIO, > why? > > > Thanks & best regards! > Crown.hg > > > > > > > Message: 4 > > Date: Fri, 03 Aug 2007 09:48:33 -0700 > > From: Tim Roberts < timr at probo.com> > > Subject: Re: [python-win32] pywin32 bugs feedback from learner > > To: python-win32 at python.org > > Message-ID: < 46B35C61.9020204 at probo.com> > > Content-Type: text/plain; charset=GB2312 > > > > Huang Guan wrote: > > > Dear Tim Roberts, > > > > > > Do you mean Task Manager? I don't want you to hide your service from > me. > > > It's my computer, and I want to know exactly what's running. > > > {Yes, I am writting a similar module. An general user of windows user > > > group could shut pythonservice.exe in the task manager, and my python > > > service would be shutdown in the same time.Is there any good ways > > > except hide pythonservice.exe process?} > > > > No legitimate process should be able to hide from me. It's MY computer, > > and I have every right to know exactly what is running on it. And if I > > decide I don't want your process to run, it's not up to you to stop me. > > > > Don't do this. If you do, pythonservice.exe will get a reputation as > > being "malware", and all Python users will suffer. > > > > > > > {I use ResHacker tool to change the Version info of vmnetdhcp.exe > > > file, change 'VALUE "CompanyName", "VMware, inc."' to be 'VALUE > > > "CompanyName", "VMware,Crop."',then??show "VMware.Inc" in Msconfig > > > successfully, as" Vmware.Crop."??But I use the same method on > > > pythonservice.exe??it doesn't work? How can I do for it?} > > > > PythonService.exe does not seem to have a version resource at all. I > > don't know if ResHacker has the ability to insert a version resource > > into a file that does not have one. > > > > And even if it could, I'm not convinced that it is ethical. > > PythonService.exe was not created by you. Why should you have the right > > to claim it? > > > > > > > {without using makepy, according to below suggestion by Mr.Roger: > > > ie.Navigate('about:blank') > > > p=ie.Document._oleobj_.QueryInterface(pythoncom.IID_IPersistStreamInit) > > > p.Load() > > > in existence p.Load() method confirmed??but how to do could use > > > P.Save() save PyISteram to a string variable(include Html header > > > info????How to do could load to ie.document via p.Load() from HTML > > > SOURCE string variable? This is my greatest concern problem.I re-sent > > > this question to Roger and pywin32 mail list, pls do me the favor on > > > these problem. Thank you. } > > > > To do this, you will somehow have to create a PyIStream object that > > saves to a string. I Googled for "using istream python" and did find one > > or two examples of people doing this. > > > > > > > 4). While using pywin32 to control IE, > > > It's certain that using win32com.client.Dispatch return IE object. > > > It can execute the JavaScript method of current transfer page, > > > the following code has been execute and come through: > > > v_iexplore=win32com.client.Dispatch('InternetExplorer.Application') > > > v_iexplore.Navigate(' > > > http://www.cpplab.com/Articles/JSCalls/TestPage/JSCallTestPage.htm' > > > < > http://www.cpplab.com/Articles/JSCalls/TestPage/JSCallTestPage.htm%27 > > >) > > > v_id=v_iexplore.Document > > > .Script._oleobj_.GetIDsOfNames('Welcome') > > > v_iexplore.Document.Script._oleobj_.Invoke(\ > > > v_id, 0, win32com.client.pythoncom.DISPATCH_METHOD, True,\ > > > 'HuanGuan') > > > But: It can't execute the above code exactly In the > > > win32com.client.DispatchWithEvents return IE object. > > > How to solve this problem ? Would you pls kindly to show me some > > examples? > > > > It's interesting that you showed us the code that worked, but not the > > code that didn't work. That's what you need to fix, right? > > > > -- > > Tim Roberts, timr at probo.com > > Providenza & Boekelheide, Inc. > > > > > > > > ------------------------------ > > > > Message: 5 > > Date: Fri, 3 Aug 2007 19:09:48 -0400 > > From: "Roger Upole" < rwupole at msn.com > > > Subject: [python-win32] Re: Python-win32 Digest, Vol 53, Issue 3 > > To: > > Message-ID: <000201c7d623$665f4eb0$0100a8c0 at rupole> > > Content-Type: text/plain; format=flowed; charset="iso-8859-1"; > > reply-type=original > > > > Huang Guan wrote: > > > Thanks for your comments, according the code suggestion you gave: > > > ie.Navigate('about:blank') > > > p=ie.Document._oleobj_.QueryInterface(pythoncom.IID_IPersistStreamInit > ) > > > p.Load(), > > > confirm Load() metchod in existence. > > > > > > Could you give some examples on how to use PyISteream for my > > > reference? It's very difficult to find use paradigm in pywin32.chm. > > > > > > 1.) How can we use p.Save() method, > > > save html source and html header into a string variant? > > > 2.) same as part 1,how to use a string variant ??string=html > > > source??,load into ie.Document control? > > > 3) If execute p.Save (), and p.Load () successfully, as initialize > > > ie.Document control with ie.Navigate ( 'about : blank') before, will > > > the IE original URL address bar become "about : blank"? I want to keep > > > the original IE address bar URL unchanged. Is it possible? > > > > > > There are a couple of IStream implementations included in the Pywin32 > > distribution. Take a look at win32com.server.util.FileStream for file > > operations, and \win32com\test\testStreams.py for a string based > > approach. > > > > Here's an example of creating an IStream suitable for loading content > from > > a file: > > import pythoncom > > from win32com.server import util > > f=open('somepage.html','r') > > fs=util.FileStream (f) > > istream=util.wrap(fs, pythoncom.IID_IStream) > > > > If you already have a document loaded, you can omit the Navigate > > part, and the URL remains as it was. > > > > Roger > > > > > > > > ------------------------------ > > > > _______________________________________________ > Message: 2 > Date: Tue, 7 Aug 2007 03:26:24 -0400 > From: "Roger Upole" > Subject: [python-win32] Re: Python-win32 Digest, Vol 53, Issue 6 > To: > Message-ID: <000201c7d8c4$44f8bc90$0100a8c0 at rupole> > Content-Type: text/plain; format=flowed; charset="iso-8859-1"; > reply-type=original > > Huang Guan wrote: > > I need your help on question 3 still: > > > > import pythoncom > > from win32com.server import util > > f=open('somepage.html','r') > > fs=util.FileStream(f) > > istream=util.wrap(fs, pythoncom.IID_IStream ) > > p=ie.Document._oleobj_.QueryInterface (pythoncom.IID_IPersistStreamInit) > > p.Load(istream) > > > > p.Load(istream)tested and excuted successful, thank you. > > > > f=open('somepage.html','w+') > > fs=util.FileStream (f) > > istream=util.wrap(fs, pythoncom.IID_IStream) > > p=ie.Document._oleobj_.QueryInterface(pythoncom.IID_IPersistStreamInit) > > p.Save(istream,True) > > > > Why p.Save(istream,True) can excuted, but error massage as below: > > pythoncom error: Unexpected gateway error > > : an integer is required > > check somepage.html file current dir,is exists,size:5kb, > > but the file is not complete html source. > > How to resolve the p.Save() problem? > > FileStream's Write method wasn't returning the length as expected. > I just checked in a fix: > > http://pywin32.cvs.sourceforge.net/pywin32/pywin32/com/win32com/server/util.py?view=log > > > v_StringIO=StringIO.StringIO() > > v_f_object=open(' somepage.html','r') > > v_StringIO.write(v_f_object.read()) > > v_f_object.close() > > fs=util.FileStream(v_StringIO) > > istream=util.wrap(fs, pythoncom.IID_IStream) > > p=ie.Document._oleobj_.QueryInterface (pythoncom.IID_IPersistStreamInit) > > p.Load(istream) > > > > p.Load(istream) excuted successfully, but do not get values from > v_StringIO, > > why? > > > > You need to seek the input stream to the beginning before loading from it. > > Roger > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070808/7677726a/attachment.html From z_m at volny.cz Wed Aug 8 21:03:17 2007 From: z_m at volny.cz (Zdenek Mejzlik) Date: Wed, 08 Aug 2007 21:03:17 +0200 Subject: [python-win32] Windows log out service problem Message-ID: <46BA1375.7090400@volny.cz> Hi. This post is similar to one sent by Tom Dalton 12 June 2007. Unfortunately, appropriate solution of his problem was not published yet. I'm trying to create a simple windows service. I found code of simple service on the Internet. Service works well as long as I'm logged in. But as soon as I log out the service is interrupted and windows event log contains the following message: The instance's SvcRun() method failed File "C:\Python25\Lib\site-packages\win32\lib\win32serviceutil.py", line 785, in SvcRun self.SvcDoRun() File "C:\altworx_repository\wwwroot\cgi-bin\pokus\aservice.py", line 20, in SvcDoRun time.sleep(10) : (4, 'Interrupted function call') Service is running on Windows XP Prof with Python 2.5. Code of the service is bellow. Has anyone any idea what's wrong? Thank you for any little help. import win32service import win32serviceutil import time import win32api import win32con class aservice(win32serviceutil.ServiceFramework): _svc_name_ = "aservice" _svc_display_name_ = "aservice - It Does nothing" def __init__(self,args): win32serviceutil.ServiceFramework.__init__(self,args) self.isAlive = True def SvcDoRun(self): import servicemanager while self.isAlive: servicemanager.LogInfoMsg("aservice - is alive and well") time.sleep(10) servicemanager.LogInfoMsg("aservice - Stopped") def SvcStop(self): import servicemanager servicemanager.LogInfoMsg("aservice - Recieved stop signal") self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) self.isAlive = False def ctrlHandler(ctrlType): return True if __name__ == '__main__': win32api.SetConsoleCtrlHandler(ctrlHandler, True) win32serviceutil.HandleCommandLine(aservice) This code is slightly modified. The original code is on http://essiene.blogspot.com/2005/04/python-windows-services.html. Z. From mhammond at skippinet.com.au Wed Aug 8 22:33:14 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 8 Aug 2007 15:33:14 -0500 Subject: [python-win32] Windows log out service problem In-Reply-To: <46BA1375.7090400@volny.cz> References: <46BA1375.7090400@volny.cz> Message-ID: <011901c7d9fb$58902990$6c01a8c0@bobcat> I believe this is caused by Windows sending a CTRL_LOGOFF_EVENT to the service - http://msdn2.microsoft.com/en-us/library/ms683242.aspx has some details. Adding your own handler for this notification may allow you to prevent the problem, but I don't have the time at the moment to experiment with that. Cheers, Mark > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org] On Behalf Of Zdenek Mejzlik > Sent: Wednesday, 8 August 2007 2:03 PM > To: python-win32 at python.org > Subject: [python-win32] Windows log out service problem > > Hi. > > This post is similar to one sent by Tom Dalton 12 June 2007. > Unfortunately, appropriate solution of his problem was not > published yet. > > I'm trying to create a simple windows service. I found code > of simple service on the Internet. Service works well as long > as I'm logged in. > But as soon as I log out the service is interrupted and > windows event log contains the following message: > > The instance's SvcRun() method failed > File > "C:\Python25\Lib\site-packages\win32\lib\win32serviceutil.py", > line 785, in SvcRun > self.SvcDoRun() > File > "C:\altworx_repository\wwwroot\cgi-bin\pokus\aservice.py", > line 20, in SvcDoRun > time.sleep(10) > : (4, 'Interrupted function call') > > Service is running on Windows XP Prof with Python 2.5. Code > of the service is bellow. Has anyone any idea what's wrong? > Thank you for any little help. > > import win32service > import win32serviceutil > import time > import win32api > import win32con > > class aservice(win32serviceutil.ServiceFramework): > _svc_name_ = "aservice" > _svc_display_name_ = "aservice - It Does nothing" > > def __init__(self,args): > win32serviceutil.ServiceFramework.__init__(self,args) > self.isAlive = True > > def SvcDoRun(self): > import servicemanager > > while self.isAlive: > servicemanager.LogInfoMsg("aservice - is alive and well") > time.sleep(10) > servicemanager.LogInfoMsg("aservice - Stopped") > > def SvcStop(self): > import servicemanager > > servicemanager.LogInfoMsg("aservice - Recieved stop signal") > self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) > self.isAlive = False > > def ctrlHandler(ctrlType): > return True > > if __name__ == '__main__': > win32api.SetConsoleCtrlHandler(ctrlHandler, True) > win32serviceutil.HandleCommandLine(aservice) > > > This code is slightly modified. The original code is on > http://essiene.blogspot.com/2005/04/python-windows-services.html. > > Z. > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From rwupole at msn.com Wed Aug 8 22:35:24 2007 From: rwupole at msn.com (Roger Upole) Date: Wed, 8 Aug 2007 16:35:24 -0400 Subject: [python-win32] Re: Windows log out service problem Message-ID: <000701c7d9fb$a857bf10$0100a8c0@rupole> Zdenek Mejzlik wrote: > Hi. > > This post is similar to one sent by Tom Dalton 12 June 2007. > Unfortunately, appropriate solution of his problem was not published yet. > > I'm trying to create a simple windows service. I found code of simple > service on the Internet. Service works well as long as I'm logged in. > But as soon as I log out the service is interrupted and windows event > log contains the following message: > > The instance's SvcRun() method failed > File "C:\Python25\Lib\site-packages\win32\lib\win32serviceutil.py", line > 785, in SvcRun > self.SvcDoRun() > File "C:\altworx_repository\wwwroot\cgi-bin\pokus\aservice.py", line 20, > in SvcDoRun > time.sleep(10) > : (4, 'Interrupted function call') > > Service is running on Windows XP Prof with Python 2.5. Code of the > service is bellow. Has anyone any idea what's wrong? Thank you for any > little help. > > import win32service > import win32serviceutil > import time > import win32api > import win32con > > class aservice(win32serviceutil.ServiceFramework): > _svc_name_ = "aservice" > _svc_display_name_ = "aservice - It Does nothing" > > def __init__(self,args): > win32serviceutil.ServiceFramework.__init__(self,args) > self.isAlive = True > > def SvcDoRun(self): > import servicemanager > > while self.isAlive: > servicemanager.LogInfoMsg("aservice - is alive and well") > time.sleep(10) > servicemanager.LogInfoMsg("aservice - Stopped") > > def SvcStop(self): > import servicemanager > > servicemanager.LogInfoMsg("aservice - Recieved stop signal") > self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) > self.isAlive = False > > def ctrlHandler(ctrlType): > return True > > if __name__ == '__main__': > win32api.SetConsoleCtrlHandler(ctrlHandler, True) > win32serviceutil.HandleCommandLine(aservice) > > > This code is slightly modified. The original code is on > http://essiene.blogspot.com/2005/04/python-windows-services.html. > > Z. The service needs to be in an alertable state to receive control signals. Try win32api.SleepEx(10000, True) in place of time.sleep. Roger From len200612 at revolutioncontrols.com Thu Aug 9 10:44:55 2007 From: len200612 at revolutioncontrols.com (Len Remmerswaal) Date: Thu, 09 Aug 2007 10:44:55 +0200 Subject: [python-win32] win32com does not recognise an Interface for events In-Reply-To: References: <46A76479.6020102@revolutioncontrols.com> <035001c7d91f$cc25a060$6c01a8c0@bobcat> Message-ID: <46BAD407.3030804@revolutioncontrols.com> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070809/9041ebf1/attachment.htm From theller at ctypes.org Thu Aug 9 21:03:15 2007 From: theller at ctypes.org (Thomas Heller) Date: Thu, 09 Aug 2007 21:03:15 +0200 Subject: [python-win32] win32com does not recognise an Interface for events In-Reply-To: <46BAC933.4080702@RevolutionControls.com> References: <46A76479.6020102@revolutioncontrols.com> <035001c7d91f$cc25a060$6c01a8c0@bobcat> <46BAC933.4080702@RevolutionControls.com> Message-ID: <46BB64F3.2020206@ctypes.org> >> >> You could try comtypes: it should support custom interfaces and >> >> custom event interfaces. >> >> >> >> 'easy_install comtypes==dev' to get the SVN version. >> >> > > Wow. The battle of the packages is afoot :-) > > Thanks for the hint: I did not know about this package. > > I have given it a try. There are a few things that appear strange to me. > > At first I tried this: > > > > import comtypes.client as cc > > class testVehikel(cc.CreateObject(progid), eventsClass): > > def __init__(self): > > (...) > > > > This produced the following exception: > > class testVehikel(cc.CreateObject(progid), eventsClass): > > TypeError: Error when calling the metaclass bases > > __init__ expected at most 1 arguments, got 3 > > > > I have no clue where this comes from, not even after trying to step towards the > > error. Does anyone? Strange? What do you mean, your own code ;-) ? CreateObject() creates an instance of a COM object and returns an interface pointer to it. You can use that directly to call COM methods or access COM properties - you cannot use this thing as a base class for another class: that's why you get this metaclass error. > > So I did it slightly different: > > > > import comtypes.client as cc > > import comtypes.gen.S7PROSIMLib as S7PS > > class testVehikel: > > def __init__(self, progid, eventsClass): > > self.intf = cc.CreateObject(progid) > > self.cb = eventsClass > > cc.GetEvents(self.intf, self.cb, S7PS.IS7ProSimEvents) > > (...) > > (.... other methods ....) > > def __del__(self): > > (.... some cleaning up ....) > > > > This runs, except that the __del__ method gets called before I expect it, and > > after it is called the other testVehikel methods still run fine. > > How is this possible? This looks a little bit better. Basically you do: intf = cc.CreateObject(progid) con = cc.GetEvents(intf, eventreceiver, event_interface) The last parameter to GetEvents is optional, some COM objects expose enough information so that comtypes can determine the default source interface itself. Then, you have to keep the object that GetEvent() returns because when this object goes away the advise connection is closed and cannot receive events any more. Third, different from the pywin32 way, you pass an object as eventreceiver, NOT a class. The eventreceiver must have methods (event handlers) corresponding to the events that it receives. events that have no handlers are silently ignored. Forth, comtypes has a useful function that will help exploring the events: ShowEvents(). This has the same signature and functionality as the GetEvents function, except that you cannot pass the eventreceiver argument: ShowEvents(obj [, interface]) constructs a universal event receiver object itself. This object will first simply print out the event methods that it finds in the source interface, and then will print out the event names and arguments when events are received. Again, you must keep the return value of the ShowEvents() call as long as you want to receive events. And finally, depending on the COM apartment your code runs in, and depending on the COM object, you may need to run a windows MessageLoop so that events are properly dispatched by COM. > > I final question: > > What should the event routines look like? Currently they look like this: > > > > class testCalls2: > > def ScanFinished(self, this, ScanInfo): > > print "Event: ScanFinished: ", ScanInfo > > (....) > > > > on the basis of .py, the result of GetMessage, saying this: > > > > IS7ProSimEvents._methods_ = [ > > COMMETHOD([helpstring(u'Fired when single scan is done.')], HRESULT, > > 'ScanFinished', > > ( [], VARIANT, 'ScanInfo' )), > > (....) > > > > I thought to have read somewhere that I need a (not further needed) 'this' > > argument. Should I do it like this or should the 'this' argument go? > > So far I have not been able to trigger any of these routines and make them do > > their printing. I think this is correct, the this parameter is needed. Thomas From z_m at volny.cz Thu Aug 9 21:43:49 2007 From: z_m at volny.cz (Zdenek Mejzlik) Date: Thu, 09 Aug 2007 21:43:49 +0200 Subject: [python-win32] Re: Windows log out service problem Message-ID: <46BB6E75.6030405@volny.cz> Simply. It works. Thank you. Z. From cappy2112 at gmail.com Fri Aug 10 06:51:36 2007 From: cappy2112 at gmail.com (Tony Cappellini) Date: Thu, 9 Aug 2007 21:51:36 -0700 Subject: [python-win32] Having multiple versions of PythonWin installed concurrently Message-ID: <8249c4ac0708092151w3f4d4269g9d649f83c75a1341@mail.gmail.com> I'm using Python2.5 & PythonWin build210 for my main development. I need to install a package that only runs under Python2.4, and I'd like to have a corresponding version of PythonWin for 2.4 installed as well. Switching between Python2.4 & 2.5 is easy enough to deal with using Python environment variables, and I would suspect the same for a version of PythonWin for 2.4- but I just want to see if there are any potential problems with having multiple versions of PythonWin installed concurrently. thanks From niki at vintech.bg Fri Aug 10 08:42:19 2007 From: niki at vintech.bg (niki) Date: Fri, 10 Aug 2007 09:42:19 +0300 Subject: [python-win32] Having multiple versions of PythonWin installed concurrently In-Reply-To: <8249c4ac0708092151w3f4d4269g9d649f83c75a1341@mail.gmail.com> References: <8249c4ac0708092151w3f4d4269g9d649f83c75a1341@mail.gmail.com> Message-ID: <46BC08CB.30207@vintech.bg> Tony Cappellini wrote: > Switching between Python2.4 & 2.5 is easy enough to deal with using > Python environment variables, and I would suspect the same for a > version of PythonWin for 2.4- but I just want to see if there are any > potential problems with having multiple versions of PythonWin > installed concurrently. Nothing IFIAK, i have 2.3, 2.4 and 2.5 installed with pywin32 Niki Spahiev From mc at mclaveau.com Fri Aug 10 09:36:02 2007 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 10 Aug 2007 09:36:02 +0200 Subject: [python-win32] Having multiple versions of PythonWin installedconcurrently References: <8249c4ac0708092151w3f4d4269g9d649f83c75a1341@mail.gmail.com> Message-ID: <000201c7db21$1cf1f090$0601a8c0@PORTABLES> Hi! I had search, in past, for have one PyWin for normal development, and one for the Python 2.3 include in OOo. But, I was not able any to carry out that... Perhaps what a guru/designer/developper would know some more? @-salutations Michel Claveau From mc at mclaveau.com Fri Aug 10 09:42:29 2007 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 10 Aug 2007 09:42:29 +0200 Subject: [python-win32] Having multiple versions of PythonWin installed concurrently References: <8249c4ac0708092151w3f4d4269g9d649f83c75a1341@mail.gmail.com> <46BC08CB.30207@vintech.bg> Message-ID: <000b01c7db22$03b7b2d0$0601a8c0@PORTABLES> Hi! > Niki: > i have 2.3, 2.4 and 2.5 installed with pywin32 But Python COM server is registred only once way. I think that it's not possible to have Python COM server on 2.5, 2.4 & 2.3 simultaneously. Perhaps I'am wrong. In this case, witch way? @+ Michel Claveau From len200612 at revolutioncontrols.com Fri Aug 10 11:37:46 2007 From: len200612 at revolutioncontrols.com (Len Remmerswaal) Date: Fri, 10 Aug 2007 11:37:46 +0200 Subject: [python-win32] win32com does not recognise an Interface for events In-Reply-To: <46BB5C6E.8010108@ctypes.org> References: <46A76479.6020102@revolutioncontrols.com> <035001c7d91f$cc25a060$6c01a8c0@bobcat> <46BAC933.4080702@RevolutionControls.com> <46BB5C6E.8010108@ctypes.org> Message-ID: <46BC31EA.90805@revolutioncontrols.com> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070810/d1de3a54/attachment.htm From theller at ctypes.org Fri Aug 10 14:23:09 2007 From: theller at ctypes.org (Thomas Heller) Date: Fri, 10 Aug 2007 14:23:09 +0200 Subject: [python-win32] win32com does not recognise an Interface for events In-Reply-To: <46BC31EA.90805@revolutioncontrols.com> References: <46A76479.6020102@revolutioncontrols.com> <035001c7d91f$cc25a060$6c01a8c0@bobcat> <46BAC933.4080702@RevolutionControls.com> <46BB5C6E.8010108@ctypes.org> <46BC31EA.90805@revolutioncontrols.com> Message-ID: Len Remmerswaal schrieb: > > import comtypes.client as cc > import comtypes.gen.S7PROSIMLib as S7PS > class testVehikel: > def __init__(self, progid, eventsClass): > self.intf = cc.CreateObject(progid) > self.rcvr = eventsClass() ## just added () to assign an obj i.o. a class > self.cb = cc.GetEvents(self.intf, self.rcvr, S7PS.IS7ProSimEvents) > (....) > > I do need the interface definition in GetEvents or I get: "TypeError: cannot > determine source interface". So be it. Sure. I just wanted to mention that often you do not have to do this. >> Forth, comtypes has a useful function that will help exploring the events: ShowEvents(). >> This has the same signature and functionality as the GetEvents function, except that >> you cannot pass the eventreceiver argument: ShowEvents(obj [, interface]) constructs >> a universal event receiver object itself. This object will first simply print out >> the event methods that it finds in the source interface, and then will print out >> the event names and arguments when events are received. Again, you must keep the >> return value of the ShowEvents() call as long as you want to receive events. >> > I suppose I'll have to download the development version for that: version 0.2.1 > seems not to have ShowEvents. Please download comtypes-0.3.2 which was released two days ago. >> And finally, depending on the COM apartment your code runs in, and depending >> on the COM object, you may need to run a windows MessageLoop so that events >> are properly dispatched by COM. >> > I'll try that: right now some events seem to occur only when a corresponding > dispatch routine is run, i.e. an event "Status changed" occurs if I call > "getStatus". I saw an example of how to do this in comtypes\test\test_ie.py. > What I wonder is how this message loop relates to the pywin message loop in > which I currently run this code, or perhaps the wxPython message loop where this > code will probably be running in later. BTW: the COM object resides in a DLL so > I would think it runs in-process. IMO in-process or outof-process doesn't matter. Any message loop should do: Either the PumpWaitingMessage function in the test_ie.py module, the pythoncom.PumpWaitingMessage funtion from pywin32, the message loop that PythonWin uses if you run the code inside that, maybe even a wxPython, Tkinter or IDLE messageloop. In the development version of comtypes in SVN I just added the PumpWaitingMessages function to the comtypes.client module. > >>> I final question: >>> What should the event routines look like? Currently they look like this: >>> >>> class testCalls2: >>> def ScanFinished(self, this, ScanInfo): >>> print "Event: ScanFinished: ", ScanInfo >>> (....) >>> >>> on the basis of .py, the result of GetMessage, saying this: >>> >>> IS7ProSimEvents._methods_ = [ >>> COMMETHOD([helpstring(u'Fired when single scan is done.')], HRESULT, >>> 'ScanFinished', >>> ( [], VARIANT, 'ScanInfo' )), >>> (....) >>> >>> I thought to have read somewhere that I need a (not further needed) 'this' >>> argument. Should I do it like this or should the 'this' argument go? >>> So far I have not been able to trigger any of these routines and make them do >>> their printing. >>> >> >> >> I think this is correct, the this parameter is needed >> > Almost correct. All event routines must return an integer, or I get this: > > Traceback (most recent call last): > File "source/callbacks.c", line 216, in 'converting callback result' > TypeError: int expected instead of NoneType instance > Exception in ignored > > after which the thing continues happily. > At first I tried returning 0 (ERROR_SUCCESS) as the HRESULT , but this hangs up > the code. Now I return 1 and it works fine. > The odd thing is that the methods in EventSink in comtypes\test\test_ie.py do > not return anything. Is this a version problem (I use 0.2.1)? I think so. Please use 0.3.2: it is much improved. BTW: You should probably subscribe to the new comtypes-users mailing list, and move this discussion over there: https://lists.sourceforge.net/lists/listinfo/comtypes-users Thomas From shaileshk at gmail.com Fri Aug 10 19:32:08 2007 From: shaileshk at gmail.com (Shailesh Kumar) Date: Fri, 10 Aug 2007 23:02:08 +0530 Subject: [python-win32] SHFileOperation doesn't work with UNICODE file paths (with non ascii characters) Message-ID: <92e4c3710708101032p7517016crab7f4ece17e1cfbf@mail.gmail.com> Hi, Kindly have a look at following sample. I am trying to copy files from a folder to another folder using SHFileOperation. The folder name as well as file name contain characters from Hiragana script (Japanese). Neither Copy nor Move operations work. The operations work if the file path doesn't contain non-ascii characters. What am I doing wrong? I have PyWin32 - v 209. from win32com.shell import shell, shellcon def fileOperation(source, destination, operation): result = shell.SHFileOperation((0, operation, source, destination, shellcon.FOF_NOCONFIRMATION | shellcon.FOF_NOERRORUI | shellcon.FOF_SILENT)) if result == 0: raise Exception("Operation failed") return result def copyFile(source, destination): return fileOperation(source, destination, shellcon.FO_COPY) def moveFile(source, destination): return fileOperation(source, destination, shellcon.FO_MOVE) if __name__ == '__main__': "Lets do some testing of the above two functions" import os import sys testDir = ur"D:\\SHFOTestsDir" os.mkdir(testDir) "Some hiragana characters" smallA = u'\u3042' KA = u'\u304B' GI = u'\u304E' folder1Name = KA * 10 folder2Name = GI * 10 folder1Path = os.path.join(testDir, folder1Name) folder2Path = os.path.join(testDir, folder2Name) os.mkdir(folder1Path) os.mkdir(folder2Path) filenames = () contents = '20' * 100 for i in range(10): filename = KA * (i + 5) filepath = os.path.join(folder1Path, filename) f = open(filepath, 'w') f.write(contents) f.close() copyFile(filepath, folder2Path) With regards, - Shailesh From rbell01824 at earthlink.net Sat Aug 11 00:33:16 2007 From: rbell01824 at earthlink.net (Richard Bell) Date: Fri, 10 Aug 2007 17:33:16 -0500 Subject: [python-win32] pythoncom/win32com hangs Message-ID: <00ad01c7db9e$720a93c0$6701a8c0@rjbmain> I've been working on a class and module to automate IE. All seemed to be working including several hundred test, so I decided to stress test by visiting a large number of pages (400 plus) for several hours to see if the code was stable in the face of repeated use. After roughly 40 minutes of operation IE and my Python application hang when visiting a particular URL. The symptoms are that IE is unresponsive and task manager must be used to kill it. Python is non-responsive to ^c until after IE is killed. But, here's one of the kickers, when the offending URL is also placed earlier in the list of test URLs there are no problems (until the later copy is encountered 40 minutes into the test at which time things hang). The problem occurs when accessing an IE attribute, in particular ie.Busy. Curiously, the attribute HAS BEEN ACCESSED many times while accessing the offending URL (ie.Busy is being checked as part of a method to determine if the page is fully loaded, so the protocol is to start the navigation, then check ie.Busy every 250ms, when IE goes not busy other checks are performed). I'm suspicious that IE is hung for its own reasons but it also appears that Python is hung probably somewhere inside win32com or some C code, but I'm not really sure. On a positive note, the problem is reliably reproducible (but it takes about 40 minutes to do so). I'm completely at a loss as to how to proceed to isolate the problem. I've read something about a debug mode for com but don't really know how to proceed. Can anyone provide any insight/guidance/ideas? Regards, Richard From rwupole at msn.com Sun Aug 12 09:46:47 2007 From: rwupole at msn.com (Roger Upole) Date: Sun, 12 Aug 2007 03:46:47 -0400 Subject: [python-win32] Re: SHFileOperation doesn't work with UNICODE file paths Message-ID: <000d01c7dcb4$f218bd00$0100a8c0@rupole> Shailesh Kumar wrote: > Hi, > > Kindly have a look at following sample. > > I am trying to copy files from a folder to another folder using SHFileOperation. > The folder name as well as file name contain characters from Hiragana > script (Japanese). Neither Copy nor Move operations work. The > operations work if the file path doesn't contain non-ascii characters. > > What am I doing wrong? > > I have PyWin32 - v 209. > > from win32com.shell import shell, shellcon > > > def fileOperation(source, destination, operation): > result = shell.SHFileOperation((0, operation, > source, destination, > shellcon.FOF_NOCONFIRMATION | > shellcon.FOF_NOERRORUI | shellcon.FOF_SILENT)) > if result == 0: > raise Exception("Operation failed") > return result > > def copyFile(source, destination): > return fileOperation(source, destination, shellcon.FO_COPY) > > def moveFile(source, destination): > return fileOperation(source, destination, shellcon.FO_MOVE) > > > if __name__ == '__main__': > "Lets do some testing of the above two functions" > import os > import sys > testDir = ur"D:\\SHFOTestsDir" > os.mkdir(testDir) > "Some hiragana characters" > smallA = u'\u3042' > KA = u'\u304B' > GI = u'\u304E' > folder1Name = KA * 10 > folder2Name = GI * 10 > folder1Path = os.path.join(testDir, folder1Name) > folder2Path = os.path.join(testDir, folder2Name) > os.mkdir(folder1Path) > os.mkdir(folder2Path) > filenames = () > contents = '20' * 100 > for i in range(10): > filename = KA * (i + 5) > filepath = os.path.join(folder1Path, filename) > f = open(filepath, 'w') > f.write(contents) > f.close() > copyFile(filepath, folder2Path) > > With regards, > - Shailesh This is another issue with compatibility with Windows 98, which doesn't support the unicode version of this function directly. It's still possible to wrap SHFileOperationW, but it takes some extra work. Python itself stops supporting Win98 as of 2.6, but Pywin32 will probably continue supporting it for some time since Mark usually creates releases for at least 2 prior versions of Python. Roger From shaileshk at gmail.com Mon Aug 13 07:49:56 2007 From: shaileshk at gmail.com (Shailesh Kumar) Date: Mon, 13 Aug 2007 11:19:56 +0530 Subject: [python-win32] SHFileOperation doesn't work with UNICODE file paths In-Reply-To: <000d01c7dcb4$f218bd00$0100a8c0@rupole> References: <000d01c7dcb4$f218bd00$0100a8c0@rupole> Message-ID: <92e4c3710708122249p52b0892dy6e94676fc09b7539@mail.gmail.com> Thanx Roger, With regards, -Shailesh On 8/12/07, Roger Upole wrote: > Shailesh Kumar wrote: > > Hi, > > > > Kindly have a look at following sample. > > > > I am trying to copy files from a folder to another folder using SHFileOperation. > > The folder name as well as file name contain characters from Hiragana > > script (Japanese). Neither Copy nor Move operations work. The > > operations work if the file path doesn't contain non-ascii characters. > > > > What am I doing wrong? > > > > I have PyWin32 - v 209. > > > > from win32com.shell import shell, shellcon > > > > > > def fileOperation(source, destination, operation): > > result = shell.SHFileOperation((0, operation, > > source, destination, > > shellcon.FOF_NOCONFIRMATION | > > shellcon.FOF_NOERRORUI | shellcon.FOF_SILENT)) > > if result == 0: > > raise Exception("Operation failed") > > return result > > > > def copyFile(source, destination): > > return fileOperation(source, destination, shellcon.FO_COPY) > > > > def moveFile(source, destination): > > return fileOperation(source, destination, shellcon.FO_MOVE) > > > > > > if __name__ == '__main__': > > "Lets do some testing of the above two functions" > > import os > > import sys > > testDir = ur"D:\\SHFOTestsDir" > > os.mkdir(testDir) > > "Some hiragana characters" > > smallA = u'\u3042' > > KA = u'\u304B' > > GI = u'\u304E' > > folder1Name = KA * 10 > > folder2Name = GI * 10 > > folder1Path = os.path.join(testDir, folder1Name) > > folder2Path = os.path.join(testDir, folder2Name) > > os.mkdir(folder1Path) > > os.mkdir(folder2Path) > > filenames = () > > contents = '20' * 100 > > for i in range(10): > > filename = KA * (i + 5) > > filepath = os.path.join(folder1Path, filename) > > f = open(filepath, 'w') > > f.write(contents) > > f.close() > > copyFile(filepath, folder2Path) > > > > With regards, > > - Shailesh > > This is another issue with compatibility with Windows 98, which doesn't > support the unicode version of this function directly. It's still possible to > wrap SHFileOperationW, but it takes some extra work. > > Python itself stops supporting Win98 as of 2.6, but Pywin32 will probably > continue supporting it for some time since Mark usually creates releases > for at least 2 prior versions of Python. > > Roger > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From mmarch at gmail.com Mon Aug 13 09:08:29 2007 From: mmarch at gmail.com (Michael March) Date: Mon, 13 Aug 2007 00:08:29 -0700 Subject: [python-win32] Remedy automation via COM.. Message-ID: <48bc40670708130008n1e63b7act4d19a0e134c6b27d@mail.gmail.com> I'm about to start a project at my current gig where I need to automate interaction with Remedy. I poked around the net via Google and I didn't see any recent posts anywhere on interfacing Python with it.. Is anyone out there using Python/COM to connect with Remedy? thanks! -- Michael F. March ----- mmarch at gmail.com "Seriously" - HSR From johan.lindvall at gmail.com Mon Aug 13 12:11:16 2007 From: johan.lindvall at gmail.com (Johan Lindvall) Date: Mon, 13 Aug 2007 12:11:16 +0200 Subject: [python-win32] Parameterless propget in Python ActiveScriptincomplete In-Reply-To: References: <3b7f01c6fb37$57f7f9c0$0f0a0a0a@enfoldsystems.local> Message-ID: Hi, > I've opened 1857023 for this bug: > http://sourceforge.net/tracker/index.php?func=detail&aid=1587023&group_id=78018&atid=551954 > > As a workaround we're distributing a patched version of dynamic.py, > where LazyDispatchItem has been disabled. Have you had a chance to look at this bug? Redistributing a patched dynamic.py is a bit cumbersome. -- /Johan. From johan.lindvall at gmail.com Mon Aug 13 14:01:37 2007 From: johan.lindvall at gmail.com (Johan Lindvall) Date: Mon, 13 Aug 2007 14:01:37 +0200 Subject: [python-win32] Parameterless propget in Python ActiveScriptincomplete In-Reply-To: References: <3b7f01c6fb37$57f7f9c0$0f0a0a0a@enfoldsystems.local> Message-ID: Hi, I've been poking around a bit in the source code and the following patch (against pywin210) more or less solves the problem. The code obviously needs to be more robust, but I am not really familiar with the inner workings of pywin32 / COM. Index: dynamic.py =================================================================== --- dynamic.py (revision 36121) +++ dynamic.py (working copy) @@ -377,6 +377,8 @@ for i in ALL_INVOKE_TYPES: try: x,t = typecomp.Bind(attr,i) + if x==0 and (attr[:3] == 'Set' or attr[:3] == 'Get'): + x,t = typecomp.Bind(attr[3:], i) # strip get / set if x==1: #it's a FUNCDESC r = olerepr._AddFunc_(typeinfo,t,0) elif x==2: #it's a VARDESC -- /Johan. From johan.lindvall at gmail.com Tue Aug 14 09:35:37 2007 From: johan.lindvall at gmail.com (Johan Lindvall) Date: Tue, 14 Aug 2007 09:35:37 +0200 Subject: [python-win32] Selecttlb doesn't handle hexadecimal version numbers (patch attached) Message-ID: Hi, It appears Selecttlb.py for pywin32 210 doesn't handle typelibs with hexadecimal version numbers. After updating our app to version 10.0 (a.0), we cannot use makepy anymore. The following patch fixed the problem: Index: selecttlb.py =================================================================== --- selecttlb.py (revision 36133) +++ selecttlb.py (working copy) @@ -92,7 +92,8 @@ major = int(major_minor[0]) minor = int(major_minor[1]) except ValueError: # crap in the registry! - continue + major = -1 # set dummy values and continue working with string based version number + minor = -1 key3 = win32api.RegOpenKey(key2, str(version)) try: =================================================================== Regards, -- /Johan. From amonroe at columbus.rr.com Tue Aug 14 14:52:18 2007 From: amonroe at columbus.rr.com (R. Alan Monroe) Date: Tue, 14 Aug 2007 08:52:18 -0400 Subject: [python-win32] Remedy automation via COM.. In-Reply-To: <48bc40670708130008n1e63b7act4d19a0e134c6b27d@mail.gmail.com> References: <48bc40670708130008n1e63b7act4d19a0e134c6b27d@mail.gmail.com> Message-ID: <115312538837.20070814085218@columbus.rr.com> > I'm about to start a project at my current gig where I need to > automate interaction with Remedy. I poked around the net via Google > and I didn't see any recent posts anywhere on interfacing Python with > it.. > Is anyone out there using Python/COM to connect with Remedy? Not using it regularly, but I did try some simple test programs like this one, a few years ago, just to see if it would work: import win32com.client as w app = w.Dispatch("Remedy.User") sess = app.Login("xxxxxx", "yyyyyy", 1) print "logged in" formlist = app.GetFormList(sess, "servername") print formlist app.Logout(sess) print "logged out" Version 5's COM abilities were pretty limited. I wondered if it would be more useful to wrap the standard C API with ctypes. Alan From raduciora at yahoo.com Fri Aug 17 12:30:49 2007 From: raduciora at yahoo.com (Radu Ciora) Date: Fri, 17 Aug 2007 03:30:49 -0700 (PDT) Subject: [python-win32] get active process list crashes Message-ID: <800068.70247.qm@web50105.mail.re2.yahoo.com> Hi all, when I try to call GetObject('winmgmts:') when an input event happens, I get the following exception: File "D:\DAProject\Workspace\context\inputhook\RDFIO.py", line 67, in wordInfo self.GetActiveProcess() File "D:\DAProject\Workspace\context\inputhook\RDFIO.py", line 71, in GetActiveProcess l_WMI = GetObject('winmgmts:') File "c:\Python24\Lib\site-packages\win32com\client\__init__.py", line 73, in GetObject return Moniker(Pathname, clsctx) File "c:\Python24\Lib\site-packages\win32com\client\__init__.py", line 88, in Moniker moniker, i, bindCtx = pythoncom.MkParseDisplayName(Pathname) pywintypes.com_error: (-2147417843, 'An outgoing call cannot be made since the application is dispatching an input-synchronous call.', None, None) Any help really appreciated. Thanks a million, Radu. ___________________________________________________________ Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now. http://uk.answers.yahoo.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070817/46ee00cf/attachment.html From raduciora at yahoo.com Fri Aug 17 12:35:14 2007 From: raduciora at yahoo.com (Radu Ciora) Date: Fri, 17 Aug 2007 03:35:14 -0700 (PDT) Subject: [python-win32] get outlook to/from fields Message-ID: <222697.70247.qm@web50105.mail.re2.yahoo.com> Hi everyone, I have an application which monitors the user input and environment. I was wondering if it can get the the to/from fields from an opened email in outlook/outlook express. I don't have a handle to Outlook as I don't start the application from inside python. Is it possible to get one? Any help much appreciated! Thanks a million, Radu. ___________________________________________________________ Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070817/2951be08/attachment.htm From kf9150 at gmail.com Fri Aug 17 18:17:29 2007 From: kf9150 at gmail.com (Kelie) Date: Fri, 17 Aug 2007 16:17:29 +0000 (UTC) Subject: [python-win32] get outlook to/from fields References: <222697.70247.qm@web50105.mail.re2.yahoo.com> Message-ID: Radu Ciora yahoo.com> writes: > Hi everyone,I have an application which monitors the user input and environment.I was wondering if it can get the the to/from fields from an opened email in outlook/outlook express.I don't have a handle to Outlook as I don't start the application from inside python. Is it possible to get one?Any help much appreciated!Thanks a million,Radu. > If the opened email is the current item, would the following be helpful? It is in VBA, but should be easy to translate to Python with pywin32. Public Sub Test() Dim myOlApp As New Outlook.Application Dim myItem As Object Set myItem = myOlApp.ActiveInspector.CurrentItem Debug.Print myItem.To Debug.Print myItem.From End Sub From jelleferinga at gmail.com Mon Aug 20 13:25:40 2007 From: jelleferinga at gmail.com (jelle) Date: Mon, 20 Aug 2007 11:25:40 +0000 (UTC) Subject: [python-win32] Array and CATIA References: <20070507140925.249630@gmx.net> Message-ID: Hi Andread, I think Thomas Paviot managed to deal with this issue. He developed a plugin for catia which is open source. If you download this, it might be of help for you dealing with this issue. Cheers, -jelle From jelleferinga at gmail.com Mon Aug 20 13:33:56 2007 From: jelleferinga at gmail.com (jelle) Date: Mon, 20 Aug 2007 11:33:56 +0000 (UTC) Subject: [python-win32] automating Adobe Indesign Message-ID: Hi, I'm working on scripting Indesign, a dtp app from Adobe. Thing is that I'm able to dispatch the application via win32com.client.Dispatch('Indesign.Application') which works just fine, but the thing is that I have no idea which methods are available: In [8]: ind = win32com.client.Dispatch('Indesign.Application') In [9]: ind. ind._ApplyTypes_ ind.__setitem__ ind._FlagAsMethod ind.__str__ ind._LazyAddAttr_ ind._builtMethods_ ind._NewEnum ind._enum_ ind._Release_ ind._find_dispatch_type_ ind.__AttrToID__ ind._get_good_object_ ind.__LazyMap__ ind._get_good_single_object_ ind.__call__ ind._lazydata_ ind.__cmp__ ind._make_method_ ind.__doc__ ind._mapCachedItems_ ind.__getattr__ ind._oleobj_ ind.__getitem__ ind._olerepr_ ind.__init__ ind._print_details_ ind.__int__ ind._proc_ ind.__len__ ind._unicode_to_string_ ind.__module__ ind._username_ ind.__nonzero__ ind._wrap_dispatch_ ind.__repr__ ind.__class__ ind.__setattr__ In [9]: doc = ind.ActiveDocument In [10]: doc Out[10]: > Since there is no *.tlb file in the program's directory, I haven't got an idea on how to get some level of introspection. Just being able to see which methods are available would be a Big Thing! Cheers, -jelle From larry.bates at websafe.com Mon Aug 20 18:55:15 2007 From: larry.bates at websafe.com (Larry Bates) Date: Mon, 20 Aug 2007 11:55:15 -0500 Subject: [python-win32] automating Adobe Indesign In-Reply-To: References: Message-ID: jelle wrote: > Hi, > > I'm working on scripting Indesign, a dtp app from Adobe. > Thing is that I'm able to dispatch the application via > win32com.client.Dispatch('Indesign.Application') > which works just fine, but the thing is that I have no idea which methods are > available: > > In [8]: ind = win32com.client.Dispatch('Indesign.Application') > > In [9]: ind. > ind._ApplyTypes_ ind.__setitem__ > ind._FlagAsMethod ind.__str__ > ind._LazyAddAttr_ ind._builtMethods_ > ind._NewEnum ind._enum_ > ind._Release_ ind._find_dispatch_type_ > ind.__AttrToID__ ind._get_good_object_ > ind.__LazyMap__ ind._get_good_single_object_ > ind.__call__ ind._lazydata_ > ind.__cmp__ ind._make_method_ > ind.__doc__ ind._mapCachedItems_ > ind.__getattr__ ind._oleobj_ > ind.__getitem__ ind._olerepr_ > ind.__init__ ind._print_details_ > ind.__int__ ind._proc_ > ind.__len__ ind._unicode_to_string_ > ind.__module__ ind._username_ > ind.__nonzero__ ind._wrap_dispatch_ > ind.__repr__ ind.__class__ > ind.__setattr__ > > In [9]: doc = ind.ActiveDocument > > In [10]: doc > Out[10]: > > > Since there is no *.tlb file in the program's directory, I haven't got an idea > on how to get some level of introspection. Just being able to see which methods > are available would be a Big Thing! > > Cheers, > > -jelle You can use the COM browser that comes with ActiveState's Python distribution to see all the methods. This normally how I figure this sort of thing out. -Larry From hd1956 at yahoo.com Mon Aug 20 21:53:11 2007 From: hd1956 at yahoo.com (RANDALL HOWELL) Date: Mon, 20 Aug 2007 12:53:11 -0700 (PDT) Subject: [python-win32] Newbee question Message-ID: <651487.2007.qm@web90415.mail.mud.yahoo.com> I am trying to figure out how to code my stop pay. I get paid 40 cents a stop for the first 22 stops, and $1.40 for stops after that. stops = 24 if stops < 22: stopPay = stops * .4 else: stopPay = stops * 1.4 print stopPay >>> 33.6 well thats not how I get paid, I get paid $8.80 for the first 22 stops + $2.80 for the last 2 stops. I know this is a elementary question, but it has got me stuck. Thanks From timr at probo.com Mon Aug 20 22:29:00 2007 From: timr at probo.com (Tim Roberts) Date: Mon, 20 Aug 2007 13:29:00 -0700 Subject: [python-win32] Newbee question In-Reply-To: <651487.2007.qm@web90415.mail.mud.yahoo.com> References: <651487.2007.qm@web90415.mail.mud.yahoo.com> Message-ID: <46C9F98C.4080105@probo.com> RANDALL HOWELL wrote: > I am trying to figure out how to code my stop pay. I > get paid 40 cents a stop for the first 22 stops, and > $1.40 for stops after that. > stops = 24 > if stops < 22: > stopPay = stops * .4 > else: > stopPay = stops * 1.4 > print stopPay > >>>> 33.6 >>>> > well thats not how I get paid, I get paid $8.80 for > the first 22 stops + $2.80 for the last 2 stops. I > know this is a elementary question, but it has got me > stuck. Just write the code like you wrote your explanation. I only had to change one line: stops = 24 if stops < 22: # First 22 stops are worth 40c each. stopPay = stops * 0.40 else: # For more than 22, we get 8.80 plus 1.40 for each stop over 22. stopPay = 8.80 + (stops-22) * 1.40 Another way to write it is to think about the stops beyond 22 as getting a 1.00 bonus: stopPay = stops * 0.40 if stops > 22: stopPay += (stops-22) * 1.00 but I don't really think that's clearer. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mmarch at gmail.com Mon Aug 20 22:30:20 2007 From: mmarch at gmail.com (Michael March) Date: Mon, 20 Aug 2007 13:30:20 -0700 Subject: [python-win32] Newbee question In-Reply-To: <651487.2007.qm@web90415.mail.mud.yahoo.com> References: <651487.2007.qm@web90415.mail.mud.yahoo.com> Message-ID: <48bc40670708201330t55ef3f48vceb1455af19f9614@mail.gmail.com> This is a python-win32 specific question? On 8/20/07, RANDALL HOWELL wrote: > > I am trying to figure out how to code my stop pay. I > get paid 40 cents a stop for the first 22 stops, and > $1.40 for stops after that. > stops = 24 > if stops < 22: > stopPay = stops * .4 > else: > stopPay = stops * 1.4 > print stopPay > >>> 33.6 > well thats not how I get paid, I get paid $8.80 for > the first 22 stops + $2.80 for the last 2 stops. I > know this is a elementary question, but it has got me > stuck. Thanks > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070820/fd670314/attachment.htm From raduciora at yahoo.com Mon Aug 20 22:49:19 2007 From: raduciora at yahoo.com (Radu Ciora) Date: Mon, 20 Aug 2007 13:49:19 -0700 (PDT) Subject: [python-win32] EnumChildWindows Message-ID: <675608.59595.qm@web50103.mail.re2.yahoo.com> Hi everyone, can anyone give me an example of use of win32gui.EnumChildWindows() function as I can't seem to make it work: my code looks like this: ... win32gui.EnumChildWindows(l_hwnd, self.windowEnumerationHandler(), l_childlist) ... def windowEnumerationHandler(hwnd, resultList): #Pass to win32gui.EnumWindows() to generate list of window handle, window text. print "hwnd: " + str(hwnd) print "resultList: " + str(resultList) resultList.append((hwnd, win32gui.GetWindowText(hwnd))) Any help much appreciated! Thanks a million, Radu. ___________________________________________________________ Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070820/e71d45b0/attachment.htm From rschroev_nospam_ml at fastmail.fm Mon Aug 20 23:11:34 2007 From: rschroev_nospam_ml at fastmail.fm (Roel Schroeven) Date: Mon, 20 Aug 2007 23:11:34 +0200 Subject: [python-win32] Newbee question In-Reply-To: <651487.2007.qm@web90415.mail.mud.yahoo.com> References: <651487.2007.qm@web90415.mail.mud.yahoo.com> Message-ID: RANDALL HOWELL schreef: > I am trying to figure out how to code my stop pay. I > get paid 40 cents a stop for the first 22 stops, and > $1.40 for stops after that. > stops = 24 > if stops < 22: > stopPay = stops * .4 > else: > stopPay = stops * 1.4 > print stopPay >>>> 33.6 > well thats not how I get paid, I get paid $8.80 for > the first 22 stops + $2.80 for the last 2 stops. I > know this is a elementary question, but it has got me > stuck. Thanks Exactly the same question has been asked and answered earlier today on the comp.lang.python newsgroup. You can follow the discussion here: http://groups.google.com/group/comp.lang.python/browse_thread/thread/a4defd225a9d5b32/3e821369c667c0c3#3e821369c667c0c3 -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven From jelleferinga at gmail.com Mon Aug 20 23:13:19 2007 From: jelleferinga at gmail.com (jelle) Date: Mon, 20 Aug 2007 21:13:19 +0000 (UTC) Subject: [python-win32] automating Adobe Indesign References: Message-ID: Hi Larry, Thanks a lot, the combrowser is a terrific suggestion, cheers! -jelle From kjcole at ubuntu.com Mon Aug 20 23:04:31 2007 From: kjcole at ubuntu.com (Kevin Cole) Date: Mon, 20 Aug 2007 17:04:31 -0400 Subject: [python-win32] Q: error when using win32print via apache: "null context handle" Message-ID: <46CA01DF.2080204@ubuntu.com> Hi, This falls under the "myopic-leading-the-blind" department. ;-) I'm helping a friend who wants to have his web site send something directly to his printer when a web form is submitted. We're working with Windoze XP, Apache2, and Python 2.4. He has two printers, one directly connected and another one on a network. When run directly from the command line, my code has no problems printing to either printer. However, when printing via the web, it prints to the local printer okay but gives the following error, in the apache error.log, when printing to the network printer (edited for brevity). > jobID = StartDocPrinter(lpr, 1, ("Delivery",None,None)) > pywintypes.error: (1775, 'StartDocPrinter', 'A null context handle was > passed from the client to the host during a remote procedure call.') While searching the web, I found vague references to the problem being related to ASP.NET, and adding to a "Web.config" file, but it doesn't help me much. I didn't think I was using ASP.NET, and am not sure where "Web.config" should live or what else it should contain. (http://blogs.msdn.com/bryanke/articles/71491.aspx) Any ideas what's going wrong here? Thanks in advance. P.S. If you'd be kind enough to CC me as well as the list, it would be appreciated. -- Kevin Cole | Key ID: 0xE6F332C7 Ubuntu Linux DC LoCo Team | WWW: http://dc.ubuntu-us.org/ Washington, D.C. (USA) | ". ! 1 |" -- Rene Magritte's computer From Jim.Vickroy at noaa.gov Mon Aug 20 22:23:04 2007 From: Jim.Vickroy at noaa.gov (Jim.Vickroy at noaa.gov) Date: Mon, 20 Aug 2007 14:23:04 -0600 Subject: [python-win32] Newbee question Message-ID: ----- Original Message ----- From: RANDALL HOWELL Date: Monday, August 20, 2007 1:53 pm Subject: [python-win32] Newbee question > I am trying to figure out how to code my stop pay. I > get paid 40 cents a stop for the first 22 stops, and > $1.40 for stops after that. > stops = 24 > if stops < 22: > stopPay = stops * .4 > else: > stopPay = stops * 1.4 > print stopPay > >>> 33.6 > well thats not how I get paid, I get paid $8.80 for > the first 22 stops + $2.80 for the last 2 stops. I > know this is a elementary question, but it has got me > stuck. Thanks try initializing a pay accumulator variable (stopPay) and then executing your if-else block in a loop over stops in the range (1,25) where stopPay is incremented by the rate in effect for that stop. P.S. This question would be more appropriate for comp.lang.python since your question is not specific to Microsoft Windows. > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From timr at probo.com Mon Aug 20 23:24:21 2007 From: timr at probo.com (Tim Roberts) Date: Mon, 20 Aug 2007 14:24:21 -0700 Subject: [python-win32] EnumChildWindows In-Reply-To: <675608.59595.qm@web50103.mail.re2.yahoo.com> References: <675608.59595.qm@web50103.mail.re2.yahoo.com> Message-ID: <46CA0685.1030401@probo.com> Radu Ciora wrote: > Hi everyone, > can anyone give me an example of use of win32gui.EnumChildWindows() > function > as I can't seem to make it work: > > my code looks like this: > ... > win32gui.EnumChildWindows(l_hwnd, self.windowEnumerationHandler(), > l_childlist) That can't be your code. That calls windowEnumerationHandler, rather than passing the address of it. > ... > def windowEnumerationHandler(hwnd, resultList): Remember that a member function always gets a "self" parameter first. All you need to do is change those two lines to: win32gui.EnumChildWindows( l_hwnd, self.windowEnumerationHandler, l_childlist ) ... def windowEnumerationHandler( self, hwnd, resultList ): -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From raduciora at yahoo.com Mon Aug 20 23:39:38 2007 From: raduciora at yahoo.com (Radu Ciora) Date: Mon, 20 Aug 2007 14:39:38 -0700 (PDT) Subject: [python-win32] EnumChildWindows Message-ID: <502110.63660.qm@web50106.mail.re2.yahoo.com> thanks for the reply Tim but that's how I got the sample from internet. Anyway I changed the code like this: ... win32gui.EnumChildWindows(l_hwnd, self.windowEnumerationHandler(l_hwnd,l_childlist), l_childlist) ... def windowEnumerationHandler(self, hwnd, resultList): ... but now I get the following error: Traceback (most recent call last): File "c:\Python24\Lib\site-packages\pyHook\HookManager.py", line 325, in MouseSwitch return func(event) File "D:\DAProject\Workspace\context\inputhook\RDFIO.py", line 111, in onMouseEvent self.whatAmIDoin(event) File "D:\DAProject\Workspace\context\inputhook\RDFIO.py", line 119, in whatAmIDoin l_appName = self.getCurrentApplication() File "D:\DAProject\Workspace\context\inputhook\RDFIO.py", line 57, in getCurrentApplication self.wordInfo() File "D:\DAProject\Workspace\context\inputhook\RDFIO.py", line 70, in wordInfo self.getActiveWindowHandle() File "D:\DAProject\Workspace\context\inputhook\RDFIO.py", line 93, in getActiveWindowHandle win32gui.EnumChildWindows(l_hwnd, self.windowEnumerationHandler(l_hwnd,l_childlist), l_childlist) TypeError: First param must be a callable object Any ideas? Thanks a million! Radu. ----- Original Message ---- From: Tim Roberts To: Python-Win32 List Sent: Monday, 20 August, 2007 10:24:21 PM Subject: Re: [python-win32] EnumChildWindows Radu Ciora wrote: > Hi everyone, > can anyone give me an example of use of win32gui.EnumChildWindows() > function > as I can't seem to make it work: > > my code looks like this: > ... > win32gui.EnumChildWindows(l_hwnd, self.windowEnumerationHandler(), > l_childlist) That can't be your code. That calls windowEnumerationHandler, rather than passing the address of it. > ... > def windowEnumerationHandler(hwnd, resultList): Remember that a member function always gets a "self" parameter first. All you need to do is change those two lines to: win32gui.EnumChildWindows( l_hwnd, self.windowEnumerationHandler, l_childlist ) ... def windowEnumerationHandler( self, hwnd, resultList ): -- 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 ___________________________________________________________ Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070820/81c16ce1/attachment.htm From mhammond at skippinet.com.au Tue Aug 21 02:05:43 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 21 Aug 2007 10:05:43 +1000 Subject: [python-win32] Q: error when using win32print via apache: "nullcontext handle" In-Reply-To: <46CA01DF.2080204@ubuntu.com> References: <46CA01DF.2080204@ubuntu.com> Message-ID: <000301c7e387$074ff840$15efe8c0$@com.au> > This falls under the "myopic-leading-the-blind" department. ;-) I'm > helping > a friend who wants to have his web site send something directly to his > printer when a web form is submitted. We're working with Windoze XP, > Apache2, and Python 2.4. > > He has two printers, one directly connected and another one on a > network. > When run directly from the command line, my code has no problems > printing > to either printer. However, when printing via the web, it prints to the > local printer okay but gives the following error, in the apache > error.log, > when printing to the network printer (edited for brevity). > > > jobID = StartDocPrinter(lpr, 1, ("Delivery",None,None)) > > pywintypes.error: (1775, 'StartDocPrinter', 'A null context handle > was > > passed from the client to the host during a remote procedure call.') The problem is almost certainly that the user running the Apache service does not have the rights to access network resources. You probably do not want to change Apache to use a user with more permissions and I'm not sure if relaxing the permissions for the shared printer (a) is any better or (b) would even work anyway. You can probably verify that is the problem by changing the user configured to run Apache, and then look beyond the Python and Apache universes for a general solution to this problem. Mark From timr at probo.com Tue Aug 21 02:19:34 2007 From: timr at probo.com (Tim Roberts) Date: Mon, 20 Aug 2007 17:19:34 -0700 Subject: [python-win32] EnumChildWindows In-Reply-To: <502110.63660.qm@web50106.mail.re2.yahoo.com> References: <502110.63660.qm@web50106.mail.re2.yahoo.com> Message-ID: <46CA2F96.5090805@probo.com> Radu Ciora wrote: > thanks for the reply Tim but that's how I got the sample from internet. > Anyway I changed the code like this: > ... > win32gui.EnumChildWindows(l_hwnd, > self.windowEnumerationHandler(l_hwnd,l_childlist), l_childlist) That's not what I wrote at all. You need to pass the function, not call the function and pass whatever it returns. Do it exactly like this: win32gui.EnumChildWindows( l_hwnd, self.windowEnumerationHandler, l_childlist ) Note that there are *no parentheses* after windowEnumerationHandler. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From larry.bates at websafe.com Tue Aug 21 15:33:11 2007 From: larry.bates at websafe.com (Larry Bates) Date: Tue, 21 Aug 2007 08:33:11 -0500 Subject: [python-win32] Q: error when using win32print via apache: "null context handle" In-Reply-To: <46CA01DF.2080204@ubuntu.com> References: <46CA01DF.2080204@ubuntu.com> Message-ID: Because people were misusing local resources almost all access to hard drives, printers, etc. has been disabled in browsers. The two ways around this are: 1) Write an ActiveX plug-in that is installed in the browser that can send to the printer. 2) Either display a printable HTML page in the browser or create a PDF report that gets downloaded to the Acrobat Reader plug-in of the browser. Then all the user has to do is hit the print button. Most people choose option 2 -Larry Kevin Cole wrote: > Hi, > > This falls under the "myopic-leading-the-blind" department. ;-) I'm helping > a friend who wants to have his web site send something directly to his > printer when a web form is submitted. We're working with Windoze XP, > Apache2, and Python 2.4. > > He has two printers, one directly connected and another one on a network. > When run directly from the command line, my code has no problems printing > to either printer. However, when printing via the web, it prints to the > local printer okay but gives the following error, in the apache error.log, > when printing to the network printer (edited for brevity). > >> jobID = StartDocPrinter(lpr, 1, ("Delivery",None,None)) >> pywintypes.error: (1775, 'StartDocPrinter', 'A null context handle was >> passed from the client to the host during a remote procedure call.') > > While searching the web, I found vague references to the problem being > related to ASP.NET, and adding to a > "Web.config" file, but it doesn't help me much. I didn't think I was using > ASP.NET, and am not sure where "Web.config" should live or what else it > should contain. (http://blogs.msdn.com/bryanke/articles/71491.aspx) > > Any ideas what's going wrong here? > > Thanks in advance. > > P.S. If you'd be kind enough to CC me as well as the list, it would be > appreciated. From vernon.cole at wirelessbeehive.com Tue Aug 21 21:46:23 2007 From: vernon.cole at wirelessbeehive.com (Vernon Cole) Date: Tue, 21 Aug 2007 13:46:23 -0600 (MDT) Subject: [python-win32] where should adodbapi be placed within python-win32? Message-ID: <59893.64.161.38.176.1187725583.squirrel@mail.wirelessbeehive.com> I suppose I should make an introduction and an announcement before asking this question. So... I am Vernon Cole. I have recently been made an admin for the adodbapi project on sourceforge. My stated purpose for seeking that appointment was to eventually retire the project by including it as part of pywin32. Mark Hammond has given his blessing to that effort. I have released adodbapi version 2.1 which includes all known bug fixes and most enhancement request patches. (see http://adodbapi.sourceforge.net for more information.) I feel that it is time for its inclusion into pywin32. Adodbapi is a pure python implementation of the complete db api 2.0 specification which uses Microsoft ADO DB as its access method. It is dependent on pywin32 as a prerequisite because it uses the COM interface to reach ADO. Included units tests operate correctly with Microsoft ACCESS tables, MS-SQL, and MySQL (using an ODBC driver.) My reason for including it in pywin32 is to prevent having to download and install a third package (in addition to pywin32 and python itself) in order to have full 2.0 level database access. One more step towards "batteries included." Mark has asked me where within the pywin32 source tree should adodbapi be placed? Here are my thoughts on the matter, your input is solicited... Existing distributions of adodbapi are at the site-packages level, siblings with pythonwin and win32com. i.e. C:\Python2x\Lib\site-packages\adodbapi . I think that they should continue to be installed at that same place to simplify upgrades on systems where the package is already installed. It feels right to me then for the source to be a new branch off of /pywin32 (i.e. /pywin32/adodbapi) rather than finding another place further down the tree. The existing directory tree looks like this: -- adodbapi-2.1 ..--adodbapi ....--__init__.py ....--adodbapi.py ..--tests ....--adodbapitest.py ....--adodbapitestconfig.py ....--adbapi20.py (and so forth) ..--license.txt ..--readme.txt ..--setup.py I understand nothing about the magic whereby the source in the CVS tree becomes the install file that I run on a target system. So my question is: would /pywin32/adodbapi/adodbapy/adodbapi.py be the correct place to put the source? -- Vernon Cole From Hien.Pham at tekelec.com Tue Aug 21 14:57:54 2007 From: Hien.Pham at tekelec.com (Pham, Hien) Date: Tue, 21 Aug 2007 07:57:54 -0500 Subject: [python-win32] Newbee question In-Reply-To: <651487.2007.qm@web90415.mail.mud.yahoo.com> Message-ID: <58292FA6B3EEFD49AEDAF6597E21E71707048C50@DCEVS2.tekelec.com> This is not a Python question - It is a Math problem: Try this: stops = 24 if stops <= 22: stopPay = stops * .4 else: stopPay = 22 * 0.4 + (stops - 22) * 1.4 print stopPay That will give you $11.60 Hope that help, H. Pham -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of RANDALL HOWELL Sent: Monday, August 20, 2007 3:53 PM To: python-win32 at python.org Subject: [python-win32] Newbee question I am trying to figure out how to code my stop pay. I get paid 40 cents a stop for the first 22 stops, and $1.40 for stops after that. stops = 24 if stops < 22: stopPay = stops * .4 else: stopPay = stops * 1.4 print stopPay >>> 33.6 well thats not how I get paid, I get paid $8.80 for the first 22 stops + $2.80 for the last 2 stops. I know this is a elementary question, but it has got me stuck. Thanks _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From victor_lebrun at yahoo.fr Thu Aug 23 11:33:17 2007 From: victor_lebrun at yahoo.fr (victor LEBRUN) Date: Thu, 23 Aug 2007 09:33:17 +0000 (GMT) Subject: [python-win32] Tr : ActiveX control in python vs ActiveX control in vb 6 (piece of code) Message-ID: <729281.81593.qm@web27604.mail.ukl.yahoo.com> ----- Message transf?r? ---- De : victor LEBRUN ? : wxpython-users at lists.sourceforge.net Envoy? le : Mercredi, 22 Ao?t 2007, 14h45mn 08s Objet : ActiveX control in python vs ActiveX control in vb 6 (piece of code) Hello, I am trying to migrate from vb 6 to python. I have a very usefull AX control. It can be : -just a bitmap -an active picture where you can plot data and put cursors -a data explorer Those 3 behavior are driven by one property in visual studio when you insert the AX control in a form: the property ModuleName: -'default' for bitmap -'Picture' for a picture I try to insert this AX control in a wxpython based application (I used one of the example delivered with wx) but when I try to change the property to get an active picture it does not work and display me the default bitmap :( Here is the pice of code #################################################################################### import wx if wx.Platform == '__WXMSW__': from wx.lib.activexwrapper import MakeActiveXClass import win32com.client try: ocx = win32com.client.gencache.EnsureModule('{33924602- C29E-4915-91B1-767CA3D675C2}',0x0,1,0) except: raise ImportError("Can't load ocx") #---------------------------------------------------------------------- class TestPanel(wx.Panel): def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1) self.pdf = None sizer = wx.BoxSizer(wx.VERTICAL) btnSizer = wx.BoxSizer(wx.HORIZONTAL) # this function creates a new class that can be used as # a wxWindow, but contains the given ActiveX control. coclass=ocx.ActiveXModuleLoader print coclass coclass.ModuleName='picture' ActiveXWrapper = MakeActiveXClass(coclass) # create an instance of the new class self.pdf = ActiveXWrapper(self) #self.pdf.ModuleName='PictureManager' sizer.Add(self.pdf, 1, wx.EXPAND) btn = wx.Button(self, wx.NewId(), "Open PDF File") wx.EVT_BUTTON(self, btn.GetId(), self.OnOpenButton) btnSizer.Add(btn, 1, wx.EXPAND|wx.ALL, 5) btn = wx.Button(self, wx.NewId(), "<-- Previous Page") wx.EVT_BUTTON(self, btn.GetId(), self.OnPrevPageButton) btnSizer.Add(btn, 1, wx.EXPAND|wx.ALL, 5) btn = wx.Button(self, wx.NewId(), "Next Page -->") wx.EVT_BUTTON(self, btn.GetId(), self.OnNextPageButton) btnSizer.Add(btn, 1, wx.EXPAND|wx.ALL, 5) btnSizer.Add((50, -1), 2, wx.EXPAND) sizer.Add(btnSizer, 0, wx.EXPAND) self.SetSizer(sizer) self.SetAutoLayout(True) wx.EVT_WINDOW_DESTROY(self, self.OnDestroy) def OnDestroy(self, evt): if self.pdf: self.pdf.Cleanup() self.pdf = None def OnOpenButton(self, event): print 'open' def OnPrevPageButton(self, event): print 'button' def OnNextPageButton(self, event): print self.pdf.ModuleName #---------------------------------------------------------------------- def runTest(frame, nb, log): if wxPlatform == '__WXMSW__': win = TestPanel(nb, log) return win else: dlg = wx.MessageDialog(frame, 'This demo only works on MSW.', 'Sorry', wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() overview = __doc__ #---------------------------------------------------------------------- if __name__ == '__main__': import sys class TestFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, "ActiveX test", size=(640, 480), style=wx.DEFAULT_FRAME_STYLE| wx.NO_FULL_REPAINT_ON_RESIZE) self.tp = TestPanel(self, sys.stdout) app = wx.PySimpleApp() frame = TestFrame() frame.Show(True) app.MainLoop() ############################################################################# I suspect that the activex control is bugged .... but how to know that since it is working perfectly under visual studio vb 6 but not with python ?:( please help me ! _____________________________________________________________________________ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail _____________________________________________________________________________ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail From rwupole at msn.com Fri Aug 24 05:29:27 2007 From: rwupole at msn.com (Roger Upole) Date: Thu, 23 Aug 2007 23:29:27 -0400 Subject: [python-win32] Re: get active process list crashes Message-ID: <001e01c7e5fe$fc1818c0$0100a8c0@rupole> Radu Ciora wrote: > Hi all, > > when I try to call GetObject('winmgmts:') when an input event happens, I get the following exception: > > File "D:\DAProject\Workspace\context\inputhook\RDFIO.py", line 67, in wordInfo > self.GetActiveProcess() > File "D:\DAProject\Workspace\context\inputhook\RDFIO.py", line 71, in GetActiveProcess > l_WMI = GetObject('winmgmts:') > File "c:\Python24\Lib\site-packages\win32com\client\__init__.py", line 73, in GetObject > return Moniker(Pathname, clsctx) > File "c:\Python24\Lib\site-packages\win32com\client\__init__.py", line 88, in Moniker > moniker, i, bindCtx = pythoncom.MkParseDisplayName(Pathname) > pywintypes.com_error: (-2147417843, 'An outgoing call cannot be made since the application is dispatching an input-synchronous > call.', None, None) > > Any help really appreciated. > > Thanks a million, > Radu Events are processed synchronously, so basically you can't make that call while the event code is running. You might be able to use a win32 event or a timer to signal the main program to perform the WMI operation. Roger From rwupole at msn.com Fri Aug 24 05:53:39 2007 From: rwupole at msn.com (Roger Upole) Date: Thu, 23 Aug 2007 23:53:39 -0400 Subject: [python-win32] Re: where should adodbapi be placed within python-win32? Message-ID: <000701c7e602$5db22eb0$0100a8c0@rupole> Vernon Cole wrote: > I suppose I should make an introduction and an announcement before asking > this question. So... > I am Vernon Cole. I have recently been made an admin for the adodbapi > project on sourceforge. My stated purpose for seeking that appointment > was to eventually retire the project by including it as part of > pywin32. Mark Hammond has given his blessing to that effort. I have > released adodbapi version 2.1 which includes all known bug fixes and > most enhancement request patches. (see http://adodbapi.sourceforge.net > for more information.) I feel that it is time for its inclusion into > pywin32. > Adodbapi is a pure python implementation of the complete db api 2.0 > specification which uses Microsoft ADO DB as its access method. It is > dependent on pywin32 as a prerequisite because it uses the COM > interface to reach ADO. Included units tests operate correctly with > Microsoft ACCESS tables, MS-SQL, and MySQL (using an ODBC driver.) My > reason for including it in pywin32 is to prevent having to download > and install a third package (in addition to pywin32 and python itself) > in order to have full 2.0 level database access. One more step towards > "batteries included." > > Mark has asked me where within the pywin32 source tree should adodbapi be > placed? Here are my thoughts on the matter, your input is solicited... > > Existing distributions of adodbapi are at the site-packages level, > siblings with pythonwin and win32com. i.e. > C:\Python2x\Lib\site-packages\adodbapi . > I think that they should continue to be installed at that same place to > simplify upgrades on systems where the package is already installed. > It feels right to me then for the source to be a new branch off of > /pywin32 (i.e. /pywin32/adodbapi) rather than finding another place > further down the tree. > > The existing directory tree looks like this: > -- adodbapi-2.1 > ..--adodbapi > ....--__init__.py > ....--adodbapi.py > ..--tests > ....--adodbapitest.py > ....--adodbapitestconfig.py > ....--adbapi20.py (and so forth) > ..--license.txt > ..--readme.txt > ..--setup.py > > I understand nothing about the magic whereby the source in the CVS tree > becomes the install file that I run on a target system. So my question is: > would /pywin32/adodbapi/adodbapy/adodbapi.py be the correct place to put > the source? > -- > Vernon Cole Installing it directly in site-packages sounds reasonable to me, as well as placing the source in /pywin32/adodbapi. If there's no C++ to compile, getting it into the installer may be as simple as adding adodbapi to the list of packages in setup.py. As a side note, how does it handle currency ? The default method for returning currency from COM is going to change to a Decimal object at some point. Roger From vernon.cole at wirelessbeehive.com Fri Aug 24 08:18:38 2007 From: vernon.cole at wirelessbeehive.com (Vernon Cole) Date: Fri, 24 Aug 2007 00:18:38 -0600 (MDT) Subject: [python-win32] Re: where should adodbapi be placed within python-win32? Message-ID: <2053.204.13.132.6.1187936318.squirrel@mail.wirelessbeehive.com> Roger Upole said: >Installing it directly in site-packages sounds reasonable to me, as well as >placing the source in /pywin32/adodbapi. If there's no C++ to compile, >getting it into the installer may be as simple as adding adodbapi to the >list of packages in setup.py. --- You understand correctly. There is no C code. --- > As a side note, how does it handle currency ? The default method for >returning currency from COM is going to change to a Decimal object >at some point. > > Roger --- adodbapi's major change between 2.0 and 2.1 is that it now returns decimal and currency columns as python Decimal objects, rather than floats. Python 2.3 or later is required for that reason. Vernon Cole software engineer From raduciora at yahoo.com Fri Aug 24 23:43:41 2007 From: raduciora at yahoo.com (Radu Ciora) Date: Fri, 24 Aug 2007 14:43:41 -0700 (PDT) Subject: [python-win32] get running application handle Message-ID: <986028.36265.qm@web50111.mail.re2.yahoo.com> Hi all, Is it possible to get a handle to a running application like the one I get when I explicitly start an application myself using the win32com.client.Dispatch("Object.Name")? Is the one retrieved by win32gui.GetForegroundWindow() the same as the one above or not, if not how can I get the handle to a running application object. I hope I made myself understand. Thanks a million, Radu. ___________________________________________________________ Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html From timr at probo.com Sat Aug 25 00:04:02 2007 From: timr at probo.com (Tim Roberts) Date: Fri, 24 Aug 2007 15:04:02 -0700 Subject: [python-win32] get running application handle In-Reply-To: <986028.36265.qm@web50111.mail.re2.yahoo.com> References: <986028.36265.qm@web50111.mail.re2.yahoo.com> Message-ID: <46CF55D2.7050608@probo.com> Radu Ciora wrote: > Is it possible to get a handle to a running application like the one I get when I explicitly start an application myself using the win32com.client.Dispatch("Object.Name")? > > Is the one retrieved by win32gui.GetForegroundWindow() the same as the one above or not, if not how can I get the handle to a running application object. > > I hope I made myself understand. > Well, you are confusing several very different constructs there. What you get back from win32com.client.Dispatch is not a handle at all; it is a pointer to a COM object. It contains methods and properties that you can call directly. What you get back from win32gui.GetForegroundWindow is just a window handle. You can send window messages to it, but there is nothing there to call, and there is no connection to any COM objects. In fact, there is no guarantee that the foreground application offers any COM services at all. Having said that, I assume that what you really want to do, for example, is to connect to a currently running instance of Word. Is that right? Somewhat surprisingly, this depends on the application. For the Office products, if you do a Dispatch on Word.Application while Word is running, you should get a pointer to the existing Word application, and should be able to manipulate the existing documents. For other applications, the answer is "it depends". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From raduciora at yahoo.com Sat Aug 25 00:23:21 2007 From: raduciora at yahoo.com (Radu Ciora) Date: Fri, 24 Aug 2007 15:23:21 -0700 (PDT) Subject: [python-win32] get running application handle Message-ID: <700333.18380.qm@web50105.mail.re2.yahoo.com> I don't seem to be able to connect to a running instance of Word. I get the following error : Traceback (most recent call last): File "c:\Python24\Lib\site-packages\pyHook\HookManager.py", line 325, in MouseSwitch return func(event) File "D:\DAProject\Workspace\context\inputhook\RDFIO.py", line 122, in onMouseEvent self.whatAmIDoin(event) File "D:\DAProject\Workspace\context\inputhook\RDFIO.py", line 130, in whatAmIDoin l_appName = self.getCurrentApplication() File "D:\DAProject\Workspace\context\inputhook\RDFIO.py", line 62, in getCurrentApplication self.wordInfo() File "D:\DAProject\Workspace\context\inputhook\RDFIO.py", line 81, in wordInfo l_wobj = win32com.client.Dispatch("Word.Application") File "c:\Python24\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "c:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "c:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147417843, 'An outgoing call cannot be made since the application is dispatching an input-synchronous call.', None, None) Thanks a million, Radu. ----- Original Message ---- From: Tim Roberts To: Python-Win32 List Sent: Friday, 24 August, 2007 11:04:02 PM Subject: Re: [python-win32] get running application handle Radu Ciora wrote: > Is it possible to get a handle to a running application like the one I get when I explicitly start an application myself using the win32com.client.Dispatch("Object.Name")? > > Is the one retrieved by win32gui.GetForegroundWindow() the same as the one above or not, if not how can I get the handle to a running application object. > > I hope I made myself understand. > Well, you are confusing several very different constructs there. What you get back from win32com.client.Dispatch is not a handle at all; it is a pointer to a COM object. It contains methods and properties that you can call directly. What you get back from win32gui.GetForegroundWindow is just a window handle. You can send window messages to it, but there is nothing there to call, and there is no connection to any COM objects. In fact, there is no guarantee that the foreground application offers any COM services at all. Having said that, I assume that what you really want to do, for example, is to connect to a currently running instance of Word. Is that right? Somewhat surprisingly, this depends on the application. For the Office products, if you do a Dispatch on Word.Application while Word is running, you should get a pointer to the existing Word application, and should be able to manipulate the existing documents. For other applications, the answer is "it depends". -- 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 ___________________________________________________________ Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now. http://uk.answers.yahoo.com/ From ckkart at hoc.net Sat Aug 25 03:11:19 2007 From: ckkart at hoc.net (Christian K.) Date: Sat, 25 Aug 2007 01:11:19 +0000 (UTC) Subject: [python-win32] how to terminate a extended mapi session Message-ID: Hi, what must I take care of by myself when I want to terminate a program which communicates with Outlook through the extended mapi interface, i.e. in addition to session.Logoff and mapi.MAPIUnitialize? Currently I get the following errors upon prorgam termination and, what is more important, Outlook hangs and has to be restarted: Win32 exception occurred releasing IUnknown at 0x01fa09a8 Win32 exception occurred releasing IUnknown at 0x01f9e5c0 Win32 exception occurred releasing IUnknown at 0x01f9e5e8 Win32 exception occurred releasing IUnknown at 0x01f9e610 Win32 exception occurred releasing IUnknown at 0x01f82a48 Win32 exception occurred releasing IUnknown at 0x01fb7fc0 Win32 exception occurred releasing IUnknown at 0x01fb7fe8 Win32 exception occurred releasing IUnknown at 0x01f82aa0 Win32 exception occurred releasing IUnknown at 0x01f82ac8 Win32 exception occurred releasing IUnknown at 0x01f82af0 Win32 exception occurred releasing IUnknown at 0x01f82400 Win32 exception occurred releasing IUnknown at 0x01f89f80 Win32 exception occurred releasing IUnknown at 0x01f82428 Win32 exception occurred releasing IUnknown at 0x047b1fa8 Thanks for any hint, Christian From mhammond at skippinet.com.au Sat Aug 25 04:09:34 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 25 Aug 2007 12:09:34 +1000 Subject: [python-win32] where should adodbapi be placed within python-win32? In-Reply-To: <59893.64.161.38.176.1187725583.squirrel@mail.wirelessbeehive.com> References: <59893.64.161.38.176.1187725583.squirrel@mail.wirelessbeehive.com> Message-ID: <03d901c7e6bc$fe797000$fb6c5000$@com.au> Just following up from Roger's comments (which I agree with): > The existing directory tree looks like this: > -- adodbapi-2.1 > ..--adodbapi > ....--__init__.py > ....--adodbapi.py > ..--tests > ....--adodbapitest.py > ....--adodbapitestconfig.py > ....--adbapi20.py (and so forth) > ..--license.txt > ..--readme.txt > ..--setup.py > > I understand nothing about the magic whereby the source in the CVS tree > becomes the install file that I run on a target system. So my question > is: > would /pywin32/adodbapi/adodbapy/adodbapi.py be the correct place to Did you mean 'adodbapy' there? > put the source? I'd be inclined to drop a level here by making 'tests' a sub-package. So you would end up with: -- adodbapi ..--__init__.py ..--adodbapi.py ..--tests ....--adodbapitest.py ....--adodbapitestconfig.py ....--adbapi20.py (and so forth) ..--license.txt ..--readme.txt and presumably: ..--setup.py will no longer be necessary (I don't think its worth still supporting creating a stand-alone package). On the other hand, this may not scale as well for the future (eg, 'docs' would need to be a child of the package too - but is that really a problem?). I'll leave this as your call though. Cheers, Mark From mhammond at skippinet.com.au Sat Aug 25 04:13:47 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 25 Aug 2007 12:13:47 +1000 Subject: [python-win32] how to terminate a extended mapi session In-Reply-To: References: Message-ID: <03da01c7e6bd$981aa940$c84ffbc0$@com.au> > what must I take care of by myself when I want to terminate a program > which > communicates with Outlook through the extended mapi interface, i.e. in > addition > to session.Logoff and mapi.MAPIUnitialize? > Currently I get the following errors upon prorgam termination and, what > is more > important, Outlook hangs and has to be restarted: > > Win32 exception occurred releasing IUnknown at 0x01fa09a8 You should ensure all references to MAPI objects have been dropped before you uninitialize MAPI. pythoncom._GetInterfaceCount() will tell you how many you have (probably 1 for each of the messages you see) Cheers, Mark From oliver at hallmarkins.net Sat Aug 25 10:01:02 2007 From: oliver at hallmarkins.net (Oliver T. Nelson) Date: Sat, 25 Aug 2007 01:01:02 -0700 Subject: [python-win32] Canceling OnBeforeClick event in MapPoint 2006 Message-ID: <46CFE1BE.4050303@hallmarkins.net> Some of you may have read this post over on the forums or wx mailing list, I'm hoping I can find someone that has gone through this problem already. Canceling this event in other languages seems to work just fine, but in python it doesn't work. The IDL for the function is: void BeforeClick(long Button, long Shift, long X, long Y, bool* Cancel) Based on this I've tried canceling the event by: return 0, True So that the byref cancel param gets set to true which should cancel the click event (works in c#). I've tried working with the calendar control and have successfully canceled the BeforeUpdate event using the same line. The only difference I can see between the two is that the calendar control is using a short for the cancel param while mappoint is using a bool. I'm using early binding btw. Below is the code I'm using to test (just the calendar code with some simple replacements for the mappoint control): def GetTestMapPointClass(): global mpParentModule win32ui.DoWaitCursor(1) mpParentModule = gencache.EnsureModule("{51C0A9CA-F7B7-4F5A-96F4-43927C6FA50F}", 0, 1, 0) win32ui.DoWaitCursor(0) if mpParentModule is None: return None class TestMPDialog(dialog.Dialog): def OnInitDialog(self): class MyMP(activex.Control, mpParentModule.MappointControl): def OnBeforeClick(self, Button, Shift, X, Y, Cancel): print "clicked" return 0, True rc = dialog.Dialog.OnInitDialog(self) self.olectl = MyMP() try: self.olectl.CreateControl("OCX", win32con.WS_TABSTOP | win32con.WS_VISIBLE, (7,43,500,300), self._obj_, 131) self.olectl.NewMap(win32com.client.constants.geoMapNorthAmerica) except win32ui.error: self.MessageBox("The MP Control could not be created") self.olectl = None self.EndDialog(win32con.IDCANCEL) return rc def OnOK(self): pass return TestMPDialog Any help appreciated. OLIVER From carl at personnelware.com Sun Aug 26 00:25:11 2007 From: carl at personnelware.com (Carl Karsten) Date: Sat, 25 Aug 2007 17:25:11 -0500 Subject: [python-win32] is win shutting down? Message-ID: <46D0AC47.3020909@personnelware.com> I am guessing there is a win api that will indicate if win is shutting down. Not catch the signal that win sends (but that would be good to know too as long as we are talking about it) but I want to check as my app starts if win is shutting down, so I can abort and log "can't start, win shutting down." Carl K From mhammond at skippinet.com.au Mon Aug 27 01:36:08 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 27 Aug 2007 09:36:08 +1000 Subject: [python-win32] Canceling OnBeforeClick event in MapPoint 2006 In-Reply-To: <46CFE1BE.4050303@hallmarkins.net> References: <46CFE1BE.4050303@hallmarkins.net> Message-ID: <051701c7e839$e7620890$b62619b0$@com.au> Hi Oliver, Over the last couple of days, Roger Upole has diagnosed a very similar issue as being related to a bug in pywin32 handling 'named' params passed from COM, which will result in such params being passed in reversed order. I'd bet this is the same issue you are seeing. I hope to have this fixed in the next pywin32 build. See https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1648655&group_i d=78018 for details. Cheers, Mark > Some of you may have read this post over on the forums or wx mailing > list, I'm hoping I can find someone that has gone through this problem > already. Canceling this event in other languages seems to work just > fine, but in python it doesn't work. > > The IDL for the function is: > > void BeforeClick(long Button, long Shift, long X, long Y, bool* Cancel) > > Based on this I've tried canceling the event by: > > return 0, True > > So that the byref cancel param gets set to true which should cancel the > click event (works in c#). > > I've tried working with the calendar control and have successfully > canceled the BeforeUpdate event using the same line. The only > difference I can see between the two is that the calendar control is > using a short for the cancel param while mappoint is using a bool. I'm > using early binding btw. > > Below is the code I'm using to test (just the calendar code with some > simple replacements for the mappoint control): > > def GetTestMapPointClass(): > global mpParentModule > win32ui.DoWaitCursor(1) > mpParentModule = > gencache.EnsureModule("{51C0A9CA-F7B7-4F5A-96F4-43927C6FA50F}", 0, 1, > 0) > win32ui.DoWaitCursor(0) > if mpParentModule is None: > return None > > class TestMPDialog(dialog.Dialog): > def OnInitDialog(self): > > class MyMP(activex.Control, > mpParentModule.MappointControl): > def OnBeforeClick(self, Button, Shift, X, Y, Cancel): > print "clicked" > return 0, True > > rc = dialog.Dialog.OnInitDialog(self) > self.olectl = MyMP() > try: > self.olectl.CreateControl("OCX", win32con.WS_TABSTOP | > win32con.WS_VISIBLE, (7,43,500,300), self._obj_, 131) > > self.olectl.NewMap(win32com.client.constants.geoMapNorthAmerica) > except win32ui.error: > self.MessageBox("The MP Control could not be created") > self.olectl = None > self.EndDialog(win32con.IDCANCEL) > > return rc > def OnOK(self): > pass > > return TestMPDialog > > > Any help appreciated. > > OLIVER > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From Brad.Johnson at ballardtech.com Mon Aug 27 22:07:03 2007 From: Brad.Johnson at ballardtech.com (Brad Johnson) Date: Mon, 27 Aug 2007 20:07:03 +0000 (UTC) Subject: [python-win32] Follow-up question References: <000b01c7d3d4$55a5df90$0100a8c0@rupole> Message-ID: Brad Johnson ballardtech.com> writes: I have successfully used the PyCom_PyObjectFromIUnknown function to get a PyIDispatch object from a raw IDispatch pointer. My next goal is to get an early bound class instance from that pointer (using a class generated from makepy). I can take the PyIDispatch object and call win32com.client.Dispatch using it as the argument. However, this will only return a late-bound CDispatch of the object, with no built methods or properties. This makes sense why this happens (why would the PyIDispatch object know anything about it's underlying class?) Is there a better way for me to go about doing this? From padmasanisowmia at yahoo.com Mon Aug 27 23:46:57 2007 From: padmasanisowmia at yahoo.com (Padmasani Sowmia) Date: Mon, 27 Aug 2007 14:46:57 -0700 (PDT) Subject: [python-win32] Visio - not able to access shapesheet, set properties to shape Message-ID: <123053.9899.qm@web33415.mail.mud.yahoo.com> Hello, I am new to Python programming. I am trying to open Visio diagram and drop a shape programmatically along with some attributes that need to be set. So far I have been successful in opening the file, dropping the shape object. Now, I have known properties in my application that I need to export it to this dropped object. Also when I pass the variable for a file name v1.Documents(variable). it is not working. Why? Any one please let me know what I am doing wrong and how this should be corrected. Thanks in advance, Here is my code: vpath = os.environ.get('TEMP') vfilename = os.path.join(vpath, ''mytemp.vst') v1 = win32com.client.Dispatch("Visio.Application") v1.visible =1 visfile = v1.Documents.Open(vfilename) #self.objsSelected fiobj = self.winparent.selected_object() loid = id2loid(fiobj.id) for vdoc in v1.Documents: #print vdoc.name #fyle_ext = vdocs[len(vdocs)-3:] if vdoc.masters.count > 0: shapes = vdoc.masters if shapes.count > 0: for shp in shapes: usrsubtype = 'Rectangle' if shp.name==usrsubtype: pinX = 1.75 pinY = 9.25 #v1.ActivePage.Drop(shp.name, pinX, pinY) #v1.ActivePage.Drop(v1.Documents(vdoc.name).Masters(shp.name), pinX, pinY) #v1.ActivePage.Drop(v1.Documents(vdoc).Masters(usrsubtype), pinX, pinY) #v1.ActivePage.Drop(vdoc.Masters(shp), pinX, pinY) #v1.ActivePage.Drop(usrsubtype, pinX, pinY) v1.ActivePage.Drop(v1.Documents("temp.vss").Masters(usrsubtype), pinX, pinY) v1.ActivePage.PageSheet.Cells("Prop.obj").Formula = loid #v1.ActiveWindow.selection.Item(1).Cells("Prop.loid").Formula = loid #v1.ActiveWindow.selection.Item(1).Cells("Prop.NAME").Formula = fiobj.name #print loid Cheers, Padmasani Sowmia --------------------------------- Shape Yahoo! in your own image. Join our Network Research Panel today! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070827/027320b5/attachment.htm From mhammond at skippinet.com.au Tue Aug 28 01:54:11 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 28 Aug 2007 09:54:11 +1000 Subject: [python-win32] Follow-up question In-Reply-To: References: <000b01c7d3d4$55a5df90$0100a8c0@rupole> Message-ID: <05d901c7e905$951e7ce0$bf5b76a0$@com.au> > Brad Johnson ballardtech.com> writes: > > I have successfully used the PyCom_PyObjectFromIUnknown function to get > a > PyIDispatch object from a raw IDispatch pointer. > > My next goal is to get an early bound class instance from that pointer > (using a > class generated from makepy). Just pass the Dispatch wrapper to gencache.EnsureDispatch() - it will run makepy and turn your object into a Dispatch backed by the makepy file. Note however that this relies on the IDispatch pointer providing type-info which identifies it - if it doesn't then somehow your code needs to know the typelib ID and jump through some extra hoops. Cheers, Mark From raduciora at yahoo.com Tue Aug 28 13:20:09 2007 From: raduciora at yahoo.com (Radu Ciora) Date: Tue, 28 Aug 2007 04:20:09 -0700 (PDT) Subject: [python-win32] get running application pointer Message-ID: <164669.69988.qm@web50112.mail.re2.yahoo.com> Hi all, I was trying to get a pointer to a running word application but it didn't seem to work. I receive the following error: Traceback (most recent call last): File "c:\Python24\Lib\site-packages\pyHook\HookManager.py", line 325, in MouseSwitch return func(event) File "D:\DAProject\Workspace\context\inputhook\RDFIO.py", line 122, in onMouseEvent self.whatAmIDoin(event) File "D:\DAProject\Workspace\context\inputhook\RDFIO.py", line 130, in whatAmIDoin l_appName = self.getCurrentApplication() File "D:\DAProject\Workspace\context\inputhook\RDFIO.py", line 62, in getCurrentApplication self.wordInfo() File "D:\DAProject\Workspace\context\inputhook\RDFIO.py", line 81, in wordInfo l_wobj = win32com.client.Dispatch("Word.Application") File "c:\Python24\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "c:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "c:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147417843, 'An outgoing call cannot be made since the application is dispatching an input-synchronous call.', None, None) Does anyone have any clue about what am I doing wrong here? Is it possible to get a handle to a running application? Any help really appreciated. Thanks a million, Radu. ----- Original Message ---- From: Tim Roberts To: Python-Win32 List Sent: Friday, 24 August, 2007 11:04:02 PM Subject: Re: [python-win32] get running application handle Radu Ciora wrote: > Is it possible to get a handle to a running application like the one I get when I explicitly start an application myself using the win32com.client.Dispatch("Object.Name")? > > Is the one retrieved by win32gui.GetForegroundWindow() the same as the one above or not, if not how can I get the handle to a running application object. > > I hope I made myself understand. > Well, you are confusing several very different constructs there. What you get back from win32com.client.Dispatch is not a handle at all; it is a pointer to a COM object. It contains methods and properties that you can call directly. What you get back from win32gui.GetForegroundWindow is just a window handle. You can send window messages to it, but there is nothing there to call, and there is no connection to any COM objects. In fact, there is no guarantee that the foreground application offers any COM services at all. Having said that, I assume that what you really want to do, for example, is to connect to a currently running instance of Word. Is that right? Somewhat surprisingly, this depends on the application. For the Office products, if you do a Dispatch on Word.Application while Word is running, you should get a pointer to the existing Word application, and should be able to manipulate the existing documents. For other applications, the answer is "it depends". -- 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 ___________________________________________________________ Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now. http://uk.answers.yahoo.com/ From victor_lebrun at yahoo.fr Tue Aug 28 17:19:25 2007 From: victor_lebrun at yahoo.fr (victor LEBRUN) Date: Tue, 28 Aug 2007 15:19:25 +0000 (GMT) Subject: [python-win32] activeX control and setting properties before runtime Message-ID: <390640.93053.qm@web27603.mail.ukl.yahoo.com> Hello ! I have an ActiveX control which has a property that can only be modified before runtime (at design time in visual basic ) is there a possibility to do that in python with pywin32 ? thank your for your help, kind regards, Victor _____________________________________________________________________________ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail From timr at probo.com Tue Aug 28 20:07:01 2007 From: timr at probo.com (Tim Roberts) Date: Tue, 28 Aug 2007 11:07:01 -0700 Subject: [python-win32] Canceling OnBeforeClick event in MapPoint 2006 In-Reply-To: <46CFE1BE.4050303@hallmarkins.net> References: <46CFE1BE.4050303@hallmarkins.net> Message-ID: <46D46445.4080806@probo.com> Oliver T. Nelson wrote: > Some of you may have read this post over on the forums or wx mailing > list, I'm hoping I can find someone that has gone through this problem > already. Canceling this event in other languages seems to work just > fine, but in python it doesn't work. > > The IDL for the function is: > > void BeforeClick(long Button, long Shift, long X, long Y, bool* Cancel) > > Based on this I've tried canceling the event by: > > return 0, True > > So that the byref cancel param gets set to true which should cancel the > click event (works in c#). > > I've tried working with the calendar control and have successfully > canceled the BeforeUpdate event using the same line. The only > difference I can see between the two is that the calendar control is > using a short for the cancel param while mappoint is using a bool. I'm > using early binding btw. > The list of types that are valid in an IDL file to be used with COM automation is very limited; the C++ "bool" type is not on that list. If this were an IDL that you controlled, you could change it to "long *". The MIDL spec defines a "Boolean" type, but that's an 8-bit type that isn't compatible with COM automation. http://msdn2.microsoft.com/en-us/library/aa367090.aspx If this is really an IDL that shipped with MapPoint, then I'd call that a Microsoft bug. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rwupole at msn.com Wed Aug 29 04:48:46 2007 From: rwupole at msn.com (Roger Upole) Date: Tue, 28 Aug 2007 22:48:46 -0400 Subject: [python-win32] Re: Canceling OnBeforeClick event in MapPoint 2006 Message-ID: <000601c7e9e7$2109dc40$0100a8c0@rupole> Oliver T. Nelson wrote: > Some of you may have read this post over on the forums or wx mailing > list, I'm hoping I can find someone that has gone through this problem > already. Canceling this event in other languages seems to work just > fine, but in python it doesn't work. > > The IDL for the function is: > > void BeforeClick(long Button, long Shift, long X, long Y, bool* Cancel) > > Based on this I've tried canceling the event by: > > return 0, True > > So that the byref cancel param gets set to true which should cancel the > click event (works in c#). Only output parameters should be returned. Try just return True It would be helpful if the makepy generated event prototypes indicated which parms are treated as output, something like: # def OnSomethingOrOther(self, arg1=defaultNamedNotOptArg, arg2=defaultNamedNotOptArg, arg3=defaultNamedNotOptArg): # return arg3 I might try to implement that when I have some time. Roger From dalekseenko at gmail.com Fri Aug 31 19:41:55 2007 From: dalekseenko at gmail.com (Dmitry Alekseenko) Date: Fri, 31 Aug 2007 10:41:55 -0700 Subject: [python-win32] Windows services in python Message-ID: <99069ac50708311041q3718356ex70e0aaa0d2204507@mail.gmail.com> Hey guys, I've written the following function to enable/disable windows services: def Enable(self, serviceName, enable, autoStart=False): startType = None if not enable: startType = win32service.SERVICE_DISABLED elif autoStart: startType = win32service.SERVICE_AUTO_START else: startType = win32service.SERVICE_DEMAND_START win32serviceutil.ChangeServiceConfig(None, serviceName, startType) And it turns out that when I call Enable('W32Time', False) it corrupts the "path to executable" property of the service. It replaces the path to "C:\Python24\lib\site-packages\win32\PythonService.exe". What wrong am I doing? Thank you. Dmitry -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070831/40b94a6a/attachment.htm From timr at probo.com Fri Aug 31 20:45:12 2007 From: timr at probo.com (Tim Roberts) Date: Fri, 31 Aug 2007 11:45:12 -0700 Subject: [python-win32] Windows services in python In-Reply-To: <99069ac50708311041q3718356ex70e0aaa0d2204507@mail.gmail.com> References: <99069ac50708311041q3718356ex70e0aaa0d2204507@mail.gmail.com> Message-ID: <46D861B8.7000404@probo.com> Dmitry Alekseenko wrote: > Hey guys, > > I've written the following function to enable/disable windows services: > > def Enable(self, serviceName, enable, autoStart=False): > startType = None > if not enable: > startType = win32service.SERVICE_DISABLED > elif autoStart: > startType = win32service.SERVICE_AUTO_START > else: > startType = win32service.SERVICE_DEMAND_START > win32serviceutil.ChangeServiceConfig(None, serviceName, startType) > > And it turns out that when I call Enable('W32Time', False) it corrupts > the "path to executable" property of the service. It replaces the path > to "C:\Python24\lib\site-packages\win32\PythonService.exe". > > What wrong am I doing? win32serviceutil.ChangeServiceConfig is a wrapper around the service management APIs, designed specifically for managing Python services. When you omit the exeName parameter, it assumes you want the generic Python service wrapper, and looks up the name. I suggest you skip the win32serviceutil wrapper altogether and call win32service.ChangeServiceConfig. That is a much more direct wrapper around the Win32 API. You will have to open the service manager yourself, but you can look at the source for win32serviceutil.py to see how to do that. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From dalekseenko at gmail.com Fri Aug 31 23:46:18 2007 From: dalekseenko at gmail.com (Dmitry Alekseenko) Date: Fri, 31 Aug 2007 14:46:18 -0700 Subject: [python-win32] Windows services in python In-Reply-To: <46D861B8.7000404@probo.com> References: <99069ac50708311041q3718356ex70e0aaa0d2204507@mail.gmail.com> <46D861B8.7000404@probo.com> Message-ID: <99069ac50708311446o5b200443l39da986ab626a1b7@mail.gmail.com> win32service methods produces the same problem: def Enable(self, serviceName, enable, autoStart=False): startType = None if not enable: startType = win32service.SERVICE_DISABLED elif autoStart: startType = win32service.SERVICE_AUTO_START else: startType = win32service.SERVICE_DEMAND_START scm = win32service.OpenSCManager(None, None, win32service.SC_MANAGER_ALL_ACCESS) svc = win32service.OpenService(scm, serviceName, win32service.SC_MANAGER_ALL_ACCESS) win32service.ChangeServiceConfig(svc, win32service.SERVICE_NO_CHANGE, startType, win32service.SERVICE_NO_CHANGE, None, None, 0, None, None, None, None) win32service.CloseServiceHandle(svc) On 8/31/07, Tim Roberts wrote: > > Dmitry Alekseenko wrote: > > Hey guys, > > > > I've written the following function to enable/disable windows services: > > > > def Enable(self, serviceName, enable, autoStart=False): > > startType = None > > if not enable: > > startType = win32service.SERVICE_DISABLED > > elif autoStart: > > startType = win32service.SERVICE_AUTO_START > > else: > > startType = win32service.SERVICE_DEMAND_START > > win32serviceutil.ChangeServiceConfig(None, serviceName, startType) > > > > And it turns out that when I call Enable('W32Time', False) it corrupts > > the "path to executable" property of the service. It replaces the path > > to "C:\Python24\lib\site-packages\win32\PythonService.exe". > > > > What wrong am I doing? > > win32serviceutil.ChangeServiceConfig is a wrapper around the service > management APIs, designed specifically for managing Python services. > When you omit the exeName parameter, it assumes you want the generic > Python service wrapper, and looks up the name. > > I suggest you skip the win32serviceutil wrapper altogether and call > win32service.ChangeServiceConfig. That is a much more direct wrapper > around the Win32 API. You will have to open the service manager > yourself, but you can look at the source for win32serviceutil.py to see > how to do that. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070831/e2d2436e/attachment.htm