From timr at probo.com Tue Mar 1 18:29:56 2005 From: timr at probo.com (Tim Roberts) Date: Tue Mar 1 18:30:11 2005 Subject: [python-win32] How to use Python to develop virtual printer? In-Reply-To: <20050301110022.B10151E400D@bag.python.org> References: <20050301110022.B10151E400D@bag.python.org> Message-ID: <4224A694.3080102@probo.com> On Mon, 28 Feb 2005 19:02:29 +0800, "Jiang Shanyi" wrote: >I want to develop a virtual printer, can anybody tell me where can I >find an existing open source virtual printer project? or Can anybody >tell me how to develop virtual printer? and how about use of python? > In order to appear as a normal printer, you have to develop a printer driver. That's going to require the use of the DDK, the Driver Development Kit. You can get this from Microsoft for just shipping and handling (about US$20). It includes all of the compilers, include files, and libraries you would need. It also includes a number of sample drivers. Drivers cannot be written in Python. The device driver interfaces are all C-style APIs. (Well, theoretically, I supposed you could write a C DLL that thunked to a Python service, but that would be more trouble than writing it in C or C++ to begin with.) -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From alex at moreati.org.uk Wed Mar 2 01:14:17 2005 From: alex at moreati.org.uk (Alex Willmer) Date: Wed Mar 2 01:14:17 2005 Subject: [python-win32] How to use Python to develop virtual printer? In-Reply-To: <90625507C4259B4CBF2FBDC3CF0AB3DC48D978@CNMAIL12.cn.utstarcom.com> References: <90625507C4259B4CBF2FBDC3CF0AB3DC48D978@CNMAIL12.cn.utstarcom.com> Message-ID: <42250559.7030303@moreati.org.uk> Jiang Shanyi wrote: >I want to develop a virtual printer, can anybody tell me where can I >find an existing open source virtual printer project? or Can anybody >tell me how to develop virtual printer? and how about use of python? >Best Regards! > > As Tim has replied, writing a virtual printer driver would be non-trivial. Perhaps we could help more if you said why you want to do this, there may be better ways to achieve your ultimate goal. Alex From niki at vintech.bg Wed Mar 2 13:19:46 2005 From: niki at vintech.bg (Niki Spahiev) Date: Wed Mar 2 13:19:54 2005 Subject: [python-win32] How to use Python to develop virtual printer? In-Reply-To: <90625507C4259B4CBF2FBDC3CF0AB3DC48D978@CNMAIL12.cn.utstarcom.com> References: <90625507C4259B4CBF2FBDC3CF0AB3DC48D978@CNMAIL12.cn.utstarcom.com> Message-ID: <4225AF62.5000909@vintech.bg> Jiang Shanyi wrote: > I want to develop a virtual printer, can anybody tell me where can I > find an existing open source virtual printer project? or Can anybody > tell me how to develop virtual printer? and how about use of python? > Best Regards!! Look for printer redirector. IIRC there is one for making PDF in sf.net. HTH Niki Spahiev From thaddon at equilar.com Wed Mar 2 23:52:37 2005 From: thaddon at equilar.com (Tom Haddon) Date: Wed Mar 2 23:52:41 2005 Subject: [python-win32] win32process user info Message-ID: <0E52D69E86D25840AAE3611CB657F9F83659C3@millenium.equilar.com> Hi, I'm trying to determine the user name that's associated with a win32process. I've got the process info like this: for process in win32process.EnumProcesses() handle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION, 0, process) How do I then determine the username for each process? Thanks, Tom --------------------------------------- Tom Haddon Equilar, Inc. 1710 South Amphlett Boulevard Suite 312 San Mateo, CA 94402 650-286-4528 (phone) 650-286-4513 (fax) thaddon@equilar.com CONFIDENTIALITY NOTICE: This is a transmission from Equilar, Inc. and may contain information which is confidential and proprietary. If you are not the addressee, any disclosure, copying or distribution or use of the contents of this message is expressly prohibited. If you have received this transmission in error, please destroy it and notify us immediately at 650-286-4512. Internet and e-mail communications are Equilar's property and Equilar reserves the right to retrieve and read any message created, sent and received. From rwupole at msn.com Thu Mar 3 04:48:41 2005 From: rwupole at msn.com (Roger Upole) Date: Thu Mar 3 04:48:48 2005 Subject: [python-win32] Re: win32process user info Message-ID: You should be able to use something like this: th=win32security.OpenProcessToken(handle,win32security.TOKEN_READ) sid=win32security.GetTokenInformation(th,win32security.TokenUser)[0] print win32security.LookupAccountSid('',sid) However, you're going to need to jack up your privileges sky-high or run the script under the SYSTEM account. Otherwise you'll get an Access Denied for most processes that aren't yours. Last time I needed to do something like this, I used the Task Scheduler to run it under the System acct. Running it as a service is another option. Roger From tony at tcapp.com Thu Mar 3 07:20:41 2005 From: tony at tcapp.com (Tony Cappellini) Date: Thu Mar 3 07:21:05 2005 Subject: [python-win32] Erratic python Win debugger operation In-Reply-To: <20050302110046.B54A91E400D@bag.python.org> References: <20050302110046.B54A91E400D@bag.python.org> Message-ID: <6.1.2.0.0.20050302221926.01f61570@mail.yamato.com> Has anyone else had the problem with the PW debugger, where the debug toolbar goes away after running a script ? From thaddon at equilar.com Thu Mar 3 14:50:51 2005 From: thaddon at equilar.com (Tom Haddon) Date: Thu Mar 3 14:50:55 2005 Subject: [python-win32] Re: win32process user info Message-ID: <0E52D69E86D25840AAE3611CB657F9F83659D1@millenium.equilar.com> Great! Works a treat! I think I'll go with the run under system account option. Tom -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org] On Behalf Of Roger Upole Sent: Wednesday, March 02, 2005 7:49 PM To: python-win32@python.org Subject: [python-win32] Re: win32process user info You should be able to use something like this: th=win32security.OpenProcessToken(handle,win32security.TOKEN_READ) sid=win32security.GetTokenInformation(th,win32security.TokenUser)[0] print win32security.LookupAccountSid('',sid) However, you're going to need to jack up your privileges sky-high or run the script under the SYSTEM account. Otherwise you'll get an Access Denied for most processes that aren't yours. Last time I needed to do something like this, I used the Task Scheduler to run it under the System acct. Running it as a service is another option. Roger _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From rogelio.flores at gmail.com Mon Mar 7 16:06:01 2005 From: rogelio.flores at gmail.com (Rogelio Flores) Date: Mon Mar 7 16:06:07 2005 Subject: [python-win32] How do I get a child's PID, or the whole process tree? In-Reply-To: <0E52D69E86D25840AAE3611CB657F9F83659D1@millenium.equilar.com> References: <0E52D69E86D25840AAE3611CB657F9F83659D1@millenium.equilar.com> Message-ID: Using win32process.CreateProcess, I can get the process handle/pid of a process I launch. Now this process launches other processes and they in turn launch other processes without using CreateProcess (so I don't have their pids), to the point where I know there are at least two levels of parent-child processes. Can I get the pids of these child/grandchild processes from the parent pid? Alternatively, can I kill the parent pid and all its children along with it? I've tried creating the process with win32con.CREATE_NEW_PROCESS_GROUP and other combinations of flags/arguments but I'm never able to kill but the parent process (all the children are left running) and I cannot find a way to get the children's pids from the parent pid or handle. It seems that win32pdhutil.py has a way to browse through process trees, but I'm not able to figure out how (using python2.0/win32all144). Is this possible, and if so, how? Thanks, -- Rogelio From s_t_a_n_i at gmx.net Wed Mar 2 01:20:27 2005 From: s_t_a_n_i at gmx.net (Stani Michiels) Date: Mon Mar 7 16:23:46 2005 Subject: [python-win32] python crash with IE Activex Message-ID: <422506CB.6040609@gmx.net> > > >Hi all, >I'm playing with the demo example ActiveXWrapper_IE.py. What I want is >avoid users access some url's. To accomplish this I'm using >OnBeforeNavigate2 event, returning a true value should cancel the request... > > >def OnBeforeNavigate2(self, pDisp, URL, Flags, TargetFrameName, >PostData, Headers, Cancel) : > self.log.write('OnBeforeNavigate2: %s\n' % URL) > > if URL == "http://www.microsoft.com/": > return 1 > > >The problem is that if I return a true value, python crashes :s > >I've been searching some info, but got no luck :( > >Any ideas? > >Thanks >Xavi Beumala > I would like to know as well. Please let me know if you have a solution. Thanks, Stani http://spe.pycs.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050302/867c9ddb/attachment.html From rogelio.flores at gmail.com Mon Mar 7 17:36:36 2005 From: rogelio.flores at gmail.com (Rogelio Flores) Date: Mon Mar 7 17:36:40 2005 Subject: [python-win32] Re: How do I get a child's PID, or the whole process tree? In-Reply-To: References: <0E52D69E86D25840AAE3611CB657F9F83659D1@millenium.equilar.com> Message-ID: On Mon, 7 Mar 2005 10:06:01 -0500, Rogelio Flores wrote: > Using win32process.CreateProcess, I can get the process handle/pid of > a process I launch. Now this process launches other processes and they > in turn launch other processes without using CreateProcess (so I don't > have their pids), to the point where I know there are at least two > levels of parent-child processes. Can I get the pids of these > child/grandchild processes from the parent pid? Alternatively, can I > kill the parent pid and all its children along with it? > > I've tried creating the process with win32con.CREATE_NEW_PROCESS_GROUP > and other combinations of flags/arguments but I'm never able to kill > but the parent process (all the children are left running) and I > cannot find a way to get the children's pids from the parent pid or > handle. It seems that win32pdhutil.py has a way to browse through > process trees, but I'm not able to figure out how (using > python2.0/win32all144). Is this possible, and if so, how? > > Thanks, > > -- > Rogelio > OK, I found a solution, using win32pdhutil.ShowAllProcesses() as a template, I can now get all the processes' pids and their parent pids. The following code snippet prints a table with these three colums: Process Name | PID | Parent PID ----------------- begin code ------------ import win32pdh object = 'Process' items, instances = win32pdh.EnumObjectItems(None, None, object, win32pdh.PERF_DETAIL_WIZARD) instance_dict = {} for instance in instances: try: instance_dict[instance] = instance_dict[instance] + 1 except KeyError: instance_dict[instance] = 0 for instance, max_instances in instance_dict.items(): for inum in xrange(max_instances+1): hq = win32pdh.OpenQuery() hcs = [] for item in ['ID Process', 'Creating Process ID']: path = win32pdh.MakeCounterPath((None,object,instance, None,inum,item)) hcs.append(win32pdh.AddCounter(hq,path)) win32pdh.CollectQueryData(hq) print "%-15s\t" % (instance[:15]), for hc in hcs: type,val=win32pdh.GetFormattedCounterValue(hc,win32pdh.PDH_FMT_LONG) print "%5d" % (val), win32pdh.RemoveCounter(hc) print win32pdh.CloseQuery(hq) ---------- end code --------------- All I needed was to realize that one of the "items" returned by win32pdh.EnumObjectItems() is 'Creating Process ID', which is the parent pid of a given process. -- Rogelio From Gareth.Walters at canberra.edu.au Wed Mar 9 01:02:34 2005 From: Gareth.Walters at canberra.edu.au (Gareth Walters) Date: Wed Mar 9 01:02:41 2005 Subject: [python-win32] problem with PySECURITY_DESCRIPTOR.SetSecurityDescriptorControl Message-ID: <422E3D1A.1020404@canberra.edu.au> G'day all, I am trying to get inheritance enabled/disabled working on some folders and I cannot work out what I am doing wrong. I am doing something like this ALLOW_INHERITANCE=SE_SELF_RELATIVE + SE_DACL_AUTO_INHERITED + SE_DACL_PRESENT DENY_INHERITANCE=SE_SELF_RELATIVE + SE_DACL_PROTECTED + SE_DACL_AUTO_INHERITED+SE_DACL_PRESENT descriptor=GetNamedSecurityInfo("d:\\work\\permcheck\\blah",SE_FILE_OBJECT,DACL_SECURITY_INFORMATION) descriptor.SetSecurityDescriptorControl(DENY_INHERITANCE,DENY_INHERITANCE) pywintypes.error: (87, 'SetSecurityDescriptorControl', 'The parameter is incorrect.') I have tried all the combinations of calling the function with differnt bitmasks but I keep getting this error. What am I doing wrong with this function? TIA -- ---Gareth Walters From rwupole at msn.com Wed Mar 9 02:42:59 2005 From: rwupole at msn.com (Roger Upole) Date: Wed Mar 9 02:43:06 2005 Subject: [python-win32] Re: problem with PySECURITY_DESCRIPTOR.SetSecurityDescriptorControl Message-ID: SetSecurityDescriptorControl can't modify SE_DACL_PRESENT or SE_SELF_RELATIVE. It should work if you remove them from the bitmask. And since it's a bitmask, they should be combined with a bitwise or instead of +, eg SE_DACL_PROTECTED | SE_DACL_AUTO_INHERITED hth Roger From oktaysafak at superonline.com Wed Mar 9 14:08:35 2005 From: oktaysafak at superonline.com (oktaysafak) Date: Wed Mar 9 14:08:39 2005 Subject: [python-win32] makepy problem with Win XP and Word 2000 Message-ID: <422EF553.3040304@superonline.com> Hello everyone, My problem: Thanks to the absolutely fabulous win32com package by Mark Hammond, I have been using Python for MS Word automation for a long time. My script was working perfectly until I upgraded to Python 2.4 (from 2.3) and Win XP (from Win Millenium). It's still working perfectly but it has substantially slowed down since the upgrade. (But very rarely, it works as fast as before - quite puzzling) What I have tried: I tried to use the makepy script on Word but it fails. It successfully generates the .py file under genpy directory but it crashes during importing the generated file. I googled on the subject and scanned the recent archives of this list and but couldn't find anything useful. Mark Hammond has suggested using the -d switch with makepy but it also fails in the same way. Someone else has written that this problem is caused by lines longer than 512 chars in the generated file and has suggested to replace some default arguments on those lines with shorter ones. I couldn't do it because there are too many lines over 512 chars in the generated file. Any ideas on what's causing this and how to successfully run makepy on MS Word (or any other info for solving this problem)? Any hints would be very much appreciated. Oktay From mhammond at skippinet.com.au Wed Mar 9 22:54:54 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed Mar 9 22:55:00 2005 Subject: [python-win32] makepy problem with Win XP and Word 2000 In-Reply-To: <422EF553.3040304@superonline.com> Message-ID: <082b01c524f2$a149c8a0$040a0a0a@enfoldsystems.local> For now, you could take the "mbcs" encoding line from the generated file. This has been fixed here and will be in build 204 (along with a fix for the "thousands of registry entries when using the debugger" (yay!). I hope to have this out within a week. The new build will also have a new "sspi" module from Roger Upole which gives us full access to the Windows security system, which is very cool (eg, automatically exchange credentials with IIS, etc) Mark > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of oktaysafak > Sent: Thursday, 10 March 2005 12:09 AM > To: python-win32@python.org > Subject: [python-win32] makepy problem with Win XP and Word 2000 > > > Hello everyone, > > My problem: > Thanks to the absolutely fabulous win32com package by Mark Hammond, I > have been using Python for MS Word automation for a long > time. My script > was working perfectly until I upgraded to Python 2.4 (from > 2.3) and Win > XP (from Win Millenium). It's still working perfectly but it has > substantially slowed down since the upgrade. (But very > rarely, it works > as fast as before - quite puzzling) > > What I have tried: > I tried to use the makepy script on Word but it fails. It > successfully > generates the .py file under genpy directory but it crashes during > importing the generated file. I googled on the subject and > scanned the > recent archives of this list and but couldn't find anything > useful. Mark > Hammond has suggested using the -d switch with makepy but it > also fails > in the same way. Someone else has written that this problem > is caused by > lines longer than 512 chars in the generated file and has > suggested to > replace some default arguments on those lines with shorter ones. I > couldn't do it because there are too many lines over 512 chars in the > generated file. > > Any ideas on what's causing this and how to successfully run > makepy on > MS Word (or any other info for solving this problem)? Any > hints would > be very much appreciated. > > Oktay > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From jdavis at wgen.net Thu Mar 10 22:40:40 2005 From: jdavis at wgen.net (Jesse Davis) Date: Thu Mar 10 22:40:44 2005 Subject: [python-win32] Using msxml SAX via win32com -- how do I implement an ISAXContentHandler in Python? Message-ID: Greetings, gurus, & salutations, swamis. Summary: Trying to use msxml's SAXXMLReader. I've implemented an ISAXContentHandler in Python (see end of post), registered it using win32com.server.register.UseCommandLine(), & then I do: >>> import win32com.client as w32c >>> h = w32c.Dispatch('Python.SyncMLBenchmarkSAXContentHandler') >>> h >>> h.characters('foobar') characters So this shows I've registered my content-handler, I can instantiate it, & when I call its characters() method, it prints 'characters' like I expected. Next, I run makepy on Msxml2.SAXXMLReader, & I try to register the content-handler with the reader. Here's the problem: >>> r = w32c.Dispatch('Msxml2.SAXXMLReader') >>> r >>> r.contentHandler = h Traceback (most recent call last): File "", line 1, in ? File "C:\Python22\Lib\site-packages\win32com\client\__init__.py", line 463, in __setattr__ self._oleobj_.Invoke(*(args + (value,) + defArgs)) com_error: (-2147352571, 'Type mismatch.', None, 2) >>> r.putContentHandler(h) Traceback (most recent call last): File "", line 1, in ? File "C:\Python22\Lib\site-packages\win32com\client\__init__.py", line 454, in __getattr__ raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr) AttributeError: '' object has no attribute 'putContentHandler' Maybe I need to run makepy on my Python.SyncMLBenchmarkSAXContentHandle CoClass, but it doesn't show up in PythonWin's makepy GUI. Similarly, "python makepy.py Python.SyncMLBenchmarkSAXContentHandler" & "python makepy.py SyncMLBenchmarkSAXContentHandler" respond "Could not locate a type library matching..." However, there are reg keys HKEY_CLASSES_ROOT\CLSID\{85DBFCAE-7AEC-4c26-A165-7B91337ED934} & HKEY_CLASSES_ROOT\Python.SyncMLBenchmarkSAXContentHandler. Any ideas? Jesse Davis =======SyncMLBenchmarkSAXContentHandler===== class SyncMLBenchmarkSAXContentHandler: _public_methods_ = ['characters', 'endDocument', 'endElement', 'endPrefixMapping', 'ignorableWhitespace', 'processingInstruction', 'skippedEntity', 'startDocument', 'startElement', 'startPrefixMapping' ] _reg_progid_ = 'Python.SyncMLBenchmarkSAXContentHandler' _reg_clsid_ = '{85DBFCAE-7AEC-4c26-A165-7B91337ED934}' def characters(self, strChars=None): print 'characters' def endDocument(self): print 'endDocument' def endElement(self, strNamespaceURI=None, strLocalName=None, strQName=None): print 'endElement' def endPrefixMapping(self, strPrefix=None): print 'endPrefixMapping' def ignorableWhitespace(self, strChars=None): print 'ignorableWhitespace' def processingInstruction(self, strTarget=None, strData=None): print 'processingInstruction' def skippedEntity(self, strName=None): print 'skippedEntity' def startDocument(self): print 'startDocument' def startElement(self, strNamespaceURI=None, strLocalName=None, strQName=None, oAttributes=None): print 'startElement' def startPrefixMapping(self, strPrefix=None, strURI=None): print 'startPrefixMapping' -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050310/7c426320/attachment.htm From peden at americanphysicians.net Fri Mar 11 00:53:48 2005 From: peden at americanphysicians.net (Paul Eden) Date: Fri Mar 11 00:53:56 2005 Subject: [python-win32] Python wmi problem Message-ID: I am interested in using the wmi wrapper module for the windows wmi python classes/modules and am having trouble. Here is what happens. >>> import wmi Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\Lib\site-packages\wmi.py", line 137, in ? win32com.client.gencache.EnsureDispatch (obj._oleobj_) File "C:\Python24\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:\Python24\Lib\site-packages\win32com\client\gencache.py", line 393, in EnsureModule module = GetModuleForTypelib(typelibCLSID, lcid, major, minor) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 262, in GetModuleForTypelib AddModuleToCache(typelibCLSID, lcid, major, minor) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 554, in AddModuleToCache dict = mod.CLSIDToClassMap AttributeError: 'module' object has no attribute 'CLSIDToClassMap' in pythonwin. I am using python 2.4, windows XP, pywin32 extensions build 203. In running makepy on the Microsoft WMI Scripting Library I get: Generating to C:\Python24\lib\site-packages\win32com\gen_py\565783C6-CB41-11D1-8B02-00 600806D9B6x0x1x2.py Failed to execute command: from win32com.client import makepy;makepy.main() Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\toolmenu.py", line 103, in HandleToolCommand exec "%s\n" % pyCmd File "", line 1, in ? File "C:\Python24\Lib\site-packages\win32com\client\makepy.py", line 362, in main GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, bForDemand = bForDemand, bBuildHidden = hiddenSpec) File "C:\Python24\Lib\site-packages\win32com\client\makepy.py", line 273, in GenerateFromTypeLibSpec gencache.AddModuleToCache(info.clsid, info.lcid, info.major, info.minor) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 554, in AddModuleToCache dict = mod.CLSIDToClassMap AttributeError: 'module' object has no attribute 'CLSIDToClassMap' makepy worked on both WMI ADSI Extension Type Library and WMICntl Type Library Any help is appreciated. Thanks, Paul Eden -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050310/6bc5481d/attachment.html From a.patt at fi.com Fri Mar 11 05:36:04 2005 From: a.patt at fi.com (Adam Patt) Date: Fri Mar 11 06:19:10 2005 Subject: [python-win32] How can I totally release a COM object reference? Message-ID: I have a call to create a Remote COM object like this: auth=DispatchEx('Authenticate.Authenticate','servername') This call is made from a zope external method. We have also made this call from a small python program that was set to run as a service. Every so often, the rcp session gets messed up and this call will always fail after this happens until the service is restarted. If we do the same thing as an app that is written in VB, the same failure will happen, but it will recover with the next call without having to restart the service. I am guessing that a reference is kept to this object that is not getting released. Is there a way for me to force python to unload the reference to the COM object? PLEASE READ THIS WARNING: Investment in securities involves the risk of loss. Past performance is no guarantee of future returns. Other methods may produce different results, and the results for different periods may vary depending on market conditions and the composition of the portfolio. Warning: Do not send time-sensitive, action-oriented messages, such as transaction requests, via e-mail as it is our policy not to accept such items electronically. All e-mail sent to or from this address will be received or otherwise recorded by the Fisher Investments corporate e-mail system and is subject to archival, monitoring or review by, and/or disclosure to, someone other than the recipient. From tim.golden at viacom-outdoor.co.uk Fri Mar 11 09:48:11 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Fri Mar 11 09:48:16 2005 Subject: [python-win32] Python wmi problem Message-ID: <9A28C052FF32734DACB0A288A3533991EBB683@vogbs009.gb.vo.local> [Paul Eden] | I am interested in using the wmi wrapper module for the | windows wmi python classes/modules and am having trouble. | | Here is what happens. | | >>> import wmi | | [... snip full traceback ...] | File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 554, in AddModuleToCache | dict = mod.CLSIDToClassMap | AttributeError: 'module' object has no attribute 'CLSIDToClassMap' | | I am using python 2.4, windows XP, pywin32 extensions build 203. I realise that this is no consolation whatsoever, but it works fine for me (although I admit I do still develop under Python 2.3 for various reasons so I can miss compatibility issues with 2.4). Hopefully someone else has some idea what's going on, since the error is deep within the pywin32 COM stuff, rather than with the WMI wrapper itself. FWIW, you could try changing the win32com.client.gencache.EnsureDispatch lines in wmi.py to be simply win32com.client.Dispatch; you would probably then have to determine the values of the constants which not now available: wbemErrInvalidQuery = -2147217385 wbemErrTimedout = -2147209215 wbemFlagReturnImmediately = 16 wbemFlagForwardOnly = 32 If you're not sure how to do that, let me know and I can send you a patched copy. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From peden at americanphysicians.net Fri Mar 11 16:50:56 2005 From: peden at americanphysicians.net (Paul Eden) Date: Fri Mar 11 16:51:12 2005 Subject: [python-win32] Python wmi problem Message-ID: That fixed the problem. Once I deleted that director and imported wmi again it all worked. Thanks Mark. Paul -----Original Message----- From: Mark Hammond [mailto:mhammond@skippinet.com.au] Sent: Thursday, March 10, 2005 5:45 PM To: Paul Eden Subject: RE: [python-win32] Python wmi problem Have a look at the file in the gen_py directory - it may be truncated, or otherwise have failed to generate. Just nuke the entire C:\Python24\lib\site-packages\win32com\gen_py directory and see what happens - it should then attempt to regenerate next time it is run, and you may see the underlying error. Mark -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org]On Behalf Of Paul Eden Sent: Friday, 11 March 2005 10:54 AM To: python-win32@python.org Subject: [python-win32] Python wmi problem I am interested in using the wmi wrapper module for the windows wmi python classes/modules and am having trouble. Here is what happens. >>> import wmi Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\Lib\site-packages\wmi.py", line 137, in ? win32com.client.gencache.EnsureDispatch (obj._oleobj_) File "C:\Python24\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:\Python24\Lib\site-packages\win32com\client\gencache.py", line 393, in EnsureModule module = GetModuleForTypelib(typelibCLSID, lcid, major, minor) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 262, in GetModuleForTypelib AddModuleToCache(typelibCLSID, lcid, major, minor) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 554, in AddModuleToCache dict = mod.CLSIDToClassMap AttributeError: 'module' object has no attribute 'CLSIDToClassMap' in pythonwin. I am using python 2.4, windows XP, pywin32 extensions build 203. In running makepy on the Microsoft WMI Scripting Library I get: Generating to C:\Python24\lib\site-packages\win32com\gen_py\565783C6-CB41-11D1-8B02-00 600806D9B6x0x1x2.py Failed to execute command: from win32com.client import makepy;makepy.main() Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\toolmenu.py", line 103, in HandleToolCommand exec "%s\n" % pyCmd File "", line 1, in ? File "C:\Python24\Lib\site-packages\win32com\client\makepy.py", line 362, in main GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, bForDemand = bForDemand, bBuildHidden = hiddenSpec) File "C:\Python24\Lib\site-packages\win32com\client\makepy.py", line 273, in GenerateFromTypeLibSpec gencache.AddModuleToCache(info.clsid, info.lcid, info.major, info.minor) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 554, in AddModuleToCache dict = mod.CLSIDToClassMap AttributeError: 'module' object has no attribute 'CLSIDToClassMap' makepy worked on both WMI ADSI Extension Type Library and WMICntl Type Library Any help is appreciated. Thanks, Paul Eden From bgailer at alum.rpi.edu Sat Mar 12 15:32:38 2005 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Sat Mar 12 16:23:05 2005 Subject: [python-win32] Prob Message-ID: <6.1.2.0.0.20050312062250.0341ea60@pop.sbcglobal.yahoo.com> What dos this error mean? and what do I need to do to fix it? Pywin32 Extensions build 203 "Can't load Python for preinstalled script" Bob Gailer mailto:bgailer@alum.rpi.edu 510 558 3275 home 303 442 2625 cell -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050312/f6bd7a44/attachment.html From oktaysafak at superonline.com Sat Mar 12 17:13:04 2005 From: oktaysafak at superonline.com (oktaysafak) Date: Sat Mar 12 17:13:09 2005 Subject: [python-win32] makepy problem with Win XP and Word 2000 In-Reply-To: <082b01c524f2$a149c8a0$040a0a0a@enfoldsystems.local> References: <082b01c524f2$a149c8a0$040a0a0a@enfoldsystems.local> Message-ID: <42331510.1060601@superonline.com> Mark, thanks for the reply. I am very glad to hear that you'll be releasing the fix soon. I forgot to mention in my previous mail but I had already tried taking out the "mbcs" encoding and it had not worked. After your mail I tried once more. It doesn't crash the same way; now I get an uncaught exception: Traceback (most recent call last): File "D:\Automation\\run.py", line 3, in ? run() File "D:\Automation\generate.py", line 440, in run i.App.visible = False File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 462, in __setattr__ raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr) AttributeError: '' object has no attribute 'visible' The module is imported correctly but now the attributes aren't there. I thought this could be of help while preparing the fix. Looking forward to the release. By the way, thanks for this wonderful package. I owe you a lot. Your work saves me countless hours. I hope to meet you one day and buy you the finest meal :) Bye, Oktay Mark Hammond wrote: >For now, you could take the "mbcs" encoding line from the generated file. >This has been fixed here and will be in build 204 (along with a fix for the >"thousands of registry entries when using the debugger" (yay!). I hope to >have this out within a week. The new build will also have a new "sspi" >module from Roger Upole which gives us full access to the Windows security >system, which is very cool (eg, automatically exchange credentials with IIS, >etc) > >Mark > > > >>-----Original Message----- >>From: python-win32-bounces@python.org >>[mailto:python-win32-bounces@python.org]On Behalf Of oktaysafak >>Sent: Thursday, 10 March 2005 12:09 AM >>To: python-win32@python.org >>Subject: [python-win32] makepy problem with Win XP and Word 2000 >> >> >>Hello everyone, >> >>My problem: >>Thanks to the absolutely fabulous win32com package by Mark Hammond, I >>have been using Python for MS Word automation for a long >>time. My script >>was working perfectly until I upgraded to Python 2.4 (from >>2.3) and Win >>XP (from Win Millenium). It's still working perfectly but it has >>substantially slowed down since the upgrade. (But very >>rarely, it works >>as fast as before - quite puzzling) >> >>What I have tried: >>I tried to use the makepy script on Word but it fails. It >>successfully >>generates the .py file under genpy directory but it crashes during >>importing the generated file. I googled on the subject and >>scanned the >>recent archives of this list and but couldn't find anything >>useful. Mark >>Hammond has suggested using the -d switch with makepy but it >>also fails >>in the same way. Someone else has written that this problem >>is caused by >>lines longer than 512 chars in the generated file and has >>suggested to >>replace some default arguments on those lines with shorter ones. I >>couldn't do it because there are too many lines over 512 chars in the >>generated file. >> >>Any ideas on what's causing this and how to successfully run >>makepy on >>MS Word (or any other info for solving this problem)? Any >>hints would >>be very much appreciated. >> >>Oktay >> >>_______________________________________________ >>Python-win32 mailing list >>Python-win32@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/20050312/44ee8f13/attachment.htm From rwupole at msn.com Sat Mar 12 18:15:11 2005 From: rwupole at msn.com (Roger Upole) Date: Sat Mar 12 18:15:18 2005 Subject: [python-win32] Re: makepy problem with Win XP and Word 2000 Message-ID: When you're using the generated wrapper modules, all the attributes and methods are case sensitive. > i.App.visible = False should be i.App.Visible=False hth Roger From jdavis at wgen.net Mon Mar 14 19:46:45 2005 From: jdavis at wgen.net (Jesse Davis) Date: Mon Mar 14 19:46:49 2005 Subject: [python-win32] Using msxml SAX via win32com -- how do I implementan ISAXContentHandler in Python? Message-ID: Hey, gurus. I've worked a bit on this problem & come up with a more fundamental question: Can COM objects created by win32com.client support QueryInterface for interfaces OTHER THAN IUnknown, IDispatch, & other builtins? In my experiments, the QI fails for IID's other than these builtins, whether I'm QIing a Python COM object or an msxml object. I need to instantiate an ISAXXMLReader from msxml, & set its 'contentHandler' to a COM object I've implemented in Python. Since reader.contentHandler = myCOMObj returns a type mismatch from COM, I assume the reader QI's myCOMObj from ISAXXMLContentHandler & fails. ________________________________ From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org] On Behalf Of Jesse Davis Sent: Thursday, March 10, 2005 4:41 PM To: python-win32@python.org Subject: [python-win32] Using msxml SAX via win32com -- how do I implementan ISAXContentHandler in Python? Greetings, gurus, & salutations, swamis. Summary: Trying to use msxml's SAXXMLReader. I've implemented an ISAXContentHandler in Python (see end of post), registered it using win32com.server.register.UseCommandLine(), & then I do: >>> import win32com.client as w32c >>> h = w32c.Dispatch('Python.SyncMLBenchmarkSAXContentHandler') >>> h >>> h.characters('foobar') characters So this shows I've registered my content-handler, I can instantiate it, & when I call its characters() method, it prints 'characters' like I expected. Next, I run makepy on Msxml2.SAXXMLReader, & I try to register the content-handler with the reader. Here's the problem: >>> r = w32c.Dispatch('Msxml2.SAXXMLReader') >>> r >>> r.contentHandler = h Traceback (most recent call last): File "", line 1, in ? File "C:\Python22\Lib\site-packages\win32com\client\__init__.py", line 463, in __setattr__ self._oleobj_.Invoke(*(args + (value,) + defArgs)) com_error: (-2147352571, 'Type mismatch.', None, 2) >>> r.putContentHandler(h) Traceback (most recent call last): File "", line 1, in ? File "C:\Python22\Lib\site-packages\win32com\client\__init__.py", line 454, in __getattr__ raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr) AttributeError: '' object has no attribute 'putContentHandler' Maybe I need to run makepy on my Python.SyncMLBenchmarkSAXContentHandle CoClass, but it doesn't show up in PythonWin's makepy GUI. Similarly, "python makepy.py Python.SyncMLBenchmarkSAXContentHandler" & "python makepy.py SyncMLBenchmarkSAXContentHandler" respond "Could not locate a type library matching..." However, there are reg keys HKEY_CLASSES_ROOT\CLSID\{85DBFCAE-7AEC-4c26-A165-7B91337ED934} & HKEY_CLASSES_ROOT\Python.SyncMLBenchmarkSAXContentHandler. Any ideas? Jesse Davis =======SyncMLBenchmarkSAXContentHandler===== class SyncMLBenchmarkSAXContentHandler: _public_methods_ = ['characters', 'endDocument', 'endElement', 'endPrefixMapping', 'ignorableWhitespace', 'processingInstruction', 'skippedEntity', 'startDocument', 'startElement', 'startPrefixMapping' ] _reg_progid_ = 'Python.SyncMLBenchmarkSAXContentHandler' _reg_clsid_ = '{85DBFCAE-7AEC-4c26-A165-7B91337ED934}' def characters(self, strChars=None): print 'characters' def endDocument(self): print 'endDocument' def endElement(self, strNamespaceURI=None, strLocalName=None, strQName=None): print 'endElement' def endPrefixMapping(self, strPrefix=None): print 'endPrefixMapping' def ignorableWhitespace(self, strChars=None): print 'ignorableWhitespace' def processingInstruction(self, strTarget=None, strData=None): print 'processingInstruction' def skippedEntity(self, strName=None): print 'skippedEntity' def startDocument(self): print 'startDocument' def startElement(self, strNamespaceURI=None, strLocalName=None, strQName=None, oAttributes=None): print 'startElement' def startPrefixMapping(self, strPrefix=None, strURI=None): print 'startPrefixMapping' From theller at python.net Tue Mar 15 13:47:39 2005 From: theller at python.net (Thomas Heller) Date: Tue Mar 15 13:48:08 2005 Subject: [python-win32] Bug in pywin32's oleargs.cpp ? Message-ID: I'm looking into com\win32com\src\oleargs.cpp, in function PyCom_VariantFromPyObject, near line 65. This code converts a Python object into a VARIANT. else if (PyLong_Check(obj)) { double dval = PyLong_AsDouble(obj); BOOL isDword = FALSE; if (dval >= 0 && dval < (double)ULONG_MAX) { DWORD dwval = (DWORD)dval; if ((double)dwval == dval) { => V_VT(var) = VT_I4; => V_I4(var) = dwval; isDword = TRUE; } } if (!isDword) { V_VT(var) = VT_R8; V_R8(var) = dval; } } Shouldn't the lines marked '=>' use VT_UI4 instead of VT_I4? Thomas From michael.erhart at magnasteyr.com Wed Mar 16 08:50:23 2005 From: michael.erhart at magnasteyr.com (michael.erhart@magnasteyr.com) Date: Wed Mar 16 08:50:26 2005 Subject: [python-win32] pyhtonwin crash Message-ID: <324B43239F9B4E4591BDE80A24A9423D266C3B@GRZMX1.io.sft.ms.steyr.com> Hi, I have a big problem with pyhtonwin. Not everytime but, sometimes I start pyhtonwin, other applications (like outlook) crashes with the message "not enough memory or ressources" or can't open a window?? My first think was, that is microsoft. But it isn't so. Sometimes pyhtonwin also can't open windows like the other programs (as example the file open window). When I close some other programs it will work!!! Very interesting. :) I think there is a problem with ressources. The only think i have seen in the windows task-manager is that pythonwin needs over 5000 User-objects. Other programs only need about 100. Can somebody help me? Thank you very much. with best reagards Michael Erhart ---------------------------------------------- Michael Erhart MAGNA STEYR Fahrzeugtechnik Liebenauer Hauptstrasse 317, A-8041 Graz Tel.: ++43 316 404 4129 Fax ++43 316 404 5953 E-Mail : michael.erhart@magnasteyr.com ---------------------------------------------- Diese Nachricht ist fuer die Magna Steyr Fahrzeugtechnik AG & Co KG rechtsunverbindlich! . . . . . . . . . . . . . . . . . . . . . . . . This message is not legally binding upon Magna Steyr Fahrzeugtechnik AG & Co KG! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify your system manager. This footnote also confirms that this email message has been swept for the presence of computer viruses. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050316/8f627d73/attachment.html From mike.spam.filter at day8.com.au Wed Mar 16 11:56:27 2005 From: mike.spam.filter at day8.com.au (Mike Thompson) Date: Wed Mar 16 12:02:11 2005 Subject: [python-win32] Re: python crash with IE Activex In-Reply-To: <422506CB.6040609@gmx.net> References: <422506CB.6040609@gmx.net> Message-ID: <423810DB.9080300@day8.com.au> Stani Michiels wrote: >> >> >>Hi all, >>I'm playing with the demo example ActiveXWrapper_IE.py. What I want is >>avoid users access some url's. To accomplish this I'm using >>OnBeforeNavigate2 event, returning a true value should cancel the request... >> >> >>def OnBeforeNavigate2(self, pDisp, URL, Flags, TargetFrameName, >>PostData, Headers, Cancel) : >> self.log.write('OnBeforeNavigate2: %s\n' % URL) >> >> if URL == "http://www.microsoft.com/": >> return 1 >> >> >>The problem is that if I return a true value, python crashes :s >> >>I've been searching some info, but got no luck :( >> >>Any ideas? >> >>Thanks >>Xavi Beumala >> > > I would like to know as well. Please let me know if you have a solution. > Thanks, > Stani > > http://spe.pycs.net > From memory ... If you don't want to do the navigation: Cancel = False if you do, then leave Cancel as its default True Perhaps code like this ... ------------------------------------------------------------------- def OnBeforeNavigate2(self, pDisp, URL, Flags, TargetFrameName, PostData, Headers, Cancel) : self.log.write('OnBeforeNavigate2: %s\n' % URL) if URL != "http://www.microsoft.com/": Cancel = False ------------------------------------------------------------------- -- Mike From tony at tcapp.com Wed Mar 16 17:28:36 2005 From: tony at tcapp.com (Tony Cappellini) Date: Wed Mar 16 17:28:55 2005 Subject: [python-win32] pyhtonwin crash Message-ID: <6.1.2.0.0.20050316082153.01f74b50@mail.yamato.com> I've had similar problems, that after running some other apps, I cannot run PythonWin. The apps I've noticed which seem to have the most problems with PythonWin are Codewright, and Editor from Borland, Eudora, an EMail client, and Outlook. When I see this problem, I double click on the PythonWin icon, and nothing happens, it never appears, no error message, nothing. It doesn' t show up in the task manager either. I usually have to reboot to clear the problem, just so I can run PythonWin. Occasionally, I've been able to close one or the other of these two apps, and I can run PythonWin, but more often I need to reboot. Another similar problem is, if I'm pulling in my email with Eudora, and launch PythonWin only the outer frame of the PythonWin window is displayed. The command line window doesn't appear, and I have to close and re-start it when Eudora is not retrieving email. I'm running XP SP2 on both systems which I've seen these problems on. I have a big problem with pyhtonwin. Not everytime but, sometimes I start pyhtonwin, other applications (like outlook) crashes with the message "not enough memory or ressources" or can't open a window?? My first think was, that is microsoft. But it isn't so. Sometimes pyhtonwin also can't open windows like the other programs (as example the file open window). When I close some other programs it will work!!! Very interesting. :) I think there is a problem with ressources. The only think i have seen in the windows task-manager is that pythonwin needs over 5000 User-objects. Other programs only need about 100. Can somebody help me? From robin at reportlab.com Thu Mar 17 13:14:51 2005 From: robin at reportlab.com (Robin Becker) Date: Thu Mar 17 13:14:53 2005 Subject: [python-win32] system toolbar icons Message-ID: <423974BB.5030209@chamonix.reportlab.co.uk> Is it a known bug that the pythonwin icon seems to persist in the system toolbar area when the toplevel window is killed. It doesn't seem to happen when the file.exit is hit. Also I seem to be able to get the pythonwin process to persist in a hidden way (I think when a debug session is killed by killing the toplevel window). This is build 203 Python 2.4 -- Robin Becker From dbrinkley01 at rowan.org Thu Mar 17 14:37:57 2005 From: dbrinkley01 at rowan.org (Damon Brinkley) Date: Thu Mar 17 14:38:40 2005 Subject: [python-win32] Active Directory, ADSI, WMI integration Message-ID: <38B083C5329C1E428CE83DAD8707A9735BCE05@EXCH.rowan-internal.org> Hello everyone. I am a sys admin in charge of about 100 windows servers in an Active Directory environment and would like to know if there's a way to use Python for my scripting needs instead of vbscript. I would like to do some ADSI and WMI type stuff with Python if possible. Any help would be much appreciated. Damon Brinkley ----------------------------------------- CONFIDENTIALITY NOTICE This e-mail and any files transmitted with it are confidential and intended only for the addressee named above. It contains information that is privileged, confidential or otherwise protected from use and disclosure. If you are not the intended recipient, you are hereby notified that any review, disclosure, copying, or dissemination of this transmission, or taking of any action in reliance on its contents, or other use is strictly prohibited. If you have received this transmission in error, any disclosure, copying, dissemination of this transmission, or other use is strictly prohibited. Please reply to the sender listed above immediately and permanently delete this message from your in box. From tim.golden at viacom-outdoor.co.uk Thu Mar 17 14:44:52 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu Mar 17 14:44:55 2005 Subject: [python-win32] Active Directory, ADSI, WMI integration Message-ID: <9A28C052FF32734DACB0A288A3533991EBB6B2@vogbs009.gb.vo.local> [Damon Brinkley] | Hello everyone. I am a sys admin in charge of about 100 | windows servers in an Active Directory environment and would | like to know if there's a way to use Python for my scripting | needs instead of vbscript. I would like to do some ADSI and | WMI type stuff with Python if possible. Any help would be | much appreciated. I've got some stuff here. I know the WMI stuff has been used by other people. The AD stuff is newer, and I'm sort of wavering between search interfaces etc. (and haven't had the time to do much with it lately). At least it might give you an idea... http://timgolden.me.uk/python Tim Golden ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From a.patt at fi.com Thu Mar 17 19:49:02 2005 From: a.patt at fi.com (Adam Patt) Date: Thu Mar 17 20:38:45 2005 Subject: [python-win32] system toolbar icons Message-ID: This is actually a windows problem I have seen many times. What happens is if any program crashes, it can leave phantom icons on the system tray. I have seen this a lot with outlook and Yahoo Pager. What you usually need to do is just move your mouse over the icon on the tray and windows will clean it up. You may need to click the icon on the try to make it go away. > -----Original Message----- > From: python-win32-bounces+a.patt=fi.com@python.org > [mailto:python-win32-bounces+a.patt=fi.com@python.org] On > Behalf Of Robin Becker > Sent: Thursday, March 17, 2005 4:15 AM > To: python-win32@python.org > Subject: [python-win32] system toolbar icons > > Is it a known bug that the pythonwin icon seems to persist in > the system toolbar area when the toplevel window is killed. > It doesn't seem to happen when the file.exit is hit. > > Also I seem to be able to get the pythonwin process to > persist in a hidden way (I think when a debug session is > killed by killing the toplevel window). > > This is build 203 Python 2.4 > -- > Robin Becker > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > PLEASE READ THIS WARNING: Investment in securities involves the risk of loss. Past performance is no guarantee of future returns. Other methods may produce different results, and the results for different periods may vary depending on market conditions and the composition of the portfolio. Warning: Do not send time-sensitive, action-oriented messages, such as transaction requests, via e-mail as it is our policy not to accept such items electronically. All e-mail sent to or from this address will be received or otherwise recorded by the Fisher Investments corporate e-mail system and is subject to archival, monitoring or review by, and/or disclosure to, someone other than the recipient. From rwupole at msn.com Thu Mar 17 21:44:37 2005 From: rwupole at msn.com (Roger Upole) Date: Thu Mar 17 21:44:45 2005 Subject: [python-win32] system toolbar icons Message-ID: The problem with the system tray icon is due to a bug in mfc 7.1 that's causing Pythonwin to not shut down correctly.. There's a workaround in CVS, and should be in the upcoming release. Roger "Robin Becker" wrote: > Is it a known bug that the pythonwin icon seems to persist in the system > toolbar > area when the toplevel window is killed. It doesn't seem to happen when > the > file.exit is hit. > > Also I seem to be able to get the pythonwin process to persist in a hidden > way > (I think when a debug session is killed by killing the toplevel window). > > This is build 203 Python 2.4 > -- > Robin Becker From richard at inferspace.com Thu Mar 17 22:24:30 2005 From: richard at inferspace.com (Richard Dybowski) Date: Thu Mar 17 22:28:02 2005 Subject: [python-win32] Cannot use Browse PythonPath in PythonWin Message-ID: <5.2.1.1.2.20050317212121.028bf820@mailhost.zen.co.uk> I have recently installed PythonWin 2.4. There is a problem with Tools->Browse PythonPath. Whenever I select it, I get the long error message shown below. I would be very grateful for any help with this matter. My operating system is Windows 98 SE (4.10.2222A) Python used is ActivePython 2.4.0-244 (from which I got PythonWin) sys.path is ['', 'C:\\WINDOWS\\SYSTEM\\PYTHON24.zip', 'C:\\WINDOWS\\Desktop', 'C:\\PYTHON24\\DLLs', 'C:\\PYTHON24\\lib', 'C:\\PYTHON24\\lib\\plat-win', 'C:\\PYTHON24\\lib\\lib-tk', 'C:\\PYTHON24\\LIB\\SITE-PACKAGES\\PYTHONWIN', 'C:\\PYTHON24', 'C:\\PYTHON24\\lib\\site-packages', 'C:\\PYTHON24\\lib\\site-packages\\win32', 'C:\\PYTHON24\\lib\\site-packages\\win32\\lib'] -----------------< Output from Browse PythonPath >-------------------------- Failed to execute command: from pywin.tools import browseProjects;browseProjects.Browse() Traceback (most recent call last): File "C:\PYTHON24\LIB\SITE-PACKAGES\PYTHONWIN\pywin\framework\toolmenu.py", line 103, in HandleToolCommand exec "%s\n" % pyCmd File "", line 1, in ? File "C:\PYTHON24\LIB\SITE-PACKAGES\PYTHONWIN\pywin\tools\browseProjects.py", line 251, in DockablePathBrowser bar.CreateWindow(win32ui.GetMainFrame(), DockableBrowserCreator, "Path Browser", 0x8e0a) File "C:\PYTHON24\LIB\SITE-PACKAGES\PYTHONWIN\pywin\docking\DockingBar.py", line 71, in CreateWindow self.dialog = apply(childCreator, (self,) + childCreatorArgs) File "C:\PYTHON24\LIB\SITE-PACKAGES\PYTHONWIN\pywin\tools\browseProjects.py", line 245, in DockableBrowserCreator list = hl.HierInit (parent, control) File "C:\PYTHON24\LIB\SITE-PACKAGES\PYTHONWIN\pywin\tools\hierlist.py", line 93, in HierInit self.AcceptRoot(self.root) File "C:\PYTHON24\LIB\SITE-PACKAGES\PYTHONWIN\pywin\tools\hierlist.py", line 220, in AcceptRoot subItems = self.GetSubList(root) File "C:\PYTHON24\LIB\SITE-PACKAGES\PYTHONWIN\pywin\tools\hierlist.py", line 268, in GetSubList return self.DelegateCall(item.GetSubList) File "C:\PYTHON24\LIB\SITE-PACKAGES\PYTHONWIN\pywin\tools\hierlist.py", line 255, in DelegateCall return fn() File "C:\PYTHON24\LIB\SITE-PACKAGES\PYTHONWIN\pywin\tools\browseProjects.py", line 178, in GetSubList hKey = win32api.RegOpenKey(regutil.GetRootKey(), keyStr) error: (2, 'RegOpenKeyEx', 'The system cannot find the file specified.') ------------------------------< End of output >----------------------------------- ------------------------------- Richard Dybowski 143 Village Way Pinner HA5 5AA, UK Tel: 07976 250092 From wyvernlist at crm3.com Fri Mar 18 01:35:42 2005 From: wyvernlist at crm3.com (wyvernlist) Date: Fri Mar 18 01:35:56 2005 Subject: [python-win32] Thread won't run in service Message-ID: <423A225E.2050301@crm3.com> Hi, I'm writing an event log monitor that will run as a service, and to do that I'm going to follow the advice someone gave me on this list earlier and implement a producer/consumer model, where one thread listens for new event log entries and pushes them onto a Queue, and the second thread reads from the Queue and mails the entry to the admin(me). I started by writing a simple service that does nothing but spawn a single thread, which in turn does nothing but listen for an error sent to the event log. Once it gets an error it logs a warning and terminates. I did this so I could experiment - problem is, it doesn't work. It doesn't complain when it runs self.monitor.start() but the thread never runs. No warning is ever logged, and it never prints to the little debug file. No exception is thrown. I pulled the code out and ran it as a regular program, and it works fine. But the thread never seems to spawn in the service. Am I missing something here? Any help would be appreciated. Thanks, Jan #!/usr/bin/env python # This service looks for DB2 error messages in the event log # When it find them, it fires off an e-mail containing their details. import win32serviceutil import win32service import win32event import dwmi import smtplib from threading import Thread from time import sleep class EvtLogMonitor (Thread): """ This class runs in a separate thread and is responsible for monitoring the event log.""" def __init__(self): Thread.__init__(self) self.c = dwmi.WMI(privileges = ["Security"]) self.watcher = self.c.watch_for( notification_type = "Creation", wmi_class = "Win32_NTLogEvent", Type = "error") def run(): """ Main point of execution for thread """ fd=open("C:\ellis\tmp\thread.txt",w) fd.write("Thread started!") fd.close() import servicemanager servicemanager.LogWarningMsg("Thread started!") error = self.watcher(100000) servicemanager.LogWarningMsg("Detected error message from "+error.SourceName) class PythonDB2ErrorMonitor (win32serviceutil.ServiceFramework): """ Service that monitors the event log for error messages """ _svc_name_ = "PythonDB2ErrorMonitor" _svc_display_name_ = "Python DB2 Error Monitor" def __init__(self,args): win32serviceutil.ServiceFramework.__init__(self,args) # Create an event to wait on self.hWaitStop = win32event.CreateEvent(None,0,0,None) self.monitor = EvtLogMonitor() def SvcStop(self): """ Called when the service receives the stop signal """ import servicemanager # Inform the SCM we are stopping self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) # Log that we are stopping servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STOPPED, (self._svc_name_,'')) # wait for thread to join self.monitor.join() # Set the event win32event.SetEvent(self.hWaitStop) def SvcDoRun(self): """ Called when the service starts running """ import servicemanager # Log that we started servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_,'')) try: self.monitor.start() except: servicemanager.LogWarningMsg("Could not start thread!") # Wait for the stop event win32event.WaitForSingleObject(self.hWaitStop,win32event.INFINITE) if __name__ == "__main__": win32serviceutil.HandleCommandLine(PythonDB2ErrorMonitor) From davidrushby at yahoo.com Fri Mar 18 02:45:43 2005 From: davidrushby at yahoo.com (David Rushby) Date: Fri Mar 18 02:45:46 2005 Subject: [python-win32] Thread won't run in service In-Reply-To: <423A225E.2050301@crm3.com> Message-ID: <20050318014543.9494.qmail@web30001.mail.mud.yahoo.com> Does the thread actually not run, or does it run, but lack the right to write files, raise an exception that you have no way of detecting, and exit? If you install the service as an administrative user who has the "Log on as a service" right (in Control Panel -> Administrative Tools -> Local Security Policy -> Local Policies -> User Rights Assignment), rather than as the "LocalSystem" user, does the program then work as expected? (I don't know whether installing the service as an administrative user is an inappropriate security risk in your situation, but I recall having trouble writing files from services that were installed as "LocalSystem".) __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From tony at tcapp.com Fri Mar 18 07:26:10 2005 From: tony at tcapp.com (Tony Cappellini) Date: Fri Mar 18 07:26:27 2005 Subject: [python-win32] Error in PythonWin docs for FlashWindow ? Message-ID: <6.1.2.0.0.20050317221939.01fc3ec8@mail.yamato.com> I was calling win32gui.FlashWindow(), with the 6 arguments specified in the PythonWin docs win32gui.FlashWindow int = FlashWindow(hwnd, bInvert , hwnd , dwFlags , uCount , dwTimeout ) The error stated that FlashWindow() only takes 2 arguments. Mark, when you get around to looking at this, if you can make all six arguments available- I can make use of them. The Win32 API shows a different argument for arg 1, being the size of the structure being passed, but that wouldn't be applicable in Python, so I guess we could really live with having only to pass args 2-6 thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050317/c549639e/attachment-0001.html From robin.czempik at gmx.de Fri Mar 18 13:00:48 2005 From: robin.czempik at gmx.de (Czempik Robin GMX) Date: Fri Mar 18 13:00:38 2005 Subject: [python-win32] Python COM Type Library Message-ID: <20050318120036.8BEB61E4007@bag.python.org> Hello to all, I got the first problem with starting programming Python with COM. I would like to use Python COM to communicate with Powerpoint. After Python COM generated me the python file for Powerpoint over the Makepy utility, I can't view the Methods etc. over the Python COM Browser in PythonWin. If I take a look at the COM Browser for the registered Type Libraries I only get the following error Message: The type info can not be loaded! What am I doing wrong, or what do I should do to see all the necessary Type Libraries. Thanks for helping Robin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050318/81e2728a/attachment.htm From david83 at laposte.net Fri Mar 18 15:39:42 2005 From: david83 at laposte.net (david83) Date: Fri Mar 18 17:17:31 2005 Subject: [python-win32] driving win32 gui Message-ID: Hello, I need to automate the installation of a program under Windows. I use python + win32 extension But I have two problems: 1) During the installation, there is a CheckListBox (with className="ListBox") and I don't know how to check the boxes of this CheckListBox. 2) After, there is an alert-message. I must click on 'Yes' button. But the posting of this message stops the execution of my Python program. Consequently I can't find this window with FindTopWindow(). Nevertheless, if I launch another Python program, I can find this window and click on 'Yes' button Do you have an idea to solve these two problems? Thank you very much. David (France) Acc?dez au courrier ?lectronique de La Poste : www.laposte.net ; 3615 LAPOSTENET (0,34?/mn) ; t?l : 08 92 68 13 50 (0,34?/mn) From timr at probo.com Fri Mar 18 18:19:43 2005 From: timr at probo.com (Tim Roberts) Date: Fri Mar 18 18:19:47 2005 Subject: [python-win32] system toolbar icons In-Reply-To: <20050318062630.745231E400F@bag.python.org> References: <20050318062630.745231E400F@bag.python.org> Message-ID: <423B0DAF.9080002@probo.com> On Thu, 17 Mar 2005 12:14:51 +0000, Robin Becker wrote: >Is it a known bug that the pythonwin icon seems to persist in the system toolbar >area when the toplevel window is killed. It doesn't seem to happen when the >file.exit is hit. > > However, let us note that this is not a Pythonwin bug. This is a Windows design flaw. It happens with ANY app with a tray icon that dies unexpectedly. If you hover your mouse over the icons, the dead icons will go away. "Harvest your zombies", as they might say in Linux. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From waldemar.osuch at gmail.com Fri Mar 18 18:55:46 2005 From: waldemar.osuch at gmail.com (Waldemar Osuch) Date: Fri Mar 18 18:55:49 2005 Subject: [python-win32] driving win32 gui In-Reply-To: References: Message-ID: <6fae95540503180955e9f28e3@mail.gmail.com> On Fri, 18 Mar 2005 15:39:42 +0100, david83 wrote: > > Hello, > > I need to automate the installation of a program under > Windows. I use python + win32 extension [...] I have not tried it but I have heard good things. http://www.tizmoi.net/watsup/intro.html http://www.brunningonline.net/simon/blog/archives/winGuiAuto.py.html From mc at mclaveau.com Fri Mar 18 19:17:02 2005 From: mc at mclaveau.com (Michel Claveau) Date: Fri Mar 18 19:17:13 2005 Subject: [python-win32] driving win32 gui References: Message-ID: <000601c52be6$b1a0b920$0701a8c0@PORTABLES> Bonjour ! >>> I need to automate the installation of a program under Windows. I use >>> python + win32 extension >>> But I have two problems: Il est possible, et facile, d'automatiser ce genre de chose avec Autoit. Voir : http://www.framasoft.net/article1568.html (en fran?ais) ou : http://www.hiddensoft.com/autoit3/ (en anglais) @-salutations -- Michel Claveau From wyvernlist at crm3.com Fri Mar 18 19:24:55 2005 From: wyvernlist at crm3.com (wyvernlist) Date: Fri Mar 18 19:25:05 2005 Subject: [python-win32] Thread won't run in service In-Reply-To: <20050318014543.9494.qmail@web30001.mail.mud.yahoo.com> References: <20050318014543.9494.qmail@web30001.mail.mud.yahoo.com> Message-ID: <423B1CF7.1080206@crm3.com> Hi David, Thanks for your reply. That could be it but I'm unable to check on my development machine (a laptop running XP Home) as the local security policy option does not exist. I'll try it on the server itself. I can actually write entries to the event log with the service, it's just that the thread I spawn appears to do nothing. Thanks, Jan David Rushby wrote: >Does the thread actually not run, or does it run, but lack the right to >write files, raise an exception that you have no way of detecting, and >exit? > >If you install the service as an administrative user who has the "Log >on as a service" right (in Control Panel -> Administrative Tools -> >Local Security Policy -> Local Policies -> User Rights Assignment), >rather than as the "LocalSystem" user, does the program then work as >expected? > >(I don't know whether installing the service as an administrative user >is an inappropriate security risk in your situation, but I recall >having trouble writing files from services that were installed as "LocalSystem".) > >__________________________________________________ >Do You Yahoo!? >Tired of spam? Yahoo! Mail has the best spam protection around >http://mail.yahoo.com >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > > > From magoldfish at gmail.com Mon Mar 21 05:56:02 2005 From: magoldfish at gmail.com (Marcus Goldfish) Date: Mon Mar 21 05:56:05 2005 Subject: [python-win32] win32gui and BitBlt()? Message-ID: <5e183f3d0503202056714f98da@mail.gmail.com> I've been working on a screen capture utility for python, but came across a snag using win32gui: I can't find BitBlt()? Does this module contain such a function? I was able to find BitBlt() as a method of PyCDC in module win32ui, but I was trying to avoid MFC. Can someone post a snippet of using win32gui (not win32ui) for screen capture? Thanks, Marcus From magoldfish at gmail.com Mon Mar 21 05:56:33 2005 From: magoldfish at gmail.com (Marcus Goldfish) Date: Mon Mar 21 05:56:35 2005 Subject: [python-win32] win32gui, win32ui -- how to release references? Message-ID: <5e183f3d050320205610961dc8@mail.gmail.com> As an addendum to my previous post: I was able to successfully do screen capturing using win32gui + win32ui, [though I am still looking for a solution that works without win32ui]. The code goes something like: l, t, r, b = win32gui.GetWindowRect(hwnd) h, w = b-t, r-l hDC = win32gui.GetDC(hwnd) tmpDC = win32ui.CreateDCFromHandle(hDC) myDC = tmpDC.CreateCompatibleDC() myBitmap = win32ui.CreateBitmap() myBitmap.CreateCompatibleBitmap(tmpDC, w, h) myDC.SelectObject(myBitmap) myDC.BitBlt((0,0), (w,h), tmpDC, (0,0), win32con.SRCCOPY) myBitmap.Paint(newDC) # process bitmap # cleanup In the C/C++ code snippets I've seen, the cleanup step usually involves ReleaseDC(hwnd, hDC), DeleteDC(myDC), and DeleteObject(myBitmap). Are these steps automatically handled in Python by win32gui and win32ui? If not, can someone post a snippet of cleanup code that works for this example? Thanks! Marcus From mc at mclaveau.com Mon Mar 21 09:01:17 2005 From: mc at mclaveau.com (Michel Claveau) Date: Mon Mar 21 09:01:30 2005 Subject: [python-win32] win32gui and BitBlt()? References: <5e183f3d0503202056714f98da@mail.gmail.com> Message-ID: <005d01c52dec$2ab84ba0$0701a8c0@PORTABLES> Hi ! Sorry, it's with PIL ; but it is a example of screenshot : import Image, ImageGrab ImageGrab.grab().save('c:\\mgold.bmp') @-salutations -- Michel Claveau From nedwards at umiacs.umd.edu Mon Mar 21 15:46:26 2005 From: nedwards at umiacs.umd.edu (Nathan Edwards) Date: Mon Mar 21 15:46:29 2005 Subject: [python-win32] Python crash after win32com.client.CastTo? Message-ID: <423EDE42.3030305@umiacs.umd.edu> I'm going out of my mind here, trying to figure out if a) I'm screwing up, b) Python's COM extensions are screwing up, or c) the Type Library I'm using is screwing up. I have a small amount of experience with Visual Basic, but no experience of the intricacies of COM interfaces. However, I am "merely" attempting to port VB code that is known to work to a less restricted context (python). The relevant code snippet looks like this: Dim theFMANSpecData As New FMANSpecData Dim theWF As FMANWiffFile Dim theWF2 As IFMANWiffFile2 theFMANSpecData.wiffFilename = wiffFilename Set theWF = theFMANSpecData.GetWiffFileObject Set theWF2 = theWF .... Call theWF2.GetScanDescription2(1, 0, 382, 1, 0, ScanDesc, fixedMass) I've used makepy to ensure static binding, and translated to this snippet as follows: from win32com.client import Dispatch, CastTo theFMANSpecData = Dispatch('Analyst.FMANSpecData') theFMANSpecData.WiffFileName = wiffFilename theWF = theFMANSpecData.GetWiffFileObject() theWF2 = CastTo(theWF,'IFMANWiffFile2') ... ScanDesc, fixedMass = theWF2.GetScanDescription2(1,0,382,1,0) I've used many of the other elements of the Analyst application's typelibs - they have all worked fine. This is the only case where a non-default interface to a class is required. When the python interpreter hits the call to GetScanDescription2, it exits immediately, no exception, no error message, no nothing. Exit status 5 (cygwin shell), %errorlevel% -1073741819 from cmd.exe prompt. Python 2.4, pywin32-203 for Python 2.4. I'm not even sure how to proceed to debug the problem. The type library is propriatary (provided by an instrument vendor). While it is possible the fault lies in that code, the library is used (and run by me on the same computer) by the VB code snippet above. python exits abruptly with no error message whether or not I use the python binary or the pythonwin binary. By inserting print statements into win32com/client/__init__.py, I've established that the crash is occuring in the call to self._oldobj_.InvokeTypes(...) in DispatchBaseClass._ApplyTypes_. Having established this, I'm pretty confident of b) above. The arguements to InvokeTypes are: dispid = 1610678272 wFlags = 1 retType = (24, 0) argTypes = ((3, 1), (3, 1), (3, 1), (3, 1), (3, 1), (16392, 2), (16389, 2)) args = (1, 0, 382, 1, 0, , ) If this is a bug in pywin, is this enough information to fix it? If not, how can I generate more helpful information? Thanks! nathan nathan -- Nathan Edwards, Ph.D. Center for Bioinformatics and Computational Biology 3119 Agriculture/Life Sciences Surge Building #296 University of Maryland, College Park, MD 20742-3360 Phone: +1 301-405-9901 Email: nedwards@umiacs.umd.edu WWWeb: http://www.umiacs.umd.edu/~nedwards From timr at probo.com Mon Mar 21 19:40:18 2005 From: timr at probo.com (Tim Roberts) Date: Mon Mar 21 19:40:21 2005 Subject: [python-win32] win32gui, win32ui -- how to release references? In-Reply-To: <20050321110042.5C96B1E400A@bag.python.org> References: <20050321110042.5C96B1E400A@bag.python.org> Message-ID: <423F1512.2050305@probo.com> On Sun, 20 Mar 2005 23:56:33 -0500, Marcus Goldfish wrote: >As an addendum to my previous post: I was able to successfully do >screen capturing using win32gui + win32ui, [though I am still looking >for a solution that works without win32ui]. > Why? win32ui is just a wrapper around user32.dll. That's the way you get UI stuff done on Windows. >In the C/C++ code snippets I've seen, the cleanup step usually >involves ReleaseDC(hwnd, hDC), DeleteDC(myDC), and >DeleteObject(myBitmap). > Right, and every programmer forgets those. That's why there are so many wrapper classes to handle them automatically. >Are these steps automatically handled in >Python by win32gui and win32ui? If not, can someone post a snippet of >cleanup code that works for this example? > Yes, it is automatic. When the objects are destroyed, the resources will be released. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From magoldfish at gmail.com Mon Mar 21 22:23:54 2005 From: magoldfish at gmail.com (Marcus Goldfish) Date: Mon Mar 21 22:23:58 2005 Subject: Fwd: [python-win32] win32gui, win32ui -- how to release references? In-Reply-To: <423F1512.2050305@probo.com> References: <20050321110042.5C96B1E400A@bag.python.org> <423F1512.2050305@probo.com> Message-ID: <5e183f3d05032113237427ef8@mail.gmail.com> > > screen capturing using win32gui + win32ui, [though I am still looking > > for a solution that works without win32ui]. > Why? win32ui is just a wrapper around user32.dll. That's the way you > get UI stuff done on Windows. Why not!? (couldn't resist) Actually, it is my understanding that one might want to avoid MFC if plans include deployment to WinCE devices. Also, I am not an MFC programmer so using MFC classes & paradigms just adds another level of complexity to the task [e.g., the resource release question: does MFC do it automatically? Does the win32ui wrap of MFC also do it automatically?] I am not opposed to using win32ui, but for this task I prefer a simpler alternative. For instance, I am also implementing screen capture using the ctypes extension, and I would like to compare the two solutions. My ctypes implementation doesn't use MFC (aside: is it even possible to use MFC with ctypes?). Also, is win32ui really just a wrapper of user32dll? I thought it was a wrap of MFC-- these two things aren't the same, are they? > >In the C/C++ code snippets I've seen, the cleanup step usually > >involves ReleaseDC(hwnd, hDC), DeleteDC(myDC), and > >DeleteObject(myBitmap). >> Are these steps automatically handled in > >Python by win32gui and win32ui? If not, can someone post a snippet of > Yes, it is automatic. When the objects are destroyed, the resources > will be released. Mark, perhaps you could chime in on this. Your previous response seemed to indicate that the win32ui objects (e.g., the PyBitmap) would be automatically handled, but that I would need to explicitly release the win32gui objects. This seems to me to contradict Tim's assertion. Not to start a contest, but is there a definitive answer to which of these resources hDC, myDC, myBitmap I need to cleanup myself, and which I can defer to python? Marcus From mhammond at skippinet.com.au Mon Mar 21 23:15:37 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon Mar 21 23:15:48 2005 Subject: [python-win32] Python crash after win32com.client.CastTo? In-Reply-To: <423EDE42.3030305@umiacs.umd.edu> Message-ID: <153f01c52e63$83302e20$040a0a0a@enfoldsystems.local> > By inserting print statements into win32com/client/__init__.py, I've > established that the crash is occuring in the call to > self._oldobj_.InvokeTypes(...) in DispatchBaseClass._ApplyTypes_. Unfortunately, _InvokeTypes_ is the main "entry point" for *all* COM calls with type information. As part of this call, Python packs all Python args into VARIANTs, then makes the actual call to the COM object. Thus, I see 2 possibilities: * pythoncom has a bug in InvokeTypes, probably in arg packing or unpacking. * The COM object has a bug once control has been passed to that. If pythoncom does have such a bug, it is subtle - all other COM objects generally work fine. Also, the symptoms don't really match what Python would do - the only thing I can see that would cause Python to "abort" like that is a call to Py_FatalError - that does indeed call the C 'abort' function, but will always cause some short error text to be printed before termination. I'm afraid that my guess is that it is the remote object. If it happens only after a CastTo, I suspect that something is going wrong there. Even though we "CastTo" an interface (IFMANWiffFile2 in this example), we are *still* using IDispatch on the object. If the remote object expected a "real" interface rather than an IDispatch based one, or the CastTo source object is incorrect, I could see how this could happen. > If this is a bug in pywin, is this enough information to fix > it? If not, how can I generate more helpful information? I'm afraid it is tricky without a debug build of pywin32. Mark From cappy2112 at gmail.com Tue Mar 22 02:48:06 2005 From: cappy2112 at gmail.com (Tony C) Date: Tue Mar 22 02:48:08 2005 Subject: [python-win32] win32com.Dispatch() vs win32com.client.gencache.EnsureDispatch() vs win32com.client.DispatchWithEvents() In-Reply-To: <20050318062630.745231E400F@bag.python.org> References: <20050318062630.745231E400F@bag.python.org> Message-ID: <8249c4ac05032117484817e110@mail.gmail.com> When I tried accessing a COM server using win32com.Dispatch() , only the first command sent to the COM server would work after dispatching it, then all susequent calles to the Execute() method would cause an excetpion. Then I read something about EnsureDispatch(), which seems to work 100% better. It always works for me. Now I want to try to setup a callback in my code, so I want to try win32com.client.DispatchWithEvents() What I would like to know is- is DispatchWithEvents() like the unreliable Dispatch(), or is it more like using EnsureDispatch() + event handling ? Does anyone have some example sof using win32com.client.DispatchWithEvents() ? thanks From niki at vintech.bg Tue Mar 22 09:31:22 2005 From: niki at vintech.bg (Niki Spahiev) Date: Tue Mar 22 09:31:33 2005 Subject: [python-win32] win32gui, win32ui -- how to release references? In-Reply-To: <423F1512.2050305@probo.com> References: <20050321110042.5C96B1E400A@bag.python.org> <423F1512.2050305@probo.com> Message-ID: <423FD7DA.2050400@vintech.bg> Tim Roberts wrote: > On Sun, 20 Mar 2005 23:56:33 -0500, Marcus Goldfish > wrote: > >> As an addendum to my previous post: I was able to successfully do >> screen capturing using win32gui + win32ui, [though I am still looking >> for a solution that works without win32ui]. >> > > Why? win32ui is just a wrapper around user32.dll. That's the way you > get UI stuff done on Windows. Not true. win32ui is wrapper around MFCxx.DLL > >> In the C/C++ code snippets I've seen, the cleanup step usually >> involves ReleaseDC(hwnd, hDC), DeleteDC(myDC), and >> DeleteObject(myBitmap). >> > > Right, and every programmer forgets those. That's why there are so many > wrapper classes to handle them automatically. > >> Are these steps automatically handled in >> Python by win32gui and win32ui? If not, can someone post a snippet of >> cleanup code that works for this example? >> > > Yes, it is automatic. When the objects are destroyed, the resources > will be released. IMHO only win32ui objects are automatic. Niki Spahiev -- ? ????????, ??????? ??????? ?????? ??? From mhammond at skippinet.com.au Tue Mar 22 09:56:48 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue Mar 22 09:56:56 2005 Subject: [python-win32] win32com.Dispatch() vswin32com.client.gencache.EnsureDispatch() vswin32com.client.DispatchWithEvents() In-Reply-To: <8249c4ac05032117484817e110@mail.gmail.com> Message-ID: <157c01c52ebd$15b0c490$040a0a0a@enfoldsystems.local> > What I would like to know is- is DispatchWithEvents() like the > unreliable Dispatch(), or is it more like using EnsureDispatch() + > event handling ? DispatchWithEvents is more like EnsureDispatch - it requires the makepy early-binding. > Does anyone have some example sof using > win32com.client.DispatchWithEvents() ? help(win32com.client.DispatchWithEvents) should print an IE example. Mark From nedwards at umiacs.umd.edu Tue Mar 22 15:10:00 2005 From: nedwards at umiacs.umd.edu (Nathan Edwards) Date: Tue Mar 22 15:10:16 2005 Subject: [python-win32] Python crash after win32com.client.CastTo? In-Reply-To: <153f01c52e63$83302e20$040a0a0a@enfoldsystems.local> References: <153f01c52e63$83302e20$040a0a0a@enfoldsystems.local> Message-ID: <42402738.4020201@umiacs.umd.edu> > Unfortunately, _InvokeTypes_ is the main "entry point" for *all* COM calls > with type information. As part of this call, Python packs all Python args > into VARIANTs, then makes the actual call to the COM object. Hmmm. I was afraid of that. > Thus, I see 2 possibilities: > * pythoncom has a bug in InvokeTypes, probably in arg packing or unpacking. Possible, but unlikely, since the args are ints with two pass by reference parameters (string and float). Nothing hairy there, I exepct that the argument unpacking and packing has proven itself over time. > * The COM object has a bug once control has been passed to that. I wouldn't be surprised, but given that very similar code works in VB, I'm guessing the issue lies somewhere at the interface. > If pythoncom does have such a bug, it is subtle - all other COM objects > generally work fine. Also, the symptoms don't really match what Python > would do - the only thing I can see that would cause Python to "abort" like > that is a call to Py_FatalError - that does indeed call the C 'abort' > function, but will always cause some short error text to be printed before > termination. I agree. > I'm afraid that my guess is that it is the remote object. If it happens > only after a CastTo, I suspect that something is going wrong there. Even > though we "CastTo" an interface (IFMANWiffFile2 in this example), we are > *still* using IDispatch on the object. If the remote object expected a > "real" interface rather than an IDispatch based one, or the CastTo source > object is incorrect, I could see how this could happen. Given my inexperience with COM etc. I guess I don't really understand the difference between a "real" interface vs a IDispatch one. The VB code declared the variables: Dim theFMANSpecData As New FMANSpecData Dim theWF As FMANWiffFile Dim theWF2 As IFMANWiffFile2 Here, theWF is declared as a FMANWiffFile (CoClass), while theWF2 is declared as IFMANWiffFile2 (Non-default Dispatch for FMANWiffFile). Using Dispatch(...), when I ask for an FMANWiffFile, I get a IFMANWiffFile (default Dispatch for FMANWiffFile). I can't do an explicit Dispatch('Analyst.IFMANWiffFile2') (not a valid class string). Later, again in VB, we have theWF = theFMANSpecData.GetWiffFileObject() theWF2 = theWF Is the CastTo "equivalent" to this assignment? Thanks, nathan -- Nathan Edwards, Ph.D. Center for Bioinformatics and Computational Biology 3119 Agriculture/Life Sciences Surge Building #296 University of Maryland, College Park, MD 20742-3360 Phone: +1 301-405-9901 Email: nedwards@umiacs.umd.edu WWWeb: http://www.umiacs.umd.edu/~nedwards From tony at tcapp.com Tue Mar 22 17:56:01 2005 From: tony at tcapp.com (Tony Cappellini) Date: Tue Mar 22 17:56:18 2005 Subject: [python-win32] win32com.Dispatch() vswin32com.client.gencache.EnsureDispatch() vswin32com.client.DispatchWithEvents() In-Reply-To: <157c01c52ebd$15b0c490$040a0a0a@enfoldsystems.local> References: <8249c4ac05032117484817e110@mail.gmail.com> <157c01c52ebd$15b0c490$040a0a0a@enfoldsystems.local> Message-ID: <6.1.2.0.0.20050322085421.01f78a00@mail.yamato.com> >help(win32com.client.DispatchWithEvents) should print an IE example. >>At 12:56 AM 03/22/05, Mark Hammond wrote: I did see the example, but didn't know which form of Dispatch it works like. I've read Chapter 12 , several times- but this stuff doesn't COM easy to me. > > What I would like to know is- is DispatchWithEvents() like the > > unreliable Dispatch(), or is it more like using EnsureDispatch() + > > event handling ? > >DispatchWithEvents is more like EnsureDispatch - it requires the makepy >early-binding. > > > Does anyone have some example sof using > > win32com.client.DispatchWithEvents() ? > >help(win32com.client.DispatchWithEvents) should print an IE example. > >Mark From timr at probo.com Tue Mar 22 20:01:57 2005 From: timr at probo.com (Tim Roberts) Date: Tue Mar 22 20:02:12 2005 Subject: [python-win32] Python crash after win32com.client.CastTo? In-Reply-To: <20050322110050.C231B1E4005@bag.python.org> References: <20050322110050.C231B1E4005@bag.python.org> Message-ID: <42406BA5.10400@probo.com> On Mon, 21 Mar 2005 09:46:26 -0500, Nathan Edwards wrote: >I'm going out of my mind here, trying to figure out if >a) I'm screwing up, >b) Python's COM extensions are screwing up, or >c) the Type Library I'm using is screwing up. > >... Call theWF2.GetScanDescription2(1, 0, 382, 1, 0, ScanDesc, fixedMass) > >I've used makepy to ensure static binding, and translated to this >snippet as follows: > > from win32com.client import Dispatch, CastTo > theFMANSpecData = Dispatch('Analyst.FMANSpecData') > theFMANSpecData.WiffFileName = wiffFilename > theWF = theFMANSpecData.GetWiffFileObject() > theWF2 = CastTo(theWF,'IFMANWiffFile2') > > ... > > ScanDesc, fixedMass = theWF2.GetScanDescription2(1,0,382,1,0) > >I've used many of the other elements of the Analyst application's >typelibs - they have all worked fine. This is the only case where a >non-default interface to a class is required. > >When the python interpreter hits the call to GetScanDescription2, it >exits immediately, no exception, no error message, no nothing. Exit >status 5 (cygwin shell), %errorlevel% -1073741819 from cmd.exe prompt. > > For what it's worth, -1073741819 is hex C0000005, which is STATUS_ACCESS_VIOLATION: a general protection fault. That's usually a wild address or a null pointer dereference. Is it possible that one of those last two parameters is actually (in,out) and not just (out)? -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From magoldfish at yahoo.com Mon Mar 21 05:17:29 2005 From: magoldfish at yahoo.com (Marcus Goldfish) Date: Tue Mar 22 21:35:34 2005 Subject: [python-win32] win32gui and BitBlt()? Message-ID: <20050321041730.87680.qmail@web31311.mail.mud.yahoo.com> I've been working on a screen capture utility for python, but came across a snag using win32gui: I can't find BitBlt()? Does this module contain such a function? I was able to find BitBlt() as a method of PyCDC in module win32ui, but I was trying to avoid MFC. Can someone post a snippet of using win32gui (not win32ui) for screen capture? Thanks, Marcus --------------------------------- Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050320/b5c291e4/attachment.html From magoldfish at yahoo.com Mon Mar 21 05:26:58 2005 From: magoldfish at yahoo.com (Marcus Goldfish) Date: Tue Mar 22 21:35:35 2005 Subject: [python-win32] win32gui, win32ui -- how to release references? Message-ID: <20050321042658.96556.qmail@web31315.mail.mud.yahoo.com> As an addendum to my previous post: I was able to successfully do screen capturing using win32gui + win32ui, [though I am still looking for a solution that works without win32ui]. The code goes something like: l, t, r, b = win32gui.GetWindowRect(hwnd) h, w = b-t, r-l hDC = win32gui.GetDC(hwnd) tmpDC = win32ui.CreateDCFromHandle(hDC) myDC = tmpDC.CreateCompatibleDC() myBitmap = win32ui.CreateBitmap() myBitmap.CreateCompatibleBitmap(tmpDC, w, h) myDC.SelectObject(myBitmap) myDC.BitBlt((0,0), (w,h), tmpDC, (0,0), win32con.SRCCOPY) myBitmap.Paint(newDC) # process bitmap # cleanup In the C/C++ code snippets I've seen, the cleanup step usually involves ReleaseDC(hwnd, hDC), DeleteDC(myDC), and DeleteObject(myBitmap). Are these steps automatically handled in Python by win32gui and win32ui? If not, can someone post a snippet of cleanup code that works for this example? Thanks! Marcus --------------------------------- Do you Yahoo!? Yahoo! Small Business - Try our new resources site! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050320/63b5ab59/attachment.htm From gavinrobb at hotpop.com Mon Mar 21 13:26:14 2005 From: gavinrobb at hotpop.com (Gavin Hotpop) Date: Tue Mar 22 21:35:36 2005 Subject: [python-win32] Using win32com to access uPNP Message-ID: <000b01c52e11$2d6c6f50$0500a8c0@FCNGAVIN> I saw this on the internet & am having a similar problem - I think. I'm not a technical person, but have worked out that the script I am running errors ->"Object Required" when it reaches the first line that uses mappingports. Did you manage to fix this - if so please help! I have tried Microsoft & Netgear but nobody seems to want to help. Thank you, Gavin Your message: Hi -- I'm trying to use the interface in win32com to access the windows uPNP service, the code is as follows: import win32com.client theNatter = win32com.client.Dispatch("HNetCfg.NATUPnP") mappingPorts = theNatter.StaticPortMappingCollection At this point mappingPorts seems to contain the null object, so it would appear that theNatter doesn't have an attribute StaticPortMappingCollection though the msdn docs claim otherwise. Also, i notice there are a number of interfaces common to HNetCfg.dll and NATUPnP - how does the above code differntiate between them ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050321/5bad5d15/attachment.html From michael.smietana at home.se Tue Mar 22 15:40:34 2005 From: michael.smietana at home.se (Michael Smietana) Date: Tue Mar 22 21:35:36 2005 Subject: [python-win32] win32gui.EnumChildWindows() "crashes" when no children exists Message-ID: <42402E62.4060108@home.se> When the method win32gui.EnumChildWindows(hwnd, callback, extra) does find the window for which to return children but the window doesn't have any children it crashes with the error: "pywintypes.error: (0, 'EnumChildWindows', 'No error message is available')". Shouldn't it just return a empty list? Rgds /m. From joe_magic at skynet.be Mon Mar 21 17:58:50 2005 From: joe_magic at skynet.be (magic joe) Date: Tue Mar 22 21:35:37 2005 Subject: [python-win32] screenshot of a window? Message-ID: <003201c52e37$416c4220$6e08f151@organizafei2bn> Thats a nice coincidence I'm also looking for screenshot but then only for a certain window. Still need to know how to find a certain window and then get its coordinates. J. From mhammond at skippinet.com.au Tue Mar 22 23:01:09 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue Mar 22 23:01:14 2005 Subject: [python-win32] win32gui.EnumChildWindows() "crashes" when nochildren exists In-Reply-To: <42402E62.4060108@home.se> Message-ID: <160d01c52f2a$a7e594e0$040a0a0a@enfoldsystems.local> > When the method win32gui.EnumChildWindows(hwnd, callback, extra) does > find the window for which to return children but the window > doesn't have > any children it crashes with the error: "pywintypes.error: (0, > 'EnumChildWindows', 'No error message is available')". > Shouldn't it just > return a empty list? Yeah, it should. This *may* be a safe change to make wrt existing programs - a program that expects to see the exception should still work if the code is changed to return an empty list. However, it is possible things will break (eg, the code could be written to assume the list has at least one entry when no exception is raised. Feel free to open a bug at sourceforge, but I'd welcome any comments... Mark From cappy2112 at gmail.com Wed Mar 23 01:00:15 2005 From: cappy2112 at gmail.com (Tony C) Date: Wed Mar 23 01:00:23 2005 Subject: [python-win32] Re: Python-win32 Digest, Vol 24, Issue 18 In-Reply-To: <20050322220115.EC1421E400F@bag.python.org> References: <20050322220115.EC1421E400F@bag.python.org> Message-ID: <8249c4ac050322160018e5a267@mail.gmail.com> Message: 8 Date: Mon, 21 Mar 2005 17:58:50 +0100 From: "magic joe" Subject: [python-win32] screenshot of a window? To: Message-ID: <003201c52e37$416c4220$6e08f151@organizafei2bn> Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Make the window you are looking for the foreground window (or search for it's handle using the text in the Titlebar)- you probably won't need the coordinates then. There are api bindings in win32gui to make the window the foreground window. Then you can use the recipe someone posted here last week, which uses PIL to grab a screenshot. That was only a few lines of Python code, plus you have to have PIL installed. Thats a nice coincidence I'm also looking for screenshot but then only for a certain window. Still need to know how to find a certain window and then get its coordinates. From simon.brunning at gmail.com Wed Mar 23 15:44:47 2005 From: simon.brunning at gmail.com (Simon Brunning) Date: Wed Mar 23 15:44:51 2005 Subject: [python-win32] win32gui.EnumChildWindows() "crashes" when nochildren exists In-Reply-To: <160d01c52f2a$a7e594e0$040a0a0a@enfoldsystems.local> References: <42402E62.4060108@home.se> <160d01c52f2a$a7e594e0$040a0a0a@enfoldsystems.local> Message-ID: <8c7f10c6050323064415b511dd@mail.gmail.com> On Wed, 23 Mar 2005 09:01:09 +1100, Mark Hammond wrote: > Yeah, it should. This *may* be a safe change to make wrt existing > programs - a program that expects to see the exception should still work if > the code is changed to return an empty list. However, it is possible things > will break (eg, the code could be written to assume the list has at least > one entry when no exception is raised. FWIW, this change wouldn't break any of my usages of win32gui.EnumChildWindows. -- Cheers, Simon B, simon@brunningonline.net, http://www.brunningonline.net/simon/blog/ From s_white19 at yahoo.com Wed Mar 23 00:18:21 2005 From: s_white19 at yahoo.com (Sean White) Date: Wed Mar 23 18:04:51 2005 Subject: [python-win32] Struct datatypes from Com objects Message-ID: <20050322231821.9300.qmail@web52305.mail.yahoo.com> Is there special usage for instantiating a struct type object defined in a com object? I am working with a com object, and in it is a struct datatype, which is later used as a required parameter for a method. I cannot seem to be able to instantiate an object of this type, and this is preventing me from being able to call the one method I need to call. I can see the type in the pythonwin com browser, as well as another com object browser from 'oakland software' I have tried dispatching it and importing it, as well as trying to define it as the base class for a new class, with no luck. It is as if it cannot be seen from my current scope. I really don't know how to better ask that question, let me know what information you might be missing. - Sean __________________________________ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail From prouleau at impathnetworks.com Wed Mar 23 19:17:37 2005 From: prouleau at impathnetworks.com (Pierre Rouleau) Date: Wed Mar 23 19:29:15 2005 Subject: [python-win32] How to get the main window handle of an application started with win32process.CreateProcess() ? Message-ID: Hi all, I am trying to send a WM_CLOSE mesage to the main window of a Win32 GUI application I started with win32process.CreateProcess(). I want to terminate the application gracefully, allowing the application to perform all of its regular cleanup and prompting it normally does when the user requests to close it. For that reason, I do not want to use win32process.TerminateProcess(). Since I started the application with win32process.CreateProcess() I have the process information. But to use win32gui.PostMessage() to the application main window I must find the main window handle of that application. Does anyone know how to do this? Thanks in advance. Pierre Rouleau From theller at python.net Wed Mar 23 20:16:15 2005 From: theller at python.net (Thomas Heller) Date: Wed Mar 23 20:24:43 2005 Subject: [python-win32] Re: How to get the main window handle of an application started with win32process.CreateProcess() ? References: Message-ID: <7jjy6um8.fsf@python.net> Pierre Rouleau writes: > Hi all, > > I am trying to send a WM_CLOSE mesage to the main window of a > Win32 GUI application I started with > win32process.CreateProcess(). I want to terminate the > application gracefully, allowing the application to perform all > of its regular cleanup and prompting it normally does when the > user requests to close it. > > For that reason, I do not want to use win32process.TerminateProcess(). > > Since I started the application with win32process.CreateProcess() I > have the process information. But to use win32gui.PostMessage() to > the application main window I must find the main window handle of that > application. > > Does anyone know how to do this? I guess you would call EnumWindows to find all top level windows, and then inspect each with GetWindowThreadProcessId to find the thread and process id. Thomas From rschroev_nospam_ml at fastmail.fm Wed Mar 23 20:11:38 2005 From: rschroev_nospam_ml at fastmail.fm (Roel Schroeven) Date: Wed Mar 23 20:39:58 2005 Subject: [python-win32] Re: How to get the main window handle of an application started with win32process.CreateProcess() ? In-Reply-To: References: Message-ID: Pierre Rouleau wrote: > Hi all, > > I am trying to send a WM_CLOSE mesage to the main window of a Win32 > GUI application I started with win32process.CreateProcess(). I want to > terminate the application gracefully, allowing the application to > perform all of its regular cleanup and prompting it normally does when > the user requests to close it. > > For that reason, I do not want to use win32process.TerminateProcess(). > > Since I started the application with win32process.CreateProcess() I have > the process information. But to use win32gui.PostMessage() to the > application main window I must find the main window handle of that > application. > > Does anyone know how to do this? You could enumerate the windows with win32gui.EnumWindows and filter those belonging to that process using win32process.GetWindowThreadProcesId. -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven From Pierre_Rouleau at impathnetworks.com Wed Mar 23 19:07:39 2005 From: Pierre_Rouleau at impathnetworks.com (Pierre Rouleau) Date: Wed Mar 23 21:47:51 2005 Subject: [python-win32] Howto get the main thread window handle of an application created with win32process.CreateProcess? Message-ID: Hi all, I am trying to send a WM_CLOSE mesage to the main window of an application I started with win32process.CreateProcess(). I want to terminate the application gracefully, allowing the application to perform all of its regular cleanup and prompting it normally does when the user requests to close it. For that reason, I do not want to use win32process.TerminateProcess(). Since I started the application with win32process.CreateProcess() I have the process information. But to use win32gui.PostMessage() to the application main window I must find the main window handle of that application. Does anyone know how to do this? Thanks in advance. Pierre Rouleau From nedwards at umiacs.umd.edu Wed Mar 23 22:50:24 2005 From: nedwards at umiacs.umd.edu (Nathan Edwards) Date: Wed Mar 23 22:50:38 2005 Subject: [python-win32] Python crash after win32com.client.CastTo? In-Reply-To: <42406BA5.10400@probo.com> References: <20050322110050.C231B1E4005@bag.python.org> <42406BA5.10400@probo.com> Message-ID: <4241E4A0.8080301@umiacs.umd.edu> > For what it's worth, -1073741819 is hex C0000005, which is > STATUS_ACCESS_VIOLATION: a general protection fault. That's usually a > wild address or a null pointer dereference. Is it possible that one of > those last two parameters is actually (in,out) and not just (out)? > The generated function declaration indicates they are both out (PyOleMissing object type), but who knows what the library internally expects... >>> help(theWF2.GetScanDescription2) Help on method GetScanDescription2 in module win32com.gen_py.5F259202-611C-11D1-A9C6-0060977F5C78x0x1x0: GetScanDescription2(self, sample=, period=, experiment=, cycle=, forChromatogram=, scanDescription=, fixedMass=) method of win32com.gen_py.5F259202-611C-11D1-A9C6-0060977F5C78x0x1x0.IFMANWiffFile2 instance method GetScanDescription2 Its only weak evidence, but when I feed in invalid input parameters, which for other functions in this library generates exceptions, the crash happens anyway (implies that even the parameter checking doesn't get done, and since this usually is done first, before any other stuff happens, it suggests we don't even make it into the library function proper.) Cheers! nathan -- Nathan Edwards, Ph.D. Center for Bioinformatics and Computational Biology 3119 Agriculture/Life Sciences Surge Building #296 University of Maryland, College Park, MD 20742-3360 Phone: +1 301-405-9901 Email: nedwards@umiacs.umd.edu WWWeb: http://www.umiacs.umd.edu/~nedwards From neil.benn at arcor.de Wed Mar 23 23:44:25 2005 From: neil.benn at arcor.de (Neil Benn) Date: Wed Mar 23 23:44:24 2005 Subject: [python-win32] WinCE RAPI Message-ID: <4241F149.2040905@arcor.de> Hello, I've seen this mentioned a few times but does anyone have a wincerapi binary they could let me have a copy of? I'd be most grateful! All and any help is greatly appreciated. Cheers, Neil From mhammond at skippinet.com.au Thu Mar 24 03:27:15 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Mar 24 03:27:25 2005 Subject: [python-win32] Python crash after win32com.client.CastTo? In-Reply-To: <4241E4A0.8080301@umiacs.umd.edu> Message-ID: <174c01c53018$ff3ec7e0$040a0a0a@enfoldsystems.local> > > For what it's worth, -1073741819 is hex C0000005, which is > > STATUS_ACCESS_VIOLATION: a general protection fault. > That's usually a > > wild address or a null pointer dereference. Is it possible > that one of > > those last two parameters is actually (in,out) and not just (out)? > > > > The generated function declaration indicates they are both out > (PyOleMissing object type), but who knows what the library internally > expects... > > >>> help(theWF2.GetScanDescription2) > Help on method GetScanDescription2 in module > win32com.gen_py.5F259202-611C-11D1-A9C6-0060977F5C78x0x1x0: > > GetScanDescription2(self, sample=, > period= object>, experiment=, cycle=, > forChromatogram=, scanDescription= object>, fixedMass=) method of > win32com.gen_py.5F259202-611C-11D1-A9C6-0060977F5C78x0x1x0.IFM > ANWiffFile2 > instance > method GetScanDescription2 Try passing explicit args for every arg, or substituting pythoncom.Missing instead of pythoncom.Empty. Mark From mhammond at skippinet.com.au Thu Mar 24 03:29:27 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Mar 24 03:29:34 2005 Subject: [python-win32] Struct datatypes from Com objects In-Reply-To: <20050322231821.9300.qmail@web52305.mail.yahoo.com> Message-ID: <174d01c53019$4d7276f0$040a0a0a@enfoldsystems.local> > Is there special usage for instantiating a struct type > object defined in a com object? > > I am working with a com object, and in it is a struct > datatype, which is later used as a required parameter > for a method. > > > I cannot seem to be able to instantiate an object of > this > type, and this is preventing me from being able to > call > the one method I need to call. See win32com.client.Record, and win32com\test\testvb.py. In a nutshell: s = win32com.client.Record("VBStruct", object) Will create a struct object called VBStruct, from the typelib that 'object' is defined in. Mark From nedwards at umiacs.umd.edu Thu Mar 24 03:54:46 2005 From: nedwards at umiacs.umd.edu (Nathan Edwards) Date: Thu Mar 24 03:54:57 2005 Subject: [python-win32] Python crash after win32com.client.CastTo? In-Reply-To: <174c01c53018$ff3ec7e0$040a0a0a@enfoldsystems.local> References: <174c01c53018$ff3ec7e0$040a0a0a@enfoldsystems.local> Message-ID: <42422BF6.8030608@umiacs.umd.edu> > Try passing explicit args for every arg, or substituting pythoncom.Missing > instead of pythoncom.Empty. Already tried the first (same result-immediate crash). Don't understand the second... I've tried explicit "correct value and type" and "incorrect value but correct type" args for every arg, immediate crash in each case. I've come across another strange behavior that I don't understand...this type library has another class that is the "blessed" way to get an object of the type I'm having trouble with. However, I can't get the interface object to instantiate: # This CoClass is known by the name 'Analyst.FMANWiffFileControl.1' class FMANWiffFileControl(CoClassBaseClass): # A CoClass # FMANWiffFileControl Class CLSID = IID('{A1A48EC4-98C6-11D1-A9F6-0060977F5C78}') coclass_sources = [ ] coclass_interfaces = [ IFMANWiffFileControl, ] default_interface = IFMANWiffFileControl class IFMANWiffFileControl(DispatchBaseClass): """IFMANWiffFileControl Interface""" CLSID = IID('{A1A48EC3-98C6-11D1-A9F6-0060977F5C78}') coclass_clsid = IID('{A1A48EC4-98C6-11D1-A9F6-0060977F5C78}') # Result is of type IFMANWiffFile def GetWiffFileObject(self, WiffFileName=defaultNamedNotOptArg, sample=defaultNamedNotOptArg): """method GetWiffFileObject""" ret = self._oleobj_.InvokeTypes(1, LCID, 1, (9, 0), ((8, 1), (3, 1)),WiffFileName, sample) if ret is not None: ret = Dispatch(ret, 'GetWiffFileObject', '{26E42183-9803-11D1-A9F6-0060977F5C78}', UnicodeToString=0) return ret _prop_map_get_ = { } _prop_map_put_ = { } This all looks fine, but attempting to instantiate the interface: >>> from win32com.client import Dispatch >>> Dispatch('Analyst.FMANWiffFileControl.1') ... com_error: (-2147467262, 'No such interface supported', None, None) >>> Dispatch('Analyst.FMANWiffFileControl') ... com_error: (-2147467262, 'No such interface supported', None, None) >>> Dispatch('Analyst.IFMANWiffFileControl') ... com_error: (-2147221005, 'Invalid class string', None, None) Why does this CoClass get created with the .1 after it? And why can't I create an interface to the FMANWiffFileControl object? Thanks, nathan -- Nathan Edwards, Ph.D. Center for Bioinformatics and Computational Biology 3119 Agriculture/Life Sciences Surge Building #296 University of Maryland, College Park, MD 20742-3360 Phone: +1 301-405-9901 Email: nedwards@umiacs.umd.edu WWWeb: http://www.umiacs.umd.edu/~nedwards From clajo04 at mac.com Thu Mar 24 04:21:21 2005 From: clajo04 at mac.com (John Clark) Date: Thu Mar 24 04:21:27 2005 Subject: [python-win32] Using a COM interface where the objects don't have ProgIDs Message-ID: <88c1593080593bf28f7eb37296f5e551@mac.com> My apologies if this is something that should be obvious to me, but I cannot figure out how to use a typelib if that typelib does not establish ProgID values for the CoClasses. The class that was created by EnsureModule() is as follows: class CaWHarvest(CoClassBaseClass): # A CoClass # CaWHarvest Class CLSID = IID('{70107C62-8ABB-11D5-961B-0010A4F73DE4}') coclass_sources = [ _ICaWHarvestEvents, ] default_source = _ICaWHarvestEvents coclass_interfaces = [ ICaWHarvest, ] default_interface = ICaWHarvest I have tried calling win32com.client.Dispatch(None, resultCLSID = IID('{70107C62-8ABB-11D5-961B-0010A4F73DE4}')) but this returned a 'Class Not registered' error. I have searched the registry for the above CLSID and have found entries, so to the best of my knowledge this COM component is registered. Beyond that I am afraid I have exceeded my knowledge of COM & Python. My only experience with calling COM components from Python has been in situations where the class has a ProgID that I would pass into Dispatch() as the parameter... I suppose I could force a programmatic ID by creating something in the registry, but it seems there should be an answer without doing that. Could someone point me in the right direction? I am sure I am just missing something obvious. Thanks, -John -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: text/enriched Size: 1399 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050323/b2bd60a8/attachment.bin From clajo04 at mac.com Thu Mar 24 06:41:40 2005 From: clajo04 at mac.com (John Clark) Date: Thu Mar 24 06:41:46 2005 Subject: Fwd: [python-win32] Using a COM interface where the objects don't have ProgIDs Message-ID: Okay - sorry for the interruption - banging at this for several more minutes gave me the direction I needed. For anyone else out there struggling, I found that if I call win32com.client.dynamic.Dispatch('{70107C62-8ABB-11D5-961B -0010A4F73DE4}') and if I actually DO register the COM control, rather than just assuming that it's registered because the DLL exists ("Of course it is registered - the file is right there! No one would place the file on the disk without actually registering the objects...") everything then seems to work as advertised (imagine that :)). Well, I guess sometimes it just helps to talk it out in email..... -John On Mar 23, 2005, at 10:21 PM, John Clark wrote: > My apologies if this is something that should be obvious to me, but I > cannot figure out how to use a typelib if that typelib does not > establish ProgID values for the CoClasses. > > The class that was created by EnsureModule() is as follows: > > class CaWHarvest(CoClassBaseClass): # A CoClass > # CaWHarvest Class > CLSID = IID('{70107C62-8ABB-11D5-961B-0010A4F73DE4}') > coclass_sources = [ > _ICaWHarvestEvents, > ] > default_source = _ICaWHarvestEvents > coclass_interfaces = [ > ICaWHarvest, > ] > default_interface = ICaWHarvest > > I have tried calling½ win32com.client.Dispatch(None, resultCLSID = > IID('{70107C62-8ABB-11D5-961B-0010A4F73DE4}')) but this returned a > 'Class Not registered' error. I have searched the registry for the > above CLSID and have found entries, so to the best of my knowledge > this COM component is registered. Beyond that I am afraid I have > exceeded my knowledge of COM & Python. > > My only experience with calling COM components from Python has been in > situations where the class has a ProgID that I would pass into > Dispatch() as the parameter... I suppose I could force a programmatic > ID by creating something in the registry, but it seems there should be > an answer without doing that. > > Could someone point me in the right direction? I am sure I am just > missing something obvious. > > Thanks, > -John_______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: text/enriched Size: 2343 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050324/78f510bc/attachment.bin From Pierre_Rouleau at ImpathNetworks.com Thu Mar 24 23:56:32 2005 From: Pierre_Rouleau at ImpathNetworks.com (Pierre Rouleau) Date: Thu Mar 24 23:56:37 2005 Subject: [python-win32] Re: How to get the main window handle of an application started with win32process.CreateProcess() ? In-Reply-To: References: Message-ID: Thanks to Thomas Heller and Roel Schroeven for the help! Here's a summary for a method I used to close an application from another, knowing only the process ID. The method is not ideal because the running child might have some dialog open. Ideally, some IPC mechanism should be used to request closing the target application. But, the method is can help under some circumstances. To terminate a GUI application from its process ID, one way would be to: - use win32gui.EnumWindows() to enumerate all windows in the system - for each window handle found, check if the process ID match the requested on by using win32process.GetWindowThreadProcess() to get the process ID of each enumerated window. - Check the window name of each enumerated window of the specified process ID using win32gui.GetWindowText(). You do not want to close a program that has a dialog open. - Once you have the main window handle of the application and you know that there are no dialog opened in the application, close the application by posting WM_CLOSE (0x10) with win32gui.PostMessage(window_handle, WM_CLOSE,0,0). Pierre Rouleau From Pierre_Rouleau at ImpathNetworks.com Fri Mar 25 00:03:54 2005 From: Pierre_Rouleau at ImpathNetworks.com (Pierre Rouleau) Date: Fri Mar 25 00:03:33 2005 Subject: [python-win32] How to get McMillan Installer accept win32gui? Message-ID: Hi all! I have been using the McMillan Installer for some time even though Gordon McMillan site is no longer up. I am using version 5b5. It has been working fine up until I updated a module to import win32gui. The Python scripts works fine but the executable created by the McMillan Installer fails importing win32gui. I have been delaying moving to py2exe and would prefer finding a solution to get the Installer working again for now. Did anyone run into this problem and found what has to be modified in the Installer to get this to work? Thanks in advance, Pierre Rouleau From michael.erhart at magnasteyr.com Fri Mar 25 07:18:10 2005 From: michael.erhart at magnasteyr.com (michael.erhart@magnasteyr.com) Date: Fri Mar 25 07:18:15 2005 Subject: [python-win32] found bug in pyhtonwin (with workaround) Message-ID: <324B43239F9B4E4591BDE80A24A9423D266C3D@GRZMX1.io.sft.ms.steyr.com> Hi, I have found a bug in pyhtonwin. Sometimes pyhtonwin allocate about 1000 Toolbars and need about 5000 windows-user-objects. So some other programs didn't work at the same time (like outlook) A workaround is to set the toolbar size in the registry manual to 1. So pythonwin only needs about 77 user-objects, and all work perfect. HKEY_CURRENT_USER\Software\Python 2.4\Python for Win32\ToolbarDefault-Summary\Bars = 1 with best regards, Michael Erhart > -----Urspr?ngliche Nachricht----- > Von: Erhart Michael, EES > Gesendet: Mittwoch, 16. M?rz 2005 08:50 > An: 'python-win32@python.org' > Betreff: pyhtonwin crash > > Hi, > > I have a big problem with pyhtonwin. > Not everytime but, sometimes I start pyhtonwin, other applications (like outlook) crashes with the message "not enough memory or ressources" or can't open a window?? > My first think was, that is microsoft. But it isn't so. Sometimes pyhtonwin also can't open windows like the other programs (as example the file open window). When I close some other programs > it will work!!! Very interesting. :) > I think there is a problem with ressources. The only think i have seen in the windows task-manager is that pythonwin needs over 5000 User-objects. Other programs > only need about 100. > > Can somebody help me? > Thank you very much. > > with best reagards > Michael Erhart > > > ---------------------------------------------- > Michael Erhart > MAGNA STEYR Fahrzeugtechnik > Liebenauer Hauptstrasse 317, A-8041 Graz > Tel.: ++43 316 404 4129 Fax ++43 316 404 5953 > E-Mail : michael.erhart@magnasteyr.com > ---------------------------------------------- > Diese Nachricht ist fuer die Magna Steyr > Fahrzeugtechnik AG & Co KG rechtsunverbindlich! > . . . . . . . . . . . . . . . . . . . . . . . . > This message is not legally binding upon > Magna Steyr Fahrzeugtechnik AG & Co KG! > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify your system manager. This footnote also confirms that this email message has been swept for the presence of computer viruses. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050325/fb59beea/attachment.html From niki at vintech.bg Fri Mar 25 10:16:59 2005 From: niki at vintech.bg (Niki Spahiev) Date: Fri Mar 25 10:17:03 2005 Subject: [python-win32] How to get McMillan Installer accept win32gui? In-Reply-To: References: Message-ID: <4243D70B.6010400@vintech.bg> Pierre Rouleau wrote: > Hi all! > > I have been using the McMillan Installer for some time even though > Gordon McMillan site is no longer up. I am using version 5b5. > > It has been working fine up until I updated a module to import win32gui. > The Python scripts works fine but the executable created by the McMillan > Installer fails importing win32gui. Try importing pywintypes before win32gui HTH Niki Spahiev From atulkat at gmail.com Fri Mar 25 14:52:17 2005 From: atulkat at gmail.com (Atul Kamat) Date: Fri Mar 25 14:52:20 2005 Subject: [python-win32] Exit Status of Microsoft Patches Message-ID: Hi! I tried installing a microsoft security patch for XP using os.system method on windows 2000 professional. The installtion failed because of incompatibility, but it still returned an exit code of ' 0 '.I also tried using os.popen2,3,4 methods but didnt work.Any Inputson how i can get the correct exit error code?.. I tried the following commands os.system('patch_name /q/z/m') and os.popen2('patch_name /q/z/m') http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/error_codes.asp Thanks and Regards Atul From mc at mclaveau.com Fri Mar 25 21:11:13 2005 From: mc at mclaveau.com (Michel Claveau) Date: Fri Mar 25 21:11:37 2005 Subject: [python-win32] Pb with COM server on rc2 ? References: <003201c52e37$416c4220$6e08f151@organizafei2bn> Message-ID: <00ad01c53176$cd10a810$0701a8c0@PORTABLES> Hi ! My english is 0.0 beta-version. Sorry. Then I write the next with easy words. I have a strange problem (yerterday & today), with COM server write with Python/Pywin The COM-server for test is simple : only one method, who return a string. The problem : With 2 cpu (one in Win-XP-SP2, other in Win-2003-server), I had install Python 2.4 rc2 & PyWin 203, and I run the COM server. The "inscription" is OK (no error, no warning). But, when I want call it, I obtain a error : "no interface" ; or, with Python, a error in "Dynamic". BUT, if I install P2.3.5 (& the PyWin 203/P23), The same script-server-COM run OK, and the use is OK. If I update to P24 rc2 : no problem. And modif (or rewrite) the COM-server is OK. On a dozain of other CPU, with Update's Python, no problem. The problem is, perhaps, only with new (virgin ?) install directky with P24.rc2. Who know that ? @-salutations -- Michel Claveau m?l : http://cerbermail.com/?6J1TthIa8B From atulkat at gmail.com Mon Mar 28 07:38:43 2005 From: atulkat at gmail.com (Atul Kamat) Date: Mon Mar 28 07:38:45 2005 Subject: [python-win32] Exit Status of Microsoft Patches In-Reply-To: References: Message-ID: Hi! I tried installing a microsoft security patch for XP using os.system method on windows 2000 professional. The installtion failed because of incompatibility, but it still returned an exit code of ' 0 '.I also tried using os.popen2,3,4 methods but didnt work.Any Inputson how i can get the correct exit error code?.. I tried the following commands os.system('patch_name /q/z/m') and os.popen2('patch_name /q/z/m') http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/error_codes.asp Thanks and Regards Atul From mhammond at skippinet.com.au Mon Mar 28 09:54:08 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon Mar 28 09:54:16 2005 Subject: [python-win32] Pb with COM server on rc2 ? In-Reply-To: <00ad01c53176$cd10a810$0701a8c0@PORTABLES> Message-ID: <1c4a01c5336b$52b29640$040a0a0a@enfoldsystems.local> > My english is 0.0 beta-version. Sorry. > Then I write the next with easy words. No problem. > I have a strange problem (yerterday & today), with COM server > write with > Python/Pywin > The COM-server for test is simple : only one method, who > return a string. > > > The problem : > > With 2 cpu (one in Win-XP-SP2, other in Win-2003-server), I > had install > Python 2.4 rc2 & PyWin 203, and I run the COM server. The > "inscription" is > OK (no error, no warning). > But, when I want call it, I obtain a error : "no interface" ; > or, with > Python, a error in "Dynamic". > > BUT, if I install P2.3.5 (& the PyWin 203/P23), The same > script-server-COM > run OK, and the use is OK. Without specific details I can only guess. Can you please post the sample (the smallest you can make it), and the complete Python tracebacks you see? Regards, Mark From mhammond at skippinet.com.au Mon Mar 28 09:58:31 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon Mar 28 09:58:40 2005 Subject: [python-win32] Exit Status of Microsoft Patches In-Reply-To: Message-ID: <1c4b01c5336b$efceec80$040a0a0a@enfoldsystems.local> > I tried installing a microsoft security patch for XP using os.system > method on windows 2000 professional. The installtion failed because of > incompatibility, but it still returned an exit code of ' 0 '.I also > tried using os.popen2,3,4 methods but didnt work.Any Inputson how i > can get the correct exit error code?.. > > I tried the following commands > os.system('patch_name /q/z/m') > and > os.popen2('patch_name /q/z/m') > > http://msdn.microsoft.com/library/default.asp?url=/library/en- > us/msi/setup/error_codes.asp My guess is that the process is simply always returning zero. You can confirm this by writing a batch file and using "if errorlevel" - eg: patch_name /q/z/m if errorlevel 1 echo Failed And seeing if you see "Failed" printed when running the .bat file from a command-prompt. Mark From mc at mclaveau.com Mon Mar 28 14:45:48 2005 From: mc at mclaveau.com (Michel Claveau) Date: Mon Mar 28 16:27:20 2005 Subject: [python-win32] Pb with COM server on rc2 ? References: <1c4a01c5336b$52b29640$040a0a0a@enfoldsystems.local> Message-ID: <000001c533a2$3d4cd090$0701a8c0@PORTABLES> >> I have a strange problem (yerterday & today), with COM server >> write with >> Python/Pywin >> The COM-server for test is simple : only one method, who >> return a string. >> >> >> The problem : >> >> With 2 cpu (one in Win-XP-SP2, other in Win-2003-server), I >> had install >> Python 2.4 rc2 & PyWin 203, and I run the COM server. The >> "inscription" is >> OK (no error, no warning). >> But, when I want call it, I obtain a error : "no interface" ; >> or, with >> Python, a error in "Dynamic". >> >> BUT, if I install P2.3.5 (& the PyWin 203/P23), The same >> script-server-COM >> run OK, and the use is OK. >Without specific details I can only guess. Can you please post the sample >(the smallest you can make it), and the complete Python tracebacks you see? > >Regards, > >Mark Hi ! I want to make few other tests, with a (new) CPU formated between the tests. Will take during few hours (days?) I will write the results here. @-salutations -- Michel Claveau From mc at mclaveau.com Mon Mar 28 21:18:22 2005 From: mc at mclaveau.com (Michel Claveau) Date: Mon Mar 28 21:18:31 2005 Subject: [python-win32] Pb with COM server on rc2 ? References: <1c4a01c5336b$52b29640$040a0a0a@enfoldsystems.local> <000001c533a2$3d4cd090$0701a8c0@PORTABLES> Message-ID: <000401c533ca$eab26f60$0701a8c0@PORTABLES> Hi ! Bonsoir ! Sorry, the problem was not PyWin32 ; but only Python-2.4rc2 If I overwrite a P24rc2 install with P24 "standard" ; the problem disappears. I have found a script without PyWin32, with a problem with RC2, and no problem with P4 "standard". I will put a message on clp. Apologies for trouble because my action. Michel Claveau From Pierre_Rouleau at ImpathNetworks.com Tue Mar 29 16:32:53 2005 From: Pierre_Rouleau at ImpathNetworks.com (Pierre Rouleau) Date: Tue Mar 29 17:03:00 2005 Subject: [python-win32] Re: How to get McMillan Installer accept win32gui? In-Reply-To: <4243D70B.6010400@vintech.bg> References: <4243D70B.6010400@vintech.bg> Message-ID: Niki Spahiev wrote: > Pierre Rouleau wrote: > >> Hi all! >> >> I have been using the McMillan Installer for some time even though >> Gordon McMillan site is no longer up. I am using version 5b5. >> >> It has been working fine up until I updated a module to import win32gui. >> The Python scripts works fine but the executable created by the >> McMillan Installer fails importing win32gui. > > > Try importing pywintypes before win32gui > Thanks for the info, unfortunately it did not work. This is what I get when I run the program built with a console (the built program is called vsm.exe): vsm\buildvsm\out1.pyz/fcntl:7: DeprecationWarning: the FCNTL module is deprecated; please use fcntl Traceback (most recent call last): File "", line 223, in ? File "c:\python\Installer\iu.py", line 277, in importHook mod = _self_doimport(nm, ctx, fqname) File "c:\python\Installer\iu.py", line 362, in doimport exec co in mod.__dict__ File "vsm\buildvsm\out1.pyz/mainframe", line 494, in ? File "c:\python\Installer\iu.py", line 299, in importHook raise ImportError, "No module named %s" % fqname ImportError: No module named win32gui Importing pywintypes befor importing win32gui does not change anything. Pierre Rouleau From andrea.gavana at agip.it Tue Mar 29 17:20:36 2005 From: andrea.gavana at agip.it (andrea.gavana@agip.it) Date: Tue Mar 29 18:17:38 2005 Subject: [python-win32] Retrieve Icons Associated To An Extension? Message-ID: Hello NG, I have searched everyweher, and I am not able to find a solution... basically, I am constructing a GUI with wxPython, in which I have a list. In this list control, I have some file. I would like to associate (to every file) its icon (on Windows). I have searched about the use of Mark Hammond's win32all extensions and also ctypes, but I didn't find a solution. Could anyone please provide a very simple example on how to retrieve an icon associated to a file extension on Windows? Thank you a lot. Andrea. ------------------------------------------------------------------------------------------------------------------------------------------ Message for the recipient only, if received in error, please notify the sender and read http://www.eni.it/disclaimer/ From Pierre_Rouleau at ImpathNetworks.com Wed Mar 30 00:06:25 2005 From: Pierre_Rouleau at ImpathNetworks.com (Pierre Rouleau) Date: Wed Mar 30 00:08:14 2005 Subject: [python-win32] Re: How to get McMillan Installer accept win32gui? Soved. In-Reply-To: References: <4243D70B.6010400@vintech.bg> Message-ID: Pierre Rouleau wrote: > Niki Spahiev wrote: > >> Pierre Rouleau wrote: >> >>> Hi all! >>> >>> I have been using the McMillan Installer for some time even though >>> Gordon McMillan site is no longer up. I am using version 5b5. >>> >>> It has been working fine up until I updated a module to import win32gui. >>> The Python scripts works fine but the executable created by the >>> McMillan Installer fails importing win32gui. >> >> >> >> Try importing pywintypes before win32gui >> > > Thanks for the info, unfortunately it did not work. This is what I get > when I run the program built with a console (the built program is called > vsm.exe): > > vsm\buildvsm\out1.pyz/fcntl:7: DeprecationWarning: the FCNTL module is > deprecated; please use fcntl > Traceback (most recent call last): > File "", line 223, in ? > File "c:\python\Installer\iu.py", line 277, in importHook > mod = _self_doimport(nm, ctx, fqname) > File "c:\python\Installer\iu.py", line 362, in doimport > exec co in mod.__dict__ > File "vsm\buildvsm\out1.pyz/mainframe", line 494, in ? > File "c:\python\Installer\iu.py", line 299, in importHook > raise ImportError, "No module named %s" % fqname > ImportError: No module named win32gui > > > Importing pywintypes befor importing win32gui does not change anything. > I finally found the problem. McMillan Installer was working properly. The issue was related to the presence of win32gui.pyd. That file was deleted by some other program. Sorry for the noise on the newsgroup. Pierre From mhammond at skippinet.com.au Wed Mar 30 00:08:54 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed Mar 30 00:09:00 2005 Subject: [python-win32] Retrieve Icons Associated To An Extension? In-Reply-To: Message-ID: <1e4b01c534ab$e658fa10$040a0a0a@enfoldsystems.local> One way is code similar to: from win32com.shell import shell, shellcon flags = shellcon.SHGFI_LARGEICON | shellcon.SHGFI_ICON | \ shellcon.SHGFI_USEFILEATTRIBUTES hr, info = shell.SHGetFileInfo(extension, win32con.FILE_ATTRIBUTE_NORMAL, flags) hicon, iicon, attr, display_name, type_name = info Mark > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of > andrea.gavana@agip.it > Sent: Wednesday, 30 March 2005 1:21 AM > To: python-win32@python.org > Subject: [python-win32] Retrieve Icons Associated To An Extension? > > > Hello NG, > > I have searched everyweher, and I am not able to find a > solution... > basically, I am constructing a GUI with wxPython, in which I > have a list. > In this list control, I have some file. I would like to > associate (to every > file) its icon (on Windows). I have searched about the use of Mark > Hammond's win32all extensions and also ctypes, but I didn't find a > solution. Could anyone please provide a very simple example on how to > retrieve an icon associated to a file extension on Windows? > > Thank you a lot. > > Andrea. > > -------------------------------------------------------------- > -------------------------------------------------------------- > -------------- > Message for the recipient only, if received in error, please > notify the > sender and read http://www.eni.it/disclaimer/ > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From cjmaloof at gmail.com Wed Mar 30 06:49:40 2005 From: cjmaloof at gmail.com (Chris Maloof) Date: Wed Mar 30 06:49:50 2005 Subject: [python-win32] reading from console child process Message-ID: <000a01c534e3$e3294380$0400a8c0@cjm> Hello, I'm trying to read the output from a WinXP console application using PythonWin -- that is, I start the application as a child process, and I want to be able to read the ASCII text in the application's screen. The child app uses MSDN functions WriteConsoleOutputChar() and WriteConsoleOutputAttributes() for output. Thus I think I need to use ReadConsoleOutput() and WriteConsoleInput() to communicate with it, as described here: http://homepages.tesco.net/~J.deBoynePollard/FGA/capture-console-win32.html . Unfortunately these don't seem to be implemented in PyWin32. Does anyone know if there's a way to do this? I'm new at this, so my apologies if the question is basic or misguided, but I haven't found an obvious solution in the archives or elsewhere. Thank you, Chris From niki at vintech.bg Wed Mar 30 11:43:08 2005 From: niki at vintech.bg (Niki Spahiev) Date: Wed Mar 30 11:43:23 2005 Subject: [python-win32] reading from console child process In-Reply-To: <000a01c534e3$e3294380$0400a8c0@cjm> References: <000a01c534e3$e3294380$0400a8c0@cjm> Message-ID: <424A74AC.5020803@vintech.bg> Chris Maloof wrote: > Hello, > > I'm trying to read the output from a WinXP console application using > PythonWin -- that is, I start the application as a child process, and I > want to be able to read the ASCII text in the application's screen. > > The child app uses MSDN functions WriteConsoleOutputChar() and > WriteConsoleOutputAttributes() for output. Thus I think I need to use > ReadConsoleOutput() and WriteConsoleInput() to communicate with it, as > described here: > http://homepages.tesco.net/~J.deBoynePollard/FGA/capture-console-win32.html > . Unfortunately these don't seem to be implemented in PyWin32. > > Does anyone know if there's a way to do this? I'm new at this, so my > apologies if the question is basic or misguided, but I haven't found an > obvious solution in the archives or elsewhere. Try console module from effbot or use ctypes. HTH Niki Spahiev From niki at vintech.bg Wed Mar 30 12:43:26 2005 From: niki at vintech.bg (Niki Spahiev) Date: Wed Mar 30 12:43:41 2005 Subject: [python-win32] Retrieve Icons Associated To An Extension? In-Reply-To: References: Message-ID: <424A82CE.90505@vintech.bg> andrea.gavana@agip.it wrote: > Hello NG, > > I have searched everyweher, and I am not able to find a solution... > basically, I am constructing a GUI with wxPython, in which I have a list. > In this list control, I have some file. I would like to associate (to every > file) its icon (on Windows). I have searched about the use of Mark > Hammond's win32all extensions and also ctypes, but I didn't find a > solution. Could anyone please provide a very simple example on how to > retrieve an icon associated to a file extension on Windows? There is wxPython based image viewer (IIRC cornflake) which has such thing. HTH Niki Spahiev From nanotube at gmail.com Wed Mar 30 17:28:36 2005 From: nanotube at gmail.com (Daniel F) Date: Wed Mar 30 17:28:38 2005 Subject: [python-win32] Help on using win32api.SendMessage to send keystrokes Message-ID: Hi, I am trying to use win32gui.SendMessage API (or PostMessage), and cannot figure out why it is not working. I would appreciate any help! Simple test script I am using is included below. I am using pywin32-203 and python 2.4, on winxp pro sp2. I am a total newbie to python, so if this is a really dumb question, please do not be surprised. :) I thank you all in advance for any help and guidance you can provide. Daniel --------------- #### Script to try to write something down in notepad import win32api import win32gui import win32con import time # get the window handle of the blank, minimized notepad window hwnd = win32gui.FindWindowEx(0, 0, 0, "Untitled - Notepad") # print it just for kicks print hwnd win32gui.ShowWindow(hwnd, win32con.SW_SHOWNORMAL) #this restores the proper window, so we know we have correct handle #just to give it a little pause time.sleep(2) print "trying to post message" #try to send it a return key win32api.SendMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0) win32api.SendMessage(hwnd, win32con.WM_KEYUP, win32con.VK_RETURN, 0) #the above generates absolutely no effect on the notepad window. #same effect no matter what vk code i use (e.g. 65 for A, VK_SPACE for space, etc) #### end of script From rays at blue-cove.com Wed Mar 30 19:36:36 2005 From: rays at blue-cove.com (Ray S) Date: Wed Mar 30 19:34:16 2005 Subject: [python-win32] reading from console child process In-Reply-To: <000a01c534e3$e3294380$0400a8c0@cjm> Message-ID: <5.2.0.4.2.20050330092137.0c8af160@blue-cove.com> At 11:49 PM 3/29/2005 -0500, Chris Maloof wrote: >Hello, > >I'm trying to read the output from a WinXP console application using >PythonWin -- that is, I start the application as a child process, and I >want to be able to read the ASCII text in the application's screen. I wrote some pipes code to do walkie-talkie with an old FROTRAN exe (that used extended ASCII) using win32pipe. It reads from the DOS box first, then sends input in response. I tried pipedream.py, but had issues with threads and the delays from the remote DOS. It is worth reading though, at least. Ray Schumacher =========================================================== # process module import os import sys import time from wxPython.wx import * import string import re def escapifyString(str): """escapifyString(string) -> string Return the given string with any non-printing ASCII characters escaped.""" pattern1 = re.compile('\[..\;..H') pattern2 = re.compile('\[2J') l = list(str) vis = string.letters + string.digits + " _!$%^&*()-=+[]{};'#:@~,./<>?|`" for i in range(len(l)): if l[i] not in vis: l[i] = '' #"\\%03o" % ord(l[i]) str = string.join(l, "") str = re.sub(pattern1, '', str) str = re.sub(pattern2, '', str) return str def getDataFrom(pipe): done = False timeout = 3 ## seconds start_time = time.time() data = '' error = None while not done: try: if(os.fstat(pipe.fileno())[6]!=0): ## this will read up to a large amount data = os.read(pipe.fileno(), 2**16) elif(len(data)): ## if the read was done on the last loop, we can quit done = True elif((time.time() - start_time) > timeout): ## something went wrong ## or, request was done at the end of the process done = True error = 'timeout error:'+ str(time.time() - start_time) print 'Error; read timed out' else: ## might be starting up the remote process... time.sleep(.01) except (IOError, OSError): print '(IOError, OSError)',(IOError, OSError) done = True return [error, data] def driveRemote(stdinput, stdoutput, resp): """ takes pipes and a string to send""" ## first, get any data available timeOut, result = getDataFrom(stdoutput) if timeOut: return 'error' print "from:'%s'\n" % escapifyString(result)[-60:], if (result==('' or None)): dlg = wxMessageDialog(parent, "resp not received!"+"\nGot '"+result+"'", 'Error', wxOK | wxICON_INFORMATION) try: dlg.ShowModal() finally: dlg.Destroy() #pgDlg.Destroy() return 'error' ## check for run-time error if (string.find(result, 'run-time error')>-1): dlg = wxMessageDialog(None, result+'\n, please wait', 'run-time error', wxICON_ERROR) try: dlg.ShowModal() print 'run-time error' while (string.find(result, 's!!')>-1): #os.write(stdinput.fileno(), '\n') #timeOut, result = getDataFrom(stdoutput) print result finally: dlg.Destroy() return 'error' if resp!=None: ## send a command try: print 'response :', resp, '\n' os.write(stdinput.fileno(), str(resp)+'\n') except IOError, e: print 'error; resp, reslt:', resp, result print "IOError %s" % e return result ============================================================= # calling module: import win32pipe import Process import string import time import os.path ## actually start remote DOS stdin, stdout = win32pipe.popen4("remote.EXE", 't') result = Process.driveRemote(stdin, stdout, '') ## Enter (or Return) From nanotube at gmail.com Thu Mar 31 03:46:43 2005 From: nanotube at gmail.com (Daniel F) Date: Thu Mar 31 03:46:47 2005 Subject: [python-win32] Re: Help on using win32api.SendMessage to send keystrokes In-Reply-To: References: Message-ID: Well... i figured it out - turns out sending the keystrokes to the top window of notepad didnt work, but sending them to the Edit child window of notepad did the trick. But this brings me to another question, although of a less urgent manner. i had to send WM_CHAR messages, rather than WM_KEYDOWN/KEYUP in order to get it to work. I have nothing against WM_CHAR, as long as everything works, but i am just curious why i was not able to achieve the same effect with the WM_KEYDOWN/KEYUP pair? any takers? Thanks, Daniel On Wed, 30 Mar 2005 10:28:36 -0500, Daniel F wrote: > Hi, > > I am trying to use win32gui.SendMessage API (or PostMessage), and > cannot figure out why > it is not working. I would appreciate any help! Simple test script I > am using is included below. > > I am using pywin32-203 and python 2.4, on winxp pro sp2. > > I am a total newbie to python, so if this is a really dumb question, > please do not be surprised. :) I thank you all in advance for any help > and guidance you can provide. > > Daniel > --------------- > #### Script to try to write something down in notepad > import win32api > import win32gui > import win32con > import time > > # get the window handle of the blank, minimized notepad window > hwnd = win32gui.FindWindowEx(0, 0, 0, "Untitled - Notepad") > > # print it just for kicks > print hwnd > > win32gui.ShowWindow(hwnd, win32con.SW_SHOWNORMAL) > #this restores the proper window, so we know we have correct handle > > #just to give it a little pause > time.sleep(2) > > print "trying to post message" > > #try to send it a return key > win32api.SendMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0) > win32api.SendMessage(hwnd, win32con.WM_KEYUP, win32con.VK_RETURN, 0) > > #the above generates absolutely no effect on the notepad window. > #same effect no matter what vk code i use (e.g. 65 for A, VK_SPACE for > space, etc) > > #### end of script > From rschroev_nospam_ml at fastmail.fm Thu Mar 31 09:45:13 2005 From: rschroev_nospam_ml at fastmail.fm (Roel Schroeven) Date: Thu Mar 31 09:52:29 2005 Subject: [python-win32] Re: Help on using win32api.SendMessage to send keystrokes In-Reply-To: References: Message-ID: Daniel F wrote: > Well... i figured it out - turns out sending the keystrokes to the top > window of notepad didnt work, but sending them to the Edit child > window of notepad did the trick. > > But this brings me to another question, although of a less urgent > manner. i had to send WM_CHAR messages, rather than WM_KEYDOWN/KEYUP > in order to get it to work. I have nothing against WM_CHAR, as long as > everything works, but i am just curious why i was not able to achieve > the same effect with the WM_KEYDOWN/KEYUP pair? any takers? I noticed in the MSDN documentation for WM_KEYUP that bits 30 and 31 of lParam should be set, while you leave all bits zero. Maybe that has to do something with it? -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven From timr at probo.com Thu Mar 31 22:16:03 2005 From: timr at probo.com (Tim Roberts) Date: Thu Mar 31 22:16:12 2005 Subject: [python-win32] Re: Help on using win32api.SendMessage to send keystrokes In-Reply-To: <20050331100019.432FF1E4061@bag.python.org> References: <20050331100019.432FF1E4061@bag.python.org> Message-ID: <424C5A83.5030408@probo.com> On Wed, 30 Mar 2005 20:46:43 -0500, Daniel F wrote: >Well... i figured it out - turns out sending the keystrokes to the top >window of notepad didnt work, but sending them to the Edit child >window of notepad did the trick. > >But this brings me to another question, although of a less urgent >manner. i had to send WM_CHAR messages, rather than WM_KEYDOWN/KEYUP >in order to get it to work. I have nothing against WM_CHAR, as long as >everything works, but i am just curious why i was not able to achieve >the same effect with the WM_KEYDOWN/KEYUP pair? any takers? > It depends entirely on what the application expects. When the keyboard driver sends keystrokes, the generic keyboard driver translates the key codes to characters, if possible. It will send WM_KEYDOWN, then WM_CHAR (if an ASCII translation exists), then WM_KEYUP. Applications can choose which ones they want to handle. In your case, you are bypassing the keyboard driver stack entirely. The standard edit control, which is all Notepad is, apparently looks only at WM_CHAR. There is no a priori method for figuring out which one is required. If you need a general solution, you send all three. In this case, since you want a specific solution, you can send just WM_CHAR. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From MJackson at parkcounty.us Thu Mar 31 23:37:42 2005 From: MJackson at parkcounty.us (Matt Jackson) Date: Thu Mar 31 23:37:46 2005 Subject: [python-win32] python windows extensions silent install? Message-ID: Is there a way to run a silent install of pywin32-203.win32-py2.4.exe? I want to do this so I can run startup command files on User's machines to install this without user interaction. I have found I can get this if I run ActivePython install with a silent install, but I was hoping I could do this with just this extension. Thanx. Matthew Jackson IT Technician Park County