From mkesper at fsfe.org Mon Sep 1 14:08:12 2008 From: mkesper at fsfe.org (Michael Kesper) Date: Mon, 1 Sep 2008 14:08:12 +0200 Subject: [python-win32] Accessing properties of share on DFS In-Reply-To: <48B55829.5020205@timgolden.me.uk> References: <20080825143047.GD13124@localhost> <48B55829.5020205@timgolden.me.uk> Message-ID: <20080901120812.GB4376@localhost> Hi, * Tim Golden [2008-08-27 14:35:37 +0100]: ? > You might be able to get there with WMI. The following > works on my own machine, but I'm not sure what machine > you'd need to access to list the DFS shares. I'll see > if I can persuade a friendly admin here to let me try > things out: Thanks for your answer. I try to try it. ;) I can access the DFS share properties via mmc from one special server, so I think I'll need to run my scripts there. As you probably guessed, there's no python installed there. > or you could come from the other end and enumerate > the Win32_ServerConnection collection to start with. Sorry, I do not exactly know how to do that. Best wishes Michael -- Free Software Foundation Europe (FSFE) [] (http://fsfeurope.org) Treten Sie der Fellowship bei! [][][] (http://fsfe.org/join) Ihre Spende erm?glicht unsere Arbeit! || (http://fsfeurope.org/donate) From mail at timgolden.me.uk Mon Sep 1 18:13:20 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 01 Sep 2008 17:13:20 +0100 Subject: [python-win32] Accessing properties of share on DFS In-Reply-To: <20080901120812.GB4376@localhost> References: <20080825143047.GD13124@localhost> <48B55829.5020205@timgolden.me.uk> <20080901120812.GB4376@localhost> Message-ID: <48BC14A0.3050202@timgolden.me.uk> Michael Kesper wrote: > Hi, > > * Tim Golden [2008-08-27 14:35:37 +0100]: > >> You might be able to get there with WMI. The following >> works on my own machine, but I'm not sure what machine >> you'd need to access to list the DFS shares. I'll see >> if I can persuade a friendly admin here to let me try >> things out: > > Thanks for your answer. I try to try it. ;) > I can access the DFS share properties via mmc from one special server, > so I think I'll need to run my scripts there. > As you probably guessed, there's no python installed there. That's not problem. The great thing with WMI is that it's installed *everywhere* and by the glory of DCOM (!) using it is a breeze. Just take that code snippet and change the line: c = wmi.WMI () to: c = wmi.WMI ("other-machine-with-dfs") and Bob's your Uncle. TJG From mdriscoll at co.marshall.ia.us Tue Sep 2 15:45:32 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Tue, 02 Sep 2008 08:45:32 -0500 Subject: [python-win32] Pb IE8-b2 + Python like ActiveScripting language In-Reply-To: <0CF37A7FCD3A4621BB844DF4008C17F9@MCI1330> References: <0CF37A7FCD3A4621BB844DF4008C17F9@MCI1330> Message-ID: <48BD437C.1020803@co.marshall.ia.us> Michel Claveau wrote: >
Hi! > > Impossible, for me, to use Python like ActiveScripting language, in a > HTA, since IE-8 beta-2 installed. > > Run OK with IE5, IE6, IE7. But IE8 does not recognize Python (I > however recorded several times python like language of ActiveScripting) > > Any idea or solution? I'll bee honest and say that I've never heard of an HTA. Upon doing a little research though, it looks like it's a self-contained web app of sorts. You might look at CherryPy. We use it for a web app on a couple of laptops and it works great. Of course, there's also IronPython + Silverlight. Both of these "solutions" are probably more complicated though. Mike From alecmunro at gmail.com Tue Sep 2 18:44:02 2008 From: alecmunro at gmail.com (Alec Munro) Date: Tue, 2 Sep 2008 13:44:02 -0300 Subject: [python-win32] Accessing other interfaces of a Dispatch created COM object In-Reply-To: <9819d58b0808291047j3de5e9d8u7647b05e49a53f97@mail.gmail.com> References: <9819d58b0808280556g46cbd1cbj85f32cc82987615a@mail.gmail.com> <9819d58b0808280632x2b139645x278d5f0675dd46c7@mail.gmail.com> <9819d58b0808280633t13d89b77u433d55924cbb73a1@mail.gmail.com> <9819d58b0808280734o33af5721y741ca9b079d074af@mail.gmail.com> <00de01c9099c$b77731c0$26659540$@com.au> <9819d58b0808291047j3de5e9d8u7647b05e49a53f97@mail.gmail.com> Message-ID: <9819d58b0809020944v488ab4a2n5127c71e7c69424b@mail.gmail.com> I'm guessing, based on the lack of responses, and the consistency of error messages, that my problem has more to do with getting the right library registered, which isn't a python-win job. So, can anyone recommend where I might go to try to solve this problem? Also, is there a way to determine which library it is that is not registered? Thanks again, Alec On Fri, Aug 29, 2008 at 2:47 PM, Alec Munro wrote: > Thanks Mark. > > After a couple of misfires, I think I figured out how to get CastTo to > work (the docstring is practically non-existent in the version I have, > perhaps it's been updated?). > > However, that puts me back at the same place I was with some of the > other attempts: > >>>> obj_i2 = CastTo(obj, "Interface_2") >>>> obj_i2.secondaryMethod() > Traceback (most recent call last): > ... > File "C:\Python25\lib\site-packages\win32com\client\__init__.py", > line 449, in _ApplyTypes_ > dispid, 0, wFlags, retType, argTypes, *args), > com_error: (-2147319779, 'Library not registered.', None, None) > > However, one interesting note is that the object generated by CastTo > is of a different version of the Type Library than the object > generated by Interface_2(obj). I don't know if that's useful > information, however. They have the same CLSID, but different > coclass_clsids. > > Thanks again, > > Alec > > On Fri, Aug 29, 2008 at 3:01 AM, Mark Hammond wrote: >> Look at the docstring for win32com.client.CastTo (and googling for that will >> probably help too) >> >> Cheers, >> >> Mark >> >>> I just discovered a third possibility, and subsequent failure: >>> >>> >>> obj_i2 = Dispatch(obj, None, Interface_2.CLSID) >>> >>> obj_i2.secondaryMethod() >>> Traceback (most recent call last): >>> ... >>> File "C:\Python25\lib\site-packages\win32com\client\__init__.py", >>> line 449, in _ApplyTypes_ >>> dispid, 0, wFlags, retType, argTypes, *args), >>> com_error: (-2147352573, 'Member not found.', None, None) >>> >>> Alec >>> >>> On Thu, Aug 28, 2008 at 10:33 AM, Alec Munro >>> wrote: >>> > Oh, and on re-reading, I do realize that the DLL itself doesn't >>> > implement those interfaces. There's a class within the DLL that does >>> > that. :) >>> > >>> > On Thu, Aug 28, 2008 at 10:32 AM, Alec Munro >>> wrote: >>> >> Hi List, >>> >> >>> >> Hopefully I have my terminology right, I'm pretty new to COM and >>> C++. >>> >> >>> >> My problem is that I have a COM DLL written in C++, that I would >>> like >>> >> to call from Python. This DLL implements 3 important interfaces, >>> each >>> >> of which is also an IDispatch implementation, like the following: >>> >> >>> >> IDispatchImpl>> &LIBID_Interface_1, 1, 0> >>> >> IDispatchImpl>> &LIBID_Interface_2, 1, 0> >>> >> IDispatchImpl>> &LIBID_Interface_3 1, 0> >>> >> >>> >> However, when I do: >>> >>>>> obj = win32com.client.Dispatch("a.b.c") >>> >>>>> obj >>> >> >>> >> >>> >> The object I get only has methods available for the first of the >>> >> interfaces. From my reading, this is simply the functionality of >>> >> IDispatch, and if I wanted to get those additional methods through >>> >> IDispatch, I would have to update the DLL, and restructure my >>> >> interfaces. I'm not confident enough in my C++ to do this, or at >>> least >>> >> it's not my first choice. >>> >> >>> >> From what I've read, there are two ways that seem to be >>> possibilities >>> >> for being able to call the methods from the other interfaces. >>> >> >>> >> The simplest one I found was the suggestion to use MakePy on the >>> type >>> >> library containing Interface_2 and Interface_3. I did this, and >>> copied >>> >> the generated file to my working directory, then did: >>> >> >>> >>>>> from interfaces import Interface_2 >>> >>>>> obj_i2 = Interface_2(obj) >>> >>>>> obj_i2 >>> >> >> at >>> >> 0x17459602> >>> >> >>> >> Unfortunately when I try: >>> >> >>> >>>>> obj_i2.secondaryMethod() >>> >> Traceback (most recent call last): >>> >> ... >>> >> File "C:\Python25\lib\site-packages\win32com\client\__init__.py", >>> >> line 449, in _ApplyTypes_ >>> >> dispid, 0, wFlags, retType, argTypes, *args), >>> >> com_error: (-2147319779, 'Library not registered.', None, None) >>> >> >>> >> The other suggestion I came across was to use QueryInterface. I >>> wasn't >>> >> sure what argument to pass to QueryInterface, so I tried using the >>> >> CLSID of the interface I wanted. >>> >> >>> >>>>> obj._oleobj_.QueryInterface(Interface_2.CLSID) >>> >> Traceback (most recent call last): >>> >> File "", line 1, in >>> >> TypeError: There is no interface object registered that supports >>> this IID >>> >> >>> >> From these error messages, it seems like perhaps there's a problem >>> >> with the registration of the type library that contains the >>> >> interfaces. I'm not really sure how to fix that, or if that is even >>> >> the problem. >>> >> >>> >> Any ideas? >>> >> >>> >> Thanks, >>> >> Alec Munro >>> >> >>> > >>> _______________________________________________ >>> python-win32 mailing list >>> python-win32 at python.org >>> http://mail.python.org/mailman/listinfo/python-win32 >> >> > From codingjester at gmail.com Tue Sep 2 19:25:55 2008 From: codingjester at gmail.com (John Bunting) Date: Tue, 2 Sep 2008 13:25:55 -0400 Subject: [python-win32] A question about custom command options in win32serviceutil Message-ID: Hey everyone, I'm creating a program for my work that will let the users automatically connect to a server that we have set up and read some data, etc. I have been trying to figure out a way to use the win32serviceutil custom options to pass some extra arguments for my users. as far as I understand it, you have to use a custom function (I think) to deal with all of your extra arguments that it doesn't recognize. I would like to be able to apply to my windows class these extra arguments, as they will just be used to pass data! is it correct in assuming that i should probably set it up like this... class service(win32service.ServiceFramework): def __init__(self): -------------- next part -------------- An HTML attachment was scrubbed... URL: From codingjester at gmail.com Tue Sep 2 19:27:10 2008 From: codingjester at gmail.com (John Bunting) Date: Tue, 2 Sep 2008 13:27:10 -0400 Subject: [python-win32] A question about custom command options in win32serviceutil In-Reply-To: References: Message-ID: sorry pressed enter too soon.... Am i just setting up a function to parse the arguments and set class variables? or is it something else! Sorry for the double email >.< ~John Bunting On Tue, Sep 2, 2008 at 1:25 PM, John Bunting wrote: > Hey everyone, > > I'm creating a program for my work that will let the users automatically > connect to a server that we have set up and read some data, etc. > > I have been trying to figure out a way to use the win32serviceutil custom > options to pass some extra arguments for my users. > > as far as I understand it, you have to use a custom function (I think) to > deal with all of your extra arguments that it doesn't recognize. > > I would like to be able to apply to my windows class these extra arguments, > as they will just be used to pass data! is it correct in assuming > > that i should probably set it up like this... > > > class service(win32service.ServiceFramework): > def __init__(self): > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From h.goebel at goebel-consult.de Wed Sep 3 17:40:46 2008 From: h.goebel at goebel-consult.de (Hartmut Goebel) Date: Wed, 03 Sep 2008 17:40:46 +0200 Subject: [python-win32] Can't import win32api from pywin32-egg in wine Message-ID: <48BEAFFE.2090705@goebel-consult.de> Hi, when running Python in Wine, I can not import win32api which is installed as pywin32-212-py2.5-win32.egg:: $ wine python Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import win32api err:module:import_dll Library pywintypes25.dll (which is needed by L"C:\\Python25\\lib\\site-packages\\pywin32-212-py2.5-win32.egg\\win32api.pyd") not found Traceback (most recent call last): File "", line 1, in ImportError: DLL load failed: Module not found >>> The dll exists, but $ ls site-packages/pywin32*.egg/pywin32_system32/pywintypes25.* site-packages/pywin32-212-py2.5-win32.egg/pywin32_system32/pywintypes25.dll This tracks down to: pywintypes.py can not find pywintypes32.dll using _win32sysloader.GetModuleFilename(filename) or _win32sysloader.LoadModule(filename) Any hints? -- Sch?nen Gru? - Regards Hartmut Goebel Dipl.-Informatiker (univ.), CISSP Goebel Consult Spezialist f?r IT-Sicherheit in komplexen Umgebungen http://www.goebel-consult.de -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3195 bytes Desc: S/MIME Cryptographic Signature URL: From mhammond at skippinet.com.au Thu Sep 4 09:18:22 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 4 Sep 2008 17:18:22 +1000 Subject: [python-win32] Can't import win32api from pywin32-egg in wine In-Reply-To: <48BEAFFE.2090705@goebel-consult.de> References: <48BEAFFE.2090705@goebel-consult.de> Message-ID: <009d01c90e5e$6e459b60$4ad0d220$@com.au> IIRC there is a bug in setuptools that prevented the post-install script running in an egg - which would prevent those 2 DLLs being copied from pywin32_system32 to either system32 or next to python.exe. Try copying them manually, or run 'pywin32_postinstall.py -install' Mark > -----Original Message----- > From: python-win32-bounces+skippy.hammond=gmail.com at python.org > [mailto:python-win32-bounces+skippy.hammond=gmail.com at python.org] On > Behalf Of Hartmut Goebel > Sent: Thursday, 4 September 2008 1:41 AM > To: python-win32 at python.org > Subject: [python-win32] Can't import win32api from pywin32-egg in wine > > Hi, > > when running Python in Wine, I can not import win32api which is > installed as pywin32-212-py2.5-win32.egg:: > > $ wine python > Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit > (Intel)] on win32 Type "help", "copyright", "credits" or "license" for > more information. > >>> import win32api > err:module:import_dll Library pywintypes25.dll (which is needed by > L"C:\\Python25\\lib\\site-packages\\pywin32-212-py2.5- > win32.egg\\win32api.pyd") > not found > Traceback (most recent call last): > File "", line 1, in > ImportError: DLL load failed: Module not found > >>> > > The dll exists, but > > $ ls site-packages/pywin32*.egg/pywin32_system32/pywintypes25.* > site-packages/pywin32-212-py2.5- > win32.egg/pywin32_system32/pywintypes25.dll > > This tracks down to: pywintypes.py can not find pywintypes32.dll using > _win32sysloader.GetModuleFilename(filename) or > _win32sysloader.LoadModule(filename) > > Any hints? > > -- > Sch?nen Gru? - Regards > Hartmut Goebel > Dipl.-Informatiker (univ.), CISSP > > Goebel Consult > Spezialist f?r IT-Sicherheit in komplexen Umgebungen http://www.goebel- > consult.de From h.goebel at goebel-consult.de Thu Sep 4 10:05:10 2008 From: h.goebel at goebel-consult.de (Hartmut Goebel) Date: Thu, 04 Sep 2008 10:05:10 +0200 Subject: [python-win32] Can't import win32api from pywin32-egg in wine In-Reply-To: <009d01c90e5e$6e459b60$4ad0d220$@com.au> References: <48BEAFFE.2090705@goebel-consult.de> <009d01c90e5e$6e459b60$4ad0d220$@com.au> Message-ID: <48BF96B6.5070209@goebel-consult.de> Hallo Mark, > IIRC there is a bug in setuptools that prevented the post-install script > running in an egg - which would prevent those 2 DLLs being copied from > pywin32_system32 to either system32 or next to python.exe. Try copying them > manually, or run 'pywin32_postinstall.py -install' Neither of these seams to work. 1) Both Scripts/pywin32_postinstall.py and Lib/site-packages/pywin32-212-py2.5-win32.egg/EGG-INFO/scripts/pywin32_postinstall.py fail. 2) Manual copy to C:\Python25, C:\Python25\DLLs and C:\windows\system32 does not help. I figured out that LoadSystemModule wants to load C:\Python25\Lib\site-packages\pywin32_system32\pywintypes25.dll which doe not exist in an egg. I prepared a patch which I will issue to the sourceforge project page. -- Sch?nen Gru? - Regards Hartmut Goebel Dipl.-Informatiker (univ.), CISSP Goebel Consult Spezialist f?r IT-Sicherheit in komplexen Umgebungen http://www.goebel-consult.de -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 4719 bytes Desc: S/MIME Cryptographic Signature URL: From mhammond at skippinet.com.au Thu Sep 4 11:50:49 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 4 Sep 2008 19:50:49 +1000 Subject: [python-win32] Can't import win32api from pywin32-egg in wine In-Reply-To: <48BF96B6.5070209@goebel-consult.de> References: <48BEAFFE.2090705@goebel-consult.de> <009d01c90e5e$6e459b60$4ad0d220$@com.au> <48BF96B6.5070209@goebel-consult.de> Message-ID: <010101c90e73$b94785f0$2bd691d0$@com.au> See also http://bugs.python.org/setuptools/issue18 - it would be great if you can work out what overlap exists... Cheers, Mark > -----Original Message----- > From: Hartmut Goebel [mailto:h.goebel at goebel-consult.de] > Sent: Thursday, 4 September 2008 6:05 PM > To: mhammond at skippinet.com.au > Cc: python-win32 at python.org > Subject: Re: [python-win32] Can't import win32api from pywin32-egg in > wine > > Hallo Mark, > > > IIRC there is a bug in setuptools that prevented the post-install > script > > running in an egg - which would prevent those 2 DLLs being copied > from > > pywin32_system32 to either system32 or next to python.exe. Try > copying them > > manually, or run 'pywin32_postinstall.py -install' > > Neither of these seams to work. > > 1) Both Scripts/pywin32_postinstall.py and > Lib/site-packages/pywin32-212-py2.5-win32.egg/EGG- > INFO/scripts/pywin32_postinstall.py > fail. > > 2) Manual copy to C:\Python25, C:\Python25\DLLs and C:\windows\system32 > does not help. > > I figured out that LoadSystemModule wants to load > C:\Python25\Lib\site-packages\pywin32_system32\pywintypes25.dll > which doe not exist in an egg. > > I prepared a patch which I will issue to the sourceforge project page. > > -- > Sch?nen Gru? - Regards > Hartmut Goebel > Dipl.-Informatiker (univ.), CISSP > > Goebel Consult > Spezialist f?r IT-Sicherheit in komplexen Umgebungen > http://www.goebel-consult.de From usmelbourne at gmail.com Fri Sep 5 06:37:43 2008 From: usmelbourne at gmail.com (Ujjaval Suthar) Date: Fri, 5 Sep 2008 14:37:43 +1000 Subject: [python-win32] pythoncom question Message-ID: <7cd54e080809042137w3fa74d1di668c6f2002d04953@mail.gmail.com> Hi all, I am working on a python application which is a multi-threaded application. I just want to make sure that I am doing the right thing or if not, please let me know. I have a parent thread which initalize the COM object inside a python object. This parent thread instantiates 4 other child threads which are independent of each other with the python object created above. As I understand this will allow calling COM object functions inside all 4 child threads. The program does not seem to complain. But my parent thread seems to go and call join method and wait till all the threads stop executing and something is not right. So, just checking was this the right way? or I have to initialize COM object separately inside all child threads? Thanks heaps. Ujjaval -------------- next part -------------- An HTML attachment was scrubbed... URL: From gagsl-py2 at yahoo.com.ar Fri Sep 5 09:52:54 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 05 Sep 2008 04:52:54 -0300 Subject: [python-win32] Internet Explorer constants Message-ID: Hello I want to control Internet Explorer. This is what I have so far: import win32com.client from win32com.client.gencache import EnsureDispatch url = "..." IE = EnsureDispatch("InternetExplorer.Application") IE.Navigate(url) IE.Visible = 1 It works fine and shows the requested page. Now I want to use the "Save As" command. Looks like I should call the IWebBrowser2.ExecWB method, passing IDM_SAVEAS as the command and MSOCMDEXECOPT_DONTPROMPTUSER in the options. But I don't know how to obtain the value for such constants... I could dig into the C header files looking for them, but is there some other way? The ExecWB method is documented here http://msdn.microsoft.com/en-us/library/aa752117(VS.85).aspx -- Gabriel Genellina From usmelbourne at gmail.com Fri Sep 5 10:19:27 2008 From: usmelbourne at gmail.com (Ujjaval Suthar) Date: Fri, 5 Sep 2008 18:19:27 +1000 Subject: [python-win32] Handling COM events in a python thread Message-ID: <7cd54e080809050119p699c7046me926c4e12d3ff343@mail.gmail.com> Hi all, I have a COM control which fires a status event called ProcessingDataAvailable(). The COM control has a method call AddData() with some data parameters. Using python, in a simple program, I can instantiate COM object via Dispatch and call AddData() method successfully. Now, I want to have a thread which keeps running and listening for ProcessingDataAvailable() event and do some processing in my program. Can somebody please give me a simple example code that shows how it can be done? I'm very new to this kind of programming. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Fri Sep 5 10:23:01 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 05 Sep 2008 09:23:01 +0100 Subject: [python-win32] Internet Explorer constants In-Reply-To: References: Message-ID: <48C0EC65.7000907@timgolden.me.uk> Gabriel Genellina wrote: > Hello > > I want to control Internet Explorer. This is what I have so far: > > import win32com.client > from win32com.client.gencache import EnsureDispatch > url = "..." > IE = EnsureDispatch("InternetExplorer.Application") > IE.Navigate(url) > IE.Visible = 1 > > It works fine and shows the requested page. Now I want to use the "Save > As" command. Looks like I should call the > IWebBrowser2.ExecWB method, passing IDM_SAVEAS as the command and > MSOCMDEXECOPT_DONTPROMPTUSER in the options. But I don't know how to > obtain the value for such constants... I could dig into the C header > files looking for them, but is there some other way? > > The ExecWB method is documented here > http://msdn.microsoft.com/en-us/library/aa752117(VS.85).aspx The usual way to get at constants after a Dispatch is via the win32com.client.constants object. In this case, the constant you want is OLECMDID_SAVEAS which... import win32com.client IE = "InternetExplorer.Application" ie = win32com.client.gencache.EnsureDispatch (IE) print win32com.client.constants.OLECMDID_SAVEAS TJG From gagsl-py2 at yahoo.com.ar Fri Sep 5 11:32:59 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 05 Sep 2008 06:32:59 -0300 Subject: [python-win32] Internet Explorer constants References: <48C0EC65.7000907@timgolden.me.uk> Message-ID: En Fri, 05 Sep 2008 05:23:01 -0300, Tim Golden escribi?: > Gabriel Genellina wrote: >> Hello >> I want to control Internet Explorer. This is what I have so far: >> import win32com.client >> from win32com.client.gencache import EnsureDispatch >> url = "..." >> IE = EnsureDispatch("InternetExplorer.Application") >> IE.Navigate(url) >> IE.Visible = 1 >> It works fine and shows the requested page. Now I want to use the >> "Save As" command. Looks like I should call the >> IWebBrowser2.ExecWB method, passing IDM_SAVEAS as the command and >> MSOCMDEXECOPT_DONTPROMPTUSER in the options. But I don't know how to >> obtain the value for such constants... I could dig into the C header >> files looking for them, but is there some other way? >> The ExecWB method is documented here >> http://msdn.microsoft.com/en-us/library/aa752117(VS.85).aspx > > The usual way to get at constants after a Dispatch > is via the win32com.client.constants object. In this > case, the constant you want is OLECMDID_SAVEAS which... > > > import win32com.client > > IE = "InternetExplorer.Application" > ie = win32com.client.gencache.EnsureDispatch (IE) > > print win32com.client.constants.OLECMDID_SAVEAS Ok, thanks! Looks like these are the names to use instead: IE.ExecWB( constants.OLECMDID_SAVEAS, constants.OLECMDEXECOPT_DONTPROMPTUSER, filename, None) Altough the ...DONTPROMPTUSER option doesn't work - the Save As dialog always appears. Some kind of permission or safety measure, I presume. My original intent was to save the file using the .mht format, but that format is not listed on the Save As dialog. I'll investigate using IMessage.CreateMHTMLBody but that's a different topic. -- Gabriel Genellina From mail at timgolden.me.uk Fri Sep 5 17:13:59 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 05 Sep 2008 16:13:59 +0100 Subject: [python-win32] Handling COM events in a python thread In-Reply-To: <7cd54e080809050119p699c7046me926c4e12d3ff343@mail.gmail.com> References: <7cd54e080809050119p699c7046me926c4e12d3ff343@mail.gmail.com> Message-ID: <48C14CB7.4060801@timgolden.me.uk> Ujjaval Suthar wrote: > Hi all, > > I have a COM control which fires a status event called > ProcessingDataAvailable(). The COM control has a method call AddData() > with some data parameters. > > Using python, in a simple program, I can instantiate COM object via > Dispatch and call AddData() method successfully. > > Now, I want to have a thread which keeps running and listening for > ProcessingDataAvailable() event and do some processing in my program. > > Can somebody please give me a simple example code that shows how it can > be done? I'm very new to this kind of programming. Well here's a crude example to get you going. It uses the MSAgent thingy which I imagine is installed (if little used) on most Windows machines. Notice that it's launching a thread to pick up events from a Queue -- the standard Python structure for communicating between threads. import win32com.client import pythoncom import Queue import threading import time events = Queue.Queue () def do_things_with_events (events): while True: event = events.get () open ("c:/temp/events.log", "a").write (str (event) + "\n") class AgentEvents: def OnHide (self, character_id, cause): events.put (("hide", character_id, cause)) # # Agent.Control.1 - Win2K characters # Agent.Control.2 - Office2K characters # agent = win32com.client.DispatchWithEvents ("Agent.Control.2", AgentEvents) agent.Connected = True def start (name, filename=None, show_immediately=True): filename = filename or ("%s.acs" % name) agent.Characters.Load (name, filename) this_agent = agent.Characters (name) this_agent.Show () if __name__ == '__main__': import time threading.Thread (target=do_things_with_events, args=(events,)).start () start ("merlin") while True: pythoncom.PumpWaitingMessages () time.sleep (0.1) From vernondcole at gmail.com Fri Sep 5 21:54:09 2008 From: vernondcole at gmail.com (Vernon Cole) Date: Fri, 5 Sep 2008 13:54:09 -0600 Subject: [python-win32] adodbapi 2.2.1 (bugfix) release. Message-ID: I found a bug in adodbapi v2.2 already. When putting data into a numeric database column, if the input was in a string (as for example the value of a wxPython grid cell), then the data would be truncated to the binary length of the field. So if I tried tried putting "12345" into an integer column, the value 1234 would be stored, because integers are 4 bytes long. This took me a while to find, since I kept looking at my wxwidgets code before finally uncovering adodbapi as the culpret. The fixed version is in the pywin32 CVS and in http://sourceforge.net/projects/adodbapi . For some good news, Mike Driscoll reports: I used your adodbapi module in my wxPython / SqlAlchemy program today and it > seemed to be returning the same data as the default module (which I think is > pyobdc). I don't know if my application truly stresses adodbapi , but it > does make lots of calls and accesses multiple tables in multiple databases. > > If anyone can test SqlAlchemy -> adodbapi -> IronPython please let us know if it works. -- Vernon -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdriscoll at co.marshall.ia.us Fri Sep 5 22:38:35 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Fri, 05 Sep 2008 15:38:35 -0500 Subject: [python-win32] Internet Explorer constants In-Reply-To: References: <48C0EC65.7000907@timgolden.me.uk> Message-ID: <48C198CB.7090501@co.marshall.ia.us> Hi Gabriel, >
En Fri, > 05 Sep 2008 05:23:01 -0300, Tim Golden escribi?: > >> Gabriel Genellina wrote: >>> Hello >>> I want to control Internet Explorer. This is what I have so far: >>> import win32com.client >>> from win32com.client.gencache import EnsureDispatch >>> url = "..." >>> IE = EnsureDispatch("InternetExplorer.Application") >>> IE.Navigate(url) >>> IE.Visible = 1 >>> It works fine and shows the requested page. Now I want to use the >>> "Save As" command. Looks like I should call the >>> IWebBrowser2.ExecWB method, passing IDM_SAVEAS as the command and >>> MSOCMDEXECOPT_DONTPROMPTUSER in the options. But I don't know how to >>> obtain the value for such constants... I could dig into the C header >>> files looking for them, but is there some other way? >>> The ExecWB method is documented here >>> http://msdn.microsoft.com/en-us/library/aa752117(VS.85).aspx >> >> The usual way to get at constants after a Dispatch >> is via the win32com.client.constants object. In this >> case, the constant you want is OLECMDID_SAVEAS which... >> >> >> import win32com.client >> >> IE = "InternetExplorer.Application" >> ie = win32com.client.gencache.EnsureDispatch (IE) >> >> print win32com.client.constants.OLECMDID_SAVEAS > > Ok, thanks! Looks like these are the names to use instead: > > IE.ExecWB( > constants.OLECMDID_SAVEAS, > constants.OLECMDEXECOPT_DONTPROMPTUSER, > filename, > None) > > Altough the ...DONTPROMPTUSER option doesn't work - the Save As dialog > always appears. Some kind of permission or safety measure, I presume. > > My original intent was to save the file using the .mht format, but > that format is not listed on the Save As dialog. I'll investigate > using IMessage.CreateMHTMLBody but that's a different topic. > You could also look at PAMIE: http://pamie.sourceforge.net/ or Mechanize: http://pypi.python.org/pypi/mechanize/0.1.7b I don't think either uses the PyWin32 library, but I hear that they're both pretty good. ------------------- Mike Driscoll Blog: http://blog.pythonlibrary.org Python Extension Building Network: http://www.pythonlibrary.org From mkesper at fsfe.org Fri Sep 5 23:47:20 2008 From: mkesper at fsfe.org (Michael Kesper) Date: Fri, 5 Sep 2008 23:47:20 +0200 Subject: [python-win32] Accessing properties of share on DFS In-Reply-To: <48BC14A0.3050202@timgolden.me.uk> References: <20080825143047.GD13124@localhost> <48B55829.5020205@timgolden.me.uk> <20080901120812.GB4376@localhost> <48BC14A0.3050202@timgolden.me.uk> Message-ID: <20080905214720.GC5062@localhost> Hi, * Tim Golden [2008-09-01 17:13:20 +0100]: ? >> * Tim Golden [2008-08-27 14:35:37 +0100]: >> >>> You might be able to get there with WMI. The following >>> works on my own machine, but I'm not sure what machine >>> you'd need to access to list the DFS shares. I'll see >>> if I can persuade a friendly admin here to let me try >>> things out: It seems I need to access net32api.NetShareGetInfo or maybe IADsFileShare, but I have to figure this out after my holiday. Until now I used the trick to simply call os.listdir() on the servers where I knew the homes are lying. os.listdir is cool enough to work with UNC paths. :) Best wishes Michael -- Free Software Foundation Europe (FSFE) [] (http://fsfeurope.org) Treten Sie der Fellowship bei! [][][] (http://fsfe.org/join) Ihre Spende erm?glicht unsere Arbeit! || (http://fsfeurope.org/donate) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 315 bytes Desc: Digital signature URL: From vernondcole at gmail.com Sun Sep 7 16:20:10 2008 From: vernondcole at gmail.com (Vernon Cole) Date: Sun, 7 Sep 2008 08:20:10 -0600 Subject: [python-win32] Fwd: adodbapi 2.2.1 (bugfix) release. In-Reply-To: References: Message-ID: [I tried sending this to two lists at once, and it seems to have been rejected by both, so this is a retry. -- VC] I found a bug in adodbapi v2.2 already. When putting data into a numeric database column, if the input was in a string (as for example the value of a wxPython grid cell), then the data would be truncated to the binary length of the field. So if I tried tried putting "12345" into an integer column, the value 1234 would be stored, because integers are 4 bytes long. This took me a while to find, since I kept looking at my wxwidgets code before finally uncovering adodbapi as the culpret. The fixed version is in the pywin32 CVS and in http://sourceforge.net/projects/adodbapi . For some good news, Mike Driscoll reports: I used your adodbapi module in my wxPython / SqlAlchemy program today and it > seemed to be returning the same data as the default module (which I think is > pyobdc). I don't know if my application truly stresses adodbapi , but it > does make lots of calls and accesses multiple tables in multiple databases. > > If anyone can test SqlAlchemy -> adodbapi -> IronPython please let us know if it works. -- Vernon -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrick at raptr.com Mon Sep 8 08:28:15 2008 From: patrick at raptr.com (Patrick Li) Date: Sun, 7 Sep 2008 23:28:15 -0700 Subject: [python-win32] how to obtain list of connected IP/port pairs on user's computer? Message-ID: <2b5a48740809072328h4cca2a56ve439212a4c399aa3@mail.gmail.com> Hi, I'm interested in writing a function that returns me the list of IP/port that the user's machine is connected to. The most naive way is to run netstat -na on the user's computer and just parse the stdout. Are there libraries I can call to achieve this as opposed to running an external command? Thanks, Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Mon Sep 8 11:01:41 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 08 Sep 2008 10:01:41 +0100 Subject: [python-win32] how to obtain list of connected IP/port pairs on user's computer? In-Reply-To: <2b5a48740809072328h4cca2a56ve439212a4c399aa3@mail.gmail.com> References: <2b5a48740809072328h4cca2a56ve439212a4c399aa3@mail.gmail.com> Message-ID: <48C4E9F5.5000605@timgolden.me.uk> Patrick Li wrote: > I'm interested in writing a function that returns me the list of IP/port > that the user's machine is connected to. The most naive way is to run > netstat -na on the user's computer and just parse the stdout. Are there > libraries I can call to achieve this as opposed to running an external > command? There was a thread about this a couple of months ago; might help: http://mail.python.org/pipermail/python-win32/2008-June/007786.html TJG From etiennepouliot at gmail.com Tue Sep 9 17:13:27 2008 From: etiennepouliot at gmail.com (Etienne Pouliot) Date: Tue, 9 Sep 2008 11:13:27 -0400 Subject: [python-win32] getting TerminalServicesProfilePath Message-ID: <729c89ef0809090813u7b81a29by2276994e3c8d51a4@mail.gmail.com> Hi, I'm trying to get TerminalServicesProfilePath property on user account in my Active Directory. adsi = win32com.client.Dispatch('ADsNameSpaces') ldap = adsi.getobject("","LDAP:") logon_ex='cn=Admin,dc=.....' password='mypassword' ex_path="LDAP://myserver/cn=test123,..." obj = ldap.OpenDSObject(ex_path,logon_ex,password,0) obj.Getinfo() Then I tryed with : print obj.TerminalServicesProfilePath or obj.get('TerminalServicesProfilePath') None worked If I use another properties instead, like DisplayName, it works. Any idea what I am doing wrong ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From Dominick.Lauzon at MSCsoftware.com Wed Sep 10 14:02:35 2008 From: Dominick.Lauzon at MSCsoftware.com (Dominick Lauzon) Date: Wed, 10 Sep 2008 08:02:35 -0400 Subject: [python-win32] Equivalent support on win64 ? Message-ID: <589DC3F5067BDD479AAAE54CE398166D418303@NAAAEX01.na.mscsoftware.com> Are we looking/expecting to obtain the same equivalent functionality and support for all win32com on win64 platforms shortly ? Dominick Lauzon -------------- next part -------------- An HTML attachment was scrubbed... URL: From Solomon.Zewdie.Altek at zf.com Wed Sep 10 14:25:27 2008 From: Solomon.Zewdie.Altek at zf.com (Solomon.Zewdie.Altek at zf.com) Date: Wed, 10 Sep 2008 14:25:27 +0200 Subject: [python-win32] ImportError: No system modul Message-ID: <8A13418356E45E4784744371A8B4DD7971FFAF@frds00501.emea.zf-world.com> Hello, I am tring to work on Excel File through python. I am using Python 2.4.2 and work on xp with an administration authorization. I implimented like that: ********************************************************* * ** ... import win32com.client ... class Python_skript(Object): def __init__(self, fileName=None): self.xlapp = win32com.client.dynamic.Dispatch("Excel.Application") if fileName: self.xlbook = self.xlapp.Workbooks.Open(fileName) else: self.xlbook = self.xlapp.Workbooks.Add() ... ********************************************************** I got the error message: "ImportError: No system modul 'pythoncom' (pythoncom24.dll)" Although the file pythoncom24.dll does exist. Can anyone help? Many Thanx! From mhammond at skippinet.com.au Wed Sep 10 14:48:17 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 10 Sep 2008 22:48:17 +1000 Subject: [python-win32] Equivalent support on win64 ? In-Reply-To: <589DC3F5067BDD479AAAE54CE398166D418303@NAAAEX01.na.mscsoftware.com> References: <589DC3F5067BDD479AAAE54CE398166D418303@NAAAEX01.na.mscsoftware.com> Message-ID: <04ff01c91343$86cc1cb0$94645610$@com.au> Regardless of what 'we' are expecting shortly, we can already find this support if only we looked (for python 2.6 anyway - other versions will require us to build it ourselves using vs2008) Mark. ---- From: python-win32-bounces+skippy.hammond=gmail.com at python.org [mailto:python-win32-bounces+skippy.hammond=gmail.com at python.org] On Behalf Of Dominick Lauzon Sent: Wednesday, 10 September 2008 10:03 PM To: python-win32 at python.org Subject: [python-win32] Equivalent support on win64 ? Are we looking/expecting to obtain the same equivalent functionality and support for all win32com on win64 platforms shortly ? Dominick Lauzon From timr at probo.com Wed Sep 10 19:35:11 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 10 Sep 2008 10:35:11 -0700 Subject: [python-win32] ImportError: No system modul In-Reply-To: <8A13418356E45E4784744371A8B4DD7971FFAF@frds00501.emea.zf-world.com> References: <8A13418356E45E4784744371A8B4DD7971FFAF@frds00501.emea.zf-world.com> Message-ID: <48C8054F.6040802@probo.com> Solomon.Zewdie.Altek at zf.com wrote: > I am tring to work on Excel File through python. > > I am using Python 2.4.2 and work on xp with an administration authorization. > > I implimented like that: > > ********************************************************* > * > ** > ... > import win32com.client > ... > class Python_skript(Object): > > def __init__(self, fileName=None): > self.xlapp = win32com.client.dynamic.Dispatch("Excel.Application") > if fileName: > self.xlbook = self.xlapp.Workbooks.Open(fileName) > else: > self.xlbook = self.xlapp.Workbooks.Add() ... > ********************************************************** > > > I got the error message: "ImportError: No system modul 'pythoncom' (pythoncom24.dll)" > > Although the file pythoncom24.dll does exist. > It must do more than "exist", of course. It must be in the right spot. How did you install pywin32? Where does it exist? And what does this say? import sys print sys.path -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From alecmunro at gmail.com Wed Sep 10 21:22:44 2008 From: alecmunro at gmail.com (Alec Munro) Date: Wed, 10 Sep 2008 16:22:44 -0300 Subject: [python-win32] Accessing other interfaces of a Dispatch created COM object In-Reply-To: <9819d58b0809020944v488ab4a2n5127c71e7c69424b@mail.gmail.com> References: <9819d58b0808280556g46cbd1cbj85f32cc82987615a@mail.gmail.com> <9819d58b0808280632x2b139645x278d5f0675dd46c7@mail.gmail.com> <9819d58b0808280633t13d89b77u433d55924cbb73a1@mail.gmail.com> <9819d58b0808280734o33af5721y741ca9b079d074af@mail.gmail.com> <00de01c9099c$b77731c0$26659540$@com.au> <9819d58b0808291047j3de5e9d8u7647b05e49a53f97@mail.gmail.com> <9819d58b0809020944v488ab4a2n5127c71e7c69424b@mail.gmail.com> Message-ID: <9819d58b0809101222m77c0648dh6e0752fc83a75ec2@mail.gmail.com> Ok, perhaps this will be useful. (Neither of these examples include the core arguments of the methods, just the ones specific to InvokeTypes) What I call a method from I1, it calls _oleobj_.InvokeTypes with the following arguments: 18, 0x0, 1, (24, 0), ((8, 1),) When I use the method from I2, it calls _ApplyTypes_(), which calls _oleobj_.InvokeTypes with the following arguments: 1, 0x0, 1, (24, 0), ((3, 1), (12, 1), (16396, 2)) Now, from my reading (of old messages by Mark :) ), the last two parameters specify method return type and argument type. In this case, it seems like both methods return VOID, which seems fine. I'm a little more concerned about the argument type. The first method is supposed to take a single string, so that looks fine. The second method takes an integer, a VT_TYPE, and a variant. I don't know if the representation here accurately represents that. The first parameter seems to be the ID of the method within the interface (or something similar), and given that I2 only has a single method, "1" seems like it could be correct. So, I'm fairly certain this puts that problem at something that happens in InvokeTypes, unrelated to the arguments I passed in. I get the impression that InvokeTypes is something of Microsofts, and there's isn't really any way to observe what it's doing? Thanks, hopefully this helps someone. Alec On Tue, Sep 2, 2008 at 1:44 PM, Alec Munro wrote: > I'm guessing, based on the lack of responses, and the consistency of > error messages, that my problem has more to do with getting the right > library registered, which isn't a python-win job. > > So, can anyone recommend where I might go to try to solve this > problem? Also, is there a way to determine which library it is that is > not registered? > > Thanks again, > > Alec > > On Fri, Aug 29, 2008 at 2:47 PM, Alec Munro wrote: >> Thanks Mark. >> >> After a couple of misfires, I think I figured out how to get CastTo to >> work (the docstring is practically non-existent in the version I have, >> perhaps it's been updated?). >> >> However, that puts me back at the same place I was with some of the >> other attempts: >> >>>>> obj_i2 = CastTo(obj, "Interface_2") >>>>> obj_i2.secondaryMethod() >> Traceback (most recent call last): >> ... >> File "C:\Python25\lib\site-packages\win32com\client\__init__.py", >> line 449, in _ApplyTypes_ >> dispid, 0, wFlags, retType, argTypes, *args), >> com_error: (-2147319779, 'Library not registered.', None, None) >> >> However, one interesting note is that the object generated by CastTo >> is of a different version of the Type Library than the object >> generated by Interface_2(obj). I don't know if that's useful >> information, however. They have the same CLSID, but different >> coclass_clsids. >> >> Thanks again, >> >> Alec >> >> On Fri, Aug 29, 2008 at 3:01 AM, Mark Hammond wrote: >>> Look at the docstring for win32com.client.CastTo (and googling for that will >>> probably help too) >>> >>> Cheers, >>> >>> Mark >>> >>>> I just discovered a third possibility, and subsequent failure: >>>> >>>> >>> obj_i2 = Dispatch(obj, None, Interface_2.CLSID) >>>> >>> obj_i2.secondaryMethod() >>>> Traceback (most recent call last): >>>> ... >>>> File "C:\Python25\lib\site-packages\win32com\client\__init__.py", >>>> line 449, in _ApplyTypes_ >>>> dispid, 0, wFlags, retType, argTypes, *args), >>>> com_error: (-2147352573, 'Member not found.', None, None) >>>> >>>> Alec >>>> >>>> On Thu, Aug 28, 2008 at 10:33 AM, Alec Munro >>>> wrote: >>>> > Oh, and on re-reading, I do realize that the DLL itself doesn't >>>> > implement those interfaces. There's a class within the DLL that does >>>> > that. :) >>>> > >>>> > On Thu, Aug 28, 2008 at 10:32 AM, Alec Munro >>>> wrote: >>>> >> Hi List, >>>> >> >>>> >> Hopefully I have my terminology right, I'm pretty new to COM and >>>> C++. >>>> >> >>>> >> My problem is that I have a COM DLL written in C++, that I would >>>> like >>>> >> to call from Python. This DLL implements 3 important interfaces, >>>> each >>>> >> of which is also an IDispatch implementation, like the following: >>>> >> >>>> >> IDispatchImpl>>> &LIBID_Interface_1, 1, 0> >>>> >> IDispatchImpl>>> &LIBID_Interface_2, 1, 0> >>>> >> IDispatchImpl>>> &LIBID_Interface_3 1, 0> >>>> >> >>>> >> However, when I do: >>>> >>>>> obj = win32com.client.Dispatch("a.b.c") >>>> >>>>> obj >>>> >> >>>> >> >>>> >> The object I get only has methods available for the first of the >>>> >> interfaces. From my reading, this is simply the functionality of >>>> >> IDispatch, and if I wanted to get those additional methods through >>>> >> IDispatch, I would have to update the DLL, and restructure my >>>> >> interfaces. I'm not confident enough in my C++ to do this, or at >>>> least >>>> >> it's not my first choice. >>>> >> >>>> >> From what I've read, there are two ways that seem to be >>>> possibilities >>>> >> for being able to call the methods from the other interfaces. >>>> >> >>>> >> The simplest one I found was the suggestion to use MakePy on the >>>> type >>>> >> library containing Interface_2 and Interface_3. I did this, and >>>> copied >>>> >> the generated file to my working directory, then did: >>>> >> >>>> >>>>> from interfaces import Interface_2 >>>> >>>>> obj_i2 = Interface_2(obj) >>>> >>>>> obj_i2 >>>> >> >>> at >>>> >> 0x17459602> >>>> >> >>>> >> Unfortunately when I try: >>>> >> >>>> >>>>> obj_i2.secondaryMethod() >>>> >> Traceback (most recent call last): >>>> >> ... >>>> >> File "C:\Python25\lib\site-packages\win32com\client\__init__.py", >>>> >> line 449, in _ApplyTypes_ >>>> >> dispid, 0, wFlags, retType, argTypes, *args), >>>> >> com_error: (-2147319779, 'Library not registered.', None, None) >>>> >> >>>> >> The other suggestion I came across was to use QueryInterface. I >>>> wasn't >>>> >> sure what argument to pass to QueryInterface, so I tried using the >>>> >> CLSID of the interface I wanted. >>>> >> >>>> >>>>> obj._oleobj_.QueryInterface(Interface_2.CLSID) >>>> >> Traceback (most recent call last): >>>> >> File "", line 1, in >>>> >> TypeError: There is no interface object registered that supports >>>> this IID >>>> >> >>>> >> From these error messages, it seems like perhaps there's a problem >>>> >> with the registration of the type library that contains the >>>> >> interfaces. I'm not really sure how to fix that, or if that is even >>>> >> the problem. >>>> >> >>>> >> Any ideas? >>>> >> >>>> >> Thanks, >>>> >> Alec Munro >>>> >> >>>> > >>>> _______________________________________________ >>>> python-win32 mailing list >>>> python-win32 at python.org >>>> http://mail.python.org/mailman/listinfo/python-win32 >>> >>> >> > From rblazecka at radical.ca Wed Sep 10 21:22:49 2008 From: rblazecka at radical.ca (Ryan Blazecka) Date: Wed, 10 Sep 2008 12:22:49 -0700 Subject: [python-win32] suggested change to pywintypes.py for non-admininstall In-Reply-To: <45F19959.20906@activestate.com> References: <014301c761fe$8ad76d70$070a0a0a@enfoldsystems.local> <45F19959.20906@activestate.com> Message-ID: Trent Mick wrote: > Given that my suggestion is no panacea, perhaps it is better to just leave it > at status quo and tell the user about the requirement to update their PATH. > > Thoughts? > > Trent > I have come across this issue, and am equally unsatisfied with the solutions I've come up with so far. all of them require the user to know too much about what's going on, and does not make the import "just work". what if we added a python wrapper module (.py) around the native (.pyd) modules? it would contain something like the following: import pywintypes import pythoncom from _win32ui import * this would allow us to ensure pywintypes is loaded before the native code runs, and the python module would just pass all of the imported stuff from the binary module through to the caller. (some extra work to set __all__ properly is probably in order here too). From timr at probo.com Wed Sep 10 21:59:36 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 10 Sep 2008 12:59:36 -0700 Subject: [python-win32] Accessing other interfaces of a Dispatch created COM object In-Reply-To: <9819d58b0809101222m77c0648dh6e0752fc83a75ec2@mail.gmail.com> References: <9819d58b0808280556g46cbd1cbj85f32cc82987615a@mail.gmail.com> <9819d58b0808280632x2b139645x278d5f0675dd46c7@mail.gmail.com> <9819d58b0808280633t13d89b77u433d55924cbb73a1@mail.gmail.com> <9819d58b0808280734o33af5721y741ca9b079d074af@mail.gmail.com> <00de01c9099c$b77731c0$26659540$@com.au> <9819d58b0808291047j3de5e9d8u7647b05e49a53f97@mail.gmail.com> <9819d58b0809020944v488ab4a2n5127c71e7c69424b@mail.gmail.com> <9819d58b0809101222m77c0648dh6e0752fc83a75ec2@mail.gmail.com> Message-ID: <48C82728.8060206@probo.com> Alec Munro wrote: > Ok, perhaps this will be useful. > > (Neither of these examples include the core arguments of the methods, > just the ones specific to InvokeTypes) > > What I call a method from I1, it calls _oleobj_.InvokeTypes with the > following arguments: > > 18, 0x0, 1, (24, 0), ((8, 1),) > > When I use the method from I2, it calls _ApplyTypes_(), which calls > _oleobj_.InvokeTypes with the following arguments: > > 1, 0x0, 1, (24, 0), ((3, 1), (12, 1), (16396, 2)) > > Now, from my reading (of old messages by Mark :) ), the last two > parameters specify method return type and argument type. Well, it's the 4th argument that gives the return type. 24 is VT_VOID. That's unusual for a COM type. > In this case, > it seems like both methods return VOID, which seems fine. I'm a little > more concerned about the argument type. The first method is supposed > to take a single string, so that looks fine. Right; 8 is VT_BSTR, which is the typical COM Unicope string type. > The second method takes > an integer, a VT_TYPE, and a variant. I don't know if the > representation here accurately represents that. > 3 is VT_I4 (long), 12 is VT_VARIANT, and 16396 is a VT_VARIANT passed by reference, meaning an output parameter. > So, I'm fairly certain this puts that problem at something that > happens in InvokeTypes, unrelated to the arguments I passed in. I get > the impression that InvokeTypes is something of Microsofts, and > there's isn't really any way to observe what it's doing? > I've lost track. What's the root problem? Is it still the "Library not registered" issue when you call a method in Interface_2? Was this all registered through a type library, or through a regsvr32 call, or what? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Jim.Vickroy at noaa.gov Wed Sep 10 21:35:15 2008 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed, 10 Sep 2008 13:35:15 -0600 Subject: [python-win32] Microsoft Visual Sourcesafe automation -- Message-ID: <48C82173.6010205@noaa.gov> Hello all, I am attempting to automate Sourcesafe access. Here is a sample session: >>> import sys >>> sys.version '2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]' >>> sys.subversion ('CPython', 'tags/r252', '60911') >>> sys.platform 'win32' >>> sys.getwindowsversion() (5, 1, 2600, 2, 'Service Pack 2') >>> import win32com.client >>> vcs = win32com.client.Dispatch('SourceSafe') >>> config = r'\\Tsg-admin-01\VSS\srcsafe.ini' >>> account = 'jim.vickroy' >>> password = raw_input('password: ') >>> vcs.Open(SrcSafeIni=config, Username=account, Password=password) Traceback (most recent call last): File "", line 1, in File "C:\Python25\lib\site-packages\win32com\gen_py\783CD4E0-9D54-11CF-B8EE-00608CC9A71Fx0x5x1.py", line 179, in Open , Username, Password) File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line 448, in _ApplyTypes_ dispid, 0, wFlags, retType, argTypes, *args), com_error: (-2147352567, 'Exception occurred.', (0, u'SourceSafe', u'Error loading resource string', u'ssusexp.hlp', -11250, -2147210254), None) >>> I'm using pywin32 build 212 and Visual Sourcesafe 6.0c build 9447. The \\Tsg-admin-01\VSS\ folder contains a SSUSEXP.CHM file but no SSUSEXP.HLP file. Any suggestions on how to proceed would be much appreciated. Thanks, -- jv From alecmunro at gmail.com Thu Sep 11 00:23:26 2008 From: alecmunro at gmail.com (Alec Munro) Date: Wed, 10 Sep 2008 19:23:26 -0300 Subject: [python-win32] Accessing other interfaces of a Dispatch created COM object In-Reply-To: <48C82728.8060206@probo.com> References: <9819d58b0808280556g46cbd1cbj85f32cc82987615a@mail.gmail.com> <9819d58b0808280632x2b139645x278d5f0675dd46c7@mail.gmail.com> <9819d58b0808280633t13d89b77u433d55924cbb73a1@mail.gmail.com> <9819d58b0808280734o33af5721y741ca9b079d074af@mail.gmail.com> <00de01c9099c$b77731c0$26659540$@com.au> <9819d58b0808291047j3de5e9d8u7647b05e49a53f97@mail.gmail.com> <9819d58b0809020944v488ab4a2n5127c71e7c69424b@mail.gmail.com> <9819d58b0809101222m77c0648dh6e0752fc83a75ec2@mail.gmail.com> <48C82728.8060206@probo.com> Message-ID: <9819d58b0809101523u5811d094kfb01109987e9491d@mail.gmail.com> Thanks for the clarification Tim. My root problem is still the "Library not registered" issue. As far as how it was registered: * I maintain a dll that defines a class that implements I1 and I2. I use regsvr to register this dll. * I1 and I2 come from a third party, and in order for my dll to work properly, it has to implement them (actually I2 is optional). * I don't know how I1 and I2 are registered. I do know that if I use the COM browser, I can go to Registered Type Libraries, find one with the typelibname that is associated with my CastTo created objects, which has "Type Library" underneath it, and underneath that are entries for I1, I2, several related interfaces, and a variety of coclasses. Like this: - TypeLibName 1.0 TypeLibrary -- IID: {00..00} -- Type Library --- I1 - Dispatch --- I2 - Dispatch --- IX - Dispatch --- CX - CoClass I've just spent some time hunting through the registry to determine the differences between I1 and I2. Looking the gen_py files, they have the same package CLSID, and the same class coclass_clsid. But their class CLSIDs differ. So I searched through the registry for those CLSIDs. They show up in the same places, once each under HKEY_CLASSES_ROOT and HKEY_LOCAL_MACHINE. Under each of them there is a "TypeLib" folder, and within that, a "default" entry. The data associated with this entry differs. In the case of I2, it's the same as the IID of the Type Library I found in the COM browser. In the case of I1, it's another GUID, but I don't know what it corresponds to. Hopefully that sheds some light on the situation (or at worst, doesn't confuse things further). Thanks again, Alec On Wed, Sep 10, 2008 at 4:59 PM, Tim Roberts wrote: > Alec Munro wrote: >> Ok, perhaps this will be useful. >> >> (Neither of these examples include the core arguments of the methods, >> just the ones specific to InvokeTypes) >> >> What I call a method from I1, it calls _oleobj_.InvokeTypes with the >> following arguments: >> >> 18, 0x0, 1, (24, 0), ((8, 1),) >> >> When I use the method from I2, it calls _ApplyTypes_(), which calls >> _oleobj_.InvokeTypes with the following arguments: >> >> 1, 0x0, 1, (24, 0), ((3, 1), (12, 1), (16396, 2)) >> >> Now, from my reading (of old messages by Mark :) ), the last two >> parameters specify method return type and argument type. > > Well, it's the 4th argument that gives the return type. 24 is VT_VOID. > That's unusual for a COM type. > >> In this case, >> it seems like both methods return VOID, which seems fine. I'm a little >> more concerned about the argument type. The first method is supposed >> to take a single string, so that looks fine. > > Right; 8 is VT_BSTR, which is the typical COM Unicope string type. > >> The second method takes >> an integer, a VT_TYPE, and a variant. I don't know if the >> representation here accurately represents that. >> > > 3 is VT_I4 (long), 12 is VT_VARIANT, and 16396 is a VT_VARIANT passed by > reference, meaning an output parameter. > >> So, I'm fairly certain this puts that problem at something that >> happens in InvokeTypes, unrelated to the arguments I passed in. I get >> the impression that InvokeTypes is something of Microsofts, and >> there's isn't really any way to observe what it's doing? >> > > I've lost track. What's the root problem? Is it still the "Library > not registered" issue when you call a method in Interface_2? Was this > all registered through a type library, or through a regsvr32 call, or what? > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From mhammond at skippinet.com.au Thu Sep 11 01:29:02 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 11 Sep 2008 09:29:02 +1000 Subject: [python-win32] suggested change to pywintypes.py for non-admininstall In-Reply-To: References: <014301c761fe$8ad76d70$070a0a0a@enfoldsystems.local> <45F19959.20906@activestate.com> Message-ID: <057001c9139d$075b0a90$16111fb0$@com.au> I'm afraid I've missed most of the context here: > I have come across this issue, and am equally unsatisfied with the > solutions I've come up with so far. all of them require the user to > know > too much about what's going on, and does not make the import "just > work". > > what if we added a python wrapper module (.py) around the native (.pyd) > modules? it would contain something like the following: > > import pywintypes > import pythoncom > from _win32ui import * In what cases is it necessary to explicitly import pywintypes before win32ui? Mark From timr at probo.com Thu Sep 11 01:33:50 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 10 Sep 2008 16:33:50 -0700 Subject: [python-win32] Accessing other interfaces of a Dispatch created COM object In-Reply-To: <9819d58b0809101523u5811d094kfb01109987e9491d@mail.gmail.com> References: <9819d58b0808280556g46cbd1cbj85f32cc82987615a@mail.gmail.com> <9819d58b0808280632x2b139645x278d5f0675dd46c7@mail.gmail.com> <9819d58b0808280633t13d89b77u433d55924cbb73a1@mail.gmail.com> <9819d58b0808280734o33af5721y741ca9b079d074af@mail.gmail.com> <00de01c9099c$b77731c0$26659540$@com.au> <9819d58b0808291047j3de5e9d8u7647b05e49a53f97@mail.gmail.com> <9819d58b0809020944v488ab4a2n5127c71e7c69424b@mail.gmail.com> <9819d58b0809101222m77c0648dh6e0752fc83a75ec2@mail.gmail.com> <48C82728.8060206@probo.com> <9819d58b0809101523u5811d094kfb01109987e9491d@mail.gmail.com> Message-ID: <48C8595E.5040906@probo.com> Alec Munro wrote: > Thanks for the clarification Tim. > > My root problem is still the "Library not registered" issue. As far as > how it was registered: > > * I maintain a dll that defines a class that implements I1 and I2. I > use regsvr to register this dll. > * I1 and I2 come from a third party, and in order for my dll to work > properly, it has to implement them (actually I2 is optional). > * I don't know how I1 and I2 are registered. I do know that if I use > the COM browser, I can go to Registered Type Libraries, find one with > the typelibname that is associated with my CastTo created objects, > which has "Type Library" underneath it, and underneath that are > entries for I1, I2, several related interfaces, and a variety of > coclasses. Like this: > - TypeLibName 1.0 TypeLibrary > -- IID: {00..00} > -- Type Library > --- I1 - Dispatch > --- I2 - Dispatch > --- IX - Dispatch > --- CX - CoClass > > I've just spent some time hunting through the registry to determine > the differences between I1 and I2. > > Looking the gen_py files, they have the same package CLSID, and the > same class coclass_clsid. But their class CLSIDs differ. > Well, we may be getting confused about identifiers here. The IID listed below the typename is the type library UUID. It identifies the type library, which is just a collection of definitions. Within the type library, you have interfaces, and you have coclasses. An interface also has an IID, and that's the important IID to use when you query for an interface. A coclass is a concrete object that implements one or more of the interfaces -- the "default" object for those interfaces, if you like. A coclass is identified by a CLSID. In gen_py, the "CLSID = IID(...)" line at the top of the file should be the type library UUID. The "CLSID = IID(...)" line at the top of each class is the IID for the interface being exposed by this coclass. The coclass_clsid is the model coclass that implements the interface. If you try to create an object of this type, PythonCom will essentially do a CoCreateObject on the coclass_clsid, using the IID of the interface. So, your two interface should have different CLSID lines at the top of the class, and you should find those IIDs listed in HKEY_CLASSES_ROOT\Interface. > So I searched through the registry for those CLSIDs. They show up in > the same places, once each under HKEY_CLASSES_ROOT and > HKEY_LOCAL_MACHINE. HKEY_CLASSES_ROOT is just a "symbolic link" shortcut to HKEY_LOCAL_MACHINE\Software\Classes. Everything in one will be in the other. No solution yet, but maybe this provides more background information. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu Sep 11 01:36:47 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 10 Sep 2008 16:36:47 -0700 Subject: [python-win32] Accessing other interfaces of a Dispatch created COM object In-Reply-To: <9819d58b0809101553i62f21843g9394acabc31d6716@mail.gmail.com> References: <9819d58b0808280556g46cbd1cbj85f32cc82987615a@mail.gmail.com> <9819d58b0808280632x2b139645x278d5f0675dd46c7@mail.gmail.com> <9819d58b0808280633t13d89b77u433d55924cbb73a1@mail.gmail.com> <9819d58b0808280734o33af5721y741ca9b079d074af@mail.gmail.com> <00de01c9099c$b77731c0$26659540$@com.au> <9819d58b0808291047j3de5e9d8u7647b05e49a53f97@mail.gmail.com> <9819d58b0809020944v488ab4a2n5127c71e7c69424b@mail.gmail.com> <9819d58b0809101222m77c0648dh6e0752fc83a75ec2@mail.gmail.com> <48C82728.8060206@probo.com> <9819d58b0809101523u5811d094kfb01109987e9491d@mail.gmail.com> <9819d58b0809101553i62f21843g9394acabc31d6716@mail.gmail.com> Message-ID: <48C85A0F.6030706@probo.com> Alec Munro wrote: > I've searched through the registry for the GUIDs I found associated > with the CLSIDs of the classes. They seem to be IIDs of type > libraries. > > The first one, associated with I1, seems to refer to a _basicUHI.tlb > file that was distributed with SDK the third-party provides for > creating the DLL we use. > > The second one, associated with I2, refers to a .dll file distributed > with the third-parties application (the one that makes use of our > DLL). > > In Visual Studio, if I look at the definition of I2, it opens up a > _basicUHI.tlh file in a temp directory. Am I correct in assuming the > .tlh file is automatically generated by VS to display a representation > of the .tlb file? > > I found regtlibv12, and ran it against _basicUHI.tlb. Now the COM > Browser has a "TypeLibName 2.0 Type Library" entry, but if I try to > access it, or run makepy against it, I get "_basicUHI.tlb can not be > loaded" or "Error loading type library/DLL.", respectively. > > This feels like it must be the source of the problem, but I'm not > really sure what to do next. > Take the IID of the type library for _basicUHI.tlb. Now, look that up in HKEY_CLASSES_ROOT\TypeLib. Somewhere in there, there should be a path to the TLB. Make sure the path is correct. You might also try running regsvr32 on the DLL file associated with I2. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rblazecka at radical.ca Thu Sep 11 01:55:42 2008 From: rblazecka at radical.ca (Ryan Blazecka) Date: Wed, 10 Sep 2008 16:55:42 -0700 Subject: [python-win32] suggested change to pywintypes.py for non-admininstall In-Reply-To: <057001c9139d$075b0a90$16111fb0$@com.au> References: <014301c761fe$8ad76d70$070a0a0a@enfoldsystems.local> <45F19959.20906@activestate.com> <057001c9139d$075b0a90$16111fb0$@com.au> Message-ID: <48C85E7E.60401@radical.ca> oops, sorry, I suppose I shouldn't be deleting so much of the message history. ;) the specific circumstance that I've come across is with a non-admin install of the win32 module. if I run python from the python directory (so that the current directory is the directory where pywintypes25.dll lives), then everything works fine. if I run python from some other directory (ie my application directory), imports of the win32 modules (win32gui, win32ui, etc) fail unless I first import pywintypes. Mark Hammond wrote: > I'm afraid I've missed most of the context here: > >> I have come across this issue, and am equally unsatisfied with the >> solutions I've come up with so far. all of them require the user to >> know >> too much about what's going on, and does not make the import "just >> work". >> >> what if we added a python wrapper module (.py) around the native (.pyd) >> modules? it would contain something like the following: >> >> import pywintypes >> import pythoncom >> from _win32ui import * > > In what cases is it necessary to explicitly import pywintypes before > win32ui? > > Mark From mhammond at skippinet.com.au Thu Sep 11 01:59:35 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 11 Sep 2008 09:59:35 +1000 Subject: [python-win32] Accessing other interfaces of a Dispatch created COM object In-Reply-To: <9819d58b0809101523u5811d094kfb01109987e9491d@mail.gmail.com> References: <9819d58b0808280556g46cbd1cbj85f32cc82987615a@mail.gmail.com> <9819d58b0808280632x2b139645x278d5f0675dd46c7@mail.gmail.com> <9819d58b0808280633t13d89b77u433d55924cbb73a1@mail.gmail.com> <9819d58b0808280734o33af5721y741ca9b079d074af@mail.gmail.com> <00de01c9099c$b77731c0$26659540$@com.au> <9819d58b0808291047j3de5e9d8u7647b05e49a53f97@mail.gmail.com> <9819d58b0809020944v488ab4a2n5127c71e7c69424b@mail.gmail.com> <9819d58b0809101222m77c0648dh6e0752fc83a75ec2@mail.gmail.com> <48C82728.8060206@probo.com> <9819d58b0809101523u5811d094kfb01109987e9491d@mail.gmail.com> Message-ID: <057d01c913a1$4e80dc20$eb829460$@com.au> I'm still a little lost too, but: > * I maintain a dll that defines a class that implements I1 and I2. I > use regsvr to register this dll. > * I1 and I2 come from a third party, and in order for my dll to work > properly, it has to implement them (actually I2 is optional). > * I don't know how I1 and I2 are registered. I don't understand the above. If you maintain the class that implements I1 and I2 how can: * they come from a 3rd party - either you maintain them, or they do? * Surely you know how they are registered? > I do know that if I use > the COM browser, I can go to Registered Type Libraries, find one with > the typelibname that is associated with my CastTo created objects, > which has "Type Library" underneath it, and underneath that are > entries for I1, I2, several related interfaces, and a variety of > coclasses. Like this: > - TypeLibName 1.0 TypeLibrary > -- IID: {00..00} > -- Type Library > --- I1 - Dispatch > --- I2 - Dispatch > --- IX - Dispatch > --- CX - CoClass > > I've just spent some time hunting through the registry to determine > the differences between I1 and I2. What I'm guessing is that the GetTypeInfo() and GetTypeLib() calls for the other dispatch object are failing. Below is how we expect things to work, demonstratrated using for Internet Explorer: >>> from win32com.client import Dispatch >>> d=Dispatch("InternetExplorer.Application") >>> d=d._oleobj_ >>> d.GetTypeInfoCount() 1 >>> d.GetTypeInfo(0) >>> i=d.GetTypeInfo(0) >>> tlb, index=i.GetContainingTypeLib() >>> tlb.GetLibAttr() (IID('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}'), 0, 1, 1, 1, 8) >>> Which is the GUID, version, locale etc information (a TLIBATTR structure) for the typelib, and you will find this in the registry. It sounds like this works for one of your objects and fails for the other (well - "fails" might mean that the call works, but returns a GID and version info for a typelib that isn't registered - ie, attempting to load that typelib would fail.) ie, you would also need the following to work: >>> guid, lcid, syskind, majver, minver, flags = tlb.GetLibAttr() >>> import pythoncom >>> pythoncom.LoadRegTypeLib(guid, majver, minver, lcid) >>> _.GetDocumentation(1) (u'DWebBrowserEvents', u'Web Browser Control Events (old)', 0, None) >>> Hope this helps, Mark From alecmunro at gmail.com Fri Sep 12 19:28:57 2008 From: alecmunro at gmail.com (Alec Munro) Date: Fri, 12 Sep 2008 14:28:57 -0300 Subject: [python-win32] Accessing other interfaces of a Dispatch created COM object In-Reply-To: <9819d58b0809120949v217de44bn8c71ac792dec70fa@mail.gmail.com> References: <9819d58b0808280556g46cbd1cbj85f32cc82987615a@mail.gmail.com> <00de01c9099c$b77731c0$26659540$@com.au> <9819d58b0808291047j3de5e9d8u7647b05e49a53f97@mail.gmail.com> <9819d58b0809020944v488ab4a2n5127c71e7c69424b@mail.gmail.com> <9819d58b0809101222m77c0648dh6e0752fc83a75ec2@mail.gmail.com> <48C82728.8060206@probo.com> <9819d58b0809101523u5811d094kfb01109987e9491d@mail.gmail.com> <057d01c913a1$4e80dc20$eb829460$@com.au> <9819d58b0809101835h1a581fpb67305217b39a40f@mail.gmail.com> <9819d58b0809120949v217de44bn8c71ac792dec70fa@mail.gmail.com> Message-ID: <9819d58b0809121028w46cf0267l3c517a33289ea595@mail.gmail.com> (I just noticed my last two responses only went to Mark. They were intended for the Mailing List and Tim as well. Sorry for the oversight.) So I just ran some tests, fruitlessly. Here is what I did: - Removed all gen_py stuff - Set registry entries for both interfaces to point to the BASICUHI typelib. - Restarted - Use Make_py on BASICUHI typelib X: Same error - Use Make_py for other typelib X: Same error - Removed all gen_py stuff - Set registry entries for both interfaces to point to other typelib. - Restarted - Use Make_py for other typelib X: Same error - Use Make_py for BASICUHI typelib X: Same error What I'm wondering at this point is how I determine what Library it is that isn't registered. That might yield some clues, but right now I'm pretty much out of ideas, and toying seriously with the idea of rewriting the dll to allow it to export the interfaces I need through IDispatch. Thanks again for your time, Alec On Fri, Sep 12, 2008 at 1:49 PM, Alec Munro wrote: > Hi Mark, > > Ok, with my first object, everything works as you demonstrated. With > my second object (the first one CastTo(,I2)), I get the "Library not > Registered" message when I call GetTypeInfo(), which I guess is what > you were expecting. > > As far as Tim's question goes, I looked up the ID for the BasicUHI > typelib in the registry, and the path there does indeed point to the > BasicUHI file. > > I've got some ideas for things I can test, for the moment, but if you > have any ideas or additional information, I would love to hear it. > > Thanks again! > > Alec > > > On Wed, Sep 10, 2008 at 10:35 PM, Alec Munro wrote: >> Thanks Mark, Tim! >> >> Lots of excellent information there for someone as COM-confused as I am. :) >> >> I'll try out your suggestions tomorrow, to see what I find, but for >> now, here's a little more information on our situation. >> >> We use a third-party solution for testing our products. This solution >> requires us to create a COM dll with a class implementing specific >> interfaces (at least I1, any others are optional). The third party >> defines the interfaces, we just provide implementations for them. The >> third party provides us with their testing solution itself, as well as >> an SDK for developing the dll. >> >> In order to use the dll, we do register it manually using regsvr32. >> Any other registrations I would assume are performed by the installers >> from the third party. >> >> We've been using this for several years now (I only took over >> maintenance on the project 6 months ago), but this is the first time >> we are trying to access the dll ourselves, so it's fairly new >> territory. >> >> Hopefully that makes sense, thanks again, >> >> Alec >> >> On Wed, Sep 10, 2008 at 8:59 PM, Mark Hammond wrote: >>> I'm still a little lost too, but: >>> >>>> * I maintain a dll that defines a class that implements I1 and I2. I >>>> use regsvr to register this dll. >>>> * I1 and I2 come from a third party, and in order for my dll to work >>>> properly, it has to implement them (actually I2 is optional). >>>> * I don't know how I1 and I2 are registered. >>> >>> I don't understand the above. If you maintain the class that implements I1 >>> and I2 how can: >>> >>> * they come from a 3rd party - either you maintain them, or they do? >>> * Surely you know how they are registered? >>> >>> >>>> I do know that if I use >>>> the COM browser, I can go to Registered Type Libraries, find one with >>>> the typelibname that is associated with my CastTo created objects, >>>> which has "Type Library" underneath it, and underneath that are >>>> entries for I1, I2, several related interfaces, and a variety of >>>> coclasses. Like this: >>>> - TypeLibName 1.0 TypeLibrary >>>> -- IID: {00..00} >>>> -- Type Library >>>> --- I1 - Dispatch >>>> --- I2 - Dispatch >>>> --- IX - Dispatch >>>> --- CX - CoClass >>>> >>>> I've just spent some time hunting through the registry to determine >>>> the differences between I1 and I2. >>> >>> What I'm guessing is that the GetTypeInfo() and GetTypeLib() calls for the >>> other dispatch object are failing. Below is how we expect things to work, >>> demonstratrated using for Internet Explorer: >>> >>>>>> from win32com.client import Dispatch >>>>>> d=Dispatch("InternetExplorer.Application") >>>>>> d=d._oleobj_ >>>>>> d.GetTypeInfoCount() >>> 1 >>>>>> d.GetTypeInfo(0) >>> >>>>>> i=d.GetTypeInfo(0) >>>>>> tlb, index=i.GetContainingTypeLib() >>>>>> tlb.GetLibAttr() >>> (IID('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}'), 0, 1, 1, 1, 8) >>>>>> >>> >>> Which is the GUID, version, locale etc information (a TLIBATTR structure) >>> for the typelib, and you will find this in the registry. It sounds like >>> this works for one of your objects and fails for the other (well - "fails" >>> might mean that the call works, but returns a GID and version info for a >>> typelib that isn't registered - ie, attempting to load that typelib would >>> fail.) ie, you would also need the following to work: >>> >>>>>> guid, lcid, syskind, majver, minver, flags = tlb.GetLibAttr() >>>>>> import pythoncom >>>>>> pythoncom.LoadRegTypeLib(guid, majver, minver, lcid) >>> >>>>>> _.GetDocumentation(1) >>> (u'DWebBrowserEvents', u'Web Browser Control Events (old)', 0, None) >>>>>> >>> >>> Hope this helps, >>> >>> Mark >>> >>> >> > From siegfried at heintze.com Sun Sep 14 09:09:23 2008 From: siegfried at heintze.com (siegfried) Date: Sun, 14 Sep 2008 00:09:23 -0700 Subject: [python-win32] Windows GUI programming with Python? Message-ID: <9D6B1ED566694FD7859249DE6088DF3D@kingmark> I just finished trying out the sample program scribble in "Python Programming in Win32". While I carefully cut and pasted from my soft copy of the book, I could not create a new document. When I finally found the source code download URL hidden in the chm file, the zip file was corrupted! This program is more what I am looking for: http://aspn.activestate.com/ASPN/Mail/Message/ActivePython/1775844 Unfortunately it does not work. Apparently I don't have to use ActiveStatePython (according to a poster in the nntp group). Where can I find similar source code that works that displays a simple window and lets me call other exotic window functions like LoadKeyboardLayout, MapVirtualKeyEx, ToUnicodeEx. That latter function produces Unicode strings and since I don't know how to display Cyrillic in a console mode app, I'm thinking I'll create a window to display it in. I'll need to know how to load a font in python too --- anyone got an example of that too? thanks! Siegfried -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jim.Vickroy at noaa.gov Sun Sep 14 14:31:23 2008 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun, 14 Sep 2008 06:31:23 -0600 Subject: [python-win32] Windows GUI programming with Python? In-Reply-To: <9D6B1ED566694FD7859249DE6088DF3D@kingmark> References: <9D6B1ED566694FD7859249DE6088DF3D@kingmark> Message-ID: <48CD041B.7080108@noaa.gov> siegfried wrote: > > I just finished trying out the sample program scribble in "Python > Programming in Win32". While I > > carefully cut and pasted from my soft copy of the book, I could not > > create a new document. When I finally found the source code download > > URL hidden in the chm file, the zip file was corrupted! > I've attached the 3 "scribble" files. I'm not a GUI programmer so others will have to answer your questions. > > > > This program is more what I am looking for: > http://aspn.activestate.com/ASPN/Mail/Message/ActivePython/1775844 > > > > Unfortunately it does not work. > Could you provide the code and the error message? > > Apparently I don't have to use ActiveStatePython (according to a > poster in the nntp group). > That is true. > > Where can I find similar source code that works > > that displays a simple window and lets me call other exotic window > > functions like LoadKeyboardLayout, MapVirtualKeyEx, ToUnicodeEx. That > > latter function produces Unicode strings and since I don't know how to > display > > Cyrillic in a console mode app, I'm thinking I'll create a window to > > display it in. I'll need to know how to load a font in python too --- > > anyone got an example of that too? > > > > > > > > thanks! > > Siegfried > > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: scribbleApp.py Type: application/x-python Size: 353 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: scribble1.py Type: application/x-python Size: 1335 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: scribble2.py Type: application/x-python Size: 4216 bytes Desc: not available URL: From Jim.Vickroy at noaa.gov Sun Sep 14 14:40:33 2008 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun, 14 Sep 2008 06:40:33 -0600 Subject: [python-win32] Microsoft Visual Sourcesafe automation -- In-Reply-To: <48C82173.6010205@noaa.gov> References: <48C82173.6010205@noaa.gov> Message-ID: <48CD0641.3000303@noaa.gov> Jim Vickroy wrote: > Hello all, > > I am attempting to automate Sourcesafe access. > > Here is a sample session: > > >>> import sys > >>> sys.version > '2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]' > >>> sys.subversion > ('CPython', 'tags/r252', '60911') > >>> sys.platform > 'win32' > >>> sys.getwindowsversion() > (5, 1, 2600, 2, 'Service Pack 2') > >>> import win32com.client > >>> vcs = win32com.client.Dispatch('SourceSafe') > >>> config = r'\\Tsg-admin-01\VSS\srcsafe.ini' > >>> account = 'jim.vickroy' > >>> password = raw_input('password: ') > >>> vcs.Open(SrcSafeIni=config, Username=account, Password=password) > Traceback (most recent call last): > File "", line 1, in > File > "C:\Python25\lib\site-packages\win32com\gen_py\783CD4E0-9D54-11CF-B8EE-00608CC9A71Fx0x5x1.py", > line 179, in Open > , Username, Password) > File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", > line 448, in _ApplyTypes_ > dispid, 0, wFlags, retType, argTypes, *args), > com_error: (-2147352567, 'Exception occurred.', (0, u'SourceSafe', > u'Error loading resource string', u'ssusexp.hlp', -11250, > -2147210254), None) > >>> > > I'm using pywin32 build 212 and Visual Sourcesafe 6.0c build 9447. > > The \\Tsg-admin-01\VSS\ folder contains a SSUSEXP.CHM file but no > SSUSEXP.HLP file. > > Any suggestions on how to proceed would be much appreciated. > > Thanks, > -- jv > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 I finally got this to work by deleting *vcs* which apparently had "somehow" become unusable. So the following does work: >>> import win32com.client >>> vcs = win32com.client.Dispatch('SourceSafe') >>> config = r'\\Tsg-admin-01\VSS\srcsafe.ini' >>> account = 'jim.vickroy' >>> vcs.Open(SrcSafeIni=config, Username=account) >>> vcs.Username u'Jim.vickroy' >>> vcs.CurrentProject u'$/RTGM/data archival' From werner.bruhin at free.fr Mon Sep 15 09:45:36 2008 From: werner.bruhin at free.fr (Werner F. Bruhin) Date: Mon, 15 Sep 2008 09:45:36 +0200 Subject: [python-win32] Windows GUI programming with Python? In-Reply-To: <9D6B1ED566694FD7859249DE6088DF3D@kingmark> References: <9D6B1ED566694FD7859249DE6088DF3D@kingmark> Message-ID: Siegfried, siegfried wrote: > I just finished trying out the sample program scribble in "Python > Programming in Win32". While I > > carefully cut and pasted from my soft copy of the book, I could not > > create a new document. When I finally found the source code download > > URL hidden in the chm file, the zip file was corrupted! > > > > This program is more what I am looking for: > http://aspn.activestate.com/ASPN/Mail/Message/ActivePython/1775844 > > > > Unfortunately it does not work. Apparently I don't have to use > ActiveStatePython (according to a poster in the nntp group). Where can I > find similar source code that works > > that displays a simple window and lets me call other exotic window > > functions like LoadKeyboardLayout, MapVirtualKeyEx, ToUnicodeEx. That > > latter function produces Unicode strings and since I don't know how to > display > > Cyrillic in a console mode app, I'm thinking I'll create a window to > > display it in. I'll need to know how to load a font in python too --- > > anyone got an example of that too? You might want to look into wxPython. It is a GUI library wrapping wxWidgets. Make sure to download the demo and use the Unicode version. In the demo look for the styledtextctrl_1 and/or the RichTextCtrl it should be close to what you would like to do. Werner > > > > > > > > thanks! > > Siegfried > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From keston.obendorf at intel.com Tue Sep 16 00:19:01 2008 From: keston.obendorf at intel.com (Obendorf, Keston) Date: Mon, 15 Sep 2008 15:19:01 -0700 Subject: [python-win32] COM: Parameterless functions seen as properties Message-ID: <12A5C15467D5B94F8E0FF265D9498ADD03AC5794@orsmsx419.amr.corp.intel.com> I'm doing COM development in both Python and C#. Things are working well, but I'm running into an issue where trying to get parameterless function returns the return value of that function, which Python then tries to call, causing an error. The C# class is an implementation of an IDL-defined interface. //IDL interface IService : IDispatch { [id(101)] HRESULT foo([out, retval] BSTR * pstr); } //C# [ComImport] [Guid("/*GUID of IService*/")] interface IService{} [ComVisible(true)] [ProgId("bar")] [Guid("Valid GUID")] public class bar : IService { public bar(){} public string foo() { return "foo"; } } Now, getting a Dispatch of "bar" in Python is where the issue lies. from win32com.client import Dispatch bar = Dispatch("bar") str = bar.foo() >>TypeError: 'unicode' object is not callable This is only a problem with the C# class. If the interface is implemented in Pythong, the above code will work. Now, this issue can be fixed by adding in _FlagAsMethod before calling bar.foo() bar._FlagAsMethod("foo") I really don't want to have to do that every time I try to call a parameterless method of a C# COM-object from Python. That's a huge headache, especially because I am trying to keep the language any one component is written in a non-issue. I've started to dive into the source code of dynamic.py and other Client modules to try and figure out how I can make this distinction at Dispatch-time, but it's rough going understanding everything that's going on in there. Does anyone have any pointers or a straight up solution to this problem? -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Tue Sep 16 01:06:01 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 16 Sep 2008 09:06:01 +1000 Subject: [python-win32] COM: Parameterless functions seen as properties In-Reply-To: <12A5C15467D5B94F8E0FF265D9498ADD03AC5794@orsmsx419.amr.corp.intel.com> References: <12A5C15467D5B94F8E0FF265D9498ADD03AC5794@orsmsx419.amr.corp.intel.com> Message-ID: <009601c91787$a25c94d0$e715be70$@com.au> It looks like 2 things are going on: * Your object isn't returning typelib info to Python when it asks. If your IDispatch returned something from GetTypeInfo() we could use, this wouldn't happen. * Without a typelib, Python can't tell if a reference to 'a.foo' is going to end up being a method call or not (ie, from Python's POV, a.foo() is just a property fetch for 'foo' and then calling the result.) When making a property reference, win32com checks for the ERRORS_BAD_CONTEXT values defined in win32com\client\dynamic.py - if it sees one of those errors, it assumes it really hit a method and handles it accordgingly. But - in your case, your object is succeeding! The simplest thing to do here is to have your object refuse to work as a property using one of the standard error codes, and Python will then try it as a method. Mark From: python-win32-bounces+skippy.hammond=gmail.com at python.org [mailto:python-win32-bounces+skippy.hammond=gmail.com at python.org] On Behalf Of Obendorf, Keston Sent: Tuesday, 16 September 2008 8:19 AM To: python-win32 at python.org Subject: [python-win32] COM: Parameterless functions seen as properties I'm doing COM development in both Python and C#. Things are working well, but I'm running into an issue where trying to get parameterless function returns the return value of that function, which Python then tries to call, causing an error. The C# class is an implementation of an IDL-defined interface. //IDL interface IService : IDispatch { [id(101)] HRESULT foo([out, retval] BSTR * pstr); } //C# [ComImport] [Guid("/*GUID of IService*/")] interface IService{} [ComVisible(true)] [ProgId("bar")] [Guid("Valid GUID")] public class bar : IService { public bar(){} public string foo() { return "foo"; } } Now, getting a Dispatch of "bar" in Python is where the issue lies. from win32com.client import Dispatch bar = Dispatch("bar") str = bar.foo() >>TypeError: 'unicode' object is not callable This is only a problem with the C# class. If the interface is implemented in Pythong, the above code will work. Now, this issue can be fixed by adding in _FlagAsMethod before calling bar.foo() bar._FlagAsMethod("foo") I really don't want to have to do that every time I try to call a parameterless method of a C# COM-object from Python. That's a huge headache, especially because I am trying to keep the language any one component is written in a non-issue. I've started to dive into the source code of dynamic.py and other Client modules to try and figure out how I can make this distinction at Dispatch-time, but it's rough going understanding everything that's going on in there. Does anyone have any pointers or a straight up solution to this problem? -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin.prochnow at team6-kg.de Tue Sep 16 15:10:09 2008 From: martin.prochnow at team6-kg.de (martin.prochnow at team6-kg.de) Date: Tue, 16 Sep 2008 15:10:09 +0200 Subject: [python-win32] VARIANT as byref parameter Message-ID: Hi, I'm trying to call a COM-function which first parameter is a reference to a VARIANT. The COM object that contains this function supports early-bound automation over MakePy. The corresponding C-code is: LONG lValue; lValue = plQueryNote->GetVarSize(); LPBYTE buff = new BYTE[lValue]; VARIANT varData; varData.vt = VT_BYREF; varData.byref = buff; plQueryNote->ReadVarBlock(&varData,0,lValue); I have no idea how to define the VARIANT and how to pass it as byref-style-parameter in python with win32com. I found no documentation for a problem like this in the web. It would be great if someone could help me. Regards, Martin From mkesper at fsfe.org Tue Sep 16 16:23:30 2008 From: mkesper at fsfe.org (Michael Kesper) Date: Tue, 16 Sep 2008 16:23:30 +0200 Subject: [python-win32] getting TerminalServicesProfilePath In-Reply-To: <729c89ef0809090813u7b81a29by2276994e3c8d51a4@mail.gmail.com> References: <729c89ef0809090813u7b81a29by2276994e3c8d51a4@mail.gmail.com> Message-ID: <20080916142330.GA4535@localhost> Hi, * Etienne Pouliot [2008-09-09 11:13:27 -0400]: ? > Hi, > > I'm trying to get TerminalServicesProfilePath property on user account in > my Active Directory. ... > If I use another properties instead, like DisplayName, it works. > > Any idea what I am doing wrong ? I always found it easiest to use Tim Golden's active_directory module [1] for accessing ADS. There you have the possibility to search for your object and do a dump() on it to see all attributes it provides. Best wishes Michael [1] http://tgolden.sc.sabren.com/python/active_directory.html -- Free Software Foundation Europe (FSFE) [] (http://fsfeurope.org) Join the Fellowship! [][][] (http://fsfe.org/join) Your donation powers our work! || (http://fsfeurope.org/donate) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 315 bytes Desc: Digital signature URL: From codingjester at gmail.com Tue Sep 16 16:27:00 2008 From: codingjester at gmail.com (John Bunting) Date: Tue, 16 Sep 2008 10:27:00 -0400 Subject: [python-win32] Adding an exe to startup... Message-ID: Hey everyone, I've been having some trouble finding information on how to add an exe that I have created to the startup of my windows box. I would like to know how I should go about adding the exe to the startup menu, without using the gui interface. I want to be able to automate this because I'm also going to be giving out some of this code to different users and I don't want to have to have them manually add the exe. Thank alot everyone, ~John -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Tue Sep 16 16:51:58 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 16 Sep 2008 15:51:58 +0100 Subject: [python-win32] Adding an exe to startup... In-Reply-To: References: Message-ID: <48CFC80E.2070109@timgolden.me.uk> John Bunting wrote: > I've been having some trouble finding information on how to add an exe > that I have created to the startup of my windows box. I would like to > know how I should go about adding the exe to the startup menu, without > using the gui interface. I want to be able to automate this because I'm > also going to be giving out some of this code to different users and I > don't want to have to have them manually add the exe. The startup menu is basically a folder which you can put shortcuts into in the normal way. For simplicity's sake, I recommend using (my) winshell module: http://timgolden.me.uk/python/winshell.html but it's only a very simple wrapper around the pywin32 extensions so you might prefer to roll your own. At least you can look at the source. The following code will do what you want (assuming you want Python to start up automatically!) import os, sys import winshell startup = winshell.startup () # use common=1 for all users print startup winshell.CreateShortcut ( Path=os.path.join (winshell.startup (), "Python.lnk"), Target=sys.executable, Icon=(sys.executable, 0), Description="Python" ) TJG From mkesper at fsfe.org Tue Sep 16 16:23:30 2008 From: mkesper at fsfe.org (Michael Kesper) Date: Tue, 16 Sep 2008 16:23:30 +0200 Subject: [python-win32] getting TerminalServicesProfilePath In-Reply-To: <729c89ef0809090813u7b81a29by2276994e3c8d51a4@mail.gmail.com> References: <729c89ef0809090813u7b81a29by2276994e3c8d51a4@mail.gmail.com> Message-ID: <20080916142330.GA4535@localhost> Hi, * Etienne Pouliot [2008-09-09 11:13:27 -0400]: ? > Hi, > > I'm trying to get TerminalServicesProfilePath property on user account in > my Active Directory. ... > If I use another properties instead, like DisplayName, it works. > > Any idea what I am doing wrong ? I always found it easiest to use Tim Golden's active_directory module [1] for accessing ADS. There you have the possibility to search for your object and do a dump() on it to see all attributes it provides. Best wishes Michael [1] http://tgolden.sc.sabren.com/python/active_directory.html -- Free Software Foundation Europe (FSFE) [] (http://fsfeurope.org) Join the Fellowship! [][][] (http://fsfe.org/join) Your donation powers our work! || (http://fsfeurope.org/donate) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 315 bytes Desc: Digital signature URL: From kevin.horn at gmail.com Tue Sep 16 20:40:58 2008 From: kevin.horn at gmail.com (Kevin Horn) Date: Tue, 16 Sep 2008 13:40:58 -0500 Subject: [python-win32] Adding an exe to startup... In-Reply-To: <48CFC80E.2070109@timgolden.me.uk> References: <48CFC80E.2070109@timgolden.me.uk> Message-ID: <562bcc10809161140g1a29fa97kbe2c600c927fd085@mail.gmail.com> There are a number of ways to do this: 1) add a shortcut to the "Startup start menu folder 2) add registry entries to various places like * [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] * see here for some other locations: http://www.doshelp.com/HowToView/Registry_Keys.htm 3) make it a service and set it to "Automatic" (probably more work than you want to do) 4) There are other more esoteric ways, but I think the above probably covers anything you are likely to want to do. Kevin Horn On Tue, Sep 16, 2008 at 9:51 AM, Tim Golden wrote: > John Bunting wrote: > >> I've been having some trouble finding information on how to add an exe >> that I have created to the startup of my windows box. I would like to know >> how I should go about adding the exe to the startup menu, without using the >> gui interface. I want to be able to automate this because I'm also going to >> be giving out some of this code to different users and I don't want to have >> to have them manually add the exe. >> > > > The startup menu is basically a folder which you can put > shortcuts into in the normal way. For simplicity's sake, > I recommend using (my) winshell module: > > http://timgolden.me.uk/python/winshell.html > > but it's only a very simple wrapper around the pywin32 > extensions so you might prefer to roll your own. At > least you can look at the source. The following code > will do what you want (assuming you want Python to > start up automatically!) > > > import os, sys > import winshell > > startup = winshell.startup () # use common=1 for all users > print startup > > winshell.CreateShortcut ( > Path=os.path.join (winshell.startup (), "Python.lnk"), > Target=sys.executable, > Icon=(sys.executable, 0), > Description="Python" > ) > > > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Sep 17 00:50:05 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 16 Sep 2008 15:50:05 -0700 Subject: [python-win32] VARIANT as byref parameter In-Reply-To: References: Message-ID: <48D0381D.5010907@probo.com> martin.prochnow at team6-kg.de wrote: > I'm trying to call a COM-function which first parameter is a reference to a VARIANT. The COM object that contains this function supports early-bound automation over MakePy. > > The corresponding C-code is: > > LONG lValue; > lValue = plQueryNote->GetVarSize(); > LPBYTE buff = new BYTE[lValue]; > VARIANT varData; > varData.vt = VT_BYREF; > varData.byref = buff; > plQueryNote->ReadVarBlock(&varData,0,lValue); > > I have no idea how to define the VARIANT and how to pass it as byref-style-parameter in python with win32com. I found no documentation for a problem like this in the web. It would be great if someone could help me. Is the parameter declared as [out,retval] in the type library? If so, then Python should create the variant and return it to you: varData = QueryNote.ReadVarBlock( 0, lValue ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From larry.bates at websafe.com Wed Sep 17 02:31:39 2008 From: larry.bates at websafe.com (Larry Bates) Date: Tue, 16 Sep 2008 19:31:39 -0500 Subject: [python-win32] Adding an exe to startup... In-Reply-To: References: Message-ID: John Bunting wrote: > Hey everyone, > > I've been having some trouble finding information on how to add an exe > that I have created to the startup of my windows box. I would like to > know how I should go about adding the exe to the startup menu, without > using the gui interface. I want to be able to automate this because I'm > also going to be giving out some of this code to different users and I > don't want to have to have them manually add the exe. > > Thank alot everyone, > > > ~John > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 Get Inno Setup and create installer that will do this for you. -Larry From nytrokiss at gmail.com Wed Sep 17 05:48:56 2008 From: nytrokiss at gmail.com (James Matthews) Date: Tue, 16 Sep 2008 20:48:56 -0700 Subject: [python-win32] Fwd: Modifying the system menu In-Reply-To: References: Message-ID: <8a6b8e350809162048n32ccf943i281f80b79b185402@mail.gmail.com> ---------- Forwarded message ---------- From: Date: Tue, Sep 16, 2008 at 8:31 PM Subject: Modifying the system menu To: python-list at python.org Hi all, I am trying to modify the system menu of all the applications in my machine. For example say - I am creating multiple desktops for windows - and I want to give every application the capability to be moved across different desktops. So I wanted to modify the basic system menu list to include the new options. The methods I could think of are - 1. Modify the basic windows set of system menu values (best option) or 2. Poll every few milliseconds and modify the system menu values of the active window For (1) I couldnt think of a way to do it. Is it even possible using python? For (2) I wrote the following code for basic testing: hwnd = win32gui.GetForegroundWindow() hw = win32gui.GetSystemMenu(hwnd, False) if hw != None: win32gui.AppendMenu(hw,win32con.MF_SEPARATOR,0,'-'); and it shows the following error: pywintypes.error: (1401, 'AppendMenu', 'Invalid menu handle.') If anyone could help me out in both the options (1) and/or (2), I would be very thankful. Thank you very much in advance, A python newbie -- http://mail.python.org/mailman/listinfo/python-list -- http://www.goldwatches.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From pramod.vaidyanathan at gmail.com Wed Sep 17 13:04:03 2008 From: pramod.vaidyanathan at gmail.com (Pramod Vaidyanathan) Date: Wed, 17 Sep 2008 07:04:03 -0400 Subject: [python-win32] Win32 Python Extensions Outlook.Application Question Message-ID: <54ee9f9e0809170404m456d2d64m6d66fbf0612339e1@mail.gmail.com> I've been struggling with a problem for the past couple of days. Can anyone provide me some help or insight? The problem comes down to this. I have an email that I have received in Microsoft Outlook that contains characters outside of the ascii set. I was able to use your library to traverse through my outlook folders and select the appropriate emails etc. There are characters in the email that are ascii, extended ascii, and other. Really, the characters outside of ascii are all "fraction" characters. I am trying to replace these characters with their respective floating point numbers (so I can parse the email and picking out the numbers I need etc.). The problem I am having is when I read the "item.Body" into body, the characters "\xe2\x85\x9b", "\xe2\x85\x9c", "\xe2\x85\x9d", "\xe2\x85\x9d" become unknown characters (question marks). These characters have unicode equivalents of u215b, u215c, u215d, and u215e. They are the fractions 1/8, 3/8, 5/8, 7/8 respectively. I have the same problem when I open the outlook email and "SaveAs" a text file or use the win32 interface to do that. Interestingly enough, when I copy and paste the email text into a text file and save it, I can parse the text file just fine using Python and none of the characters are lost. I get the feeling that the problem is occurring when I read the email's body with "item.Body", but I am not sure how I can read it using a different encoding scheme. I have included my code below. I would be extremely grateful if someone could provide some insight as to how I can get around this. Thanks! Pramod import codecs, win32com.client,string,re def parseEmailsWithFractions(): # Create instance of Outlook o = win32com.client.Dispatch("Outlook.Application") mapi = o.GetNamespace("MAPI") folder=mapi.Folders["Folder_NAME"] numItems=folder.Items.Count+1 SubjectNotFound=1 for i in range(1,501): item = folder.Items[numItems-i] for attribute in attributes: subject=item.Subject body=item.Body disclaimerStart=body.find("------") if subject.find("SUBJECT_TO_FIND") >=0 and SubjectNotFound: print subject EncodedBody=body.encode("utf-8") print repr(EncodedBody) #Replacing all fractional characters with decimals EncodedBody=EncodedBody.replace("\xc2\xbe",".75") EncodedBody=EncodedBody.replace("\xc2\xbc",".25") EncodedBody=EncodedBody.replace("\xc2\xbd",".5") EncodedBody=EncodedBody.replace("\xe2\x85\x9b",".125") EncodedBody=EncodedBody.replace("\xe2\x85\x9c",".375") EncodedBody=EncodedBody.replace("\xe2\x85\x9d",".625") EncodedBody=EncodedBody.replace("\xe2\x85\x9d",".875") print EncodedBody SubjectNotFound=0 parseEmailsWithFractions() -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Wed Sep 17 13:38:40 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 17 Sep 2008 12:38:40 +0100 Subject: [python-win32] Win32 Python Extensions Outlook.Application Question In-Reply-To: <54ee9f9e0809170404m456d2d64m6d66fbf0612339e1@mail.gmail.com> References: <54ee9f9e0809170404m456d2d64m6d66fbf0612339e1@mail.gmail.com> Message-ID: <48D0EC40.8010905@timgolden.me.uk> Pramod Vaidyanathan wrote: > The problem comes down to this. I have an email that I have received in > Microsoft Outlook that contains characters outside of the ascii set. I > was able to use your library to traverse through my outlook folders and > select the appropriate emails etc. There are characters in the email > that are ascii, extended ascii, and other. The problem I > am having is when I read the "item.Body" into body, the characters > "\xe2\x85\x9b", "\xe2\x85\x9c", "\xe2\x85\x9d", "\xe2\x85\x9d" become > unknown characters (question marks). These characters have unicode > equivalents of u215b, u215c, u215d, and u215e. They are the fractions > 1/8, 3/8, 5/8, 7/8 respectively. I'm not sure whether you're confused or I am. Just to clarify: the Body attribute of an Outlook MailItem is returned to Python as a unicode object. In my case (having sent myself an email containing the characters you mention) it looks like this: u'\u215b\u215c\u215d\u215e' Exactly how these chars will be output will depend on your console, locale settings etc. If you want to replace those as decimals, you can simply do this, eg: body = message.Body.replace (u"\u215b", u"0.125") You don't need to encode it to anything unless you have some other reason to do that. TJG From pramod.vaidyanathan at gmail.com Wed Sep 17 13:41:59 2008 From: pramod.vaidyanathan at gmail.com (Pramod Vaidyanathan) Date: Wed, 17 Sep 2008 07:41:59 -0400 Subject: [python-win32] Win32 Python Extensions Outlook.Application Question In-Reply-To: <48D0EC40.8010905@timgolden.me.uk> References: <54ee9f9e0809170404m456d2d64m6d66fbf0612339e1@mail.gmail.com> <48D0EC40.8010905@timgolden.me.uk> Message-ID: <54ee9f9e0809170441m2cc988cai11359cad83b7c9f9@mail.gmail.com> Thanks for your quick reply. I'm probably confused. I'll give that a try. On Wed, Sep 17, 2008 at 7:38 AM, Tim Golden wrote: > Pramod Vaidyanathan wrote: > >> The problem comes down to this. I have an email that I have received in >> Microsoft Outlook that contains characters outside of the ascii set. I was >> able to use your library to traverse through my outlook folders and select >> the appropriate emails etc. There are characters in the email that are >> ascii, extended ascii, and other. The problem I am having is when I read >> the "item.Body" into body, the characters "\xe2\x85\x9b", "\xe2\x85\x9c", >> "\xe2\x85\x9d", "\xe2\x85\x9d" become unknown characters (question marks). >> These characters have unicode equivalents of u215b, u215c, u215d, and >> u215e. They are the fractions 1/8, 3/8, 5/8, 7/8 respectively. >> > > I'm not sure whether you're confused or I am. > Just to clarify: the Body attribute of an Outlook > MailItem is returned to Python as a unicode object. > > In my case (having sent myself an email containing the > characters you mention) it looks like this: > > u'\u215b\u215c\u215d\u215e' > > Exactly how these chars will be output will depend on your > console, locale settings etc. If you want to replace > those as decimals, you can simply do this, eg: > > body = message.Body.replace (u"\u215b", u"0.125") > > You don't need to encode it to anything unless > you have some other reason to do that. > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Wed Sep 17 15:58:36 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 17 Sep 2008 14:58:36 +0100 Subject: [python-win32] Win32 Python Extensions Outlook.ApplicationQuestion In-Reply-To: <1FD8FD0C19027145B941FAB2BC40C7B30259362C@extxmb17.nam.nsroot.net> References: <54ee9f9e0809170404m456d2d64m6d66fbf0612339e1@mail.gmail.com> <48D0EC40.8010905@timgolden.me.uk> <1FD8FD0C19027145B941FAB2BC40C7B302593624@extxmb17.nam.nsroot.net> <48D10511.4060503@timgolden.me.uk> <1FD8FD0C19027145B941FAB2BC40C7B30259362C@extxmb17.nam.nsroot.net> Message-ID: <48D10D0C.3020109@timgolden.me.uk> Vaidyanathan, Pramod wrote: > Thanks Tim, > > Unfortunately my resutls are still as follows. I still have question > mark characters. Is it possibly a microsoft outlook versioning issue? > > u' \xbe \xbc \xbd \xbd \xbd \xbd\r\n\xbe \xbc \xbd \xbd \xbd \xbd > \xbd\r\n\xbe \xbc\r\n\xbe \xbc > \r\n > \r\n? \r\n? \xbd ? \xbe\r\n' Must admit I'm mystified, if that's the result of running the code I gave. You're clearly getting a unicode object, so the only reason there should be question mark characters in there would be if the text contained question mark characters. You haven't done any kind of encoding for unknown-replacement to occur. To confirm: that output above is the result of doing: print repr (message.Body) Anyone else got any ideas? TJG From mail at timgolden.me.uk Wed Sep 17 16:22:58 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 17 Sep 2008 15:22:58 +0100 Subject: [python-win32] Win32 Python ExtensionsOutlook.ApplicationQuestion In-Reply-To: <1FD8FD0C19027145B941FAB2BC40C7B302593632@extxmb17.nam.nsroot.net> References: <54ee9f9e0809170404m456d2d64m6d66fbf0612339e1@mail.gmail.com> <48D0EC40.8010905@timgolden.me.uk> <1FD8FD0C19027145B941FAB2BC40C7B302593624@extxmb17.nam.nsroot.net> <48D10511.4060503@timgolden.me.uk><1FD8FD0C19027145B941FAB2BC40C7B30259362C@extxmb17.nam.nsroot.net> <48D10D0C.3020109@timgolden.me.uk> <1FD8FD0C19027145B941FAB2BC40C7B302593632@extxmb17.nam.nsroot.net> Message-ID: <48D112C2.5020208@timgolden.me.uk> Vaidyanathan, Pramod wrote: > Yes, > > Print repr (message.Body) > > I am using Microsoft Outlook (2000). Are you using outlook 2003 by > chance? Yep. > I just discovered that when I do the exact same thing in Outlook 2003, > the problem disappears. I believe it's some sort of settings issue in my > version of Outlook 2000. You wouldn't know what that might be would > you? If not, I'm sure I can dig it up by comparing. I don't know of anything, I'm afraid. > Thanks again for all of your help - turned out to be something stupid as > it often is. Glad to be of help. And thanks for keeping the list updated; it often helps when trawling the archives looking for similar problems to one's own. TJG From timr at probo.com Wed Sep 17 20:07:34 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 17 Sep 2008 11:07:34 -0700 Subject: [python-win32] Fwd: Modifying the system menu In-Reply-To: <8a6b8e350809162048n32ccf943i281f80b79b185402@mail.gmail.com> References: <8a6b8e350809162048n32ccf943i281f80b79b185402@mail.gmail.com> Message-ID: <48D14766.6050203@probo.com> James Matthews wrote: > > Hi all, > I am trying to modify the system menu of all the applications in > my machine. > For example say - I am creating multiple desktops for windows - > and I want to give every application the capability to be moved across > different desktops. So I wanted to modify the basic system menu list > to include the new options. > > The methods I could think of are - > 1. Modify the basic windows set of system menu values (best option) There is no central repository where this is stored, so there's no place to change. > 2. Poll every few milliseconds and modify the system menu values of > the active window Ick Windows don't come and go that often, and you only need to do this once for each application. The correct option is (3) install a Windows hook to watch for new application to activate, and modify the menu in the hook. You will have to use a hook in order to catch the menu item being chosen anyway. There are Python modules to handle some kinds of hooks, but overall this would be much easier in C. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Sep 17 20:43:36 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 17 Sep 2008 11:43:36 -0700 Subject: [python-win32] VARIANT as byref parameter In-Reply-To: References: Message-ID: <48D14FD8.8050207@probo.com> martin.prochnow at team6-kg.de wrote: > > > Is the parameter declared as [out,retval] in the type library? > > This is how the function is declared in the file that MakePy has > generated: > > def ReadVarBlock(self, pbBuff=defaultNamedNotOptArg, > dwOffset=defaultNamedNotOptArg, dwLen=defaultNamedNotOptArg): > return self._oleobj_.InvokeTypes(58, LCID, 1, (3, 0), ((16396, 0), > (3, 0), (3, 0)),pbBuff > , dwOffset, dwLen) > > > If so, then Python should create the variant and return it to you: > > varData = QueryNote.ReadVarBlock( 0, lValue ) > > This line produces a type mismatch error. > Well, that implies that the buffer is an in/out variant, not an output. I'm not sure how to construct a buffer Pythoncom will correctly translate in this instance. Mark, maybe? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From alecmunro at gmail.com Wed Sep 17 21:10:51 2008 From: alecmunro at gmail.com (Alec Munro) Date: Wed, 17 Sep 2008 16:10:51 -0300 Subject: [python-win32] Accessing other interfaces of a Dispatch created COM object In-Reply-To: <9819d58b0809121028w46cf0267l3c517a33289ea595@mail.gmail.com> References: <9819d58b0808280556g46cbd1cbj85f32cc82987615a@mail.gmail.com> <9819d58b0808291047j3de5e9d8u7647b05e49a53f97@mail.gmail.com> <9819d58b0809020944v488ab4a2n5127c71e7c69424b@mail.gmail.com> <9819d58b0809101222m77c0648dh6e0752fc83a75ec2@mail.gmail.com> <48C82728.8060206@probo.com> <9819d58b0809101523u5811d094kfb01109987e9491d@mail.gmail.com> <057d01c913a1$4e80dc20$eb829460$@com.au> <9819d58b0809101835h1a581fpb67305217b39a40f@mail.gmail.com> <9819d58b0809120949v217de44bn8c71ac792dec70fa@mail.gmail.com> <9819d58b0809121028w46cf0267l3c517a33289ea595@mail.gmail.com> Message-ID: <9819d58b0809171210h159b3402t654bd3e011e4bb@mail.gmail.com> I'm back. I've taken a crack at rewriting the DLL to export the methods I need through IDispatch. Unfortunately, what I discovered (and I'm probably describing this in the wrong way), is that the class is declared ATL_NO_VTABLE, and as far as I can tell, the third-party app relies on the interfaces being exported through IDispatch. This means that the methods suggested here won't work: http://www.sellsbrothers.com/tools/multidisp/ Or at least the first two. So I'm back to trying to figure out what might be going wrong in my attempts to access the current implementation through Python. I wonder, is there any way to log IDispatch operations? If so, that might tell me what the third-party operation was doing differently. I would be happy to hear any other suggestions. Thanks, Alec On Fri, Sep 12, 2008 at 2:28 PM, Alec Munro wrote: > (I just noticed my last two responses only went to Mark. They were > intended for the Mailing List and Tim as well. Sorry for the > oversight.) > > So I just ran some tests, fruitlessly. Here is what I did: > > - Removed all gen_py stuff > - Set registry entries for both interfaces to point to the BASICUHI typelib. > - Restarted > - Use Make_py on BASICUHI typelib > > X: Same error > > - Use Make_py for other typelib > > X: Same error > > - Removed all gen_py stuff > - Set registry entries for both interfaces to point to other typelib. > - Restarted > - Use Make_py for other typelib > > X: Same error > > - Use Make_py for BASICUHI typelib > > X: Same error > > What I'm wondering at this point is how I determine what Library it is > that isn't registered. That might yield some clues, but right now I'm > pretty much out of ideas, and toying seriously with the idea of > rewriting the dll to allow it to export the interfaces I need through > IDispatch. > > Thanks again for your time, > > Alec > > > On Fri, Sep 12, 2008 at 1:49 PM, Alec Munro wrote: >> Hi Mark, >> >> Ok, with my first object, everything works as you demonstrated. With >> my second object (the first one CastTo(,I2)), I get the "Library not >> Registered" message when I call GetTypeInfo(), which I guess is what >> you were expecting. >> >> As far as Tim's question goes, I looked up the ID for the BasicUHI >> typelib in the registry, and the path there does indeed point to the >> BasicUHI file. >> >> I've got some ideas for things I can test, for the moment, but if you >> have any ideas or additional information, I would love to hear it. >> >> Thanks again! >> >> Alec >> >> >> On Wed, Sep 10, 2008 at 10:35 PM, Alec Munro wrote: >>> Thanks Mark, Tim! >>> >>> Lots of excellent information there for someone as COM-confused as I am. :) >>> >>> I'll try out your suggestions tomorrow, to see what I find, but for >>> now, here's a little more information on our situation. >>> >>> We use a third-party solution for testing our products. This solution >>> requires us to create a COM dll with a class implementing specific >>> interfaces (at least I1, any others are optional). The third party >>> defines the interfaces, we just provide implementations for them. The >>> third party provides us with their testing solution itself, as well as >>> an SDK for developing the dll. >>> >>> In order to use the dll, we do register it manually using regsvr32. >>> Any other registrations I would assume are performed by the installers >>> from the third party. >>> >>> We've been using this for several years now (I only took over >>> maintenance on the project 6 months ago), but this is the first time >>> we are trying to access the dll ourselves, so it's fairly new >>> territory. >>> >>> Hopefully that makes sense, thanks again, >>> >>> Alec >>> >>> On Wed, Sep 10, 2008 at 8:59 PM, Mark Hammond wrote: >>>> I'm still a little lost too, but: >>>> >>>>> * I maintain a dll that defines a class that implements I1 and I2. I >>>>> use regsvr to register this dll. >>>>> * I1 and I2 come from a third party, and in order for my dll to work >>>>> properly, it has to implement them (actually I2 is optional). >>>>> * I don't know how I1 and I2 are registered. >>>> >>>> I don't understand the above. If you maintain the class that implements I1 >>>> and I2 how can: >>>> >>>> * they come from a 3rd party - either you maintain them, or they do? >>>> * Surely you know how they are registered? >>>> >>>> >>>>> I do know that if I use >>>>> the COM browser, I can go to Registered Type Libraries, find one with >>>>> the typelibname that is associated with my CastTo created objects, >>>>> which has "Type Library" underneath it, and underneath that are >>>>> entries for I1, I2, several related interfaces, and a variety of >>>>> coclasses. Like this: >>>>> - TypeLibName 1.0 TypeLibrary >>>>> -- IID: {00..00} >>>>> -- Type Library >>>>> --- I1 - Dispatch >>>>> --- I2 - Dispatch >>>>> --- IX - Dispatch >>>>> --- CX - CoClass >>>>> >>>>> I've just spent some time hunting through the registry to determine >>>>> the differences between I1 and I2. >>>> >>>> What I'm guessing is that the GetTypeInfo() and GetTypeLib() calls for the >>>> other dispatch object are failing. Below is how we expect things to work, >>>> demonstratrated using for Internet Explorer: >>>> >>>>>>> from win32com.client import Dispatch >>>>>>> d=Dispatch("InternetExplorer.Application") >>>>>>> d=d._oleobj_ >>>>>>> d.GetTypeInfoCount() >>>> 1 >>>>>>> d.GetTypeInfo(0) >>>> >>>>>>> i=d.GetTypeInfo(0) >>>>>>> tlb, index=i.GetContainingTypeLib() >>>>>>> tlb.GetLibAttr() >>>> (IID('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}'), 0, 1, 1, 1, 8) >>>>>>> >>>> >>>> Which is the GUID, version, locale etc information (a TLIBATTR structure) >>>> for the typelib, and you will find this in the registry. It sounds like >>>> this works for one of your objects and fails for the other (well - "fails" >>>> might mean that the call works, but returns a GID and version info for a >>>> typelib that isn't registered - ie, attempting to load that typelib would >>>> fail.) ie, you would also need the following to work: >>>> >>>>>>> guid, lcid, syskind, majver, minver, flags = tlb.GetLibAttr() >>>>>>> import pythoncom >>>>>>> pythoncom.LoadRegTypeLib(guid, majver, minver, lcid) >>>> >>>>>>> _.GetDocumentation(1) >>>> (u'DWebBrowserEvents', u'Web Browser Control Events (old)', 0, None) >>>>>>> >>>> >>>> Hope this helps, >>>> >>>> Mark >>>> >>>> >>> >> > From alecmunro at gmail.com Wed Sep 17 21:28:55 2008 From: alecmunro at gmail.com (Alec Munro) Date: Wed, 17 Sep 2008 16:28:55 -0300 Subject: [python-win32] Accessing other interfaces of a Dispatch created COM object In-Reply-To: <9819d58b0809171210h159b3402t654bd3e011e4bb@mail.gmail.com> References: <9819d58b0808280556g46cbd1cbj85f32cc82987615a@mail.gmail.com> <9819d58b0809020944v488ab4a2n5127c71e7c69424b@mail.gmail.com> <9819d58b0809101222m77c0648dh6e0752fc83a75ec2@mail.gmail.com> <48C82728.8060206@probo.com> <9819d58b0809101523u5811d094kfb01109987e9491d@mail.gmail.com> <057d01c913a1$4e80dc20$eb829460$@com.au> <9819d58b0809101835h1a581fpb67305217b39a40f@mail.gmail.com> <9819d58b0809120949v217de44bn8c71ac792dec70fa@mail.gmail.com> <9819d58b0809121028w46cf0267l3c517a33289ea595@mail.gmail.com> <9819d58b0809171210h159b3402t654bd3e011e4bb@mail.gmail.com> Message-ID: <9819d58b0809171228m5f71c45fld2b8a62dec388d03@mail.gmail.com> If you hear a loud slapping sound, that's my hand and forehead. :) I just recalled that the third-party gives us a test application that uses the COM component. Including source. It's in C#, which is new to me, but looks pretty straightforward. I'm going to figure out how they do, then see if I can do the same thing through Python. Sorry I didn't think of this sooner. Alec On Wed, Sep 17, 2008 at 4:10 PM, Alec Munro wrote: > I'm back. > > I've taken a crack at rewriting the DLL to export the methods I need > through IDispatch. Unfortunately, what I discovered (and I'm probably > describing this in the wrong way), is that the class is declared > ATL_NO_VTABLE, and as far as I can tell, the third-party app relies on > the interfaces being exported through IDispatch. This means that the > methods suggested here won't work: > > http://www.sellsbrothers.com/tools/multidisp/ > > Or at least the first two. > > So I'm back to trying to figure out what might be going wrong in my > attempts to access the current implementation through Python. > > I wonder, is there any way to log IDispatch operations? If so, that > might tell me what the third-party operation was doing differently. > > I would be happy to hear any other suggestions. > > Thanks, > > Alec > > On Fri, Sep 12, 2008 at 2:28 PM, Alec Munro wrote: >> (I just noticed my last two responses only went to Mark. They were >> intended for the Mailing List and Tim as well. Sorry for the >> oversight.) >> >> So I just ran some tests, fruitlessly. Here is what I did: >> >> - Removed all gen_py stuff >> - Set registry entries for both interfaces to point to the BASICUHI typelib. >> - Restarted >> - Use Make_py on BASICUHI typelib >> >> X: Same error >> >> - Use Make_py for other typelib >> >> X: Same error >> >> - Removed all gen_py stuff >> - Set registry entries for both interfaces to point to other typelib. >> - Restarted >> - Use Make_py for other typelib >> >> X: Same error >> >> - Use Make_py for BASICUHI typelib >> >> X: Same error >> >> What I'm wondering at this point is how I determine what Library it is >> that isn't registered. That might yield some clues, but right now I'm >> pretty much out of ideas, and toying seriously with the idea of >> rewriting the dll to allow it to export the interfaces I need through >> IDispatch. >> >> Thanks again for your time, >> >> Alec >> >> >> On Fri, Sep 12, 2008 at 1:49 PM, Alec Munro wrote: >>> Hi Mark, >>> >>> Ok, with my first object, everything works as you demonstrated. With >>> my second object (the first one CastTo(,I2)), I get the "Library not >>> Registered" message when I call GetTypeInfo(), which I guess is what >>> you were expecting. >>> >>> As far as Tim's question goes, I looked up the ID for the BasicUHI >>> typelib in the registry, and the path there does indeed point to the >>> BasicUHI file. >>> >>> I've got some ideas for things I can test, for the moment, but if you >>> have any ideas or additional information, I would love to hear it. >>> >>> Thanks again! >>> >>> Alec >>> >>> >>> On Wed, Sep 10, 2008 at 10:35 PM, Alec Munro wrote: >>>> Thanks Mark, Tim! >>>> >>>> Lots of excellent information there for someone as COM-confused as I am. :) >>>> >>>> I'll try out your suggestions tomorrow, to see what I find, but for >>>> now, here's a little more information on our situation. >>>> >>>> We use a third-party solution for testing our products. This solution >>>> requires us to create a COM dll with a class implementing specific >>>> interfaces (at least I1, any others are optional). The third party >>>> defines the interfaces, we just provide implementations for them. The >>>> third party provides us with their testing solution itself, as well as >>>> an SDK for developing the dll. >>>> >>>> In order to use the dll, we do register it manually using regsvr32. >>>> Any other registrations I would assume are performed by the installers >>>> from the third party. >>>> >>>> We've been using this for several years now (I only took over >>>> maintenance on the project 6 months ago), but this is the first time >>>> we are trying to access the dll ourselves, so it's fairly new >>>> territory. >>>> >>>> Hopefully that makes sense, thanks again, >>>> >>>> Alec >>>> >>>> On Wed, Sep 10, 2008 at 8:59 PM, Mark Hammond wrote: >>>>> I'm still a little lost too, but: >>>>> >>>>>> * I maintain a dll that defines a class that implements I1 and I2. I >>>>>> use regsvr to register this dll. >>>>>> * I1 and I2 come from a third party, and in order for my dll to work >>>>>> properly, it has to implement them (actually I2 is optional). >>>>>> * I don't know how I1 and I2 are registered. >>>>> >>>>> I don't understand the above. If you maintain the class that implements I1 >>>>> and I2 how can: >>>>> >>>>> * they come from a 3rd party - either you maintain them, or they do? >>>>> * Surely you know how they are registered? >>>>> >>>>> >>>>>> I do know that if I use >>>>>> the COM browser, I can go to Registered Type Libraries, find one with >>>>>> the typelibname that is associated with my CastTo created objects, >>>>>> which has "Type Library" underneath it, and underneath that are >>>>>> entries for I1, I2, several related interfaces, and a variety of >>>>>> coclasses. Like this: >>>>>> - TypeLibName 1.0 TypeLibrary >>>>>> -- IID: {00..00} >>>>>> -- Type Library >>>>>> --- I1 - Dispatch >>>>>> --- I2 - Dispatch >>>>>> --- IX - Dispatch >>>>>> --- CX - CoClass >>>>>> >>>>>> I've just spent some time hunting through the registry to determine >>>>>> the differences between I1 and I2. >>>>> >>>>> What I'm guessing is that the GetTypeInfo() and GetTypeLib() calls for the >>>>> other dispatch object are failing. Below is how we expect things to work, >>>>> demonstratrated using for Internet Explorer: >>>>> >>>>>>>> from win32com.client import Dispatch >>>>>>>> d=Dispatch("InternetExplorer.Application") >>>>>>>> d=d._oleobj_ >>>>>>>> d.GetTypeInfoCount() >>>>> 1 >>>>>>>> d.GetTypeInfo(0) >>>>> >>>>>>>> i=d.GetTypeInfo(0) >>>>>>>> tlb, index=i.GetContainingTypeLib() >>>>>>>> tlb.GetLibAttr() >>>>> (IID('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}'), 0, 1, 1, 1, 8) >>>>>>>> >>>>> >>>>> Which is the GUID, version, locale etc information (a TLIBATTR structure) >>>>> for the typelib, and you will find this in the registry. It sounds like >>>>> this works for one of your objects and fails for the other (well - "fails" >>>>> might mean that the call works, but returns a GID and version info for a >>>>> typelib that isn't registered - ie, attempting to load that typelib would >>>>> fail.) ie, you would also need the following to work: >>>>> >>>>>>>> guid, lcid, syskind, majver, minver, flags = tlb.GetLibAttr() >>>>>>>> import pythoncom >>>>>>>> pythoncom.LoadRegTypeLib(guid, majver, minver, lcid) >>>>> >>>>>>>> _.GetDocumentation(1) >>>>> (u'DWebBrowserEvents', u'Web Browser Control Events (old)', 0, None) >>>>>>>> >>>>> >>>>> Hope this helps, >>>>> >>>>> Mark >>>>> >>>>> >>>> >>> >> > From alecmunro at gmail.com Wed Sep 17 21:54:30 2008 From: alecmunro at gmail.com (Alec Munro) Date: Wed, 17 Sep 2008 16:54:30 -0300 Subject: [python-win32] Accessing other interfaces of a Dispatch created COM object In-Reply-To: <9819d58b0809171228m5f71c45fld2b8a62dec388d03@mail.gmail.com> References: <9819d58b0808280556g46cbd1cbj85f32cc82987615a@mail.gmail.com> <9819d58b0809101222m77c0648dh6e0752fc83a75ec2@mail.gmail.com> <48C82728.8060206@probo.com> <9819d58b0809101523u5811d094kfb01109987e9491d@mail.gmail.com> <057d01c913a1$4e80dc20$eb829460$@com.au> <9819d58b0809101835h1a581fpb67305217b39a40f@mail.gmail.com> <9819d58b0809120949v217de44bn8c71ac792dec70fa@mail.gmail.com> <9819d58b0809121028w46cf0267l3c517a33289ea595@mail.gmail.com> <9819d58b0809171210h159b3402t654bd3e011e4bb@mail.gmail.com> <9819d58b0809171228m5f71c45fld2b8a62dec388d03@mail.gmail.com> Message-ID: <9819d58b0809171254n1c59cac0tc0c7a0dd45f266a2@mail.gmail.com> I've taken a look, and I can't say I had an "aha" moment, or anything like that, but perhaps I have learned something important. Setting up the COM object seems very straightforward: Type t = Type.GetTypeFromCLSID("{e04f970b-53ce-420a-86f8-55374677703d}") component = (basic.I1)Activator.CreateInstance(t) component_2 = component as I2 The ID referenced there is the ID of the coclass in the COM DLL. I've looked into where it gets "basic" from, and the important property seems to be: Identity: {35F40DBC-6CB3-4EEC-843B-57BB52CA2A93}\1.0\0\tlbimp This ID is the CLSID of the Type Library in _basicUHI.tlb I'll see if I can reproduce this exactly in Python, and if I get any different results. Alec On Wed, Sep 17, 2008 at 4:28 PM, Alec Munro wrote: > If you hear a loud slapping sound, that's my hand and forehead. :) > > I just recalled that the third-party gives us a test application that > uses the COM component. Including source. > > It's in C#, which is new to me, but looks pretty straightforward. I'm > going to figure out how they do, then see if I can do the same thing > through Python. > > Sorry I didn't think of this sooner. > > Alec > > On Wed, Sep 17, 2008 at 4:10 PM, Alec Munro wrote: >> I'm back. >> >> I've taken a crack at rewriting the DLL to export the methods I need >> through IDispatch. Unfortunately, what I discovered (and I'm probably >> describing this in the wrong way), is that the class is declared >> ATL_NO_VTABLE, and as far as I can tell, the third-party app relies on >> the interfaces being exported through IDispatch. This means that the >> methods suggested here won't work: >> >> http://www.sellsbrothers.com/tools/multidisp/ >> >> Or at least the first two. >> >> So I'm back to trying to figure out what might be going wrong in my >> attempts to access the current implementation through Python. >> >> I wonder, is there any way to log IDispatch operations? If so, that >> might tell me what the third-party operation was doing differently. >> >> I would be happy to hear any other suggestions. >> >> Thanks, >> >> Alec >> >> On Fri, Sep 12, 2008 at 2:28 PM, Alec Munro wrote: >>> (I just noticed my last two responses only went to Mark. They were >>> intended for the Mailing List and Tim as well. Sorry for the >>> oversight.) >>> >>> So I just ran some tests, fruitlessly. Here is what I did: >>> >>> - Removed all gen_py stuff >>> - Set registry entries for both interfaces to point to the BASICUHI typelib. >>> - Restarted >>> - Use Make_py on BASICUHI typelib >>> >>> X: Same error >>> >>> - Use Make_py for other typelib >>> >>> X: Same error >>> >>> - Removed all gen_py stuff >>> - Set registry entries for both interfaces to point to other typelib. >>> - Restarted >>> - Use Make_py for other typelib >>> >>> X: Same error >>> >>> - Use Make_py for BASICUHI typelib >>> >>> X: Same error >>> >>> What I'm wondering at this point is how I determine what Library it is >>> that isn't registered. That might yield some clues, but right now I'm >>> pretty much out of ideas, and toying seriously with the idea of >>> rewriting the dll to allow it to export the interfaces I need through >>> IDispatch. >>> >>> Thanks again for your time, >>> >>> Alec >>> >>> >>> On Fri, Sep 12, 2008 at 1:49 PM, Alec Munro wrote: >>>> Hi Mark, >>>> >>>> Ok, with my first object, everything works as you demonstrated. With >>>> my second object (the first one CastTo(,I2)), I get the "Library not >>>> Registered" message when I call GetTypeInfo(), which I guess is what >>>> you were expecting. >>>> >>>> As far as Tim's question goes, I looked up the ID for the BasicUHI >>>> typelib in the registry, and the path there does indeed point to the >>>> BasicUHI file. >>>> >>>> I've got some ideas for things I can test, for the moment, but if you >>>> have any ideas or additional information, I would love to hear it. >>>> >>>> Thanks again! >>>> >>>> Alec >>>> >>>> >>>> On Wed, Sep 10, 2008 at 10:35 PM, Alec Munro wrote: >>>>> Thanks Mark, Tim! >>>>> >>>>> Lots of excellent information there for someone as COM-confused as I am. :) >>>>> >>>>> I'll try out your suggestions tomorrow, to see what I find, but for >>>>> now, here's a little more information on our situation. >>>>> >>>>> We use a third-party solution for testing our products. This solution >>>>> requires us to create a COM dll with a class implementing specific >>>>> interfaces (at least I1, any others are optional). The third party >>>>> defines the interfaces, we just provide implementations for them. The >>>>> third party provides us with their testing solution itself, as well as >>>>> an SDK for developing the dll. >>>>> >>>>> In order to use the dll, we do register it manually using regsvr32. >>>>> Any other registrations I would assume are performed by the installers >>>>> from the third party. >>>>> >>>>> We've been using this for several years now (I only took over >>>>> maintenance on the project 6 months ago), but this is the first time >>>>> we are trying to access the dll ourselves, so it's fairly new >>>>> territory. >>>>> >>>>> Hopefully that makes sense, thanks again, >>>>> >>>>> Alec >>>>> >>>>> On Wed, Sep 10, 2008 at 8:59 PM, Mark Hammond wrote: >>>>>> I'm still a little lost too, but: >>>>>> >>>>>>> * I maintain a dll that defines a class that implements I1 and I2. I >>>>>>> use regsvr to register this dll. >>>>>>> * I1 and I2 come from a third party, and in order for my dll to work >>>>>>> properly, it has to implement them (actually I2 is optional). >>>>>>> * I don't know how I1 and I2 are registered. >>>>>> >>>>>> I don't understand the above. If you maintain the class that implements I1 >>>>>> and I2 how can: >>>>>> >>>>>> * they come from a 3rd party - either you maintain them, or they do? >>>>>> * Surely you know how they are registered? >>>>>> >>>>>> >>>>>>> I do know that if I use >>>>>>> the COM browser, I can go to Registered Type Libraries, find one with >>>>>>> the typelibname that is associated with my CastTo created objects, >>>>>>> which has "Type Library" underneath it, and underneath that are >>>>>>> entries for I1, I2, several related interfaces, and a variety of >>>>>>> coclasses. Like this: >>>>>>> - TypeLibName 1.0 TypeLibrary >>>>>>> -- IID: {00..00} >>>>>>> -- Type Library >>>>>>> --- I1 - Dispatch >>>>>>> --- I2 - Dispatch >>>>>>> --- IX - Dispatch >>>>>>> --- CX - CoClass >>>>>>> >>>>>>> I've just spent some time hunting through the registry to determine >>>>>>> the differences between I1 and I2. >>>>>> >>>>>> What I'm guessing is that the GetTypeInfo() and GetTypeLib() calls for the >>>>>> other dispatch object are failing. Below is how we expect things to work, >>>>>> demonstratrated using for Internet Explorer: >>>>>> >>>>>>>>> from win32com.client import Dispatch >>>>>>>>> d=Dispatch("InternetExplorer.Application") >>>>>>>>> d=d._oleobj_ >>>>>>>>> d.GetTypeInfoCount() >>>>>> 1 >>>>>>>>> d.GetTypeInfo(0) >>>>>> >>>>>>>>> i=d.GetTypeInfo(0) >>>>>>>>> tlb, index=i.GetContainingTypeLib() >>>>>>>>> tlb.GetLibAttr() >>>>>> (IID('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}'), 0, 1, 1, 1, 8) >>>>>>>>> >>>>>> >>>>>> Which is the GUID, version, locale etc information (a TLIBATTR structure) >>>>>> for the typelib, and you will find this in the registry. It sounds like >>>>>> this works for one of your objects and fails for the other (well - "fails" >>>>>> might mean that the call works, but returns a GID and version info for a >>>>>> typelib that isn't registered - ie, attempting to load that typelib would >>>>>> fail.) ie, you would also need the following to work: >>>>>> >>>>>>>>> guid, lcid, syskind, majver, minver, flags = tlb.GetLibAttr() >>>>>>>>> import pythoncom >>>>>>>>> pythoncom.LoadRegTypeLib(guid, majver, minver, lcid) >>>>>> >>>>>>>>> _.GetDocumentation(1) >>>>>> (u'DWebBrowserEvents', u'Web Browser Control Events (old)', 0, None) >>>>>>>>> >>>>>> >>>>>> Hope this helps, >>>>>> >>>>>> Mark >>>>>> >>>>>> >>>>> >>>> >>> >> > From mhammond at skippinet.com.au Thu Sep 18 02:14:51 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 18 Sep 2008 10:14:51 +1000 Subject: [python-win32] VARIANT as byref parameter In-Reply-To: <48D14FD8.8050207@probo.com> References: <48D14FD8.8050207@probo.com> Message-ID: <01d101c91923$9591a630$c0b4f290$@com.au> > Well, that implies that the buffer is an in/out variant, not an output. > I'm not sure how to construct a buffer Pythoncom will correctly > translate in this instance. Mark, maybe? I'm not sure - but I'm not even sure it is legal automation to do that: > LONG lValue; > lValue = plQueryNote->GetVarSize(); > LPBYTE buff = new BYTE[lValue]; > VARIANT varData; > varData.vt = VT_BYREF; > varData.byref = buff; > plQueryNote->ReadVarBlock(&varData,0,lValue); Isn't VT_BYREF a modifier? It looks to me like the variant in this snippet isn't legal. What I'd really like to see is an example in VBScript/VB or any other IDispatch aware language that isn't c++ ;) Cheers, MArk From mhammond at skippinet.com.au Thu Sep 18 02:35:03 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 18 Sep 2008 10:35:03 +1000 Subject: [python-win32] Win32 Python ExtensionsOutlook.ApplicationQuestion In-Reply-To: <48D112C2.5020208@timgolden.me.uk> References: <54ee9f9e0809170404m456d2d64m6d66fbf0612339e1@mail.gmail.com> <48D0EC40.8010905@timgolden.me.uk> <1FD8FD0C19027145B941FAB2BC40C7B302593624@extxmb17.nam.nsroot.net> <48D10511.4060503@timgolden.me.uk><1FD8FD0C19027145B941FAB2BC40C7B30259362C@extxmb17.nam.nsroot.net> <48D10D0C.3020109@timgolden.me.uk> <1FD8FD0C19027145B941FAB2BC40C7B302593632@extxmb17.nam.nsroot.net> <48D112C2.5020208@timgolden.me.uk> Message-ID: <01ef01c91926$669963b0$33cc2b10$@com.au> > > I just discovered that when I do the exact same thing in Outlook > > 2003, > > the problem disappears. I believe it's some sort of settings issue in > > my > > version of Outlook 2000. You wouldn't know what that might be would > > you? If not, I'm sure I can dig it up by comparing. I'm guessing it is simply a bug on Outlook 2000 that caused the data to internally round-trip via an encoding and decoding. I'd be very surprised if there was a setting to cause this behaviour (otoh, I've been very surprised before :) FWIW, note that for the spambayes project, we used the (more painful) low-level MAPI interfaces directly and didn't strike this problem - so the bug is probably in the simple MAPI layer. Cheers, Mark From keston.obendorf at intel.com Thu Sep 18 02:07:43 2008 From: keston.obendorf at intel.com (Obendorf, Keston) Date: Wed, 17 Sep 2008 17:07:43 -0700 Subject: [python-win32] COM: Parameterless functions seen as properties In-Reply-To: <009601c91787$a25c94d0$e715be70$@com.au> References: <12A5C15467D5B94F8E0FF265D9498ADD03AC5794@orsmsx419.amr.corp.intel.com> <009601c91787$a25c94d0$e715be70$@com.au> Message-ID: <12A5C15467D5B94F8E0FF265D9498ADD03B2C1F1@orsmsx419.amr.corp.intel.com> Thanks. I don't think the issue is that GetTypeInfo() is not returning anything, but it's returning something that cannot be used properly. I wrote another implementation of the parameterless function, this time in C++. The implementation in C++ works just fine: retStr = Dispatch("c++implementation").getNLType() --causes no exceptions and works as intended. I've been stepping through the CDispatch creation process, which on the account of both C# and C++ implementations seems to go OK. In both run-throughs, dynamic is able to get both typeinfo and typecomp. I judge that this happens because in both cases the _olerepr_ of the CDispatch object is a LazyDispatchItem not DispatchItem, which only happens if both typeinfo and typecomp are defined. The implementations diverge, however, in _getattr_, specifically when calling __LazyMap__. The C++ implementation returns a 1, whereas the C# implementation returns None. This is due to the fact that in _LazyAddAttr_ , typecomp.Bind returns (0, None) for all invoke types for the C# implementation whereas the C++ implementation binds to INVOKE_FUNC. (This leads me to conclude that the typecomp for the C# implementation is bad in some way. That is probably more an issue for a C# mailing list. I don't think it's Python's fault.) _getattr_ allows recovery from this issue with a last ditch effort, which you reference in your post as the second thing that could be going on. Unfortunately, it sets the invoke type by default to pythoncom.INVOKE_PROPERTYGET. C# does not seem to care that its function is not a property, and returns an evaluation of the function rather than throwing an exception. I don't know if there is a way to prevent this behavior. I feel like there's not much information in this posting for all its words. =( I figured out HOW it is failing, but not exactly WHY. It looks like this is a problem in the way C# handles IDispatch and ITypeInfo. P.S. I am new to this whole mailing-list thing, so I don't know exactly what e-mail addresses to send this post to. Let's hope it winds up in the right place. Thanks, Keston ________________________________ From: Mark Hammond [mailto:skippy.hammond at gmail.com] On Behalf Of Mark Hammond Sent: Monday, September 15, 2008 4:06 PM To: Obendorf, Keston; python-win32 at python.org Subject: RE: [python-win32] COM: Parameterless functions seen as properties It looks like 2 things are going on: * Your object isn't returning typelib info to Python when it asks. If your IDispatch returned something from GetTypeInfo() we could use, this wouldn't happen. * Without a typelib, Python can't tell if a reference to 'a.foo' is going to end up being a method call or not (ie, from Python's POV, a.foo() is just a property fetch for 'foo' and then calling the result.) When making a property reference, win32com checks for the ERRORS_BAD_CONTEXT values defined in win32com\client\dynamic.py - if it sees one of those errors, it assumes it really hit a method and handles it accordgingly. But - in your case, your object is succeeding! The simplest thing to do here is to have your object refuse to work as a property using one of the standard error codes, and Python will then try it as a method. Mark From: python-win32-bounces+skippy.hammond=gmail.com at python.org [mailto:python-win32-bounces+skippy.hammond=gmail.com at python.org] On Behalf Of Obendorf, Keston Sent: Tuesday, 16 September 2008 8:19 AM To: python-win32 at python.org Subject: [python-win32] COM: Parameterless functions seen as properties I'm doing COM development in both Python and C#. Things are working well, but I'm running into an issue where trying to get parameterless function returns the return value of that function, which Python then tries to call, causing an error. The C# class is an implementation of an IDL-defined interface. //IDL interface IService : IDispatch { [id(101)] HRESULT foo([out, retval] BSTR * pstr); } //C# [ComImport] [Guid("/*GUID of IService*/")] interface IService{} [ComVisible(true)] [ProgId("bar")] [Guid("Valid GUID")] public class bar : IService { public bar(){} public string foo() { return "foo"; } } Now, getting a Dispatch of "bar" in Python is where the issue lies. from win32com.client import Dispatch bar = Dispatch("bar") str = bar.foo() >>TypeError: 'unicode' object is not callable This is only a problem with the C# class. If the interface is implemented in Pythong, the above code will work. Now, this issue can be fixed by adding in _FlagAsMethod before calling bar.foo() bar._FlagAsMethod("foo") I really don't want to have to do that every time I try to call a parameterless method of a C# COM-object from Python. That's a huge headache, especially because I am trying to keep the language any one component is written in a non-issue. I've started to dive into the source code of dynamic.py and other Client modules to try and figure out how I can make this distinction at Dispatch-time, but it's rough going understanding everything that's going on in there. Does anyone have any pointers or a straight up solution to this problem? -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Thu Sep 18 02:45:10 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 18 Sep 2008 10:45:10 +1000 Subject: [python-win32] Accessing other interfaces of a Dispatch created COM object In-Reply-To: <9819d58b0809171254n1c59cac0tc0c7a0dd45f266a2@mail.gmail.com> References: <9819d58b0808280556g46cbd1cbj85f32cc82987615a@mail.gmail.com> <9819d58b0809101222m77c0648dh6e0752fc83a75ec2@mail.gmail.com> <48C82728.8060206@probo.com> <9819d58b0809101523u5811d094kfb01109987e9491d@mail.gmail.com> <057d01c913a1$4e80dc20$eb829460$@com.au> <9819d58b0809101835h1a581fpb67305217b39a40f@mail.gmail.com> <9819d58b0809120949v217de44bn8c71ac792dec70fa@mail.gmail.com> <9819d58b0809121028w46cf0267l3c517a33289ea595@mail.gmail.com> <9819d58b0809171210h159b3402t654bd3e011e4bb@mail.gmail.com> <9819d58b0809171228m5f71c45fld2b8a62dec388d03@mail.gmail.com> <9819d58b0809171254n1c59cac0tc0c7a0dd45f266a2@mail.gmail.com> Message-ID: <01f901c91927$d0ee0ad0$72ca2070$@com.au> > I've taken a look, and I can't say I had an "aha" moment, or anything > like that, but perhaps I have learned something important. > > Setting up the COM object seems very straightforward: > > Type t = Type.GetTypeFromCLSID("{e04f970b-53ce-420a-86f8- > 55374677703d}") > > component = (basic.I1)Activator.CreateInstance(t) > > component_2 = component as I2 Note that many compiled languages only need the typelib at compile time - once built, they don't need the typelib to be installed and registered on the target system. This is in contrast to Python, where the typelib is needed at runtime (unless makepy has been successfully run - the typelib is then needed at makepy time - which is still at "runtime" unless py2exe etc is involved). Indeed, the typelib may not even need to be registered on the build system - just a reference to it on disk by the build process would be enough. So - it still sounds to me that one of the 2 typelibs you rely on aren't registered, and that your other compiled applications don't notice this. Have you tried asking the people who supply the binaries you are using? Mark From mhammond at skippinet.com.au Thu Sep 18 02:48:43 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 18 Sep 2008 10:48:43 +1000 Subject: [python-win32] COM: Parameterless functions seen as properties In-Reply-To: <12A5C15467D5B94F8E0FF265D9498ADD03B2C1F1@orsmsx419.amr.corp.intel.com> References: <12A5C15467D5B94F8E0FF265D9498ADD03AC5794@orsmsx419.amr.corp.intel.com> <009601c91787$a25c94d0$e715be70$@com.au> <12A5C15467D5B94F8E0FF265D9498ADD03B2C1F1@orsmsx419.amr.corp.intel.com> Message-ID: <020301c91928$530df660$f929e320$@com.au> The difference in behaviour of ITypeComp.Bind() is interesting, and I agree is the main problem here. However, from what you have said, I'm surprised that a makepy-backed implementation isn't working for you. The first thing we do when getting an object is ask for its type info so we can get the CLSID of the object. We then lookup the CLSID in our makepy/gencache map, and if we find it, the entire process you outline is skipped - we already know the dispid and flags for each of the attributes. Thus, given your objects implement most of the typeinfo stuff correctly, I'm surprised this isn't working for you. Have you tried running makepy on your typelib? Cheers, Mark From: Obendorf, Keston [mailto:keston.obendorf at intel.com] Sent: Thursday, 18 September 2008 10:08 AM To: mhammond at skippinet.com.au; python-win32 at python.org Subject: RE: [python-win32] COM: Parameterless functions seen as properties Thanks. I don't think the issue is that GetTypeInfo() is not returning anything, but it's returning something that cannot be used properly. I wrote another implementation of the parameterless function, this time in C++. The implementation in C++ works just fine: retStr = Dispatch("c++implementation").getNLType() --causes no exceptions and works as intended. I've been stepping through the CDispatch creation process, which on the account of both C# and C++ implementations seems to go OK. In both run-throughs, dynamic is able to get both typeinfo and typecomp. I judge that this happens because in both cases the _olerepr_ of the CDispatch object is a LazyDispatchItem not DispatchItem, which only happens if both typeinfo and typecomp are defined. The implementations diverge, however, in _getattr_, specifically when calling __LazyMap__. The C++ implementation returns a 1, whereas the C# implementation returns None. This is due to the fact that in _LazyAddAttr_ , typecomp.Bind returns (0, None) for all invoke types for the C# implementation whereas the C++ implementation binds to INVOKE_FUNC. (This leads me to conclude that the typecomp for the C# implementation is bad in some way. That is probably more an issue for a C# mailing list. I don't think it's Python's fault.) _getattr_ allows recovery from this issue with a last ditch effort, which you reference in your post as the second thing that could be going on. Unfortunately, it sets the invoke type by default to pythoncom.INVOKE_PROPERTYGET. C# does not seem to care that its function is not a property, and returns an evaluation of the function rather than throwing an exception. I don't know if there is a way to prevent this behavior. I feel like there's not much information in this posting for all its words. =( I figured out HOW it is failing, but not exactly WHY. It looks like this is a problem in the way C# handles IDispatch and ITypeInfo. P.S. I am new to this whole mailing-list thing, so I don't know exactly what e-mail addresses to send this post to. Let's hope it winds up in the right place. Thanks, Keston _____ From: Mark Hammond [mailto:skippy.hammond at gmail.com] On Behalf Of Mark Hammond Sent: Monday, September 15, 2008 4:06 PM To: Obendorf, Keston; python-win32 at python.org Subject: RE: [python-win32] COM: Parameterless functions seen as properties It looks like 2 things are going on: * Your object isn't returning typelib info to Python when it asks. If your IDispatch returned something from GetTypeInfo() we could use, this wouldn't happen. * Without a typelib, Python can't tell if a reference to 'a.foo' is going to end up being a method call or not (ie, from Python's POV, a.foo() is just a property fetch for 'foo' and then calling the result.) When making a property reference, win32com checks for the ERRORS_BAD_CONTEXT values defined in win32com\client\dynamic.py - if it sees one of those errors, it assumes it really hit a method and handles it accordgingly. But - in your case, your object is succeeding! The simplest thing to do here is to have your object refuse to work as a property using one of the standard error codes, and Python will then try it as a method. Mark From: python-win32-bounces+skippy.hammond=gmail.com at python.org [mailto:python-win32-bounces+skippy.hammond=gmail.com at python.org] On Behalf Of Obendorf, Keston Sent: Tuesday, 16 September 2008 8:19 AM To: python-win32 at python.org Subject: [python-win32] COM: Parameterless functions seen as properties I'm doing COM development in both Python and C#. Things are working well, but I'm running into an issue where trying to get parameterless function returns the return value of that function, which Python then tries to call, causing an error. The C# class is an implementation of an IDL-defined interface. //IDL interface IService : IDispatch { [id(101)] HRESULT foo([out, retval] BSTR * pstr); } //C# [ComImport] [Guid("/*GUID of IService*/")] interface IService{} [ComVisible(true)] [ProgId("bar")] [Guid("Valid GUID")] public class bar : IService { public bar(){} public string foo() { return "foo"; } } Now, getting a Dispatch of "bar" in Python is where the issue lies. from win32com.client import Dispatch bar = Dispatch("bar") str = bar.foo() >>TypeError: 'unicode' object is not callable This is only a problem with the C# class. If the interface is implemented in Pythong, the above code will work. Now, this issue can be fixed by adding in _FlagAsMethod before calling bar.foo() bar._FlagAsMethod("foo") I really don't want to have to do that every time I try to call a parameterless method of a C# COM-object from Python. That's a huge headache, especially because I am trying to keep the language any one component is written in a non-issue. I've started to dive into the source code of dynamic.py and other Client modules to try and figure out how I can make this distinction at Dispatch-time, but it's rough going understanding everything that's going on in there. Does anyone have any pointers or a straight up solution to this problem? -------------- next part -------------- An HTML attachment was scrubbed... URL: From keston.obendorf at intel.com Thu Sep 18 22:32:06 2008 From: keston.obendorf at intel.com (Obendorf, Keston) Date: Thu, 18 Sep 2008 13:32:06 -0700 Subject: [python-win32] COM: Parameterless functions seen as properties In-Reply-To: <020301c91928$530df660$f929e320$@com.au> References: <12A5C15467D5B94F8E0FF265D9498ADD03AC5794@orsmsx419.amr.corp.intel.com> <009601c91787$a25c94d0$e715be70$@com.au> <12A5C15467D5B94F8E0FF265D9498ADD03B2C1F1@orsmsx419.amr.corp.intel.com> <020301c91928$530df660$f929e320$@com.au> Message-ID: <12A5C15467D5B94F8E0FF265D9498ADD03B2C5FF@orsmsx419.amr.corp.intel.com> Yes I have tried makepy. I haven't actually had any success with makepy in the past except when running it on type libraries created with the MIDL compiler. The gen_py modules created from tlbs exported from .NET assemblies just don't work. They don't have definitions for any of the methods of the classes, just the interfaces, and attempting to call any of the interface methods on an instance grabbed by Dispatch fails with an Attribute Error. Just an aside on how I'm getting the .tlb. When C# builds it generates a .dll. I then use REGASM with the /tlb to register the .dll and export a tlb from the dll and register that as well. I think I'll go poke around on the MSDN forums for awhile. _Keston ________________________________ From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: Wednesday, September 17, 2008 5:49 PM To: Obendorf, Keston; python-win32 at python.org Subject: RE: [python-win32] COM: Parameterless functions seen as properties The difference in behaviour of ITypeComp.Bind() is interesting, and I agree is the main problem here. However, from what you have said, I'm surprised that a makepy-backed implementation isn't working for you. The first thing we do when getting an object is ask for its type info so we can get the CLSID of the object. We then lookup the CLSID in our makepy/gencache map, and if we find it, the entire process you outline is skipped - we already know the dispid and flags for each of the attributes. Thus, given your objects implement most of the typeinfo stuff correctly, I'm surprised this isn't working for you. Have you tried running makepy on your typelib? Cheers, Mark -------------- next part -------------- An HTML attachment was scrubbed... URL: From juanmpubill at hotmail.com Thu Sep 18 20:39:40 2008 From: juanmpubill at hotmail.com (Juan Manuel Pubill) Date: Thu, 18 Sep 2008 18:39:40 +0000 Subject: [python-win32] Pythonwin telit Message-ID: Hola quer?a saber si hay posibilidad de conseguir alguna versi?n m?s nueva que la que distribuye Telit del pythonwin porque es poco estable y tiene varios bugs. Sin m?s muchas gracias _________________________________________________________________ Get more from your digital life. Find out how. http://www.windowslive.com/default.html?ocid=TXT_TAGLM_WL_Home2_082008 -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Sep 19 02:05:03 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 18 Sep 2008 17:05:03 -0700 Subject: [python-win32] Pythonwin telit In-Reply-To: References: Message-ID: <48D2ECAF.9010106@probo.com> Juan Manuel Pubill wrote: > > Hola quer?a saber si hay posibilidad de conseguir alguna versi?n m?s > nueva que la que distribuye Telit del pythonwin porque es poco estable > y tiene varios bugs. > BabelFish translates this as: > Hello it wanted to know if there is possibility of securing some > version newer than the one than it distributes Telit of pythonwin > because he is little stable and it has several bugs. Immediately thank > you very much You can always fetch the latest version directly from the source, http://sourceforge.net/projects/pywin32. However, there haven't been any significant bugs in quite a long time. What version are you using, and what "bugs" do you see? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From alecmunro at gmail.com Fri Sep 19 16:32:53 2008 From: alecmunro at gmail.com (Alec Munro) Date: Fri, 19 Sep 2008 11:32:53 -0300 Subject: [python-win32] Accessing other interfaces of a Dispatch created COM object In-Reply-To: <01f901c91927$d0ee0ad0$72ca2070$@com.au> References: <9819d58b0808280556g46cbd1cbj85f32cc82987615a@mail.gmail.com> <9819d58b0809101523u5811d094kfb01109987e9491d@mail.gmail.com> <057d01c913a1$4e80dc20$eb829460$@com.au> <9819d58b0809101835h1a581fpb67305217b39a40f@mail.gmail.com> <9819d58b0809120949v217de44bn8c71ac792dec70fa@mail.gmail.com> <9819d58b0809121028w46cf0267l3c517a33289ea595@mail.gmail.com> <9819d58b0809171210h159b3402t654bd3e011e4bb@mail.gmail.com> <9819d58b0809171228m5f71c45fld2b8a62dec388d03@mail.gmail.com> <9819d58b0809171254n1c59cac0tc0c7a0dd45f266a2@mail.gmail.com> <01f901c91927$d0ee0ad0$72ca2070$@com.au> Message-ID: <9819d58b0809190732w5d860ae5qd0f67c1172835b65@mail.gmail.com> Hi Mark, I am able to run MakePy successfully, at least as far as I can tell. Does that affect your conclusion? Is there any way I can figure out what library it is looking for when I call the following (from your earlier example)? >>> d.GetTypeInfo(0) As that also raises the "library not registered" exception. I've been in some contact with the vendor who supplies us with this, mostly when I started trying to use Python for this purpose. I've recently updated them on my progress, and I'm waiting for a response. Thanks again. Alec On Wed, Sep 17, 2008 at 9:45 PM, Mark Hammond wrote: >> I've taken a look, and I can't say I had an "aha" moment, or anything >> like that, but perhaps I have learned something important. >> >> Setting up the COM object seems very straightforward: >> >> Type t = Type.GetTypeFromCLSID("{e04f970b-53ce-420a-86f8- >> 55374677703d}") >> >> component = (basic.I1)Activator.CreateInstance(t) >> >> component_2 = component as I2 > > Note that many compiled languages only need the typelib at compile time - > once built, they don't need the typelib to be installed and registered on > the target system. This is in contrast to Python, where the typelib is > needed at runtime (unless makepy has been successfully run - the typelib is > then needed at makepy time - which is still at "runtime" unless py2exe etc > is involved). Indeed, the typelib may not even need to be registered on the > build system - just a reference to it on disk by the build process would be > enough. > > So - it still sounds to me that one of the 2 typelibs you rely on aren't > registered, and that your other compiled applications don't notice this. > Have you tried asking the people who supply the binaries you are using? > > Mark > > From gagsl-py2 at yahoo.com.ar Sat Sep 20 04:10:55 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 19 Sep 2008 23:10:55 -0300 Subject: [python-win32] Pythonwin telit References: Message-ID: En Thu, 18 Sep 2008 15:39:40 -0300, Juan Manuel Pubill escribi?: > Hola quer?a saber si hay posibilidad de conseguir alguna versi?n m?s > nueva que la que distribuye Telit del pythonwin porque es poco estable y > tiene varios bugs. > Sin m?s muchas gracias Lista de Python en castellano: python-es at aditel.org == http://dir.gmane.org/gmane.comp.python.general.castellano -- Gabriel Genellina From amicitas at gmail.com Sat Sep 20 20:36:57 2008 From: amicitas at gmail.com (mir amicitas) Date: Sat, 20 Sep 2008 11:36:57 -0700 Subject: [python-win32] Drag and drop of files (CF_HDROP) Message-ID: <55e194140809201136r5466d5d9te1acdf9edb431e26@mail.gmail.com> I have been trying to implement drag and drop of files in python. My application will written in PyQt4 but they I want to use the native drag and drop for windows as PyQt only supports mime based dragging, which does not work for some of the windows applications that I want to connect with. I have made a certain amount of progress getting this to work using pywin32, however I have gotten stuck. So far I have been able to implement dragging of text (CF_TEXT or CF_UNICODETEXT). This basically took reimplementing the IDropSource & IDataObject objects, wrapping them using win32com.server.util.wrap() and then calling pythoncom.DoDragDrop(). For some of this I have been able to follow allong with the code in testClipboard.py that is included with the pywin32 installaiton. The next thing that I want to do is to use CF_HDROP as the format type with a list of file locations. I am getting stuck at the point when I actually add the list of file locations to the pythoncom.STGMEDIUM() object. >From what I can gather this data needs to be placed into a DROPFILES structure (msdn page on CF_HDROP & DROPFILES). So my questing is how to I create this structure in pywin32? Any help on this would be appretiated, particularly since I can't find documentation for a lot of this stuff (I have resorted to greping the source code to find stuff). I am totaly new to win32 programming so this has been a bit more that I meant to bite off. If anyone knows of an easyer way to achive this I would be happy to hear of it. Thanks, -- amicitas -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Sun Sep 21 11:25:57 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Sun, 21 Sep 2008 10:25:57 +0100 Subject: [python-win32] Drag and drop of files (CF_HDROP) In-Reply-To: <55e194140809201136r5466d5d9te1acdf9edb431e26@mail.gmail.com> References: <55e194140809201136r5466d5d9te1acdf9edb431e26@mail.gmail.com> Message-ID: <48D61325.9090308@timgolden.me.uk> mir amicitas wrote: > I have been trying to implement drag and drop of files in python. My > application will written in PyQt4 but they I want to use the native drag and > drop for windows as PyQt only supports mime based dragging, which does not > work for some of the windows applications that I want to connect with. > > I have made a certain amount of progress getting this to work using pywin32, > however I have gotten stuck. > > So far I have been able to implement dragging of text (CF_TEXT or > CF_UNICODETEXT). This basically took reimplementing the IDropSource & > IDataObject objects, wrapping them using win32com.server.util.wrap() and > then calling pythoncom.DoDragDrop(). For some of this I have been able to > follow allong with the code in testClipboard.py that is included with the > pywin32 installaiton. > > The next thing that I want to do is to use CF_HDROP as the format type with > a list of file locations. I am getting stuck at the point when I actually > add the list of file locations to the pythoncom.STGMEDIUM() object. > >>From what I can gather this data needs to be placed into a DROPFILES > structure (msdn page on CF_HDROP & > DROPFILES). > So my questing is how to I create this structure in pywin32? > > > Any help on this would be appretiated, particularly since I can't find > documentation for a lot of this stuff (I have resorted to greping the source > code to find stuff). I am totaly new to win32 programming so this has been > a bit more that I meant to bite off. Can you have a look at this thread from earlier this year to see if it helps to answer you question: http://mail.python.org/pipermail/python-win32/2008-April/007409.html TJG From amicitas at gmail.com Sun Sep 21 22:36:02 2008 From: amicitas at gmail.com (mir amicitas) Date: Sun, 21 Sep 2008 13:36:02 -0700 Subject: [python-win32] Drag and drop of files (CF_HDROP) In-Reply-To: <48D61325.9090308@timgolden.me.uk> References: <55e194140809201136r5466d5d9te1acdf9edb431e26@mail.gmail.com> <48D61325.9090308@timgolden.me.uk> Message-ID: <55e194140809211336y144fc291t1ddead337356bc68@mail.gmail.com> > > > Can you have a look at this thread from earlier this > year to see if it helps to answer you question: > > http://mail.python.org/pipermail/python-win32/2008-April/007409.html > > TJG Thanks Tim for sending along that thread. This is close to what I need (and provides some useful information). This example however takes the data out of the STGMEDIUM object, rather than putting the data into it. In doing so the data object does not have to be defined. The relevant code from the example is: def Drop (self, data_object, key_state, point, effect): data = data_object.GetData ((15, None, 1, -1, 1)) n_files = shell.DragQueryFileW (data.data_handle, -1) filenames = [ shell.DragQueryFileW (data.data_handle, n_file) \ for n_file in range (n_files) ] So my question is how can I make the data object so that I can place it into the data object. Here is the snippet of code from my project showing what I want to do. class TestDataObjectFile: _com_interfaces_ = [pythoncom.IID_IDataObject] _public_methods_ = IDataObject_Methods def __init__(self, file_path): global num_do_objects num_do_objects += 1 self.file_path = file_path self.supported_fe = [] cf = win32con.CF_HDROP fe = cf, None, pythoncom.DVASPECT_CONTENT, -1, pythoncom.TYMED_HGLOBAL self.supported_fe.append(fe) def __del__(self): global num_do_objects num_do_objects -= 1 def _query_interface_(self, iid): if iid==pythoncom.IID_IEnumFORMATETC: return NewEnum(self.supported_fe, iid=iid) def GetData(self, fe): print 'GetData' ret_stg = None cf, target, aspect, index, tymed = fe print cf, win32con.CF_HDROP if aspect & pythoncom.DVASPECT_CONTENT and \ tymed==pythoncom.TYMED_HGLOBAL: if cf == win32con.CF_HDROP: ret_stg = pythoncom.STGMEDIUM() ret_stg.set(pythoncom.TYMED_HGLOBAL, self.file_path) if ret_stg is None: print 'No ret_stg.' raise COMException(hresult=winerror.E_NOTIMPL) return ret_stg . . . ---- The point where I am stuck is the lines in getData: ret_stg = pythoncom.STGMEDIUM() ret_stg.set(pythoncom.TYMED_HGLOBAL, self.file_path) The problem is that what needs to be placed into ret_stg is not the file_names (as I have done above), but a data structure. So my question is how do I get the filenames into the data object? Thanks again for your help with this. - Novi -------------- next part -------------- An HTML attachment was scrubbed... URL: From rwupole at msn.com Mon Sep 22 01:14:00 2008 From: rwupole at msn.com (Roger Upole) Date: Sun, 21 Sep 2008 19:14:00 -0400 Subject: [python-win32] Re: Drag and drop of files (CF_HDROP) Message-ID: You can use struct.pack to create a buffer containing a DROPFILES struct: """ typedef struct _DROPFILES { DWORD pFiles; POINT pt; BOOL fNC; BOOL fWide; } DROPFILES, *LPDROPFILES; """ fname_buf='\0'.join(fnames)+'\0\0' fmt="lllll%ss" %len(fname_buf) df=struct.pack(fmt, 20, 0, 0, 0, 0, fname_buf) ret_stg.set(pythoncom.TYMED_HGLOBAL, df) Roger From imageguy1206 at gmail.com Mon Sep 22 03:10:25 2008 From: imageguy1206 at gmail.com (geoff) Date: Sun, 21 Sep 2008 22:10:25 -0300 Subject: [python-win32] Virtual print driver - similiar to winpdf Message-ID: <3ee0b280809211810j7d516500o9e93c9673ee82e2b@mail.gmail.com> Would creating a virtual print driver be possible with pywin32, similiar to the windows pdf driver ? WE have an old application that outputs data to a dotmatrix printer. WE would like to extend this application and integrate it with another application and the simplest way to do this would be to capture the print output, extract some information from the print output and then forward that information to a database application. Any suggestions. I have found a couple of websites about print drivers (google is my friend !) but thought I might ask here for some advice and guidance. g. From amicitas at gmail.com Mon Sep 22 07:18:38 2008 From: amicitas at gmail.com (mir amicitas) Date: Sun, 21 Sep 2008 22:18:38 -0700 Subject: [python-win32] Drag and drop of files (CF_HDROP) In-Reply-To: References: Message-ID: <55e194140809212218n7bd9633ev31ef83ee7ebb5fb3@mail.gmail.com> Thank you for you help, that works perfectly. I can now drag files from my program (yay!). One more question . . . In the Microsoft specification for DoDragDrop there are 4 arguments (data, source, allowed effects, used effect). However in the pythoncom implementation only 3 arguments are allowed. Is there a reason for this? Here is the page on that function from ms: http://msdn.microsoft.com/en-us/library/ms678486(VS.85).aspx - novi -------------- next part -------------- An HTML attachment was scrubbed... URL: From rwupole at msn.com Mon Sep 22 10:35:24 2008 From: rwupole at msn.com (Roger Upole) Date: Mon, 22 Sep 2008 04:35:24 -0400 Subject: [python-win32] Re: Drag and drop of files (CF_HDROP) Message-ID: mir amicitas" wrote: > Thank you for you help, that works perfectly. I can now drag files from > my > program (yay!). > > One more question . . . > > In the Microsoft specification for DoDragDrop there are 4 arguments (data, > source, allowed effects, used effect). However in the pythoncom > implementation only 3 arguments are allowed. Is there a reason for this? > > Here is the page on that function from ms: > http://msdn.microsoft.com/en-us/library/ms678486(VS.85).aspx > > - novi The last arg is output, and will be returned from the function. Roger From timr at probo.com Mon Sep 22 19:41:57 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 22 Sep 2008 10:41:57 -0700 Subject: [python-win32] Virtual print driver - similiar to winpdf In-Reply-To: <3ee0b280809211810j7d516500o9e93c9673ee82e2b@mail.gmail.com> References: <3ee0b280809211810j7d516500o9e93c9673ee82e2b@mail.gmail.com> Message-ID: <48D7D8E5.7070106@probo.com> geoff wrote: > Would creating a virtual print driver be possible with pywin32, > similiar to the windows pdf driver ? > WE have an old application that outputs data to a dotmatrix printer. > WE would like to extend this application and integrate it with another > application and the simplest way to do this would be to capture the > print output, extract some information from the print output and then > forward that information to a database application. > > Any suggestions. > > I have found a couple of websites about print drivers (google is my > friend !) but thought I might ask here for some advice and guidance. > This is trickier than you might guess. Does the application actually write to the printer using a Windows printer driver? Some old applications that just used a printer for logging wrote directly to the parallel ports. That kind of thing is almost impossible to trap. If it does, how does it pick the printer? If it doesn't present you with a dialog, then it might be picking the printer by name. That means you can't just install your own driver, unless you use the same name. If it does present you with a dialog, can you use the Generic / Text-Only printer driver, and have it dump to a text file? (That's one of the standard printer drivers built-in to Windows.) If you really need a driver, you are not going to be able to do this from Python. There are a sample printer drivers in the WDK (Windows Driver Kit). It is not a project to be undertaken lightly. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From imageguy1206 at gmail.com Mon Sep 22 21:20:47 2008 From: imageguy1206 at gmail.com (geoff) Date: Mon, 22 Sep 2008 15:20:47 -0400 Subject: [python-win32] Virtual print driver - similiar to winpdf In-Reply-To: <48D7D8E5.7070106@probo.com> References: <3ee0b280809211810j7d516500o9e93c9673ee82e2b@mail.gmail.com> <48D7D8E5.7070106@probo.com> Message-ID: <3ee0b280809221220q277e3c9ap262d84da3bce85a0@mail.gmail.com> Thanks for you guidance Tim. After reviewing I am coming to the same conclusion. > This is trickier than you might guess. Does the application actually > write to the printer using a Windows printer driver? Some old > applications that just used a printer for logging wrote directly to the > parallel ports. That kind of thing is almost impossible to trap. If it > does, how does it pick the printer? The application is quite "configurable". Printers can be configured so the application to write to either a port (including UNC path), a Windows print driver or directly to a file that is specificed within the application. We typically use the "generic/text" driver to define the "windows" printers, however, just pointing the app to "LPT1:" works just fine too. If it doesn't present you with a > dialog, then it might be picking the printer by name. That means you > can't just install your own driver, unless you use the same name. If it > does present you with a dialog, can you use the Generic / Text-Only > printer driver, and have it dump to a text file? (That's one of the > standard printer drivers built-in to Windows.) I have thought of the Windows printer defined as "file" however, I don't want the user to be prompted for the file name each time and haven't found a way to suppress this. > If you really need a driver, you are not going to be able to do this > from Python. There are a sample printer drivers in the WDK (Windows > Driver Kit). It is not a project to be undertaken lightly. Yes, I am starting to understand that :-( What we are trying to do is capture the printing "dynamically" while the user is running the application ( -- think of invoice printing in a business). The app output is text, with some printer control codes embedded to change fonts, colors, newlines, etc, but other than that it is just ascii text printed line-by-line sent to the specificied port or file. The problem we see with the "print to a file" approach is we would like the system to react immediately when the user "prints" and having some sort of "polling" to watch the file isn't the best solution as it introduces a delay/latency. One option I was considering is using Windows printer defined as a "Standard TCP/IP Printer Port". Our thinking is to manually configure a printer in Windows and then use the LPR or RAW method of this print monitor to redirect the output to our program via TCP/IP. Haven't tested this , however, the thinking is that this would tell us immediately when the user is printing and our utility could re-act accordingly. Any thoughts or comments or guidance would be truly appreciated. g. From python at kareta.de Tue Sep 23 00:02:41 2008 From: python at kareta.de (=?ISO-8859-1?Q?J=FCrgen_Kareta?=) Date: Tue, 23 Sep 2008 00:02:41 +0200 Subject: [python-win32] Virtual print driver - similiar to winpdf In-Reply-To: <3ee0b280809221220q277e3c9ap262d84da3bce85a0@mail.gmail.com> References: <3ee0b280809211810j7d516500o9e93c9673ee82e2b@mail.gmail.com> <48D7D8E5.7070106@probo.com> <3ee0b280809221220q277e3c9ap262d84da3bce85a0@mail.gmail.com> Message-ID: <48D81601.3000308@kareta.de> > Thanks for you guidance Tim. After reviewing I am coming to the same > conclusion. > > >> This is trickier than you might guess. Does the application actually >> write to the printer using a Windows printer driver? Some old >> applications that just used a printer for logging wrote directly to the >> parallel ports. That kind of thing is almost impossible to trap. If it >> does, how does it pick the printer? >> > > The application is quite "configurable". Printers can be configured > so the application to write to either a port (including UNC path), a > Windows print driver or directly to a file that is specificed within > the application. We typically use the "generic/text" driver to > define the "windows" printers, however, just pointing the app to > "LPT1:" works just fine too. > > If it doesn't present you with a > >> dialog, then it might be picking the printer by name. That means you >> can't just install your own driver, unless you use the same name. If it >> does present you with a dialog, can you use the Generic / Text-Only >> printer driver, and have it dump to a text file? (That's one of the >> standard printer drivers built-in to Windows.) >> > > I have thought of the Windows printer defined as "file" however, I > don't want the user to be prompted for the file name each time and > haven't found a way to suppress this. > > >> If you really need a driver, you are not going to be able to do this >> from Python. There are a sample printer drivers in the WDK (Windows >> Driver Kit). It is not a project to be undertaken lightly. >> > > Yes, I am starting to understand that :-( > > What we are trying to do is capture the printing "dynamically" while > the user is running the application ( -- think of invoice printing in > a business). The app output is text, with some printer control codes > embedded to change fonts, colors, newlines, etc, but other than that > it is just ascii text printed line-by-line sent to the specificied > port or file. > > The problem we see with the "print to a file" approach is we would > like the system to react immediately when the user "prints" and having > some sort of "polling" to watch the file isn't the best solution as it > introduces a delay/latency. > > One option I was considering is using Windows printer defined as a > "Standard TCP/IP Printer Port". Our thinking is to manually configure > a printer in Windows and then use the LPR or RAW method of this print > monitor to redirect the output to our program via TCP/IP. Haven't > tested this , however, the thinking is that this would tell us > immediately when the user is printing and our utility could re-act > accordingly. > > Any thoughts or comments or guidance would be truly appreciated. > > g. > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > Hi Geoff, redmon: http://pages.cs.wisc.edu/~ghost/redmon/ might be an option for you. I use it for years now without any problems. In one case I provide printing capabilities inside citrix apps for vpn users and in an other case I extended an application with fax functionality. One can either use a temporary file or send the data directly to a python script. It also works nice when the python script is installed as a windows service. Regards, J?rgen From patrick at raptr.com Tue Sep 23 04:25:30 2008 From: patrick at raptr.com (Patrick Li) Date: Mon, 22 Sep 2008 19:25:30 -0700 Subject: [python-win32] idle detection on system? Message-ID: <2b5a48740809221925u1254a23fi160173e4bbeb0696@mail.gmail.com> Hi, Does anyone know how I can detect if a system is idle? By idle I am referring to a user being away from the computer (no keyboard or mouse movement) for X minutes. Tried searching around but I haven't found anything that mentions how I can hook into these two events. Thanks in advance, Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: From imageguy1206 at gmail.com Tue Sep 23 05:21:31 2008 From: imageguy1206 at gmail.com (geoff) Date: Mon, 22 Sep 2008 23:21:31 -0400 Subject: [python-win32] Virtual print driver - similiar to winpdf In-Reply-To: <48D81601.3000308@kareta.de> References: <3ee0b280809211810j7d516500o9e93c9673ee82e2b@mail.gmail.com> <48D7D8E5.7070106@probo.com> <3ee0b280809221220q277e3c9ap262d84da3bce85a0@mail.gmail.com> <48D81601.3000308@kareta.de> Message-ID: <3ee0b280809222021h4702109m1e40885c91f2fac6@mail.gmail.com> > Hi Geoff, > > redmon: http://pages.cs.wisc.edu/~ghost/redmon/ might be an option for you. > I use it for years now without any problems. In one case I provide printing > capabilities inside citrix apps for vpn users and in an other case I > extended an application with fax functionality. One can either use a > temporary file or send the data directly to a python script. It also works > nice when the python script is installed as a windows service. > Thanks I will give that a try. g. From mail at timgolden.me.uk Tue Sep 23 09:50:19 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 23 Sep 2008 08:50:19 +0100 Subject: [python-win32] idle detection on system? In-Reply-To: <2b5a48740809221925u1254a23fi160173e4bbeb0696@mail.gmail.com> References: <2b5a48740809221925u1254a23fi160173e4bbeb0696@mail.gmail.com> Message-ID: <48D89FBB.8050406@timgolden.me.uk> Patrick Li wrote: > Hi, > Does anyone know how I can detect if a system is idle? By idle I am > referring to a user being away from the computer (no keyboard or mouse > movement) for X minutes. Tried searching around but I haven't found > anything that mentions how I can hook into these two events. I knew there had been some discussion about this in the past, but my attempts at searching the archives were frustrated by the huge number of posts about "IDLE"! In short: you can use the Scheduled Tasks API to trigger something when the system has been idle for x minutes: http://mail.python.org/pipermail/python-list/2005-May/323848.html Alternatively, the GetLastInputInfo API might be what you want: http://msdn.microsoft.com/en-us/library/ms646302(VS.85).aspx TJG From andrea.gavana at gmail.com Tue Sep 23 13:03:08 2008 From: andrea.gavana at gmail.com (Andrea Gavana) Date: Tue, 23 Sep 2008 12:03:08 +0100 Subject: [python-win32] Invalid or corrupted installer... Message-ID: Hi All, I am having few problems in downloading and installing the release 212 of PyWin32 (and all the other releases as well) from SourceForge. Whatever executable file I try to download from SourceForge (I need the pywin32-212.win32-py2.5.exe for my Python version), the download remains stuck at 4.4/4.7 MB (the pywin32-212.win32-py2.5.exe file size is 5.3 MB) for a couple of minutes, and then it leaves me with a corrupted installation file which cannot be run. Is anyone else experiencing the same issues? I have tried from 3 different computers here at work but with the same results, and also from 4 different mirrors at SourceForge and from another mirror (indipendent from SourceForge) here: http://gforge.inria.fr/frs/?group_id=79&release_id=1150 This is Windows XP SP2, Python 2.5.2. Thank you for all your suggestions. Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.alice.it/infinity77/ From mail at timgolden.me.uk Tue Sep 23 13:12:46 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 23 Sep 2008 12:12:46 +0100 Subject: [python-win32] Invalid or corrupted installer... In-Reply-To: References: Message-ID: <48D8CF2E.6030903@timgolden.me.uk> Andrea Gavana wrote: > Hi All, > > I am having few problems in downloading and installing the release > 212 of PyWin32 (and all the other releases as well) from SourceForge. > Whatever executable file I try to download from SourceForge (I need > the pywin32-212.win32-py2.5.exe for my Python version), the download > remains stuck at 4.4/4.7 MB (the pywin32-212.win32-py2.5.exe file size > is 5.3 MB) for a couple of minutes, and then it leaves me with a > corrupted installation file which cannot be run. > Is anyone else experiencing the same issues? Not sure why there might be a problem. To help you out, I've just dropped a copy here: http://timgolden.me.uk/python/downloads/pywin32-212.win32-py2.5.exe TJG From andrea.gavana at gmail.com Tue Sep 23 13:34:02 2008 From: andrea.gavana at gmail.com (Andrea Gavana) Date: Tue, 23 Sep 2008 12:34:02 +0100 Subject: [python-win32] Invalid or corrupted installer... In-Reply-To: <48D8CF2E.6030903@timgolden.me.uk> References: <48D8CF2E.6030903@timgolden.me.uk> Message-ID: Hi Tim, On Tue, Sep 23, 2008 at 12:12 PM, Tim Golden wrote: > Andrea Gavana wrote: >> >> Hi All, >> >> I am having few problems in downloading and installing the release >> 212 of PyWin32 (and all the other releases as well) from SourceForge. >> Whatever executable file I try to download from SourceForge (I need >> the pywin32-212.win32-py2.5.exe for my Python version), the download >> remains stuck at 4.4/4.7 MB (the pywin32-212.win32-py2.5.exe file size >> is 5.3 MB) for a couple of minutes, and then it leaves me with a >> corrupted installation file which cannot be run. >> Is anyone else experiencing the same issues? > > > Not sure why there might be a problem. To help you out, > I've just dropped a copy here: > > http://timgolden.me.uk/python/downloads/pywin32-212.win32-py2.5.exe Thank you for your help, I appreciate it. Unfortunately I am still having the same issue, even with the download you kindly provided. IE downloaded only 4.7 MB of the installer, and when I double-click it I get the "Invalid or corrupted file" message. At this point, it may be something due to our company firewall/internet management, although I was able to download other files (bigger, smaller, from SourceForge and not). I am 110% puzzled and a bit angry with our internet policy here (why don't they let me use Firefox?), also because I use the win32* extensions for all my applications and PythonWin as editor for my files :-( Thank you again. Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.alice.it/infinity77/ From mdriscoll at co.marshall.ia.us Tue Sep 23 15:12:09 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Tue, 23 Sep 2008 08:12:09 -0500 Subject: [python-win32] Virtual print driver - similiar to winpdf In-Reply-To: <3ee0b280809221220q277e3c9ap262d84da3bce85a0@mail.gmail.com> References: <3ee0b280809211810j7d516500o9e93c9673ee82e2b@mail.gmail.com> <48D7D8E5.7070106@probo.com> <3ee0b280809221220q277e3c9ap262d84da3bce85a0@mail.gmail.com> Message-ID: <48D8EB29.60502@co.marshall.ia.us> geoff wrote: > Thanks for you guidance Tim. After reviewing I am coming to the same > conclusion. > > >> This is trickier than you might guess. Does the application actually >> write to the printer using a Windows printer driver? Some old >> applications that just used a printer for logging wrote directly to the >> parallel ports. That kind of thing is almost impossible to trap. If it >> does, how does it pick the printer? >> > > The application is quite "configurable". Printers can be configured > so the application to write to either a port (including UNC path), a > Windows print driver or directly to a file that is specificed within > the application. We typically use the "generic/text" driver to > define the "windows" printers, however, just pointing the app to > "LPT1:" works just fine too. > > If it doesn't present you with a > >> dialog, then it might be picking the printer by name. That means you >> can't just install your own driver, unless you use the same name. If it >> does present you with a dialog, can you use the Generic / Text-Only >> printer driver, and have it dump to a text file? (That's one of the >> standard printer drivers built-in to Windows.) >> > > I have thought of the Windows printer defined as "file" however, I > don't want the user to be prompted for the file name each time and > haven't found a way to suppress this. > > >> If you really need a driver, you are not going to be able to do this >> from Python. There are a sample printer drivers in the WDK (Windows >> Driver Kit). It is not a project to be undertaken lightly. >> > > Yes, I am starting to understand that :-( > > What we are trying to do is capture the printing "dynamically" while > the user is running the application ( -- think of invoice printing in > a business). The app output is text, with some printer control codes > embedded to change fonts, colors, newlines, etc, but other than that > it is just ascii text printed line-by-line sent to the specificied > port or file. > > The problem we see with the "print to a file" approach is we would > like the system to react immediately when the user "prints" and having > some sort of "polling" to watch the file isn't the best solution as it > introduces a delay/latency. > > One option I was considering is using Windows printer defined as a > "Standard TCP/IP Printer Port". Our thinking is to manually configure > a printer in Windows and then use the LPR or RAW method of this print > monitor to redirect the output to our program via TCP/IP. Haven't > tested this , however, the thinking is that this would tell us > immediately when the user is printing and our utility could re-act > accordingly. > > Any thoughts or comments or guidance would be truly appreciated. > > g. > > You might take a look at Pyla. It's a print to fax library. I think it's kind of what you're talking about. I've been trying to hack it off and on for a while now as we only need a little of its functionality here at work. There isn't much for docs, so you'll have to read the source. Here's a link: http://www.teamsw.it/pyla/ Mike From andrea.gavana at gmail.com Tue Sep 23 17:01:39 2008 From: andrea.gavana at gmail.com (Andrea Gavana) Date: Tue, 23 Sep 2008 16:01:39 +0100 Subject: [python-win32] Invalid or corrupted installer... In-Reply-To: <48D903B3.4090203@timgolden.me.uk> References: <48D8CF2E.6030903@timgolden.me.uk> <48D903B3.4090203@timgolden.me.uk> Message-ID: Hi Tim, On Tue, Sep 23, 2008 at 3:56 PM, Tim Golden wrote: > Also, I take it that if you can't use Firefox, you can't use wget either? No, our firewall blocks *everything* that is not internet explorer (!) > http://users.ugent.be/~bpuype/wget/ > > or Python urrllib? The same as above, unfortunately. In any case, our IT has managed to download it few minutes ago using an external connection and now I am back to work. No explanation was provided for the reason of the corrupted download (!) In any case, thank you so much to Tim and Harald for helping me! Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.alice.it/infinity77/ From mail at timgolden.me.uk Tue Sep 23 17:07:06 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 23 Sep 2008 16:07:06 +0100 Subject: [python-win32] Invalid or corrupted installer... In-Reply-To: References: <48D8CF2E.6030903@timgolden.me.uk> <48D903B3.4090203@timgolden.me.uk> Message-ID: <48D9061A.8010204@timgolden.me.uk> Andrea Gavana wrote: ... No explanation was provided for the reason of the > corrupted download (!) There used to be a general warning on sites which offered tgz for download that IE would do something weird with them. I never experienced the problem myself, and in any case that was years (and versions) ago so I assumed that whatever it was had been fixed long before. Maybe not... TJG From p.f.moore at gmail.com Tue Sep 23 17:36:06 2008 From: p.f.moore at gmail.com (Paul Moore) Date: Tue, 23 Sep 2008 16:36:06 +0100 Subject: [python-win32] Invalid or corrupted installer... In-Reply-To: <48D9061A.8010204@timgolden.me.uk> References: <48D8CF2E.6030903@timgolden.me.uk> <48D903B3.4090203@timgolden.me.uk> <48D9061A.8010204@timgolden.me.uk> Message-ID: <79990c6b0809230836p1c0a40cj365d8848d3f05dfe@mail.gmail.com> 2008/9/23 Tim Golden : > Andrea Gavana wrote: > ... No explanation was provided for the reason of the >> >> corrupted download (!) > > > There used to be a general warning on sites which offered > tgz for download that IE would do something weird with them. > I never experienced the problem myself, and in any case that > was years (and versions) ago so I assumed that whatever it > was had been fixed long before. Maybe not... Sorry, that was meant to go to the list: What tends to happen is that something decides to automatically uncompress, or "fix" the name, so you end up with a .tgz file which actually only contains .tar data, or a .tar file which is gzipped as well. Renaming the file usually fixes this for me. Paul From imageguy1206 at gmail.com Tue Sep 23 20:11:50 2008 From: imageguy1206 at gmail.com (geoff) Date: Tue, 23 Sep 2008 14:11:50 -0400 Subject: [python-win32] Virtual print driver - similiar to winpdf In-Reply-To: <48D8EB29.60502@co.marshall.ia.us> References: <3ee0b280809211810j7d516500o9e93c9673ee82e2b@mail.gmail.com> <48D7D8E5.7070106@probo.com> <3ee0b280809221220q277e3c9ap262d84da3bce85a0@mail.gmail.com> <48D8EB29.60502@co.marshall.ia.us> Message-ID: <3ee0b280809231111u3651a3f9n90ae1506f1e00226@mail.gmail.com> > You might take a look at Pyla. It's a print to fax library. I think it's > kind of what you're talking about. I've been trying to hack it off and on > for a while now as we only need a little of its functionality here at work. > There isn't much for docs, so you'll have to read the source. Here's a link: > http://www.teamsw.it/pyla/ > > Mike > Thanks Mike. I think I am going to dig deeper into using a Windows printer defined as using the "Standard TCPIP Port" and my own program based on SocketServer to grab to output when it it created. I set up a very crude test last night and I think this will do exactly what i need - ie can react immediately when the user is printing something, complete access to the datastream and of course pure python solution for easy maintenance :-) . keep you posted. g. From mail at timgolden.me.uk Tue Sep 23 21:57:48 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 23 Sep 2008 20:57:48 +0100 Subject: [python-win32] Virtual print driver - similiar to winpdf In-Reply-To: <3ee0b280809231111u3651a3f9n90ae1506f1e00226@mail.gmail.com> References: <3ee0b280809211810j7d516500o9e93c9673ee82e2b@mail.gmail.com> <48D7D8E5.7070106@probo.com> <3ee0b280809221220q277e3c9ap262d84da3bce85a0@mail.gmail.com> <48D8EB29.60502@co.marshall.ia.us> <3ee0b280809231111u3651a3f9n90ae1506f1e00226@mail.gmail.com> Message-ID: <48D94A3C.5030304@timgolden.me.uk> geoff wrote: >> You might take a look at Pyla. It's a print to fax library. I think it's >> kind of what you're talking about. I've been trying to hack it off and on >> for a while now as we only need a little of its functionality here at work. >> There isn't much for docs, so you'll have to read the source. Here's a link: >> http://www.teamsw.it/pyla/ >> >> Mike >> > Thanks Mike. > I think I am going to dig deeper into using a Windows printer defined > as using the "Standard TCPIP Port" and my own program based on > SocketServer to grab to output when it it created. I set up a very > crude test last night and I think this will do exactly what i need - > ie can react immediately when the user is printing something, complete > access to the datastream and of course pure python solution for easy > maintenance :-) . Sounds like a technique that's worth knowing about. Do keep us posted, even if it turns out to be a dead-end. TJG From amicitas at gmail.com Wed Sep 24 09:46:19 2008 From: amicitas at gmail.com (mir amicitas) Date: Wed, 24 Sep 2008 00:46:19 -0700 Subject: [python-win32] Drag and drop of files (CF_HDROP) In-Reply-To: References: Message-ID: <55e194140809240046oa8c2e81v2496a90b208760cf@mail.gmail.com> >The last arg is output, and will be returned from the function. > In that case I am confused about the output coming out of DoDragDrop(). The output that I get for different cases: drag canceled: 0 copy succeed: 1 move succeed: 0 I expect that move succeed would give me a value of 2 (shellcon.DROPEFFEC_MOVE). With the output above I cannot tell weather a move succeded or the drop got canceled. This is not critical functionality for me (I don't need to know the end result). At this point I am just curious. Below I am including the dragging code that I put together, just in case it is useful to anyone. (if anyone happens to notice something horribly wrong with it let me know though.) - Novi ------------------------------------------- import pythoncom import win32con import winerror import win32clipboard from win32com.server.util import NewEnum, wrap from win32com.server.exception import COMException from win32com.shell import shellcon num_do_objects = 0 def WrapCOMObject(ob, iid=None): return wrap(ob, iid=iid, useDispatcher = 0) def PackDROPFILESStructure(file_name_array): import struct """ typedef struct _DROPFILES { DWORD pFiles; POINT pt; BOOL fNC; BOOL fWide; } DROPFILES, *LPDROPFILES; """ file_name_buffer='\0'.join(file_name_array)+'\0\0' fmt="lllll%ss" %len(file_name_buffer) dropfiles=struct.pack(fmt, 20, 0, 0, 0, 0, file_name_buffer) return dropfiles def RegisterClipboardFormats(qmimedata): """ Here we extract all of the formats from the qmimedata object and register them. This will give us an ID for each type. This will return a dictionary with the ID's and descriptions for each mime type. """ mime_formats = qmimedata.formats() format_dictionary = dict() for format in mime_formats: id = win32clipboard.RegisterClipboardFormat(str(format)) format_dictionary[id] = format return format_dictionary def GetClipboardFormats(qmimedata): """ What I want to do here is to check if any of the mime data in the QMimeData object can/should be converted into a standard windows clipboard format. If it can I will extract the data here. This essentially does what QWindowsMime probably does, but since QWindowsMime is not in PyQt4 I have to do this myself. """ format_dictionary = dict() if qmimedata.hasText(): id = win32con.CF_TEXT data = str(qmimedata.text()) format_dictionary[id] = data id = win32con.CF_UNICODETEXT data = unicode(qmimedata.text()) format_dictionary[id] = data if qmimedata.hasUrls(): files = [] for url in qmimedata.urls(): file_name = url.toLocalFile() if file_name: files.append(str(file_name)) if files: id = win32con.CF_HDROP format_dictionary[id] = files return format_dictionary class IDropSource: _com_interfaces_ = [pythoncom.IID_IDropSource] _public_methods_ = ["QueryContinueDrag", "GiveFeedback"] def __init__(self): pass def __del__(self): pass def QueryContinueDrag(self, is_escape_pressed, modifier_key_state): if is_escape_pressed == True: return winerror.DRAGDROP_S_CANCEL if (modifier_key_state & win32con.MK_LBUTTON) == False and \ (modifier_key_state & win32con.MK_RBUTTON) == False: return winerror.DRAGDROP_S_DROP return winerror.S_OK def GiveFeedback(self, effect): return winerror.DRAGDROP_S_USEDEFAULTCURSORS class IDataObject: _com_interfaces_ = [pythoncom.IID_IDataObject] _public_methods_ = ["GetData", "GetDataHere", "QueryGetData" \ ,"GetCanonicalFormatEtc", "SetData", "EnumFormatEtc" \ ,"DAdvise", "DUnadvise", "EnumDAdvise"] def __init__(self, qmimedata): global num_do_objects num_do_objects += 1 self.qmimedata = qmimedata self.mime_formats = RegisterClipboardFormats(qmimedata) self.clipboard_formats = GetClipboardFormats(qmimedata) self.supported_formatetc = [] for format in self.mime_formats: formatetc = format, None, pythoncom.DVASPECT_CONTENT, -1, pythoncom.TYMED_HGLOBAL self.supported_formatetc.append(formatetc) for format in self.clipboard_formats: formatetc = format, None, pythoncom.DVASPECT_CONTENT, -1, pythoncom.TYMED_HGLOBAL self.supported_formatetc.append(formatetc) def __del__(self): global num_do_objects num_do_objects -= 1 def _query_interface_(self, iid): if iid==pythoncom.IID_IEnumFORMATETC: return NewEnum(self.supported_formatetc, iid=iid) def GetData(self, formatetc_in): #print 'GetData' ret_stg = None cf_in, target_in, aspect_in, index_in, tymed_in = formatetc_in # Loop through the supported formats. # We do this as opposed to directly searching mime_formats & clipboard_formats # mostly just to make sure the order is consistant. for formatetc in self.supported_formatetc: cf, target, aspect, index, tymed = formatetc if (aspect_in == aspect) and \ (tymed_in & tymed) and \ (cf_in == cf): ret_stg = pythoncom.STGMEDIUM() if self.mime_formats.has_key(cf): data = self.qmimedata.data(self.mime_formats[cf]) ret_stg.set(tymed, data) elif self.clipboard_formats.has_key(cf): data = self.clipboard_formats[cf] if cf == win32con.CF_TEXT or cf_in == win32con.CF_UNICODETEXT: ret_stg.set(tymed, data) elif cf == win32con.CF_HDROP: dropfiles = PackDROPFILESStructure(data) ret_stg.set(tymed, dropfiles) else: print "hystrixNtDrag.IDataObject.GetData:" print " Programming Error: id should be supported but isn't" if ret_stg is None: raise COMException(hresult=winerror.E_NOTIMPL) return ret_stg def GetDataHere(self, formatetc): #print 'GetDataHere' raise COMException(hresult=winerror.E_NOTIMPL) def QueryGetData(self, formatetc_in): #print 'QueryGetData' cf_in, target_in, aspect_in, index_in, tymed_in = formatetc_in for formatetc in self.supported_formatetc: cf, target, aspect, index, tymed = formatetc if (aspect_in & aspect) and \ (tymed_in & tymed) and \ (cf_in == cf): return winerror.S_OK raise COMException(hresult=winerror.DV_E_FORMATETC) return winerror.DV_E_FORMATETC def GetCanonicalFormatEtc(self, formatetc): #print 'GetCanonicalFormatEtc' RaiseCOMException(winerror.DATA_S_SAMEFORMATETC) # return fe def SetData(self, formatetc, medium, fRelease): #print 'SetData' raise COMException(hresult=winerror.E_NOTIMPL) def EnumFormatEtc(self, direction): #print 'EnumFormatEtc' if direction != pythoncom.DATADIR_GET: raise COMException(hresult=winerror.E_NOTIMPL) return NewEnum(self.supported_formatetc, iid=pythoncom.IID_IEnumFORMATETC) def DAdvise(self, formatetc, flags, sink): #print 'DAdvise' raise COMException(hresult=winerror.E_NOTIMPL) def DUnadvise(self, connection): #print 'DUnadvise' raise COMException(hresult=winerror.E_NOTIMPL) def EnumDAdvise(self): #print 'EnumDAdvise' raise COMException(hresult=winerror.E_NOTIMPL) def DoDragDrop(qmimedata, allow_copy=True, allow_move=False): source = IDropSource() source = WrapCOMObject(source, iid=pythoncom.IID_IDropSource) data_object = IDataObject(qmimedata) data_object = WrapCOMObject(data_object, iid=pythoncom.IID_IDataObject) effect_mask = 0 if allow_copy: effect_mask += shellcon.DROPEFFECT_COPY if allow_move: effect_mask += shellcon.DROPEFFECT_MOVE value = pythoncom.DoDragDrop(data_object, source, effect_mask) print value -------------- next part -------------- An HTML attachment was scrubbed... URL: From waxingfervor at hotmail.com Wed Sep 24 14:47:00 2008 From: waxingfervor at hotmail.com (kurt munson) Date: Wed, 24 Sep 2008 12:47:00 +0000 Subject: [python-win32] Controlling Excel via COM: errors with conditional formatting Message-ID: I have written a Python program to control MS Excel via win32com.client. This allows me to create and control an Excel spreadsheet.I want to use Excel's conditional formatting to color certain cells, but I can't get it to work.Here's the code I use: import win32com.clientxl= win32com.client.Dispatch("Excel.Application")............channamesSheet.Cells(6,3).FormatConditions.Add() Type:=1, Operator:=4, Formula1:="=C5"channamesSheet.Cells(6,3).FormatConditions(1).Interior.ColorIndex = 3I got this code from a record and replay macro in Excel, then swapped out the xl constants for numeric values (1 and 4).This gives me a syntax error when running.I have tried both .Add and .Add(), since sometimes these () are necessary.What am I doing wrong? _________________________________________________________________ Get more out of the Web. Learn 10 hidden secrets of Windows Live. http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008 -------------- next part -------------- An HTML attachment was scrubbed... URL: From Solomon.Zewdie.Altek at zf.com Wed Sep 24 15:00:04 2008 From: Solomon.Zewdie.Altek at zf.com (Solomon.Zewdie.Altek at zf.com) Date: Wed, 24 Sep 2008 15:00:04 +0200 Subject: [python-win32] Controlling Excel via COM: errors with conditionalformatting References: Message-ID: <8A13418356E45E4784744371A8B4DD7971FFC2@frds00501.emea.zf-world.com> How about this?: channamesSheet.Cells(6, 3).Font.FontSize = 10 channamesSheet.Cells(6, 3).Font.ColorIndex = "blue" channamesSheet.Cells(6, 3).Value = "something..." channamesSheet.Cells(6, 3).Font.Name = "Arial" ... I am not 100% sure whether it works, but i would try that! Regards, Solomon Z. Von: python-win32-bounces+solomon.zewdie.altek=zf.com at python.org im Auftrag von kurt munson Gesendet: Mi 24.09.2008 14:47 An: python-win32 at python.org Betreff: [python-win32] Controlling Excel via COM: errors with conditionalformatting I have written a Python program to control MS Excel via win32com.client. This allows me to create and control an Excel spreadsheet. I want to use Excel's conditional formatting to color certain cells, but I can't get it to work. Here's the code I use: import win32com.client xl= win32com.client.Dispatch("Excel.Application") .... .... .... channamesSheet.Cells(6,3).FormatConditions.Add() Type:=1, Operator:=4, Formula1:="=C5" channamesSheet.Cells(6,3).FormatConditions(1).Interior.ColorIndex = 3 I got this code from a record and replay macro in Excel, then swapped out the xl constants for numeric values (1 and 4). This gives me a syntax error when running. I have tried both .Add and .Add(), since sometimes these () are necessary. What am I doing wrong? ________________________________ Get more out of the Web. Learn 10 hidden secrets of Windows Live. Learn Now From Solomon.Zewdie.Altek at zf.com Wed Sep 24 15:07:07 2008 From: Solomon.Zewdie.Altek at zf.com (Solomon.Zewdie.Altek at zf.com) Date: Wed, 24 Sep 2008 15:07:07 +0200 Subject: [python-win32] Controlling Excel via COM: errors withconditionalformatting References: <8A13418356E45E4784744371A8B4DD7971FFC2@frds00501.emea.zf-world.com> Message-ID: <8A13418356E45E4784744371A8B4DD7971FFC3@frds00501.emea.zf-world.com> correction: ...ColorIndex = 3 (i think the value, that ColorIndex gets is an integer not a string) ________________________________ Von: python-win32-bounces+solomon.zewdie.altek=zf.com at python.org im Auftrag von Solomon.Zewdie.Altek at zf.com Gesendet: Mi 24.09.2008 15:00 An: waxingfervor at hotmail.com; python-win32 at python.org Betreff: Re: [python-win32] Controlling Excel via COM: errors withconditionalformatting How about this?: channamesSheet.Cells(6, 3).Font.FontSize = 10 channamesSheet.Cells(6, 3).Font.ColorIndex = "blue" channamesSheet.Cells(6, 3).Value = "something..." channamesSheet.Cells(6, 3).Font.Name = "Arial" ... I am not 100% sure whether it works, but i would try that! Regards, Solomon Z. Von: python-win32-bounces+solomon.zewdie.altek=zf.com at python.org im Auftrag von kurt munson Gesendet: Mi 24.09.2008 14:47 An: python-win32 at python.org Betreff: [python-win32] Controlling Excel via COM: errors with conditionalformatting I have written a Python program to control MS Excel via win32com.client. This allows me to create and control an Excel spreadsheet. I want to use Excel's conditional formatting to color certain cells, but I can't get it to work. Here's the code I use: import win32com.client xl= win32com.client.Dispatch("Excel.Application") .... .... .... channamesSheet.Cells(6,3).FormatConditions.Add() Type:=1, Operator:=4, Formula1:="=C5" channamesSheet.Cells(6,3).FormatConditions(1).Interior.ColorIndex = 3 I got this code from a record and replay macro in Excel, then swapped out the xl constants for numeric values (1 and 4). This gives me a syntax error when running. I have tried both .Add and .Add(), since sometimes these () are necessary. What am I doing wrong? ________________________________ Get more out of the Web. Learn 10 hidden secrets of Windows Live. Learn Now _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From mhammond at skippinet.com.au Wed Sep 24 15:12:22 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 24 Sep 2008 23:12:22 +1000 Subject: [python-win32] Drag and drop of files (CF_HDROP) In-Reply-To: <55e194140809240046oa8c2e81v2496a90b208760cf@mail.gmail.com> References: <55e194140809240046oa8c2e81v2496a90b208760cf@mail.gmail.com> Message-ID: <020801c91e47$30e512c0$92af3840$@com.au> An interesting read is http://msdn.microsoft.com/en-us/library/bb776904.aspx - it shows that lots of interesting state is communicated via SetData calls with custom formats. The IAsyncOperation interface is also an interesting distraction. Cheers, Mark From: python-win32-bounces+skippy.hammond=gmail.com at python.org [mailto:python-win32-bounces+skippy.hammond=gmail.com at python.org] On Behalf Of mir amicitas Sent: Wednesday, 24 September 2008 5:46 PM To: python-win32 at python.org Subject: Re: [python-win32] Drag and drop of files (CF_HDROP) >The last arg is output, and will be returned from the function. > In that case I am confused about the output coming out of DoDragDrop(). The output that I get for different cases: drag canceled: 0 copy succeed: 1 move succeed: 0 I expect that move succeed would give me a value of 2 (shellcon.DROPEFFEC_MOVE). With the output above I cannot tell weather a move succeded or the drop got canceled. This is not critical functionality for me (I don't need to know the end result). At this point I am just curious. Below I am including the dragging code that I put together, just in case it is useful to anyone. (if anyone happens to notice something horribly wrong with it let me know though.) - Novi ------------------------------------------- import pythoncom import win32con import winerror import win32clipboard from win32com.server.util import NewEnum, wrap from win32com.server.exception import COMException from win32com.shell import shellcon num_do_objects = 0 def WrapCOMObject(ob, iid=None): return wrap(ob, iid=iid, useDispatcher = 0) def PackDROPFILESStructure(file_name_array): import struct """ typedef struct _DROPFILES { DWORD pFiles; POINT pt; BOOL fNC; BOOL fWide; } DROPFILES, *LPDROPFILES; """ file_name_buffer='\0'.join(file_name_array)+'\0\0' fmt="lllll%ss" %len(file_name_buffer) dropfiles=struct.pack(fmt, 20, 0, 0, 0, 0, file_name_buffer) return dropfiles def RegisterClipboardFormats(qmimedata): """ Here we extract all of the formats from the qmimedata object and register them. This will give us an ID for each type. This will return a dictionary with the ID's and descriptions for each mime type. """ mime_formats = qmimedata.formats() format_dictionary = dict() for format in mime_formats: id = win32clipboard.RegisterClipboardFormat(str(format)) format_dictionary[id] = format return format_dictionary def GetClipboardFormats(qmimedata): """ What I want to do here is to check if any of the mime data in the QMimeData object can/should be converted into a standard windows clipboard format. If it can I will extract the data here. This essentially does what QWindowsMime probably does, but since QWindowsMime is not in PyQt4 I have to do this myself. """ format_dictionary = dict() if qmimedata.hasText(): id = win32con.CF_TEXT data = str(qmimedata.text()) format_dictionary[id] = data id = win32con.CF_UNICODETEXT data = unicode(qmimedata.text()) format_dictionary[id] = data if qmimedata.hasUrls(): files = [] for url in qmimedata.urls(): file_name = url.toLocalFile() if file_name: files.append(str(file_name)) if files: id = win32con.CF_HDROP format_dictionary[id] = files return format_dictionary class IDropSource: _com_interfaces_ = [pythoncom.IID_IDropSource] _public_methods_ = ["QueryContinueDrag", "GiveFeedback"] def __init__(self): pass def __del__(self): pass def QueryContinueDrag(self, is_escape_pressed, modifier_key_state): if is_escape_pressed == True: return winerror.DRAGDROP_S_CANCEL if (modifier_key_state & win32con.MK_LBUTTON) == False and \ (modifier_key_state & win32con.MK_RBUTTON) == False: return winerror.DRAGDROP_S_DROP return winerror.S_OK def GiveFeedback(self, effect): return winerror.DRAGDROP_S_USEDEFAULTCURSORS class IDataObject: _com_interfaces_ = [pythoncom.IID_IDataObject] _public_methods_ = ["GetData", "GetDataHere", "QueryGetData" \ ,"GetCanonicalFormatEtc", "SetData", "EnumFormatEtc" \ ,"DAdvise", "DUnadvise", "EnumDAdvise"] def __init__(self, qmimedata): global num_do_objects num_do_objects += 1 self.qmimedata = qmimedata self.mime_formats = RegisterClipboardFormats(qmimedata) self.clipboard_formats = GetClipboardFormats(qmimedata) self.supported_formatetc = [] for format in self.mime_formats: formatetc = format, None, pythoncom.DVASPECT_CONTENT, -1, pythoncom.TYMED_HGLOBAL self.supported_formatetc.append(formatetc) for format in self.clipboard_formats: formatetc = format, None, pythoncom.DVASPECT_CONTENT, -1, pythoncom.TYMED_HGLOBAL self.supported_formatetc.append(formatetc) def __del__(self): global num_do_objects num_do_objects -= 1 def _query_interface_(self, iid): if iid==pythoncom.IID_IEnumFORMATETC: return NewEnum(self.supported_formatetc, iid=iid) def GetData(self, formatetc_in): #print 'GetData' ret_stg = None cf_in, target_in, aspect_in, index_in, tymed_in = formatetc_in # Loop through the supported formats. # We do this as opposed to directly searching mime_formats & clipboard_formats # mostly just to make sure the order is consistant. for formatetc in self.supported_formatetc: cf, target, aspect, index, tymed = formatetc if (aspect_in == aspect) and \ (tymed_in & tymed) and \ (cf_in == cf): ret_stg = pythoncom.STGMEDIUM() if self.mime_formats.has_key(cf): data = self.qmimedata.data(self.mime_formats[cf]) ret_stg.set(tymed, data) elif self.clipboard_formats.has_key(cf): data = self.clipboard_formats[cf] if cf == win32con.CF_TEXT or cf_in == win32con.CF_UNICODETEXT: ret_stg.set(tymed, data) elif cf == win32con.CF_HDROP: dropfiles = PackDROPFILESStructure(data) ret_stg.set(tymed, dropfiles) else: print "hystrixNtDrag.IDataObject.GetData:" print " Programming Error: id should be supported but isn't" if ret_stg is None: raise COMException(hresult=winerror.E_NOTIMPL) return ret_stg def GetDataHere(self, formatetc): #print 'GetDataHere' raise COMException(hresult=winerror.E_NOTIMPL) def QueryGetData(self, formatetc_in): #print 'QueryGetData' cf_in, target_in, aspect_in, index_in, tymed_in = formatetc_in for formatetc in self.supported_formatetc: cf, target, aspect, index, tymed = formatetc if (aspect_in & aspect) and \ (tymed_in & tymed) and \ (cf_in == cf): return winerror.S_OK raise COMException(hresult=winerror.DV_E_FORMATETC) return winerror.DV_E_FORMATETC def GetCanonicalFormatEtc(self, formatetc): #print 'GetCanonicalFormatEtc' RaiseCOMException(winerror.DATA_S_SAMEFORMATETC) # return fe def SetData(self, formatetc, medium, fRelease): #print 'SetData' raise COMException(hresult=winerror.E_NOTIMPL) def EnumFormatEtc(self, direction): #print 'EnumFormatEtc' if direction != pythoncom.DATADIR_GET: raise COMException(hresult=winerror.E_NOTIMPL) return NewEnum(self.supported_formatetc, iid=pythoncom.IID_IEnumFORMATETC) def DAdvise(self, formatetc, flags, sink): #print 'DAdvise' raise COMException(hresult=winerror.E_NOTIMPL) def DUnadvise(self, connection): #print 'DUnadvise' raise COMException(hresult=winerror.E_NOTIMPL) def EnumDAdvise(self): #print 'EnumDAdvise' raise COMException(hresult=winerror.E_NOTIMPL) def DoDragDrop(qmimedata, allow_copy=True, allow_move=False): source = IDropSource() source = WrapCOMObject(source, iid=pythoncom.IID_IDropSource) data_object = IDataObject(qmimedata) data_object = WrapCOMObject(data_object, iid=pythoncom.IID_IDataObject) effect_mask = 0 if allow_copy: effect_mask += shellcon.DROPEFFECT_COPY if allow_move: effect_mask += shellcon.DROPEFFECT_MOVE value = pythoncom.DoDragDrop(data_object, source, effect_mask) print value -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Sep 24 19:35:09 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 24 Sep 2008 10:35:09 -0700 Subject: [python-win32] Controlling Excel via COM: errors with conditional formatting In-Reply-To: References: Message-ID: <48DA7A4D.4010706@probo.com> kurt munson wrote: > I have written a Python program to control MS Excel via > win32com.client. This allows me to create and control an Excel > spreadsheet. > > I want to use Excel's conditional formatting to color certain cells, > but I can't get it to work. > > Here's the code I use: > > |import win32com.client > xl= win32com.client.Dispatch("Excel.Application") > .... > .... > .... > channamesSheet.Cells(6,3).FormatConditions.Add() Type:=1, > Operator:=4, Formula1:="=C5" > channamesSheet.Cells(6,3).FormatConditions(1).Interior.ColorIndex = 3| > > I got this code from a record and replay macro in Excel, then swapped > out the xl constants for numeric values (1 and 4). > > This gives me a syntax error when running. > > I have tried both .Add and .Add(), since sometimes these () are necessary. > > What am I doing wrong? What you are doing wrong is writing Python scripts as if it were Visual Basic. Solomon gave you the code, but you need to understand that Python and Visual Basic are different languages. When Excel records a macro, it records it in Visual Basic. The "Arg:=Value" syntax is a Visual Basic syntax. The "sometimes these () are necessary" comment comes from Visual Basic. By the way, after you use Dispatch, all of Excel's "xl" constants are available to you. import win32com.client xl = win32com.client.dispatch( "Excel.Application" ) print win32com.clients.constants.xlLandscape -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Solomon.Zewdie.Altek at zf.com Mon Sep 29 16:41:20 2008 From: Solomon.Zewdie.Altek at zf.com (Solomon.Zewdie.Altek at zf.com) Date: Mon, 29 Sep 2008 16:41:20 +0200 Subject: [python-win32] error: 'CoInitialize not found' Message-ID: <8A13418356E45E4784744371A8B4DD7971FFCA@frds00501.emea.zf-world.com> Hi, is someone among you guys out there familier with this kind of error message or rather knows the cause and the solution?: " File "F:\2_4_2\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch pywintypes.com_error: (-2147221008, 'CoInitialize not found.', None, None) " What i am trying to do is: - instancing a class B (which i would like to use as an excel api) in class A - creating an object of this class(B) and than - using its Methods(like opening excel files, etc...) Code in Class A: ... classB_obj = classB (InputFile,True,1) classB_obj.startExcel() ... Code in Class B: .. def __init__(self, filename=None, visible, sheet): self.xlapp = win32com.client.dynamic.Dispatch("Excel.Application") self.workbook = xlFile = self.xlapp.Workbooks.Open(filename) self.xlapp.visible = visible self.worksheet = self.xlapp.Sheets(sheet) ... def startExcel(self): ... Unfortunately it doesn't work. I have tested Class B stand a lone and it works.... So the problem seems to be somehow in the interaction between class A and Class B. I am thankful for every suggestion and help!!! Solomon From mhammond at skippinet.com.au Tue Sep 30 08:50:45 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 30 Sep 2008 16:50:45 +1000 Subject: [python-win32] Attributes on exceptions Message-ID: <048801c922c8$ef1a4690$cd4ed3b0$@com.au> It is way past time that the pywin32 exception objects grew attributes instead of only being available via indexing. In other words, instead of writing: except win32api.error, exc: if exc[0] == ERROR_CODE: ... you can say: except win32api.error, exc: if exc.winerror == ERROR_CODE: ... Code that uses exception attributes will also port easier to py3k - but note that I'm not proposing anyone *must* use exception attributes - any changes will be backwards compatible. So - a few questions: * I've come up with the following for the names: win32api.error, exc: exc.winerror == exc[0] - 'winerror' as that is what python 2.5 and later use for the windows error code in its builtin exceptions. exc.funcname == exc[1] - 'funcname' as its close to 'filename', used by python builtin exceptions. exc.strerror == exc[2] - 'strerror' again as that is what Python builtin WindowsError exception uses, for example. pythoncom.error, exc: exc.hresult == exc[0] - not 'winerror' as its not a windows error code - it's a hresult. exc.strerror == exc[1] - strerror to be consistent. exc.excepinfo == exc[2] - named after the win32 EXCEPINFO struct. Remains a tuple without attributes. exc.argerror == exc[3] - no good reason for this name! do they sound reasonable? Speak now or forever hold your peace :) * The implementation has caused a subtle change in the way an exception is *printed* - eg, consider now: >>> win32api.CloseHandle(1) ... error: (6, 'CloseHandle', 'The handle is invalid.') versus in the new world: >>> win32api.CloseHandle(1) ... pywintypes.error: (6, 'CloseHandle', 'The handle is invalid.') Note the 'pywintypes.' prefix on the output; a com error will also be identified as coming from 'pywintypes'. The class name hasn't changed, just the way the class is instantiated has (I'm cheating by defining the classes in .py code embedded in a string in pywintypes!) Does anyone see a problem with that? Thanks, Mark From haraldarminmassa at gmail.com Tue Sep 30 09:29:45 2008 From: haraldarminmassa at gmail.com (Harald Armin Massa) Date: Tue, 30 Sep 2008 09:29:45 +0200 Subject: [python-win32] Attributes on exceptions In-Reply-To: <048801c922c8$ef1a4690$cd4ed3b0$@com.au> References: <048801c922c8$ef1a4690$cd4ed3b0$@com.au> Message-ID: <7be3f35d0809300029i381592descb507c9bb617098c@mail.gmail.com> Mark, > exc.excepinfo == exc[2] - named after the win32 EXCEPINFO struct. Remains > a tuple without attributes. Would'nt it be a good point to use a named tuple, at least on Pythons where that is available? > Does anyone see a problem with that? Not me. Harald -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 no fx, no carrier pigeon - EuroPython 2009 will take place in Birmingham - Stay tuned! From arve.knudsen at gmail.com Tue Sep 30 11:17:14 2008 From: arve.knudsen at gmail.com (Arve Knudsen) Date: Tue, 30 Sep 2008 11:17:14 +0200 Subject: [python-win32] Extending DLL search path? Message-ID: Hi I have a C++ program which embeds Python and is itself modularized into several DLLs. The Python part (extensions) of the application again links to these DLLs, the problem is the containing catalog (also containing the executable itself) is not on the PATH, so the DLLs aren't resolved when loading the Python extensions. Is there any smart way of extending the DLL search path at runtime? Thanks, Arve From rdahlstrom at directedge.com Tue Sep 30 13:18:46 2008 From: rdahlstrom at directedge.com (Dahlstrom, Roger) Date: Tue, 30 Sep 2008 07:18:46 -0400 Subject: [python-win32] error: 'CoInitialize not found' In-Reply-To: <8A13418356E45E4784744371A8B4DD7971FFCA@frds00501.emea.zf-world.com> References: <8A13418356E45E4784744371A8B4DD7971FFCA@frds00501.emea.zf-world.com> Message-ID: If you didn't get the answer already, you need to call pythoncom.CoInitialize() prior to the code that is throwing an error, probably put it right after init. -----Original Message----- From: python-win32-bounces+rdahlstrom=directedge.com at python.org [mailto:python-win32-bounces+rdahlstrom=directedge.com at python.org] On Behalf Of Solomon.Zewdie.Altek at zf.com Sent: Monday, September 29, 2008 10:41 AM To: python-win32 at python.org Subject: [python-win32] error: 'CoInitialize not found' Hi, is someone among you guys out there familier with this kind of error message or rather knows the cause and the solution?: " File "F:\2_4_2\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch pywintypes.com_error: (-2147221008, 'CoInitialize not found.', None, None) " What i am trying to do is: - instancing a class B (which i would like to use as an excel api) in class A - creating an object of this class(B) and than - using its Methods(like opening excel files, etc...) Code in Class A: ... classB_obj = classB (InputFile,True,1) classB_obj.startExcel() ... Code in Class B: .. def __init__(self, filename=None, visible, sheet): self.xlapp = win32com.client.dynamic.Dispatch("Excel.Application") self.workbook = xlFile = self.xlapp.Workbooks.Open(filename) self.xlapp.visible = visible self.worksheet = self.xlapp.Sheets(sheet) ... def startExcel(self): ... Unfortunately it doesn't work. I have tested Class B stand a lone and it works.... So the problem seems to be somehow in the interaction between class A and Class B. I am thankful for every suggestion and help!!! Solomon _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 DISCLAIMER: This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. NOTICE REGARDING PRIVACY AND CONFIDENTIALITY Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications. www.directedge.com From Solomon.Zewdie.Altek at zf.com Tue Sep 30 13:34:17 2008 From: Solomon.Zewdie.Altek at zf.com (Solomon.Zewdie.Altek at zf.com) Date: Tue, 30 Sep 2008 13:34:17 +0200 Subject: [python-win32] error: 'CoInitialize not found' In-Reply-To: Message-ID: <8A13418356E45E4784744371A8B4DD7971B0CD@frds00501.emea.zf-world.com> Yes, I found the similar solution at google and it works now!!! But tnx, anyhow! -----Urspr?ngliche Nachricht----- Von: Dahlstrom, Roger [mailto:rdahlstrom at directedge.com] Gesendet: Dienstag, 30. September 2008 13:19 An: Zewdie Solomon EXT FRD ALTEK; python-win32 at python.org Betreff: RE: [python-win32] error: 'CoInitialize not found' If you didn't get the answer already, you need to call pythoncom.CoInitialize() prior to the code that is throwing an error, probably put it right after init. -----Original Message----- From: python-win32-bounces+rdahlstrom=directedge.com at python.org [mailto:python-win32-bounces+rdahlstrom=directedge.com at python.org] On Behalf Of Solomon.Zewdie.Altek at zf.com Sent: Monday, September 29, 2008 10:41 AM To: python-win32 at python.org Subject: [python-win32] error: 'CoInitialize not found' Hi, is someone among you guys out there familier with this kind of error message or rather knows the cause and the solution?: " File "F:\2_4_2\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch pywintypes.com_error: (-2147221008, 'CoInitialize not found.', None, None) " What i am trying to do is: - instancing a class B (which i would like to use as an excel api) in class A - creating an object of this class(B) and than - using its Methods(like opening excel files, etc...) Code in Class A: ... classB_obj = classB (InputFile,True,1) classB_obj.startExcel() ... Code in Class B: .. def __init__(self, filename=None, visible, sheet): self.xlapp = win32com.client.dynamic.Dispatch("Excel.Application") self.workbook = xlFile = self.xlapp.Workbooks.Open(filename) self.xlapp.visible = visible self.worksheet = self.xlapp.Sheets(sheet) ... def startExcel(self): ... Unfortunately it doesn't work. I have tested Class B stand a lone and it works.... So the problem seems to be somehow in the interaction between class A and Class B. I am thankful for every suggestion and help!!! Solomon _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 DISCLAIMER: This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. NOTICE REGARDING PRIVACY AND CONFIDENTIALITY Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications. www.directedge.com From le.dahut at laposte.net Tue Sep 30 15:41:10 2008 From: le.dahut at laposte.net (le dahut) Date: Tue, 30 Sep 2008 15:41:10 +0200 Subject: [python-win32] NT service and login prompt Message-ID: <48E22C76.2090908@laposte.net> Hello, Is it possible to tell windows to wait a python service has started before the login prompt is displayed ?