From mhammond at skippinet.com.au Sun Apr 1 13:35:59 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 1 Apr 2007 21:35:59 +1000 Subject: [python-win32] access to attribute non-(full)-Ascii In-Reply-To: <000701c7736d$0ea96340$0701a8c0@PORTABLES> Message-ID: <059f01c77451$ec7e4660$0200a8c0@enfoldsystems.local> > >From Python+PyWin32, when I want access to properties (attributes) > containing some characters no-Ascii (e.g. letters with > accents, or unicode > characters), Python screech! > > I need this in bridges Python-Javascript (via ActiveScripting > or via drive > InternetExplorer.Application). > When I control the Javascript side, I make a little function > who return (a > pointer on) the object ; if the attribute is an object. > > But, if you know a way for access to these kind of > attributes, I will read > your answer, with mental thanks. It would help alot if you could provide some sample code, and the full traceback you get. Cheers, Mark From nytrokiss at gmail.com Mon Apr 2 21:20:40 2007 From: nytrokiss at gmail.com (James Matthews) Date: Mon, 2 Apr 2007 12:20:40 -0700 Subject: [python-win32] C# Vs Python Message-ID: <8a6b8e350704021220x431ec8bj5c014d8539f1f20a@mail.gmail.com> I am not asking for a very detailed comparison that i know no one will give i am just wondering for windows development which language would be better? What i mean is GUI apps, interfacing with excel,word and outlook etc.. Thanks James -- http://www.goldwatches.com/watches.asp?Brand=39 http://www.wazoozle.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070402/892d88dd/attachment.html From bgailer at alum.rpi.edu Mon Apr 2 21:32:00 2007 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Mon, 02 Apr 2007 12:32:00 -0700 Subject: [python-win32] C# Vs Python In-Reply-To: <8a6b8e350704021220x431ec8bj5c014d8539f1f20a@mail.gmail.com> References: <8a6b8e350704021220x431ec8bj5c014d8539f1f20a@mail.gmail.com> Message-ID: <46115A30.4090309@alum.rpi.edu> James Matthews wrote: > I am not asking for a very detailed comparison that i know no one will > give i am just wondering for windows development which language would > be better? What i mean is GUI apps, interfacing with excel,word and > outlook etc.. Well, for one, Python requires a lot less code to accomplish the same task: The following is a very simple C# program, a version of the classic "Hello, world!" example: class ExampleClass { static void Main() { System.Console.WriteLine("Hello, world!"); } } Th Python equivalent is: print "Hello, world!" With the assistance of Mark Hammond's excellent pywin package, COM interfacing is at least as easy as in other languages: import win32com.client xl = win32com.client.Dispatch("excel.application") xl.visible = True wb = xl.WorkBooks.Open(filename) sh = wb.Sheets(1) etc. There are various GUI toolkits available. I've not done much with them. -- Bob Gailer 510-978-4454 From nytrokiss at gmail.com Mon Apr 2 21:51:53 2007 From: nytrokiss at gmail.com (James Matthews) Date: Mon, 2 Apr 2007 12:51:53 -0700 Subject: [python-win32] C# Vs Python In-Reply-To: <46115A30.4090309@alum.rpi.edu> References: <8a6b8e350704021220x431ec8bj5c014d8539f1f20a@mail.gmail.com> <46115A30.4090309@alum.rpi.edu> Message-ID: <8a6b8e350704021251r70bc0b65x9c44818497a7d7eb@mail.gmail.com> Thank you Bob but does python's windows extensions really have the power of the .NET classes On 4/2/07, Bob Gailer wrote: > > James Matthews wrote: > > I am not asking for a very detailed comparison that i know no one will > > give i am just wondering for windows development which language would > > be better? What i mean is GUI apps, interfacing with excel,word and > > outlook etc.. > Well, for one, Python requires a lot less code to accomplish the same > task: > > The following is a very simple C# program, a version of the classic > "Hello, world!" example: > > class ExampleClass > { > static void Main() > { > System.Console.WriteLine("Hello, world!"); > } > } > > > Th Python equivalent is: > > print "Hello, world!" > > With the assistance of Mark Hammond's excellent pywin package, COM > interfacing is at least as easy as in other languages: > import win32com.client > xl = win32com.client.Dispatch("excel.application") > xl.visible = True > wb = xl.WorkBooks.Open(filename) > sh = wb.Sheets(1) > etc. > > There are various GUI toolkits available. I've not done much with them. > > -- > Bob Gailer > 510-978-4454 > > -- http://www.goldwatches.com/watches.asp?Brand=39 http://www.wazoozle.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070402/657f5c33/attachment.htm From bgailer at alum.rpi.edu Mon Apr 2 21:58:01 2007 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Mon, 02 Apr 2007 12:58:01 -0700 Subject: [python-win32] C# Vs Python In-Reply-To: <8a6b8e350704021251r70bc0b65x9c44818497a7d7eb@mail.gmail.com> References: <8a6b8e350704021220x431ec8bj5c014d8539f1f20a@mail.gmail.com> <46115A30.4090309@alum.rpi.edu> <8a6b8e350704021251r70bc0b65x9c44818497a7d7eb@mail.gmail.com> Message-ID: <46116049.4050905@alum.rpi.edu> James Matthews wrote: > Thank you Bob but does python's windows extensions really have the > power of the .NET classes Sorry, I know nothing about .NET. Perhaps some other list lurker can speak to that. Or could you provide an example of a .NET class and its usage in C#? -- Bob Gailer 510-978-4454 From mbrighton at neuropace.com Mon Apr 2 22:04:44 2007 From: mbrighton at neuropace.com (Mark C. Brighton) Date: Mon, 2 Apr 2007 13:04:44 -0700 Subject: [python-win32] C# Vs Python Message-ID: <704BA3F951BFE84B92F3B773D506C074020B5519@laguna.neuropace.com> If you're interested in using Python with .NET, you should check out IronPython: http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython They've implemented Python in .NET. Personally, I've never used it. Mark Brighton Senior Software Engineer NeuroPace -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Bob Gailer Sent: Monday, April 02, 2007 12:58 PM To: James Matthews Cc: python-win32 Subject: Re: [python-win32] C# Vs Python James Matthews wrote: > Thank you Bob but does python's windows extensions really have the > power of the .NET classes Sorry, I know nothing about .NET. Perhaps some other list lurker can speak to that. Or could you provide an example of a .NET class and its usage in C#? -- Bob Gailer 510-978-4454 _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From cmenge at gmail.com Mon Apr 2 22:17:51 2007 From: cmenge at gmail.com (Christian Menge) Date: Mon, 2 Apr 2007 16:17:51 -0400 Subject: [python-win32] C# Vs Python In-Reply-To: <46115A30.4090309@alum.rpi.edu> References: <8a6b8e350704021220x431ec8bj5c014d8539f1f20a@mail.gmail.com> <46115A30.4090309@alum.rpi.edu> Message-ID: At the Python site: http://wiki.python.org/moin/IronPython On 4/2/07, Bob Gailer wrote: > > James Matthews wrote: > > I am not asking for a very detailed comparison that i know no one will > > give i am just wondering for windows development which language would > > be better? What i mean is GUI apps, interfacing with excel,word and > > outlook etc.. > Well, for one, Python requires a lot less code to accomplish the same > task: > > The following is a very simple C# program, a version of the classic > "Hello, world!" example: > > class ExampleClass > { > static void Main() > { > System.Console.WriteLine("Hello, world!"); > } > } > > > Th Python equivalent is: > > print "Hello, world!" > > With the assistance of Mark Hammond's excellent pywin package, COM > interfacing is at least as easy as in other languages: > import win32com.client > xl = win32com.client.Dispatch("excel.application") > xl.visible = True > wb = xl.WorkBooks.Open(filename) > sh = wb.Sheets(1) > etc. > > There are various GUI toolkits available. I've not done much with them. > > -- > Bob Gailer > 510-978-4454 > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070402/c5d5345f/attachment.html From timr at probo.com Mon Apr 2 22:22:08 2007 From: timr at probo.com (Tim Roberts) Date: Mon, 02 Apr 2007 13:22:08 -0700 Subject: [python-win32] C# Vs Python In-Reply-To: <8a6b8e350704021251r70bc0b65x9c44818497a7d7eb@mail.gmail.com> References: <8a6b8e350704021220x431ec8bj5c014d8539f1f20a@mail.gmail.com> <46115A30.4090309@alum.rpi.edu> <8a6b8e350704021251r70bc0b65x9c44818497a7d7eb@mail.gmail.com> Message-ID: <461165F0.40705@probo.com> James Matthews wrote: > Thank you Bob but does python's windows extensions really have the > power of the .NET classes It depends on what you need to do. The .NET class library is, of course, far more extensive than the Python standard library even with the Win32 extensions, but for most tasks, you don't NEED the vastness of the CLR. It might be interesting for you to investigate IronPython. This is an implementation of Python as a full .NET language, with access to the entire Common Language Runtime. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From fuzzyman at voidspace.org.uk Mon Apr 2 22:14:13 2007 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Mon, 02 Apr 2007 21:14:13 +0100 Subject: [python-win32] C# Vs Python In-Reply-To: <8a6b8e350704021220x431ec8bj5c014d8539f1f20a@mail.gmail.com> References: <8a6b8e350704021220x431ec8bj5c014d8539f1f20a@mail.gmail.com> Message-ID: <46116415.8090708@voidspace.org.uk> James Matthews wrote: > I am not asking for a very detailed comparison that i know no one will > give i am just wondering for windows development which language would > be better? What i mean is GUI apps, interfacing with excel,word and > outlook etc.. > You can have the best of both worlds with IronPython. Python is syntactically and semantically more concise than C#, with language features like higher order functions, list comprehensions, standard polymorphic containers and much more. IronPython allows you to use .NET classes - and the interface with C# is basically seamless (except for .NET attributes). At Resolver we have a 20 000 line IronPython application (plus around 75 000 lines of test code) which has just gone to our first customer. I highly recommend it - particularly if you have .NET experience. Where CPython beats IronPython is cross-platform capabilities. On the other hand, Windows Forms (.NET) is better than any GUI toolkit I've seen. Michael Foord http://www.voidspace.org.uk/ironpython/index.shtml > Thanks > James > > -- > http://www.goldwatches.com/watches.asp?Brand=39 > http://www.wazoozle.com > ------------------------------------------------------------------------ > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From nytrokiss at gmail.com Tue Apr 3 01:36:06 2007 From: nytrokiss at gmail.com (James Matthews) Date: Mon, 2 Apr 2007 16:36:06 -0700 Subject: [python-win32] C# Vs Python In-Reply-To: <461165F0.40705@probo.com> References: <8a6b8e350704021220x431ec8bj5c014d8539f1f20a@mail.gmail.com> <46115A30.4090309@alum.rpi.edu> <8a6b8e350704021251r70bc0b65x9c44818497a7d7eb@mail.gmail.com> <461165F0.40705@probo.com> Message-ID: <8a6b8e350704021636m24b1ec61m55f99337fbf862b2@mail.gmail.com> I am looking into IronPython however first i am going to learn .NET to see what it has to offer On 4/2/07, Tim Roberts wrote: > > James Matthews wrote: > > Thank you Bob but does python's windows extensions really have the > > power of the .NET classes > > It depends on what you need to do. The .NET class library is, of > course, far more extensive than the Python standard library even with > the Win32 extensions, but for most tasks, you don't NEED the vastness of > the CLR. > > It might be interesting for you to investigate IronPython. This is an > implementation of Python as a full .NET language, with access to the > entire Common Language Runtime. > > -- > 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 > -- http://www.goldwatches.com/watches.asp?Brand=39 http://www.wazoozle.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070402/6c74dcca/attachment.htm From mmarch at gmail.com Tue Apr 3 23:37:57 2007 From: mmarch at gmail.com (Michael March) Date: Tue, 3 Apr 2007 14:37:57 -0700 Subject: [python-win32] How to figure out the COM object name? Message-ID: <48bc40670704031437p7c693bb8jbf5e9e2f2fdac968@mail.gmail.com> Newbie question.. I am trying to connect to a COM object.. and I can't figure how to code it.. In Makepy the name of the COM object is: OTA COM 9.0 Type LIbrary (1.0) The DDL is: OTAClient.dll The VB samples have stuff like this.. Dim td as New TDConnection td.InitConnectionEx "http://:port/qcbin" etc... What should my..... obj=win32com.client.Dispatch("........... ...look like? thanks! -- Michael F. March ----- mmarch at gmail dot com From timr at probo.com Wed Apr 4 00:16:07 2007 From: timr at probo.com (Tim Roberts) Date: Tue, 03 Apr 2007 15:16:07 -0700 Subject: [python-win32] How to figure out the COM object name? In-Reply-To: <48bc40670704031437p7c693bb8jbf5e9e2f2fdac968@mail.gmail.com> References: <48bc40670704031437p7c693bb8jbf5e9e2f2fdac968@mail.gmail.com> Message-ID: <4612D227.5060704@probo.com> Michael March wrote: > I am trying to connect to a COM object.. and I can't figure how to code it.. > > In Makepy the name of the COM object is: > OTA COM 9.0 Type LIbrary (1.0) > > The DDL is: > OTAClient.dll > > The VB samples have stuff like this.. > Dim td as New TDConnection > td.InitConnectionEx "http://:port/qcbin" > etc... > > What should my..... > obj=win32com.client.Dispatch("........... > ...look like? > It should be as simple as td = win32com.client.Dispatch( "TDConnection" ) td.InitConnectionEx( "http://server:port/qcbin" ) That is, assuming they support late binding. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mmarch at gmail.com Wed Apr 4 00:19:28 2007 From: mmarch at gmail.com (Michael March) Date: Tue, 3 Apr 2007 15:19:28 -0700 Subject: [python-win32] How to figure out the COM object name? In-Reply-To: <4612D227.5060704@probo.com> References: <48bc40670704031437p7c693bb8jbf5e9e2f2fdac968@mail.gmail.com> <4612D227.5060704@probo.com> Message-ID: <48bc40670704031519k3ca382b1p6b4214a5d58a635f@mail.gmail.com> Here is what I get when I try that... >>> td = win32com.client.Dispatch("TDConnection") Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Python24\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python24\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221005, 'Invalid class string', None, None) On 4/3/07, Tim Roberts wrote: > Michael March wrote: > > I am trying to connect to a COM object.. and I can't figure how to code it.. > > > > In Makepy the name of the COM object is: > > OTA COM 9.0 Type LIbrary (1.0) > > > > The DDL is: > > OTAClient.dll > > > > The VB samples have stuff like this.. > > Dim td as New TDConnection > > td.InitConnectionEx "http://:port/qcbin" > > etc... > > > > What should my..... > > obj=win32com.client.Dispatch("........... > > ...look like? > > > > It should be as simple as > td = win32com.client.Dispatch( "TDConnection" ) > td.InitConnectionEx( "http://server:port/qcbin" ) > > That is, assuming they support late binding. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > > ______________________________________________ From tchough at tchough.com Wed Apr 4 00:17:40 2007 From: tchough at tchough.com (TC Hough) Date: Tue, 3 Apr 2007 17:17:40 -0500 Subject: [python-win32] Win32 service with tray icon Message-ID: <200704031717.40946.tchough@tchough.com> Hi all, I'm writing a win32 service in Python. I'd like to add a tray icon displayed whenever the service is running. I have played around with SysTrayIcon.py [1], but if a user logs off and logs back on, the tray icon disappears even though the service is still running. I think the answer is probably getting my service to recreate the icon whenever a logon event happens. I don't really know much about win32 programming, though. Can someone point me in the right direction to solve this problem? Thanks, TC [1] http://www.brunningonline.net/simon/blog/archives/SysTrayIcon.py.html From mhammond at skippinet.com.au Wed Apr 4 02:00:38 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 4 Apr 2007 10:00:38 +1000 Subject: [python-win32] How to figure out the COM object name? In-Reply-To: <48bc40670704031437p7c693bb8jbf5e9e2f2fdac968@mail.gmail.com> Message-ID: <07f701c7764c$47a339a0$0200a8c0@enfoldsystems.local> > Newbie question.. > > I am trying to connect to a COM object.. and I can't figure > how to code it.. You really need to consult the documentation for the object itself. > > In Makepy the name of the COM object is: > > OTA COM 9.0 Type LIbrary (1.0) Try opening the file generated by makepy - if you are lucky, you will find a comment along the lines of: This CoClass is known by the name 'Some.Name.Here' Mark From mhammond at skippinet.com.au Wed Apr 4 02:01:51 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 4 Apr 2007 10:01:51 +1000 Subject: [python-win32] Win32 service with tray icon In-Reply-To: <200704031717.40946.tchough@tchough.com> Message-ID: <07f801c7764c$7309c280$0200a8c0@enfoldsystems.local> > I'm writing a win32 service in Python. I'd like to add a > tray icon displayed > whenever the service is running. I have played around with > SysTrayIcon.py > [1], but if a user logs off and logs back on, the tray icon > disappears even > though the service is still running. I think the answer is > probably getting > my service to recreate the icon whenever a logon event > happens. I don't > really know much about win32 programming, though. Can > someone point me in > the right direction to solve this problem? Services have trouble interacting with the desktop. The general approach is to have a dedicated taskbar application that communicates with the dedicated service using some kind of IPC. Mark From mmarch at gmail.com Wed Apr 4 02:02:25 2007 From: mmarch at gmail.com (Michael March) Date: Tue, 3 Apr 2007 17:02:25 -0700 Subject: [python-win32] How to figure out the COM object name? In-Reply-To: <07f701c7764c$47a339a0$0200a8c0@enfoldsystems.local> References: <48bc40670704031437p7c693bb8jbf5e9e2f2fdac968@mail.gmail.com> <07f701c7764c$47a339a0$0200a8c0@enfoldsystems.local> Message-ID: <48bc40670704031702g4da649d3m5f5e0661dc6480ba@mail.gmail.com> # This CoClass is known by the name 'TDClient80.AmarillusHash.1' Is that my golden ticket? On 4/3/07, Mark Hammond wrote: > > Newbie question.. > > > > I am trying to connect to a COM object.. and I can't figure > > how to code it.. > > You really need to consult the documentation for the object itself. > > > > > In Makepy the name of the COM object is: > > > > OTA COM 9.0 Type LIbrary (1.0) > > Try opening the file generated by makepy - if you are lucky, you will find a > comment along the lines of: > > This CoClass is known by the name 'Some.Name.Here' > > Mark > > -- Michael F. March ----- mmarch at gmail.com Ph: (415)462-1910 ---- Fax: (602)296-0400 P.O. Box 2254 ---- Phoenix, AZ 85002-2254 "Seriously" - HSR From mhammond at skippinet.com.au Wed Apr 4 02:07:59 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 4 Apr 2007 10:07:59 +1000 Subject: [python-win32] How to figure out the COM object name? In-Reply-To: <48bc40670704031702g4da649d3m5f5e0661dc6480ba@mail.gmail.com> Message-ID: <07fa01c7764d$4e60e200$0200a8c0@enfoldsystems.local> > # This CoClass is known by the name 'TDClient80.AmarillusHash.1' > > Is that my golden ticket? You tell us! :) But quite possibly. If that is the only occurance, it probably is. If there are others, you probably need to inspect the methods available to work out the correct one. Mark From mmarch at gmail.com Wed Apr 4 02:14:14 2007 From: mmarch at gmail.com (Michael March) Date: Tue, 3 Apr 2007 17:14:14 -0700 Subject: [python-win32] How to figure out the COM object name? In-Reply-To: <07fa01c7764d$4e60e200$0200a8c0@enfoldsystems.local> References: <48bc40670704031702g4da649d3m5f5e0661dc6480ba@mail.gmail.com> <07fa01c7764d$4e60e200$0200a8c0@enfoldsystems.local> Message-ID: <48bc40670704031714k16ed487o87b2a10011480bb0@mail.gmail.com> Arg! I typed too soon.. There were a ton of those strings in the file and one of them WAS the correct one! Thanks LAZY WEB! :) On 4/3/07, Mark Hammond wrote: > > # This CoClass is known by the name 'TDClient80.AmarillusHash.1' > > > > Is that my golden ticket? > > You tell us! :) But quite possibly. If that is the only occurance, it > probably is. If there are others, you probably need to inspect the methods > available to work out the correct one. > > Mark > > -- Michael F. March ----- mmarch at gmail.com Ph: (415)462-1910 ---- Fax: (602)296-0400 P.O. Box 2254 ---- Phoenix, AZ 85002-2254 "Seriously" - HSR From tnelson at onresolve.com Wed Apr 4 10:31:51 2007 From: tnelson at onresolve.com (Trent Nelson) Date: Wed, 4 Apr 2007 10:31:51 +0200 Subject: [python-win32] C# Vs Python In-Reply-To: <46116415.8090708@voidspace.org.uk> References: <8a6b8e350704021220x431ec8bj5c014d8539f1f20a@mail.gmail.com> <46116415.8090708@voidspace.org.uk> Message-ID: > Where CPython beats IronPython is cross-platform capabilities. IronPython can use standard CPython modules though, right? I've dropped my ipy.exe in C:\Python25 and it doesn't seem to have a problem with things like os.path, which isn't available in IP (unless I'm doing something brain dead). > On the other hand, Windows Forms (.NET) is better than any GUI toolkit > I've seen. Out of interest, have you ever used Qt/PyQt? Qt blew MFC-style apps out of the water in terms of developer friendliness a few years ago (which is when I switched to it for all our C++ development, which is why I'm somewhat biased). I'd be interested to hear from others in a similar situation that can provide a comparison between Qt/PyQt and Windows Forms .NET. Trent. From kevin.horn at gmail.com Wed Apr 4 15:20:01 2007 From: kevin.horn at gmail.com (Kevin Horn) Date: Wed, 4 Apr 2007 08:20:01 -0500 Subject: [python-win32] C# Vs Python In-Reply-To: References: <8a6b8e350704021220x431ec8bj5c014d8539f1f20a@mail.gmail.com> <46116415.8090708@voidspace.org.uk> Message-ID: <562bcc10704040620i4eb4064ckcbb54d29ca7f7207@mail.gmail.com> Michael Foord gave an excellent talk at PyCon about developing using IronPython and Windows Forms, which might be of interest. The presentation is here: http://www.voidspace.org.uk/ironpython/presentation.html Kevin Horn On 4/4/07, Trent Nelson wrote: > > > Where CPython beats IronPython is cross-platform capabilities. > > IronPython can use standard CPython modules though, right? I've dropped > my ipy.exe in C:\Python25 and it doesn't seem to have a problem with > things like os.path, which isn't available in IP (unless I'm doing > something brain dead). > > > On the other hand, Windows Forms (.NET) is better than any GUI toolkit > > I've seen. > > Out of interest, have you ever used Qt/PyQt? Qt blew MFC-style apps out > of the water in terms of developer friendliness a few years ago (which > is when I switched to it for all our C++ development, which is why I'm > somewhat biased). I'd be interested to hear from others in a similar > situation that can provide a comparison between Qt/PyQt and Windows > Forms .NET. > > > Trent. > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070404/00cbbcb8/attachment.html From fuzzyman at voidspace.org.uk Wed Apr 4 16:05:28 2007 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 04 Apr 2007 15:05:28 +0100 Subject: [python-win32] C# Vs Python In-Reply-To: References: <8a6b8e350704021220x431ec8bj5c014d8539f1f20a@mail.gmail.com> <46116415.8090708@voidspace.org.uk> Message-ID: <4613B0A8.4070506@voidspace.org.uk> Trent Nelson wrote: >> Where CPython beats IronPython is cross-platform capabilities. >> > > IronPython can use standard CPython modules though, right? I've dropped > my ipy.exe in C:\Python25 and it doesn't seem to have a problem with > things like os.path, which isn't available in IP (unless I'm doing > something brain dead). > You're right. If you add the standard library to your path then *most* of the pure Python modules 'just work'. > >> On the other hand, Windows Forms (.NET) is better than any GUI toolkit >> I've seen. >> > > Out of interest, have you ever used Qt/PyQt? Qt blew MFC-style apps out > of the water in terms of developer friendliness a few years ago (which > is when I switched to it for all our C++ development, which is why I'm > somewhat biased). I'd be interested to hear from others in a similar > situation that can provide a comparison between Qt/PyQt and Windows > Forms .NET. > > I've never used Qt I'm afraid. Windows Forms seems like a generally sane and friendly API - even when called from Python. :-) Michael Foord http://www.voidspace.org.uk/ironpython/index.shtml From davidf at sjsoft.com Wed Apr 4 13:34:17 2007 From: davidf at sjsoft.com (David Fraser) Date: Wed, 04 Apr 2007 13:34:17 +0200 Subject: [python-win32] adodbapi update - where to post? In-Reply-To: <460C596B.1050109@wirelessbeehive.com> References: <460C596B.1050109@wirelessbeehive.com> Message-ID: <46138D39.8040201@sjsoft.com> Vernon Cole wrote: > Henrik seems to have disappeared from the Internet and no maintenance > of the adodbapi site on soureceforge has happened in several years. > Question for this group: > Should I attempt to take over the project on sourceforge, or should > adodbapi be added to python-win as part of its library? This is great - we have our own internal version of an ADO DBAPI-2 Python library that we use internally and tried to release at some stage (around the same time as adodbapi) but to little interest so haven't kept up a public version. I tried to look at merging it with adodbapi at one point but got a bit swamped... David From arkanes at gmail.com Wed Apr 4 17:46:56 2007 From: arkanes at gmail.com (Chris Mellon) Date: Wed, 4 Apr 2007 10:46:56 -0500 Subject: [python-win32] Event log exception reporting with services Message-ID: <4866bea60704040846h3cdee7aeid7b96ca6df326424@mail.gmail.com> The servicemanager implementation writes an entry into the windows error log when an exception causes a service to drop out of DoRun. This works great with Python2.4, but with Python 2.5 I don't get the error messages. I'm using the prebuilt installers from the SF site, version 210 for both. This affects both py2exed executables and when running via PythonService.exe. I'm pretty lost on what the problem might be, does anyone have any suggestions? From fuzzyman at voidspace.org.uk Wed Apr 4 21:26:57 2007 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 04 Apr 2007 20:26:57 +0100 Subject: [python-win32] C# Vs Python In-Reply-To: <8a6b8e350704021636m24b1ec61m55f99337fbf862b2@mail.gmail.com> References: <8a6b8e350704021220x431ec8bj5c014d8539f1f20a@mail.gmail.com> <46115A30.4090309@alum.rpi.edu> <8a6b8e350704021251r70bc0b65x9c44818497a7d7eb@mail.gmail.com> <461165F0.40705@probo.com> <8a6b8e350704021636m24b1ec61m55f99337fbf862b2@mail.gmail.com> Message-ID: <4613FC01.60401@voidspace.org.uk> James Matthews wrote: > I am looking into IronPython however first i am going to learn .NET to > see what it has to offer IronPython is a *great* way to learn .NET. Particularly via the interactive interpreter. Instantiating and configuring classes is a lot simpler without all the C# boilerplate. Michael Foord http://www.voidspace.org.uk/ironpython/index.shtml > > On 4/2/07, *Tim Roberts* < timr at probo.com > wrote: > > James Matthews wrote: > > Thank you Bob but does python's windows extensions really have the > > power of the .NET classes > > It depends on what you need to do. The .NET class library is, of > course, far more extensive than the Python standard library even with > the Win32 extensions, but for most tasks, you don't NEED the > vastness of > the CLR. > > It might be interesting for you to investigate IronPython. This is an > implementation of Python as a full .NET language, with access to the > entire Common Language Runtime. > > -- > 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 > > > > > -- > http://www.goldwatches.com/watches.asp?Brand=39 > http://www.wazoozle.com > ------------------------------------------------------------------------ > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From arkanes at gmail.com Wed Apr 4 22:06:20 2007 From: arkanes at gmail.com (Chris Mellon) Date: Wed, 4 Apr 2007 15:06:20 -0500 Subject: [python-win32] C# Vs Python In-Reply-To: <4613B0A8.4070506@voidspace.org.uk> References: <8a6b8e350704021220x431ec8bj5c014d8539f1f20a@mail.gmail.com> <46116415.8090708@voidspace.org.uk> <4613B0A8.4070506@voidspace.org.uk> Message-ID: <4866bea60704041306s2eb319cdia06ab8d2dfa25adc@mail.gmail.com> On 4/4/07, Michael Foord wrote: > Trent Nelson wrote: > >> Where CPython beats IronPython is cross-platform capabilities. > >> > > > > IronPython can use standard CPython modules though, right? I've dropped > > my ipy.exe in C:\Python25 and it doesn't seem to have a problem with > > things like os.path, which isn't available in IP (unless I'm doing > > something brain dead). > > > You're right. If you add the standard library to your path then *most* > of the pure Python modules 'just work'. > > *pure python* modules, note, not C extension modules. "Python for .NET" (http://pythonnet.sourceforge.net/) is like ctypes for .NET - it allows you to load, call, even subclass .NET classes from within CPython. From mmarch at gmail.com Wed Apr 4 23:09:52 2007 From: mmarch at gmail.com (Michael March) Date: Wed, 4 Apr 2007 14:09:52 -0700 Subject: [python-win32] How to figure out the COM object name? In-Reply-To: <48bc40670704031714k16ed487o87b2a10011480bb0@mail.gmail.com> References: <48bc40670704031702g4da649d3m5f5e0661dc6480ba@mail.gmail.com> <07fa01c7764d$4e60e200$0200a8c0@enfoldsystems.local> <48bc40670704031714k16ed487o87b2a10011480bb0@mail.gmail.com> Message-ID: <48bc40670704041409r260af3e7ifa556991919171c6@mail.gmail.com> Just a quick follow-up.. Since getting past the issue of how to determine the name of the COM object... my programming adventures of scripting to access Mercury Quality Center has been insanely great. The first thing I did was 'port' some of the VB examples to Python and just in number of lines the Python versions had 2/3rds the number of lines as compared to the VB versions. Again.. thanks everyone! On 4/3/07, Michael March wrote: > Arg! I typed too soon.. > > There were a ton of those strings in the file and one of them WAS the > correct one! > > Thanks LAZY WEB! :) > > On 4/3/07, Mark Hammond wrote: > > > # This CoClass is known by the name 'TDClient80.AmarillusHash.1' > > > > > > Is that my golden ticket? > > > > You tell us! :) But quite possibly. If that is the only occurance, it > > probably is. If there are others, you probably need to inspect the methods > > available to work out the correct one. > > > > Mark > > > > > > > -- > > > Michael F. March ----- mmarch at gmail.com > Ph: (415)462-1910 ---- Fax: (602)296-0400 > P.O. Box 2254 ---- Phoenix, AZ 85002-2254 > "Seriously" - HSR > -- Michael F. March ----- mmarch at gmail.com Ph: (415)462-1910 ---- Fax: (602)296-0400 P.O. Box 2254 ---- Phoenix, AZ 85002-2254 "Seriously" - HSR From mhammond at skippinet.com.au Thu Apr 5 07:10:44 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 5 Apr 2007 15:10:44 +1000 Subject: [python-win32] Event log exception reporting with services In-Reply-To: <4866bea60704040846h3cdee7aeid7b96ca6df326424@mail.gmail.com> Message-ID: <001201c77740$c3ff01b0$020a0a0a@enfoldsystems.local> I can't reproduce this. If I change win32\Demos\service\pipeTestService.py to raise an error in the SvcDoRun() function, after starting the service I see the exception in the event log. Were both 2.4 and 2.5 installed with admin rights? Mark > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org]On Behalf Of Chris Mellon > Sent: Thursday, 5 April 2007 1:47 AM > To: python-win32 at python.org > Subject: [python-win32] Event log exception reporting with services > > > The servicemanager implementation writes an entry into the windows > error log when an exception causes a service to drop out of DoRun. > This works great with Python2.4, but with Python 2.5 I don't get the > error messages. I'm using the prebuilt installers from the SF site, > version 210 for both. This affects both py2exed executables and when > running via PythonService.exe. > > I'm pretty lost on what the problem might be, does anyone > have any suggestions? > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From arkanes at gmail.com Thu Apr 5 19:20:15 2007 From: arkanes at gmail.com (Chris Mellon) Date: Thu, 5 Apr 2007 12:20:15 -0500 Subject: [python-win32] Event log exception reporting with services In-Reply-To: <001201c77740$c3ff01b0$020a0a0a@enfoldsystems.local> References: <4866bea60704040846h3cdee7aeid7b96ca6df326424@mail.gmail.com> <001201c77740$c3ff01b0$020a0a0a@enfoldsystems.local> Message-ID: <4866bea60704051020o562b7d38r434100985fdd543@mail.gmail.com> Yes, there both installed from the stock python.org installers and "for all users" by an admin user. Update - it's working for my own services now, too. I rebooted last night to install patches, perhaps there was a bad message dll or something was stuck in memory. On 4/5/07, Mark Hammond wrote: > I can't reproduce this. If I change win32\Demos\service\pipeTestService.py > to raise an error in the SvcDoRun() function, after starting the service I > see the exception in the event log. Were both 2.4 and 2.5 installed with > admin rights? > > Mark > > > -----Original Message----- > > From: python-win32-bounces at python.org > > [mailto:python-win32-bounces at python.org]On Behalf Of Chris Mellon > > Sent: Thursday, 5 April 2007 1:47 AM > > To: python-win32 at python.org > > Subject: [python-win32] Event log exception reporting with services > > > > > > The servicemanager implementation writes an entry into the windows > > error log when an exception causes a service to drop out of DoRun. > > This works great with Python2.4, but with Python 2.5 I don't get the > > error messages. I'm using the prebuilt installers from the SF site, > > version 210 for both. This affects both py2exed executables and when > > running via PythonService.exe. > > > > I'm pretty lost on what the problem might be, does anyone > > have any suggestions? > > _______________________________________________ > > Python-win32 mailing list > > Python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > From nguyenvanminh at gmail.com Sat Apr 7 09:44:28 2007 From: nguyenvanminh at gmail.com (=?UTF-8?Q?Nguy=E1=BB=85n_V=C4=83n_Minh?=) Date: Sat, 7 Apr 2007 14:44:28 +0700 Subject: [python-win32] ImportError: No module named twisted.internet ? Message-ID: <9fe61de40704070044v47300aaev5baab40e7e982ddd@mail.gmail.com> hi list, i build BitTorrent-5.0.7 project in windows platform. When i run command build.bat, i've get error massages: C:\Python24\BitTorrent-5.0.7>c:\Python24\python.exe -OO winsetup.py py2exe Traceback (most recent call last): File "winsetup.py", line 24, in ? from BitTorrent.platform import get_shell_dir, shellcon File "C:\Python24\BitTorrent-5.0.7\BitTorrent\__init__.py", line 49, in ? from BitTorrent.platform import get_temp_subdir, get_dot_dir, is_frozen_exe File "C:\Python24\BitTorrent-5.0.7\BitTorrent\platform.py", line 120, in ? from BTL.defer import ThreadedDeferred File "c:\Python24\lib\BTL\defer.py", line 15, in ? from twisted.internet import defer ImportError: No module named twisted.internet Anyone can help me solv this problem! Thanks, -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070407/aee8c50c/attachment.htm From p.f.moore at gmail.com Sat Apr 7 21:49:02 2007 From: p.f.moore at gmail.com (Paul Moore) Date: Sat, 7 Apr 2007 20:49:02 +0100 Subject: [python-win32] How to make a window client area "transparent" Message-ID: <79990c6b0704071249o3d19fe83t9abe6bba172f6bf8@mail.gmail.com> This is only vaguely a Python related question - I'm writing Python code, but the basic issue I have is with Win32 programming regardless of language - but I don't know a really good forum for Win32 API technical coding questions (aside: can anyone point me to such a forum - high signal-to-noise ratio, focus on Win32 API rather than .NET or similar?) What I want to achieve is client-area transparency for a window - essentially, make the client area transparent, without the window border, title bar, etc being transparent. I'm aware of layered windows and alpha blending - but this affects the window border as well as the client area, so it's not what I'm after. Is what I'm looking for possible? If so, can anyone give me a pointer to how to achieve it? On a slightly related note, I know I can use SystemParametersInfo with SPI_GETDESKWALLPAPER to get the filename of the bmp file being used as the desktop wallpaper - but can I get the method that bitmap is used (stretch, center or tile)? I want to replicate (part of) the desktop in a window, and without that information, I'm a bit stuck! Thanks, and sorry for the off-topic post. Paul. From kc106_2005-pywin32 at yahoo.com Sat Apr 7 21:54:32 2007 From: kc106_2005-pywin32 at yahoo.com (kc106_2005-pywin32 at yahoo.com) Date: Sat, 7 Apr 2007 12:54:32 -0700 (PDT) Subject: [python-win32] Constants quit working under Python 2.5 Message-ID: <496229.53767.qm@web51402.mail.re2.yahoo.com> Hi list, I upgraded to Python 2.5 for evaluation and testing. After installing the pywin32-210.win32-py2.5.exe, I found that the constants module doesn't work. For example, this code fails: from win32com.client import Dispatch, constants print constants.xlDown I re-execute makepy.py and selected "Microsoft Office 10.0 Object Library (2.2)" but the problem persists. What should I do? Thanks, -- John Henry From rwupole at msn.com Sat Apr 7 23:56:31 2007 From: rwupole at msn.com (Roger Upole) Date: Sat, 7 Apr 2007 17:56:31 -0400 Subject: [python-win32] Re: Constants quit working under Python 2.5 Message-ID: <000701c7795f$9b3c1ad0$0100a8c0@rupole> kc106_2005-pywin32 at yahoo.com wrote: > Hi list, > > I upgraded to Python 2.5 for evaluation and testing. After installing the pywin32-210.win32-py2.5.exe, I found that the > constants module doesn't work. For example, this code fails: > > from win32com.client import Dispatch, constants > > print constants.xlDown > > I re-execute makepy.py and selected "Microsoft Office 10.0 Object Library (2.2)" but the problem persists. > > What should I do? > > Thanks, > > -- > John Henry xlDown appears to be in the Excel object library rather than the Office object library. hth Roger From mail at timgolden.me.uk Sun Apr 8 11:45:31 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Sun, 08 Apr 2007 10:45:31 +0100 Subject: [python-win32] How to make a window client area "transparent" In-Reply-To: <79990c6b0704071249o3d19fe83t9abe6bba172f6bf8@mail.gmail.com> References: <79990c6b0704071249o3d19fe83t9abe6bba172f6bf8@mail.gmail.com> Message-ID: <4618B9BB.1020003@timgolden.me.uk> Paul Moore wrote: > What I want to achieve is client-area transparency for a window - > essentially, make the client area transparent, without the window > border, title bar, etc being transparent. I'm aware of layered windows > and alpha blending - but this affects the window border as well as the > client area, so it's not what I'm after. > Can't help here, I'm afraid, except to say that if you can spot an opensource project already doing what you want, might be worth going through their code to see how they do it. (Although it might be mired deep in wx / Qt / whatever). Likely candidates are the IM/email clients which seem to use such effects. > On a slightly related note, I know I can use SystemParametersInfo with > SPI_GETDESKWALLPAPER to get the filename of the bmp file being used as > the desktop wallpaper - but can I get the method that bitmap is used > (stretch, center or tile)? I want to replicate (part of) the desktop > in a window, and without that information, I'm a bit stuck! > This one I can help with, at least from the WMI direction (!). You can interrogate the Win32_Desktop classes for that information. The complication is that WMI doesn't know which user's desktop you want, since it's running as a service not as a user (if you see what I mean). In any case, here's the starting point; I really must find a more elegant way to handle associators. import wmi import win32api c = wmi.WMI () for this_machine in c.Win32_ComputerSystem (): for user in this_machine.associators (wmi_result_class="Win32_UserAccount"): if user.Name == win32api.GetUserName (): for desktop in user.associators (wmi_result_class="Win32_Desktop"): print desktop.Wallpaper, desktop.WallpaperStretched, desktop.WallpaperTiled Obviously you could also do it this way: import getpass import socket hostname = socket.gethostname () username = getpass.getuser () desktopname = "%s\\%s" % (hostname, username) for desktop in c.Win32_Desktop (Name=desktopname): print desktop.Wallpaper # etc. Chances are there's a more straightforward win32api-ish way of doing this, but this approach certainly works. TJG From simon.dahlbacka at gmail.com Sun Apr 8 12:07:14 2007 From: simon.dahlbacka at gmail.com (Simon Dahlbacka) Date: Sun, 8 Apr 2007 13:07:14 +0300 Subject: [python-win32] How to make a window client area "transparent" In-Reply-To: <79990c6b0704071249o3d19fe83t9abe6bba172f6bf8@mail.gmail.com> References: <79990c6b0704071249o3d19fe83t9abe6bba172f6bf8@mail.gmail.com> Message-ID: <57124720704080307r64070d37p38612f9022e9b1c3@mail.gmail.com> Are you simulating Vista behavior on non-vista system, or do you want a glass-enabled application on vista? If the latter, then I suspect there are better api:s to start from, unfortunately I'm not familiar with them and cannot give any further pointers.. regards, Simon On 4/7/07, Paul Moore wrote: > > This is only vaguely a Python related question - I'm writing Python > code, but the basic issue I have is with Win32 programming regardless > of language - but I don't know a really good forum for Win32 API > technical coding questions (aside: can anyone point me to such a forum > - high signal-to-noise ratio, focus on Win32 API rather than .NET or > similar?) > > What I want to achieve is client-area transparency for a window - > essentially, make the client area transparent, without the window > border, title bar, etc being transparent. I'm aware of layered windows > and alpha blending - but this affects the window border as well as the > client area, so it's not what I'm after. > > Is what I'm looking for possible? If so, can anyone give me a pointer > to how to achieve it? > > On a slightly related note, I know I can use SystemParametersInfo with > SPI_GETDESKWALLPAPER to get the filename of the bmp file being used as > the desktop wallpaper - but can I get the method that bitmap is used > (stretch, center or tile)? I want to replicate (part of) the desktop > in a window, and without that information, I'm a bit stuck! > > Thanks, and sorry for the off-topic post. > > Paul. > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070408/9fa6bf68/attachment.html From p.f.moore at gmail.com Sun Apr 8 14:06:49 2007 From: p.f.moore at gmail.com (Paul Moore) Date: Sun, 8 Apr 2007 13:06:49 +0100 Subject: [python-win32] How to make a window client area "transparent" In-Reply-To: <57124720704080307r64070d37p38612f9022e9b1c3@mail.gmail.com> References: <79990c6b0704071249o3d19fe83t9abe6bba172f6bf8@mail.gmail.com> <57124720704080307r64070d37p38612f9022e9b1c3@mail.gmail.com> Message-ID: <79990c6b0704080506v3e800a22p525ee3ae2137f496@mail.gmail.com> On 08/04/07, Simon Dahlbacka wrote: > Are you simulating Vista behavior on non-vista system, or do you want a > glass-enabled application on vista? I'm doing this on XP. If it's a Vista look, I wasn't aware of it... :-) Thanks for the information, though, it might help me in some google searches. And thanks to Tim for the info on how to get the desktop info from WMI. Paul From mail at timgolden.me.uk Sun Apr 8 17:26:09 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Sun, 08 Apr 2007 16:26:09 +0100 Subject: [python-win32] uAnn: WMI 1.3 *and a tutorial* Message-ID: <46190991.3010607@timgolden.me.uk> I've finally got round to putting together a tutorial for the WMI module, covering the basics and some advanced stuff. I've uploaded it to: http://tgolden.sc.sabren.com/python/wmi-tutorial.html along with release 1.3 of the WMI module itself, which adds support for Extrinsic events. ***************** Python WMI Module ***************** What is it? =========== Windows Management Instrumentation (WMI) is Microsoft's implementation of Web-Based Enterprise Management (WBEM), an industry initiative to provide a Common Information Model (CIM) for pretty much any information about a computer system. The Python WMI module is a lightweight wrapper on top of the pywin32 extensions, and hides some of the messy plumbing needed to get Python to talk to the WMI API. It's pure Python and should work with any version of Python from 2.1 onwards (list comprehensions) and any recent version of pywin32. Where do I get it? ================== http://timgolden.me.uk/python/wmi.html Copyright & License? ==================== (c) Tim Golden 5th June 2003 Licensed under the (GPL-compatible) MIT License: http://www.opensource.org/licenses/mit-license.php How do I install it? ==================== When all's said and done, it's just a module. But for those who like setup programs: python setup.py install Prerequisites ============= If you're running a recent Python (2.1+) on a recent Windows (2k, 2k3, XP)and you have Mark Hammond's win32 extensions installed, you're probably up-and-running already. Otherwise... Windows ------- If you're running Win9x / NT4 you'll need to get WMI support from Microsoft. Microsoft URLs change quite often, so I suggest you do this: http://www.google.com/search?q=wmi+downloads Python ------ http://www.python.org/ (just in case you didn't know) pywin32 (was win32all) ---------------------- http://starship.python.net/crew/mhammond/win32/Downloads.html Specifically, builds 154/155 fixed a problem which affected the WMI moniker construction. You can still work without this fix, but some more complex monikers will fail. How do I use it? ================ There's a tutorial at http://timgolden.me.uk/python/wmi-tutorial.html and examples at: http://timgolden.me.uk/python/wmi_cookbook.html but as a quick taster, try this, to show all stopped services: import wmi c = wmi.WMI () for s in c.Win32_Service (): if s.State == 'Stopped': print s.Caption, s.State From kc106_2005-pywin32 at yahoo.com Mon Apr 9 22:46:29 2007 From: kc106_2005-pywin32 at yahoo.com (kc106_2005-pywin32 at yahoo.com) Date: Mon, 9 Apr 2007 13:46:29 -0700 (PDT) Subject: [python-win32] Re: Constants quit working under Python 2.5 Message-ID: <877431.58061.qm@web51412.mail.re2.yahoo.com> > > Hi list, > > > > I upgraded to Python 2.5 for evaluation and testing. > After installing the pywin32-210.win32-py2.5.exe, I found that the > > constants module doesn't work. For example, this code fails: > > > > from win32com.client import Dispatch, constants > > > > print constants.xlDown > > > > I re-execute makepy.py and selected "Microsoft Office 10.0 Object > > Library (2.2)" but the problem persists. > > > > What should I do? > > > > Thanks, > > > > -- > > John Henry > > xlDown appears to be in the Excel object library rather than > the Office object library. > > hth > Roger > > > Thanks for the reply. That's the one I've been using before the migration to 2.5. I went back and tried both Microsoft Excel 10.0 (1.4) and 5.0 (1.0) Object Library and the failures are the same. -- John Henry From f.g.- at gmx.de Tue Apr 10 11:51:55 2007 From: f.g.- at gmx.de (=?iso-8859-1?Q?Frank_G=FCnther?=) Date: Tue, 10 Apr 2007 11:51:55 +0200 Subject: [python-win32] Emulate a keystroke for Kbhit function (Conio.h) Message-ID: <001501c77b55$df7e9540$1a6fa8c0@tracetronic.local> Hi All, I've automated a console application using win32pipe.popen2 by capturing the output stream and writing the input stream. So far it works fine but the console application uses Kbhit() from conio.h in some cases. Is there a possibility to fill the keyboard buffer and emulate a keystroke for the process opened by win32pipe? Win32api.SendMessage can't be used because there is no window for the console application. The user keystrokes are captured by my wx-application that automates the console application but I don't know how to forward the keystroke to Kbhit. Ciao, Frank From ghankiewicz at rastertech.es Tue Apr 10 14:23:43 2007 From: ghankiewicz at rastertech.es (Grzegorz Adam Hankiewicz) Date: Tue, 10 Apr 2007 14:23:43 +0200 Subject: [python-win32] Recovering a DLL with ctypes from a VB project Message-ID: <461B81CF.7010505@rastertech.es> Hello. I have an old VB project using a dynamic library. I thought it would be good to use this from Python through ctypes. However, the information of function names in the dll is stripped. If I open the dll with the dependency viewer I get something like: 4 (0x0004) Function N/A Entry point 0x0006C3A8 6 (0x0006) Function N/A Entry point 0x00001000 ... up to entry 1081. However, the VB project using this DLL contains a "Public declare" file which only uses 22 functions, and they are in the form: Public Declare Function DllGetVersion _ Lib "LIBDLL" _ Alias "#2" _ () _ As String where the only thing changing is the name of the function, the alias number and the type of parameters (this function doesn't require any). The aliases start with "#1" and go up to "#21". Now, how do I relate this into Python? I can access the DLL: dll = ctypes.windll.LIBDLL prototype = ctypes.WINFUNCTYPE(ctypes.wintypes.LPCSTR) GetDllVersion = prototype(dll[6]) print "GetDllVersion: '%s'" % repr(GetDllVersion()) So I thought the alias #2 thingy specifies the order inside the DLL, which would be function 6, since that is the second one. But the result I'm getting is GetDllVersion: '' \x07\x10D'' The respective VB code would be: MsgBox ("Version " & DllGetVersion) Which outputs: Version 1.3.0 (Build 403) Far different from what I'm getting in python. So how can I use the VB declaration file to access the DLL the same way? Unfortunately the DLL doesn't expose the names, so I can only access functions with the attribute getter using an index. I tried to search for the function using a loop over all the functions, but that seems to hang up on nearly every second function. Besides, I might be doing something wrong with the return value. Any suggestions? -- Rastertech Espa?a S.A. Grzegorz Adam Hankiewicz /Jefe de Producto TeraVial/ C/ Perfumer?a 21. Nave I. Pol?gono industrial La Mina 28770 Colmenar Viejo. Madrid (Espa?a) Tel. +34 918 467 390 (Ext.18) *?* Fax +34 918 457 889 ghankiewicz at rastertech.es *?* www.rastertech.es -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070410/d285be44/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: sig.png Type: image/png Size: 10038 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20070410/d285be44/attachment.png From mail at timgolden.me.uk Tue Apr 10 14:48:33 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 10 Apr 2007 13:48:33 +0100 Subject: [python-win32] Emulate a keystroke for Kbhit function (Conio.h) In-Reply-To: <001501c77b55$df7e9540$1a6fa8c0@tracetronic.local> References: <001501c77b55$df7e9540$1a6fa8c0@tracetronic.local> Message-ID: <461B87A1.2090606@timgolden.me.uk> Frank G?nther wrote: > I've automated a console application using win32pipe.popen2 by capturing the > output stream and writing the input stream. So far it works fine but the > console application uses Kbhit() from conio.h in some cases. Is there a > possibility to fill the keyboard buffer and emulate a keystroke for the > process opened by win32pipe? > Win32api.SendMessage can't be used because there is no window for the > console application. The user keystrokes are captured by my wx-application > that automates the console application but I don't know how to forward the > keystroke to Kbhit. Not at all my area, I'm afraid, but I have thought about it a bit. Console windows do have a window handle (which you can get hold of via the win32console functions) so there *might* be a way of sending keys to it, but I'm not at all sure of the interactions between the Windows messaging and c-lib things like kbhit. This is really pexpect territory which doesn't seem to be available under Windows (unless you're prepared to try Cygwin which I can never bring myself to like). TJG From mark.m.mcmahon at gmail.com Tue Apr 10 19:38:37 2007 From: mark.m.mcmahon at gmail.com (Mark Mc Mahon) Date: Tue, 10 Apr 2007 13:38:37 -0400 Subject: [python-win32] ANN: pywinauto 0.3.7 now released Message-ID: <71b6302c0704101038x7653d08ax5dd237a731e36c4d@mail.gmail.com> Hi, 0.3.7 release of pywinauto is now available. pywinauto is an open-source (LGPL) package for using Python as a GUI automation 'driver' for Windows NT based Operating Systems (NT/W2K/XP/Vista?). SourceForge project page: http://sourceforge.net/projects/pywinauto Download from SourceForge http://sourceforge.net/project/showfiles.php?group_id=157379 Here is the list of changes from the previous release (0.3.6): 0.3.7 Merge of Wait changes and various bug fixes/improvements ------------------------------------------------------------------ 10-April-2007 * Added Timings.WaitUntil() and Timings.WaitUntilPasses() which handle the various wait until something in the code. Also refactored existing waits to use these two methods. * Fixed a major Handle leak in RemoteMemorBlock class (which is used extensively for 'Common' controls. I was using OpenHandle to open the process handle, but was not calling CloseHandle() for each corresponding OpenHandle(). * Added an active_() method to Application class to return the active window of the application. * Added an 'active' option to WindowSpecification.Wait() and WaitNot(). * Some cleanup of the clipboard module. GetFormatName() was improved and GetData() made a little more robust. * Added an option to findwindows.find_windows() to find only active windows (e.g. active_only = True). Default is False. * Fixed a bug in the timings.Timings class - timing values are Now accessed through the class (Timings) and not through the intance (self). * Updated ElementTree import in XMLHelpers so that it would work on Python 2.5 (where elementtree is a standard module) as well as other versions where ElementTree is a separate module. * Enhanced Item selection for ListViews, TreeViews - it is now possible to pass strings and they will be searched for. More documentation is required though. * Greatly enhanced Toolbar button clicking, selection, etc. Though more documentation is required. * Added option to ClickInput() to allow mouse wheel movements to be made. * menuwrapper.Menu.GetProperties() now returns a dict like all other GetProperties() methods. This dict for now only has one key 'MenuItems' which contains the list of menuitems (which had been the previous return value). Thanks Mark -------------------------------------------- Mark Mc Mahon Manchester, NH 03110, USA

pywinauto 0.3.7 Simple Windows GUI automation with Python. (10-Apr-07) From rwupole at msn.com Wed Apr 11 08:30:54 2007 From: rwupole at msn.com (Roger Upole) Date: Wed, 11 Apr 2007 02:30:54 -0400 Subject: [python-win32] Re: Emulate a keystroke for Kbhit function (Conio.h) Message-ID: <000701c77c02$f685a140$0100a8c0@rupole> Frank G?nther wrote: > Hi All, > > I've automated a console application using win32pipe.popen2 by capturing the > output stream and writing the input stream. So far it works fine but the > console application uses Kbhit() from conio.h in some cases. Is there a > possibility to fill the keyboard buffer and emulate a keystroke for the > process opened by win32pipe? > Win32api.SendMessage can't be used because there is no window for the > console application. The user keystrokes are captured by my wx-application > that automates the console application but I don't know how to forward the > keystroke to Kbhit. > > Ciao, > Frank You should be able to use PyConsoleScreenBuffer.WriteConsoleInput to send keystrokes to the app. The tricky part will be getting a handle to the console for the child process. Roger From rwupole at msn.com Wed Apr 11 08:41:31 2007 From: rwupole at msn.com (Roger Upole) Date: Wed, 11 Apr 2007 02:41:31 -0400 Subject: [python-win32] Re: Constants quit working under Python 2.5 Message-ID: <000201c77c04$724a64e0$0100a8c0@rupole> wrote in message news:877431.58061.qm at web51412.mail.re2.yahoo.com... >> > Hi list, >> > >> > I upgraded to Python 2.5 for evaluation and testing. >> After installing the pywin32-210.win32-py2.5.exe, I found that the >> > constants module doesn't work. For example, this code fails: >> > >> > from win32com.client import Dispatch, constants >> > >> > print constants.xlDown >> > >> > I re-execute makepy.py and selected "Microsoft Office 10.0 Object >> > Library (2.2)" but the problem persists. >> > >> > What should I do? >> > >> > Thanks, >> > >> > -- >> > John Henry >> >> xlDown appears to be in the Excel object library rather than >> the Office object library. >> >> hth >> Roger >> >> >> > > Thanks for the reply. > > That's the one I've been using before the migration to 2.5. I went back and tried both Microsoft Excel 10.0 (1.4) and 5.0 > (1.0) Object Library and the failures are the same. > Try clearing out your gen_py folder and starting from scratch. The below works for me with 2.5. >>> import win32com.client >>> xl=win32com.client.gencache.EnsureDispatch('Excel.Application',0) >>> print win32com.client.constants.xlDown -4121 >>> Roger From ghankiewicz at rastertech.es Thu Apr 12 16:05:23 2007 From: ghankiewicz at rastertech.es (Grzegorz Adam Hankiewicz) Date: Thu, 12 Apr 2007 16:05:23 +0200 Subject: [python-win32] How to make a standalone MFC script? Message-ID: <461E3CA3.2010607@rastertech.es> Hello. I want to embed an ActiveX control in a program and I see that the webbrowser example works very well replacing the appropriate lines. However, the webbrowser example doesn't run outside of the Pythonwin environment, as many other examples. What would I need to do to make the webbrowser a standalone script which I could py2exe it later? -- Rastertech Espa?a S.A. Grzegorz Adam Hankiewicz /Jefe de Producto TeraVial/ C/ Perfumer?a 21. Nave I. Pol?gono industrial La Mina 28770 Colmenar Viejo. Madrid (Espa?a) Tel. +34 918 467 390 (Ext.18) *?* Fax +34 918 457 889 ghankiewicz at rastertech.es *?* www.rastertech.es From vernon.cole at wirelessbeehive.com Thu Apr 12 19:52:56 2007 From: vernon.cole at wirelessbeehive.com (Vernon Cole) Date: Thu, 12 Apr 2007 11:52:56 -0600 (MDT) Subject: [python-win32] adodbapi-2.1 release candidate 1 ready for testing Message-ID: <1938.204.13.132.6.1176400376.squirrel@mail.wirelessbeehive.com> Greetings, all: I have collected all of the patches I could find, and have included them along with some of my own code to create an updated version of adodbapi. This should really be published on the sourceforge project, but since the project administrator is no longer available, I am hosting the release candidate on an old linux box at my home. Please be gentle with downloads. Mark Hammond has kindly invited me to include adodbapi in a future version of the win32all package. I believe that would be best for all and plan to accept his invitation rather than attempt to take over the sourceforge project. The temporary site for the release candidate(s) is: ftp://ftp.vernonsComputerShop.com Prerequisites: * Python 2.3 or higher. * Mark Hammond's win32all python for windows extensions. Whats new in version 2.1? 1. Use of Decimal.decimal data type for currency data. 2. add optional timeout parameter to the connect method i.e.: adodbapi.connect( connectionString, timeout=60) [thanks to: Patrik Simons] 3. improved detection of underlying transaction support [ Thomas Albrecht ] 4. fixed record set closing bug and adoRowIDtype [ Erik Rose ] 5. client-side cursoring [ Erik Rose ] 6. correct string length for qmark parameter substitution [ Jevon a.k.a. Guybrush Threepwood ] This appears to correct the "One Character In Each Field" bug. 7. replaced the try-four-strategies parameter substitution with a single, more introspective method. 8. separated the test scripts from the core module -- TO DO -- may need to add CoUninitialize to the connection.close() -- controls are unreliable, sometimes adodbapi.verbose=True works, other times must use adodbapi.adodbapi.verbose=True to get the same effect. -- Vernon Cole mailto://vernon.cole at wirelessbeehive.com Peppermill Casinos, Inc Wendover, Nevada http://wendoverfun.com From mhammond at skippinet.com.au Fri Apr 13 00:56:27 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 13 Apr 2007 08:56:27 +1000 Subject: [python-win32] How to make a standalone MFC script? In-Reply-To: <461E3CA3.2010607@rastertech.es> Message-ID: <05cc01c77d55$ce9657c0$020a0a0a@enfoldsystems.local> > I want to embed an ActiveX control in a program and I see that the > webbrowser example works very well replacing the appropriate lines. > However, the webbrowser example doesn't run outside of the Pythonwin > environment, as many other examples. > > What would I need to do to make the webbrowser a standalone > script which > I could py2exe it later? It would be very difficult to try and host a web browser control in a non-GUI application. You really are limited to hosting it in either pythonwin or wxWindows. You should be able to get both of those environments working with py2exe, but it might not qualify as a "standalone script" for you. Cheers, Mark From david.wursteisen at zslide.com Fri Apr 13 09:40:58 2007 From: david.wursteisen at zslide.com (Wursteisen David) Date: Fri, 13 Apr 2007 09:40:58 +0200 Subject: [python-win32] ImportError: No module named twisted.internet ? Message-ID: <461F340A.3080707@zslide.com> Have you tried to install the last version of Twisted ? (http://twistedmatrix.com/trac/) uhm, do you know some good resources to do some modifications on this last version of this client ? Because earch time I try to launch it under windows with python, it crash... (I use the package BitTorrent5.0.7.tar.gz from Bittorrent.com) Regards From ghankiewicz at rastertech.es Fri Apr 13 12:41:10 2007 From: ghankiewicz at rastertech.es (Grzegorz Adam Hankiewicz) Date: Fri, 13 Apr 2007 12:41:10 +0200 Subject: [python-win32] How to make a standalone MFC script? In-Reply-To: <05cc01c77d55$ce9657c0$020a0a0a@enfoldsystems.local> References: <05cc01c77d55$ce9657c0$020a0a0a@enfoldsystems.local> Message-ID: <461F5E46.5060203@rastertech.es> Mark Hammond wrote: > It would be very difficult to try and host a web browser control in a > non-GUI application. You really are limited to hosting it in either > pythonwin or wxWindows. You should be able to get both of those > environments working with py2exe, but it might not qualify as a "standalone > script" for you. It would, I didn't explain myself properly, sorry. When I double click the createwin.py example it opens a dialog with a control and just works. When I double click the webbrowser.py it asks me to be run from inside Pythonwin. I should have asked my question this way: How do I mix createwin.py and webbrowser.py to have them run without opening pythonwin separately and later creating a binary with py2exe? Much longer, though. The reason why I wanted to do this is because I want to embed a the crystal reports activex component in a wxpython application, but my first tries didn't work. OTOH modifying webbrowser.py was easy and worked, but only inside pythonwin. By now I've managed to successfully run the activex component inside wxpython, so I won't need help with the createwin+webbrowser question, though I'm still interested on the technical reasons why one works and the other doesn't (I'm a total newbie to win32 programing). http://lists.wxwidgets.org/cgi-bin/ezmlm-cgi?11:msn:63578:ihehakhbfokpnmnnafdc The example code posted in the above URL doesn't use wxPython's activex module because it doesn't allow me to specify the version of the activex control along with the clsid string, unlike gencache's EnsureModule(). I wonder what trickery does win32com to locate the correct version of the clsid, which wxpython is unable to do. -- Rastertech Espa?a S.A. Grzegorz Adam Hankiewicz /Jefe de Producto TeraVial/ C/ Perfumer?a 21. Nave I. Pol?gono industrial La Mina 28770 Colmenar Viejo. Madrid (Espa?a) Tel. +34 918 467 390 (Ext.18) *?* Fax +34 918 457 889 ghankiewicz at rastertech.es *?* www.rastertech.es From mjohnson at mpjconsultancy.com Fri Apr 13 18:25:15 2007 From: mjohnson at mpjconsultancy.com (mjohnson) Date: Fri, 13 Apr 2007 17:25:15 +0100 Subject: [python-win32] Registering an excel addin Message-ID: <87397bdd83dc4845a81295f171012867@mpjconsultancy.com> Apologies if this is in an incorrect format, but I have just stumbled on the list whilst trying to solve my problem from win32com.client import Dispatch xlApp = Dispatch("Excel.Application") time.sleep(40) xlApp.Visible = 1 wb=xlApp.Workbooks.Add() xlApp.RegisterXLL("C:\Program Files\TestApp\Program\EXLXL32.XLL") the register step returns false and does not register EXLXL32.XLL. I haven't included anything else because the following steps are dependant on the add-in being loaded which it is not Thanks in advance Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070413/76fc5e42/attachment.html From mark.m.mcmahon at gmail.com Fri Apr 13 18:53:09 2007 From: mark.m.mcmahon at gmail.com (Mark Mc Mahon) Date: Fri, 13 Apr 2007 12:53:09 -0400 Subject: [python-win32] Registering an excel addin In-Reply-To: <87397bdd83dc4845a81295f171012867@mpjconsultancy.com> References: <87397bdd83dc4845a81295f171012867@mpjconsultancy.com> Message-ID: <71b6302c0704130953t40ce99d1wae308a287c3d5b1b@mail.gmail.com> Hi, The problem may be the following... "C:\Program Files\TestApp\Program\EXLXL32.XLL" != r"C:\Program Files\TestApp\Program\EXLXL32.XLL" Otherwise I have no idea about XLL files :-) Mark On 4/13/07, mjohnson wrote: > Apologies if this is in an incorrect format, but I have just stumbled on the > list whilst trying to solve my problem > > from win32com.client import Dispatch > xlApp = Dispatch("Excel.Application") > time.sleep(40) > xlApp.Visible = 1 > wb=xlApp.Workbooks.Add() > xlApp.RegisterXLL("C:\Program > Files\TestApp\Program\EXLXL32.XLL") > > the register step returns false and does not register EXLXL32.XLL. > > I haven't included anything else because the following steps are dependant > on the add-in being loaded which it is not > > Thanks in advance > Martin > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From timr at probo.com Fri Apr 13 19:20:20 2007 From: timr at probo.com (Tim Roberts) Date: Fri, 13 Apr 2007 10:20:20 -0700 Subject: [python-win32] Registering an excel addin In-Reply-To: <87397bdd83dc4845a81295f171012867@mpjconsultancy.com> References: <87397bdd83dc4845a81295f171012867@mpjconsultancy.com> Message-ID: <461FBBD4.6020106@probo.com> mjohnson wrote: > Apologies if this is in an incorrect format, but I have just stumbled > on the list whilst trying to solve my problem > > from win32com.client import Dispatch > xlApp = Dispatch("Excel.Application") > time.sleep(40) > xlApp.Visible = 1 > wb=xlApp.Workbooks.Add() > xlApp.RegisterXLL("C:\Program Files\TestApp\Program\EXLXL32.XLL") > > the register step returns false and does not register EXLXL32.XLL. Yes, Mark is exactly right. The "\T" in your file name is actually a "tab" character, rather than the two characters you think it is. You have three choices: 1. Double the backslashes: "C:\\Program Files\\TestApp\\Program\\EXLXL32.XLL" 2. Use the "r" syntax: r"C:\Program Files\TestApp\Program\EXLXL32.XLL" 3. Use forward slashes: "C:/Program Files/TestApp/Program/EXLXL32.XLL" Any of them will work. Choose the one that makes the most sense to you. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From burkhard.doliwa at cst.com Mon Apr 16 12:44:06 2007 From: burkhard.doliwa at cst.com (burkhard.doliwa at cst.com) Date: Mon, 16 Apr 2007 12:44:06 +0200 Subject: [python-win32] standalone python scripting engine Message-ID: <4ED578ACA7.059485B2TFSWLCQP@cst.com> Dear all, I am looking for an option to create a standalone python scripting engine (in contrast to regularly installing python and registering the Python Scripting Engine with axscript\client\pyscript.py). The goal is to make python scripts (.pys) visible to cscript, without installing python system-wide. Any ideas are appreciated, Burkhard -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070416/c34f0edd/attachment.htm From graemeglass at gmail.com Mon Apr 16 14:02:29 2007 From: graemeglass at gmail.com (Graeme Glass) Date: Mon, 16 Apr 2007 14:02:29 +0200 Subject: [python-win32] standalone python scripting engine In-Reply-To: <4ED578ACA7.059485B2TFSWLCQP@cst.com> References: <4ED578ACA7.059485B2TFSWLCQP@cst.com> Message-ID: Maybe Portable Python (http://www.portablepython.com/, http://www.voidspace.org.uk/python/movpy/)? Or you could write a python script that takes a python script as an argument and executes it, then freeze that using py2exe (http://www.py2exe.org/) or cx_freeze (http://python.net/crew/atuining/cx_Freeze/) or some such tool. (I don't think that would be recommended, or work very well thought, but just giving you some ideas as to things to look into) On 4/16/07, burkhard.doliwa at cst.com wrote: > > Dear all, > > > > I am looking for an option to create a standalone python scripting > engine (in contrast to regularly installing python and registering the > Python Scripting Engine with axscript\client\pyscript.py). The goal is > to make python scripts (.pys) visible to cscript, without installing > python system-wide. > > > > Any ideas are appreciated, > > Burkhard > > > > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070416/87cdd61c/attachment.html From ckkart at hoc.net Wed Apr 18 04:00:54 2007 From: ckkart at hoc.net (Christian K.) Date: Wed, 18 Apr 2007 11:00:54 +0900 Subject: [python-win32] com events while running wx main loop Message-ID: Hi, I'm trying to recieve com events in a wxpython application. I modified an example posted here by Thomas Heller some time ago. It seems that the events are not delivered. Am I doing something wrong or is this just a limitation of com/wxPython? Thanks for any hint, Christian From ckkart at hoc.net Wed Apr 18 04:24:50 2007 From: ckkart at hoc.net (Christian K.) Date: Wed, 18 Apr 2007 11:24:50 +0900 Subject: [python-win32] com events while running wx main loop In-Reply-To: References: Message-ID: sorry. I forgot the attachment. Christian -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: wx_com.py Url: http://mail.python.org/pipermail/python-win32/attachments/20070418/0f72eba9/attachment.pot From steven.james at gmail.com Wed Apr 18 15:15:29 2007 From: steven.james at gmail.com (Steven James) Date: Wed, 18 Apr 2007 09:15:29 -0400 Subject: [python-win32] How to use IExtractImage in python Message-ID: I am attempting to add a simple thumbnail preview in a wxpython app I'm putting together. IExtractImage seems to be the way to access the thumbnails that Windows Explorer uses. (I can't use PIL or similar because I'm previewing AutoCAD .dwg files). I am adapting some Delphi COM code (from here) as follows--i've removed the Malloc and other unnecessary statements: --begin delphi code-- if NOERROR = SHGetDesktopFolder(DesktopFolder) then DesktopFolder.ParseDisplayName(0, nil, 'C:\WINNT', Eaten, ItemIDList, Attributes); DesktopFolder.BindToObject(ItemIDList, nil, IShellFolder, TargetFolder); TargetFolder.ParseDisplayName(0, nil, 'delphi_wallpaper1024.bmp', Eaten, ItemIDList, Attributes); TargetFolder.GetUIObjectOf(0, 1, ItemIDList, IExtractImage, nil, XtractImg); Malloc.Free(ItemIDList); --end delphi code-- --begin python adaption-- testPath = "C:\\" testFileName = "test.dwg" #also have tried test.bmp, test.png iSHFolder = shell.SHGetDesktopFolder() eaten, idList, attr = iSHFolder.ParseDisplayName(0, None, testPath) targetFolder = iSHFolder.BindToObject(idList, None, shell.IID_IShellFolder) eaten, targetIdList, attr = targetFolder.ParseDisplayName(0, None, testFileName) pprint ([eaten, targetIdList, attr]) extractImage = targetFolder.GetUIObjectOf(0, [targetIdList], pythoncom.MakeIID ('{BB2E617C-0920-11D1-9A0B-00C04FC2D6C1}'),0) --end python adaptation-- The python code fails on the last statement, throwing the following exception: TypeError: There is no interface object registered that supports this IID Any ideas on how to use this interface in python? I have googled for hours. Thanks, Steven James -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070418/971240cc/attachment.html From theller at ctypes.org Wed Apr 18 20:50:48 2007 From: theller at ctypes.org (Thomas Heller) Date: Wed, 18 Apr 2007 20:50:48 +0200 Subject: [python-win32] com events while running wx main loop In-Reply-To: References: Message-ID: Christian K. schrieb: > sorry. I forgot the attachment. > > Christian > > > > ------------------------------------------------------------------------ > > import unittest > import comtypes.client > > import wx > > class EventHandler(object): > """Instances are called when the COM object fires events.""" > def __init__(self, view, name): > self.view = view > self.name = name > > def __call__(self, this, *args, **kw): > self.view.write(unicode("Event %s fired" % self.name, args, kw)) Here is the problem: ^^^^^^^^^^^^ You are calling the unicode function with three arguments ;-). Unfortunately, by default you do not get a traceback that points out the problem. You can enable the tracebacks with these lines at the top of your script: import logging logging.basicConfig(level=logging.WARNING) BTW: I see that you are using an old version of comtypes (in recent versions the CreateObject function does not accept a 'sink' argument any longer; you have to setup the events by calling comtypes.client.GetEvents function, and keep the returned object as long as you want to receive the events). Unfortunately I have never released a newer comtypes, but you can get it with 'easy_install comtypes==dev', if you have svn installed. Thomas PS: I'll attach a working script that I have made, it connects to internet explorer which is my favorite com client for testing (although I don't use it for browsing). -------------- next part -------------- A non-text attachment was scrubbed... Name: x.py Type: application/x-python Size: 1956 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20070418/ccd50daa/attachment.bin From mhammond at skippinet.com.au Thu Apr 19 01:19:42 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 19 Apr 2007 09:19:42 +1000 Subject: [python-win32] How to use IExtractImage in python In-Reply-To: Message-ID: <0af901c78210$0bebd140$020a0a0a@enfoldsystems.local> I'm afraid that IExtractImage is not yet exposed by pywin32 - it would not be too hard if you are interested in testing a new implementation. Note that IExtractIcon is exposed - that may nor may-not work for you though. Cheers, Mark -----Original Message----- From: python-win32-bounces+mhammond=keypoint.com.au at python.org [mailto:python-win32-bounces+mhammond=keypoint.com.au at python.org]On Behalf Of Steven James Sent: Wednesday, 18 April 2007 11:15 PM To: python-win32 at python.org Subject: [python-win32] How to use IExtractImage in python I am attempting to add a simple thumbnail preview in a wxpython app I'm putting together. IExtractImage seems to be the way to access the thumbnails that Windows Explorer uses. (I can't use PIL or similar because I'm previewing AutoCAD .dwg files). I am adapting some Delphi COM code (from here) as follows--i've removed the Malloc and other unnecessary statements: --begin delphi code-- if NOERROR = SHGetDesktopFolder(DesktopFolder) then DesktopFolder.ParseDisplayName(0, nil, 'C:\WINNT', Eaten, ItemIDList, Attributes); DesktopFolder.BindToObject(ItemIDList, nil, IShellFolder, TargetFolder); TargetFolder.ParseDisplayName(0, nil, 'delphi_wallpaper1024.bmp', Eaten, ItemIDList, Attributes); TargetFolder.GetUIObjectOf(0, 1, ItemIDList, IExtractImage, nil, XtractImg); Malloc.Free(ItemIDList); --end delphi code-- --begin python adaption-- testPath = "C:\\" testFileName = "test.dwg" #also have tried test.bmp, test.png iSHFolder = shell.SHGetDesktopFolder() eaten, idList, attr = iSHFolder.ParseDisplayName(0, None, testPath) targetFolder = iSHFolder.BindToObject (idList, None, shell.IID_IShellFolder) eaten, targetIdList, attr = targetFolder.ParseDisplayName(0, None, testFileName) pprint ([eaten, targetIdList, attr]) extractImage = targetFolder.GetUIObjectOf(0, [targetIdList], pythoncom.MakeIID('{BB2E617C-0920-11D1-9A0B-00C04FC2D6C1}' ),0) --end python adaptation-- The python code fails on the last statement, throwing the following exception: TypeError: There is no interface object registered that supports this IID Any ideas on how to use this interface in python? I have googled for hours. Thanks, Steven James -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070419/a0155f19/attachment.html From ckkart at hoc.net Thu Apr 19 04:32:42 2007 From: ckkart at hoc.net (Christian K.) Date: Thu, 19 Apr 2007 11:32:42 +0900 Subject: [python-win32] com events while running wx main loop In-Reply-To: References: Message-ID: Thomas Heller wrote: > Christian K. schrieb: >> sorry. I forgot the attachment. >> >> Christian >> >> >> >> ------------------------------------------------------------------------ >> >> import unittest >> import comtypes.client >> >> import wx >> >> class EventHandler(object): >> """Instances are called when the COM object fires events.""" >> def __init__(self, view, name): >> self.view = view >> self.name = name >> >> def __call__(self, this, *args, **kw): >> self.view.write(unicode("Event %s fired" % self.name, args, kw)) > > Here is the problem: ^^^^^^^^^^^^ silly. Thanks. Works fine with the old version of comtypes I had installed. Now I installed comtypes from svn and get this error running your new example: Traceback (most recent call last): File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 64, in ? Listener() File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 50, in __init__ self.com_init() File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 59, in com_init self.s = comtypes.client.GetEvents(self.o, sink) File "c:\Python24\Lib\site-packages\comtypes\client\__init__.py", line 358, in GetEvents raise TypeError("cannot determine source interface") TypeError: cannot determine source interface As I'm real beginner with python on windows I'd like to ask some elementary questions if you don't mind: 1) Does comtypes depend on pywin32? 2) It seems that it provides the same (similar) mapi interface as pywin32, so can it be used as a replacement for pywin32? 3) Does comtypes expose the extended mapi? Thanks for your help, Christian From cappy2112 at gmail.com Thu Apr 19 18:52:17 2007 From: cappy2112 at gmail.com (Tony Cappellini) Date: Thu, 19 Apr 2007 09:52:17 -0700 Subject: [python-win32] How to use IExtractImage in python Message-ID: <8249c4ac0704190952t57278c06mbb2299215a49fa22@mail.gmail.com> Steven Would it be possible to launch AutoCad, then use Python/PIL to do screenshots of the images? Message: 1 Date: Wed, 18 Apr 2007 09:15:29 -0400 From: "Steven James" Subject: [python-win32] How to use IExtractImage in python To: python-win32 at python.org Message-ID: Content-Type: text/plain; charset="iso-8859-1" I am attempting to add a simple thumbnail preview in a wxpython app I'm putting together. IExtractImage seems to be the way to access the thumbnails that Windows Explorer uses. (I can't use PIL or similar because I'm previewing AutoCAD .dwg files). I am adapting some Delphi COM code (from here) as follows--i've removed the Malloc and other unnecessary statements: From theller at ctypes.org Thu Apr 19 21:02:22 2007 From: theller at ctypes.org (Thomas Heller) Date: Thu, 19 Apr 2007 21:02:22 +0200 Subject: [python-win32] com events while running wx main loop In-Reply-To: References: Message-ID: Christian K. schrieb: > > Now I installed comtypes from svn and get this error running your new > example: > > Traceback (most recent call last): > File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 64, in ? > Listener() > File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 50, in > __init__ > self.com_init() > File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 59, in > com_init > self.s = comtypes.client.GetEvents(self.o, sink) > File "c:\Python24\Lib\site-packages\comtypes\client\__init__.py", > line 358, in GetEvents > raise TypeError("cannot determine source interface") > TypeError: cannot determine source interface First of all, when you install a new comtypes version you should clear the contents of the comtypes\gen directory, so that the typelib wrappers can be regenerated. The old versions from previous comtypes releases should better not be used. Second, if you are running the exact sample that I posted then it should work for InternetExplorer, and with slight changes also for Outlook. At least it worked for me. Third, the GetEvents function requires that the COM object exposes type information, and that this information includes info about the outgoing default interface. Some objects do not do this, then you have to find the outgoing interface yourself and pass that as the 'interface=...' parameter to the GetEvents function (this description is from memory, read the sources to find out). > As I'm real beginner with python on windows I'd like to ask some > elementary questions if you don't mind: > 1) Does comtypes depend on pywin32? No, it is completely independend. > 2) It seems that it provides the same (similar) mapi interface as > pywin32, so can it be used as a replacement for pywin32? > 3) Does comtypes expose the extended mapi? I never used mapi so I cannot really answer this. comtypes normally creates the typelib wrappers itself; when these contain the mapi interfaces then there are chances that it would work. > Thanks for your help, Christian If you are a newbie to COM, and pywin32 exposes the functionality that you need you should probably better use pywin32. It is stable, well maintained, and documented. You should probably get the 'Python Programming on Win32' book, or at least read the online sample chapter. However, if you are brave, if you need to use non-dispatch based interfaces; then comtypes may be what you want. Hope it really helps, Thomas From steven.james at gmail.com Fri Apr 20 01:57:37 2007 From: steven.james at gmail.com (Steven James) Date: Thu, 19 Apr 2007 19:57:37 -0400 Subject: [python-win32] How to use IExtractImage in python In-Reply-To: References: <8249c4ac0704190952t57278c06mbb2299215a49fa22@mail.gmail.com> Message-ID: I could generate the thumbnails myself, or write a script to generate the thumbnails, yes. Unfortunately in this case the files I'm previewing may change at any time so pre-generation of the previews would not be possible. I also need to be able to generate them on the fly. I could write a server app to monitor the folders and auto-generate the thumbnails through AutoCAD, but would require me to have a server running AutoCAD (as I would not want to take over the client's computer for generation of the thumbnails). I did actually consider doing this, but I think I may put some effort in to getting IExtractImage to work, because that would allow thumbnails of all types with the COM interface implemented, as well as solving my immediate problem. I have been delving in to the process of adding support for IExtractImage to pythonwin. I have run makegw on the necessary files, added the resulting .cpp and .h files to com/win32comext/shell/src, added references in shell.cpp and setup.py, and now it seems all that is left to do is implement the proper data types which makegw did not know how to handle. (Also, if it would help anyone, I patched my makegw to run under Python 2.5 with no regex or regsub modules.) I have a few questions about the next steps, for those who may have done this before: I am left with a few lines of code in the PyIExtractImage.cpp file that look like this: if (bPythonIsHappy && !PyObject_AsDWORD *( obpdwPriority, &pdwPriority )) bPythonIsHappy = FALSE; I am assuming I either need to find or write an implementation of PyObject_AsDWORD*. What would be the proper file to put this function in? It looks like I need DWORD*, const SIZE*, and HBITMAP*. Does all of this look right to you? It seems like at least DWORD should already be written somewhere, but I can't seem to find it. Any help/advice would be appreciated. Thanks for the responses so far. Steven James On 4/19/07, Tony Cappellini < cappy2112 at gmail.com> wrote: > > Steven > > Would it be possible to launch AutoCad, then use Python/PIL to do > screenshots of the images? > > Message: 1 > Date: Wed, 18 Apr 2007 09:15:29 -0400 > From: "Steven James" > Subject: [python-win32] How to use IExtractImage in python > To: python-win32 at python.org > Message-ID: > > Content-Type: text/plain; charset="iso-8859-1" > > I am attempting to add a simple thumbnail preview in a wxpython app I'm > putting together. IExtractImage seems to be the way to access the > thumbnails > that Windows Explorer uses. > > (I can't use PIL or similar because I'm previewing AutoCAD .dwg files). > > I am adapting some Delphi COM code (from > here< http://www.delphi3000.com/articles/article_3806.asp?SK=>) > as follows--i've removed the Malloc and other unnecessary statements: > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070419/08092d48/attachment.html From mhammond at skippinet.com.au Fri Apr 20 02:50:16 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 20 Apr 2007 10:50:16 +1000 Subject: [python-win32] How to use IExtractImage in python In-Reply-To: Message-ID: <0c5201c782e5$dd472f20$020a0a0a@enfoldsystems.local> > I have been delving in to the process of adding support for IExtractImage to > pythonwin. I have run makegw on the necessary files, added the resulting .cpp > and .h files to com/win32comext/shell/src, added references in shell.cpp and > setup.py, and now it seems all that is left to do is implement the proper > data types which makegw did not know how to handle. (Also, if it would > help anyone, I patched my makegw to run under Python 2.5 with no regex > or regsub modules.) Excellent - please feel free to send me the patches. makegw is *very* dumb though. > I have a few questions about the next steps, for those who may have done this before: > I am left with a few lines of code in the PyIExtractImage.cpp file that look like this: > if (bPythonIsHappy && !PyObject_AsDWORD *( obpdwPriority, &pdwPriority )) bPythonIsHappy = FALSE; See above - makepy is dumb :) For now, PyInt_AsLong should work fine for a DWORD. HBITMAP should just use PyLong_FromVoidPtr (or however that is spelt), and a SIZE already has PyWinObject_FromSIZE. You will just need to correct the invalid indirections created by makegw - eg, your line above would read as: > DWORD dwPriority; > if (bPythonIsHappy && !PyInt_AsLong( obpdwPriority, (long *)&dwPriority )) bPythonIsHappy = FALSE; Also, please see the existing support for IExtractIcon - this new interface should be almost identical - just one or 2 data types appear to be different between the interfaces (HICON -> HBITMAP being the most obvious one) Cheers, Mark From ckkart at hoc.net Fri Apr 20 09:09:17 2007 From: ckkart at hoc.net (Christian K.) Date: Fri, 20 Apr 2007 16:09:17 +0900 Subject: [python-win32] com events while running wx main loop In-Reply-To: References: Message-ID: Thomas Heller wrote: > Christian K. schrieb: >> Now I installed comtypes from svn and get this error running your new >> example: >> >> Traceback (most recent call last): >> File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 64, in ? >> Listener() >> File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 50, in >> __init__ >> self.com_init() >> File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 59, in >> com_init >> self.s = comtypes.client.GetEvents(self.o, sink) >> File "c:\Python24\Lib\site-packages\comtypes\client\__init__.py", >> line 358, in GetEvents >> raise TypeError("cannot determine source interface") >> TypeError: cannot determine source interface > > First of all, when you install a new comtypes version you should clear the > contents of the comtypes\gen directory, so that the typelib wrappers can > be regenerated. The old versions from previous comtypes releases should > better not be used. I had the comtypes directory removed before installing from svn. > Second, if you are running the exact sample that I posted then it should work > for InternetExplorer, and with slight changes also for Outlook. At least > it worked for me. Well, here it doesn't. > Third, the GetEvents function requires that the COM object exposes type information, > and that this information includes info about the outgoing default interface. > Some objects do not do this, then you have to find the outgoing interface yourself > and pass that as the 'interface=...' parameter to the GetEvents function (this description > is from memory, read the sources to find out) Ok, I've no idea what the 'interface' is in this case. Time for a good book obviously. >> 2) It seems that it provides the same (similar) mapi interface as >> pywin32, so can it be used as a replacement for pywin32? >> 3) Does comtypes expose the extended mapi? > > I never used mapi so I cannot really answer this. > comtypes normally creates the typelib wrappers itself; when these > contain the mapi interfaces then there are chances that it would work. The point why I was asking that, is, that in order to circumvent some silly Outlook security barrier when accessing it with simple mapi one has to use the extended mapi interface according to what I've understood from googeling. pywin32 ships with an example of how to create a new mail using the extended mapi and I guess this is the way to go for me. But honestly I still know too few to even use all those acronyms properly :) > If you are a newbie to COM, and pywin32 exposes the functionality that you need > you should probably better use pywin32. It is stable, well maintained, and documented. > You should probably get the 'Python Programming on Win32' book, or at least read > the online sample chapter. Thank you for pointing that out. > However, if you are brave, if you need to use non-dispatch based interfaces; then > comtypes may be what you want. I successfully read out the Outlook inbox using comtpyes but finally switched back to pywin32 because I was not able to interprete the value of MailItem.CreationTime, e.g: obj.Session.Folders['mail.server.com'].Folders['INBOX'].Items.Item(1).CreationTime which looks like a posix timestamp which dates back to the 70th. I guess pywin32 is doing some conversion there and comtypes is not? Anyway I'll have a look at both again after having read some more documentation. Christian From theller at ctypes.org Fri Apr 20 11:29:55 2007 From: theller at ctypes.org (Thomas Heller) Date: Fri, 20 Apr 2007 11:29:55 +0200 Subject: [python-win32] com events while running wx main loop In-Reply-To: References: Message-ID: Christian K. schrieb: > Thomas Heller wrote: >> Christian K. schrieb: >>> Now I installed comtypes from svn and get this error running your new >>> example: >>> >>> Traceback (most recent call last): >>> File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 64, in ? >>> Listener() >>> File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 50, in >>> __init__ >>> self.com_init() >>> File "C:\Dokumente und Einstellungen\ck\Desktop\x.py", line 59, in >>> com_init >>> self.s = comtypes.client.GetEvents(self.o, sink) >>> File "c:\Python24\Lib\site-packages\comtypes\client\__init__.py", >>> line 358, in GetEvents >>> raise TypeError("cannot determine source interface") >>> TypeError: cannot determine source interface >> >> First of all, when you install a new comtypes version you should clear the >> contents of the comtypes\gen directory, so that the typelib wrappers can >> be regenerated. The old versions from previous comtypes releases should >> better not be used. > > I had the comtypes directory removed before installing from svn. > >> Second, if you are running the exact sample that I posted then it should work >> for InternetExplorer, and with slight changes also for Outlook. At least >> it worked for me. > > Well, here it doesn't. I will try to find this problem later. > I successfully read out the Outlook inbox using comtpyes but finally > switched back to pywin32 because I was not able to interprete the value > of MailItem.CreationTime, > e.g: > obj.Session.Folders['mail.server.com'].Folders['INBOX'].Items.Item(1).CreationTime > which looks like a posix timestamp which dates back to the 70th. I guess > pywin32 is doing some conversion there and comtypes is not? pywin32 uses the IDispatch interface, which probably returns the time in a VARIANT with typecode VT_DATE, and of type C double. This way the code knows that a date/time is meant and can convert accordingly. The outlook type library seems to use the C double also, but comtypes does not know that a date/time is meant. In COM, date/time is represented as double, in days since 30. Dec 1899. In comtypes\automation is code to do the conversion from/to VARIANT instances, from what I see there you should be able to do the conversion yourself with code like this: import datetime _com_null_date = datetime.datetime(1899, 12, 30, 0, 0, 0) def double_to_datetime(days): "Takes a COM date/time value, a float, and returns a datetime object" return datetime.timedelta(days=days) + _com_null_date Thomas From sven.wikstrom at scania.com Fri Apr 20 13:45:07 2007 From: sven.wikstrom at scania.com (=?iso-8859-1?Q?Wikstr=F6m_Sven?=) Date: Fri, 20 Apr 2007 13:45:07 +0200 Subject: [python-win32] Accessing other than default COM interface Message-ID: Hi. I'm a COM newbie so please excuse my ignorance! I have a coclass exposing a set of interfaces to COM: coclass ICAList { [default] interface _ICAList; interface _Object; interface IList; interface ICollection; interface IEnumerable; }; The default interface "ICAList" does not have an indexer nor GetItem function, so I would like to access the non default "IList" interface. Desired usage of indexer: >> p = win32com.client.Dispatch("test.Class1"); >> list = p.GetICAList() >> # Get the "IList" interface instead....somehow....? >> for item in range(0, 5): >> print list[item].Name Can this be done in Python 2.2? Many thanks. /Sven From theller at ctypes.org Fri Apr 20 20:20:02 2007 From: theller at ctypes.org (Thomas Heller) Date: Fri, 20 Apr 2007 20:20:02 +0200 Subject: [python-win32] com events while running wx main loop In-Reply-To: References: Message-ID: Christian K. schrieb: > > I successfully read out the Outlook inbox using comtpyes but finally > switched back to pywin32 because I was not able to interprete the value > of MailItem.CreationTime, > e.g: > obj.Session.Folders['mail.server.com'].Folders['INBOX'].Items.Item(1).CreationTime > which looks like a posix timestamp which dates back to the 70th. I guess > pywin32 is doing some conversion there and comtypes is not? Here is a little hack that automatically converts COM date/time objects (doubles) from or to Python datetime objects. You have to insert this code near the top of the generated comtypes.gen._00062FFF_0000_0000_C000_000000000046_0_9_1 module (this is the module that is imported by comtypes.gen.Outlook on my system. BTW I have outlook 2002, if you have a different version the module name may be different). It replaces the c_double datetype used in that module with a subclass that converts automatically in COM method calls: import datetime _com_null_date = datetime.datetime(1899, 12, 30, 0, 0, 0) class com_datetime(c_double): """COM represents date/time values as double. The value is the number of days since 1899, Dec 30.""" def __ctypes_from_outparam__(self): # When an [out] parameter is retrived from a COM method call, # this special method is called. Return a datetime object. return datetime.timedelta(seconds=self.value * 86400.) + _com_null_date @classmethod def from_param(cls, value): if isinstance(value, (float, int, long)): # convert a unix timestamp into a datetime instance. value = datetime.datetime.fromtimestamp(value) if isinstance(value, datetime.datetime): # Convert a datetime instance into a COM date. delta = value - _com_null_date # a day has 24 * 60 * 60 = 86400 seconds com_days = delta.days + (delta.seconds + delta.microseconds * 1e-6) / 86400. return cls(com_days) raise TypeError("need timestamp or datetime object") c_double = com_datetime Thomas From theller at ctypes.org Fri Apr 20 20:26:00 2007 From: theller at ctypes.org (Thomas Heller) Date: Fri, 20 Apr 2007 20:26:00 +0200 Subject: [python-win32] com events while running wx main loop In-Reply-To: References: Message-ID: Christian K. schrieb: >> Second, if you are running the exact sample that I posted then it should work >> for InternetExplorer, and with slight changes also for Outlook. At least >> it worked for me. > > Well, here it doesn't. comtypes uses fairly extensive logging calls in certain areas. You can enable this to find out the reason. Here is a little code snippet that shows what happens on my system when I call GetEvents() with Internet Explorer: from comtypes.client import CreateObject, GetEvents import logging ie = CreateObject("InternetExplorer.Application") logging.basicConfig(level=logging.DEBUG) GetEvents(ie, sink=object()) and here is the output: DEBUG:comtypes.client._events: using sinkinterface from clsid DEBUG:comtypes.client._events:Start advise DEBUG:comtypes._comobject:.QueryInterface({00000003-000 0-0000-C000-000000000046}) -> E_NOINTERFACE DEBUG:comtypes._comobject:.QueryInterface({00000003-000 0-0000-C000-000000000046}) -> E_NOINTERFACE DEBUG:comtypes._comobject:.QueryInterface({0000001B-000 0-0000-C000-000000000046}) -> E_NOINTERFACE DEBUG:comtypes._comobject:.QueryInterface({00000000-000 0-0000-C000-000000000046}) -> S_OK DEBUG:comtypes._comobject:1 active COM objects: Added DEBUG:comtypes._comobject:.AddRef() -> 1 DEBUG:comtypes._comobject:.AddRef() -> 2 DEBUG:comtypes._comobject:.QueryInterface({00000018-000 0-0000-C000-000000000046}) -> E_NOINTERFACE DEBUG:comtypes._comobject:.QueryInterface({00000019-000 0-0000-C000-000000000046}) -> E_NOINTERFACE DEBUG:comtypes._comobject:.QueryInterface({4C1E39E1-E3E 3-4296-AA86-EC938D896E92}) -> E_NOINTERFACE DEBUG:comtypes._comobject:.Release() -> 1 DEBUG:comtypes._comobject:.QueryInterface({34A715A0-658 7-11D0-924A-0020AFC7AC4D}) -> S_OK DEBUG:comtypes._comobject:.AddRef() -> 2 DEBUG:comtypes._comobject:.AddRef() -> 3 DEBUG:comtypes:Release DEBUG:comtypes._comobject:.Release() -> 2 DEBUG:comtypes._comobject:.Release() -> 1 DEBUG:comtypes._comobject:.Release() -> 0 DEBUG:comtypes._comobject:0 active COM objects: Removed DEBUG:comtypes:Release DEBUG:comtypes:Calling CoUnititialize() DEBUG:comtypes:CoUnititialize() done. You should run the snippet yourself and compare the output. Thomas From steven.james at gmail.com Fri Apr 20 21:22:05 2007 From: steven.james at gmail.com (Steven James) Date: Fri, 20 Apr 2007 15:22:05 -0400 Subject: [python-win32] How to use IExtractImage in python In-Reply-To: <0c5201c782e5$dd472f20$020a0a0a@enfoldsystems.local> References: <0c5201c782e5$dd472f20$020a0a0a@enfoldsystems.local> Message-ID: Thank your your excellent help, Mark. I have gotten everything to compile properly, and can call IExtractImage::GetLocation and IExtractImage::Extract from python on the necessary files. Even the exceptions on unknown file types seem to be handled properly. The final problem is getting the image data into python (and using it in wxpython). The final return type is an HBITMAP, which I can see as an int in Python using PyLong_FromVoidPtr, or as a PyHANDLE in python using PyWinObject_FromHANDLE. I realize that a discussion on wxpython would be outside this group's topic, but if anyone could tell me where to start looking for a way to do this, I would greatly appreciate it. From what I can tell, wxpython/wxwindows uses the HBITMAP type internally to store images, and it appears to be a pointer to a DIB in memory. If so, it may be possible to use wx.BitmapFromBuffer, wx.BitmapFromBits, or some similar function, if I can somehow convert the HBITMAP data (instead of the handle) to a string. Thanks, Steven James On 4/19/07, Mark Hammond wrote: > > > I have been delving in to the process of adding support for > IExtractImage > to > > pythonwin. I have run makegw on the necessary files, added the resulting > .cpp > > and .h files to com/win32comext/shell/src, added references in shell.cpp > and > > setup.py, and now it seems all that is left to do is implement the > proper > > data types which makegw did not know how to handle. (Also, if it would > > help anyone, I patched my makegw to run under Python 2.5 with no regex > > or regsub modules.) > > Excellent - please feel free to send me the patches. makegw is *very* > dumb > though. > > > I have a few questions about the next steps, for those who may have done > this before: > > > I am left with a few lines of code in the PyIExtractImage.cpp file that > look like this: > > > if (bPythonIsHappy && !PyObject_AsDWORD *( obpdwPriority, &pdwPriority > )) > bPythonIsHappy = FALSE; > > See above - makepy is dumb :) For now, PyInt_AsLong should work fine for > a > DWORD. HBITMAP should just use PyLong_FromVoidPtr (or however that is > spelt), and a SIZE already has PyWinObject_FromSIZE. You will just need > to > correct the invalid indirections created by makegw - eg, your line above > would read as: > > > DWORD dwPriority; > > if (bPythonIsHappy && !PyInt_AsLong( obpdwPriority, (long *)&dwPriority > )) > bPythonIsHappy = FALSE; > > Also, please see the existing support for IExtractIcon - this new > interface > should be almost identical - just one or 2 data types appear to be > different > between the interfaces (HICON -> HBITMAP being the most obvious one) > > Cheers, > > Mark > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070420/c4089c57/attachment.htm From ckkart at hoc.net Sat Apr 21 01:19:29 2007 From: ckkart at hoc.net (Christian K) Date: Sat, 21 Apr 2007 08:19:29 +0900 Subject: [python-win32] com events while running wx main loop In-Reply-To: References: Message-ID: Thomas Heller wrote: > Christian K. schrieb: >>> Second, if you are running the exact sample that I posted then it should work >>> for InternetExplorer, and with slight changes also for Outlook. At least >>> it worked for me. >> Well, here it doesn't. > > comtypes uses fairly extensive logging calls in certain areas. You can enable this > to find out the reason. Here is a little code snippet that shows what happens on > my system when I call GetEvents() with Internet Explorer: > > > from comtypes.client import CreateObject, GetEvents > import logging > ie = CreateObject("InternetExplorer.Application") > logging.basicConfig(level=logging.DEBUG) > GetEvents(ie, sink=object()) > Thank you very much for all your help so far. I'll be quiet for the next two weeks since I'm out of town. Christian From niki at vintech.bg Sat Apr 21 10:41:54 2007 From: niki at vintech.bg (Niki Spahiev) Date: Sat, 21 Apr 2007 11:41:54 +0300 Subject: [python-win32] How to use IExtractImage in python In-Reply-To: References: <0c5201c782e5$dd472f20$020a0a0a@enfoldsystems.local> Message-ID: <4629CE52.5010704@vintech.bg> > I realize that a discussion on wxpython would be outside this group's > topic, but if anyone could tell me where to start looking for a way to > do this, I would greatly appreciate it. From what I can tell, > wxpython/wxwindows uses the HBITMAP type internally to store images, and > it appears to be a pointer to a DIB in memory. If so, it may be possible > to use wx.BitmapFromBuffer, wx.BitmapFromBits, or some similar function, > if I can somehow convert the HBITMAP data (instead of the handle) to a > string. IIRC you can use wxDC.GetSafeHDC() and then win32gui to copy data to wxBitmap HTH Niki Spahiev From mjohnson at mpjconsultancy.com Wed Apr 25 16:30:52 2007 From: mjohnson at mpjconsultancy.com (mjohnson) Date: Wed, 25 Apr 2007 15:30:52 +0100 Subject: [python-win32] excel xla runautomacros Message-ID: <47686397d85a42d0885edcc1778452df@mpjconsultancy.com> I am having a problem with an excel add-in which is installed via xlApp.Workbooks.Open("C:/Program Files/Program/XLOF32.xla").RunAutoMacros(1) I can then add the add-in and install it via xlApp.AddIns.Add ("C:/Program Files/Program/XLOF32.xla",True) xlApp.AddIns.Item(Index='Excel Functions').Installed=True My problem is that the macro may have already been run, which generates a dialog warning that it is already open. The question, is there a way of detecting whether the add-in is already open? Thanks Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070425/9aeb4812/attachment.htm From benn at cenix-bioscience.com Wed Apr 25 17:33:31 2007 From: benn at cenix-bioscience.com (Neil Benn) Date: Wed, 25 Apr 2007 17:33:31 +0200 Subject: [python-win32] Registering a Server COM to make it visible in the reference list Message-ID: <462F74CB.3060103@cenix-bioscience.com> Hello, I have made a COM server using python and registered it using win32com.server.register.UseCommandLine(TrackingClient). That all works fine and I can instantiate it using late binding, however I now need to reference that in C# or VBA in excel. The problem I have is that when I lok for the server in the refernces list in VS2005 or Excel - the progId of this doesn't appear in the list of availa ble COM servers. Interestingly it does in PythonWin under the category of Python COM Server. this is real pain as I would need to include the class in my namespace in VS2005 (Exscel was only a test - I need VS2005). Is there a setting which allows me to publish this and/or is there a typelibrary I can generate to import in VS2005? My details are as follows: _reg_clsid_ = '{AC578D8E-A6F7-4388-BE37-04E7D6A489AE}' _reg_progid_ = 'BarcodeTracking.SOAPClient' _reg_desc_ = 'ActiveX component to connect to the barcode tracking server' Thanks for your help. Cheers, Neil -- Neil Benn MSc Head of Automation benn at cenix-bioscience.com Tel. +49 (0)351 4173-XXX Fax +49 (0)351 4173-109 Cenix BioScience GmbH Tatzberg 47 01307 Dresden, Germany www.cenix-bioscience.com --------------------------------------------------------- Sitz der Gesellschaft (Place of Business): Dresden Gesch?ftsf?hrer (CEO): Dr. Christophe J. Echeverri Amtsgericht (Local Court): Dresden, HRB 19964 Ust-ID (VAT-No.): DE205824437 --------------------------------------------------------- WICHTIGE INFORMATION: Diese Email, inklusive der Anh?nge, ist ausschlie?lich f?r den Gebrauch durch die hierzu berechtigten Empf?nger bestimmt. Sollten Sie nicht der fuer diese Email bestimmte Adressat sein, ist Ihnen jede Veroeffentlichung, Vervielfaeltigung oder Weitergabe dieses Dokuments untersagt. Bitte senden Sie eine Email an info at cenix-bioscience.com, falls Sie diese Email versehentlich erhalten haben. Vielen Dank! IMPORTANT NOTICE: This message, including any attached documents, is intended only for the use of the individual or entity to which it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this Message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify Cenix BioScience immediately by email at info at cenix-bioscience.com. Thank you. From timr at probo.com Wed Apr 25 19:02:28 2007 From: timr at probo.com (Tim Roberts) Date: Wed, 25 Apr 2007 10:02:28 -0700 Subject: [python-win32] excel xla runautomacros In-Reply-To: <47686397d85a42d0885edcc1778452df@mpjconsultancy.com> References: <47686397d85a42d0885edcc1778452df@mpjconsultancy.com> Message-ID: <462F89A4.7050701@probo.com> mjohnson wrote: > I am having a problem with an excel add-in which is installed via > xlApp.Workbooks.Open("C:/Program > Files/Program/XLOF32.xla").RunAutoMacros(1) > > I can then add the add-in and install it via > xlApp.AddIns.Add ("C:/Program Files/Program/XLOF32.xla",True) > xlApp.AddIns.Item(Index='Excel Functions').Installed=True > > My problem is that the macro may have already been run, which > generates a dialog warning that it is already open. > > The question, is there a way of detecting whether the add-in is > already open? Well, xlApp.AddIns is a collection. You should be able to query the collection item by item and check to see whether the add-in is present. I'm leaving the code as "an exercise for the reader", but something like this should be possible: for addin in range( xlApp.AddIns.Count ): if xlApp.AddIns.item(addin).Filename??? I don't know exactly which property you'd need to query. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From hjiwani at wscm.net Wed Apr 25 21:33:37 2007 From: hjiwani at wscm.net (Hussain Jiwani) Date: Wed, 25 Apr 2007 14:33:37 -0500 Subject: [python-win32] excel xla runautomacros In-Reply-To: <462F89A4.7050701@probo.com> References: <47686397d85a42d0885edcc1778452df@mpjconsultancy.com> <462F89A4.7050701@probo.com> Message-ID: <9E0CC1A9D55BE54CAD39E562649F171601441F66@wscmmail.wscm.corp> Following is a snippet of code that I have been using to figure out if an addin in installed. xlApp = win32com.client.dynamic.Dispatch('Excel.Application') xlApp.DisplayAlerts = 0 xlApp.Interactive = 1 if xlApp.Application.Addins.Count <= 0: print "Terminating: No add_ins are available" xlApp.quit return 0 # Addin name should be Analysis ToolPak or Analys32 lnAddins=0 for ia in range(1, xlApp.Application.Addins.Count): ## print xlApp.Application.Addins(ia).Title ## print str(string.lower(xlApp.Application.Addins(ia).Title)), "xx" ## print string.find(str(string.lower(xlApp.Application.Addins(ia).Title)), "analysis toolpak") if string.find(str(string.lower(xlApp.Application.Addins(ia).Title)), "analysis toolpak") >= 0 or string.find(string.lower(xlApp.Application.Addins(ia).Title), "analys32") >= 0: lnAddins=ia print lnAddins if lnAddins==0: print "Terminating. Analysis ToolPak or Analy32 addins are not availabe" xlApp.quit return xlApp.Application.Addins(lnAddins).Installed = 0 xlApp.Application.Addins(lnAddins).Installed = 1 Hussain -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Roberts Sent: Wednesday, April 25, 2007 12:02 PM To: Python-Win32 List Subject: Re: [python-win32] excel xla runautomacros mjohnson wrote: > I am having a problem with an excel add-in which is installed via > xlApp.Workbooks.Open("C:/Program > Files/Program/XLOF32.xla").RunAutoMacros(1) > > I can then add the add-in and install it via > xlApp.AddIns.Add ("C:/Program Files/Program/XLOF32.xla",True) > xlApp.AddIns.Item(Index='Excel Functions').Installed=True > > My problem is that the macro may have already been run, which > generates a dialog warning that it is already open. > > The question, is there a way of detecting whether the add-in is > already open? Well, xlApp.AddIns is a collection. You should be able to query the collection item by item and check to see whether the add-in is present. I'm leaving the code as "an exercise for the reader", but something like this should be possible: for addin in range( xlApp.AddIns.Count ): if xlApp.AddIns.item(addin).Filename??? I don't know exactly which property you'd need to query. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 Disclaimer This e-mail and any attachments is confidential and intended solely for the use of the individual(s) to whom it is addressed. Any views or opinions presented are solely those of the author and do not necessarily represent those of Waterstone Capital Management, L.P and affiliates. If you are not the intended recipient, be advised that you have received this e-mail in error and that any use, dissemination, printing, forwarding or copying of this email is strictly prohibited. Please contact the sender if you have received this e-mail in error. You should also be aware that e-mails are susceptible to interference and you should not assume that the contents of this e-mail originated from the sender above or that they have been accurately reproduced in their original form. Waterstone Capital Management, L.P. and affiliates accepts no responsibility for information, or errors or omissions in this e-mail or use or misuse thereof. If in doubt, please verify the authenticity with the sender. From timr at probo.com Wed Apr 25 22:06:27 2007 From: timr at probo.com (Tim Roberts) Date: Wed, 25 Apr 2007 13:06:27 -0700 Subject: [python-win32] excel xla runautomacros In-Reply-To: <9E0CC1A9D55BE54CAD39E562649F171601441F66@wscmmail.wscm.corp> References: <47686397d85a42d0885edcc1778452df@mpjconsultancy.com> <462F89A4.7050701@probo.com> <9E0CC1A9D55BE54CAD39E562649F171601441F66@wscmmail.wscm.corp> Message-ID: <462FB4C3.9020306@probo.com> Hussain Jiwani wrote: > Following is a snippet of code that I have been using to figure out if > an addin in installed. > > xlApp = win32com.client.dynamic.Dispatch('Excel.Application') > xlApp.DisplayAlerts = 0 > xlApp.Interactive = 1 > if xlApp.Application.Addins.Count <= 0: > print "Terminating: No add_ins are available" > xlApp.quit > return 0 > > # Addin name should be Analysis ToolPak or Analys32 > lnAddins=0 > for ia in range(1, xlApp.Application.Addins.Count): > That stops one too soon. Remember that range(1,4) returns [1,2,3]. You should either use range(xlApp.Application.AddIns.Count) and refer to AddIns(ia+1), or you should use range(1, xlApp.Application.AddIns.Count+1) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From f.guerrieri at gmail.com Thu Apr 26 08:24:55 2007 From: f.guerrieri at gmail.com (Francesco Guerrieri) Date: Thu, 26 Apr 2007 08:24:55 +0200 Subject: [python-win32] updating a registered com server Message-ID: <79b79e730704252324g6cc53dcdg7146109b1fd5abf3@mail.gmail.com> Hello, this is my first post to the ml. I am rather new to python under windows, so probably mine is an easy question, but I've searched for a solution and found none. I am writing a (set of) simple COM servers, which basically take the input from excel worksheets, do some computation, invoke some C++ dll and return the output on some other excel sheet. I'm working on winXp professional, with active python 2.5 and excel 2002. I've been able to make a first prototype of the thing working (enough for being encouranged to further go on pythonizing the various tasks of my job :-) ), but I've met the following annoying problem: I register the server with the usual if __name__ == '__main__': win32com.server.register.UseCommandLine(....) Then I find that I want to add/change/correct something, and I register it again. The problem is that Excel persists in calling the OLD server. At first I believed that it was my fault, since I hadn't changed the _reg_clsid_ . (more on this later). But even if I changed it, Excel persisted in calling the old server. I've found two solutions, both of them ugly: a) closing and restarting excel (which is way too long, and undesiderable since maybe I've been writing something on the sheets) or b) re-naming the .py file and re-running it. This means that I have a directory full of mySeverXX.py for XX = 1, 2, ... infinity :-) so my questions are: 1) is there a way to refresh the list of servers that excel looks for? 1b) is this in someway connected with the generated .pyc files? by changing the names I am forcing the interpreter to compile it again, am not I? 2) what happens if I register with the same _reg_clsid_? Is my registry irreversibly messed up? This is all for now. I hope you can help me! thanks in advance, Francesco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070426/3b262ada/attachment.htm From niki at vintech.bg Thu Apr 26 10:19:07 2007 From: niki at vintech.bg (Niki Spahiev) Date: Thu, 26 Apr 2007 11:19:07 +0300 Subject: [python-win32] updating a registered com server In-Reply-To: <79b79e730704252324g6cc53dcdg7146109b1fd5abf3@mail.gmail.com> References: <79b79e730704252324g6cc53dcdg7146109b1fd5abf3@mail.gmail.com> Message-ID: <4630607B.8020006@vintech.bg> > so my questions are: > 1) is there a way to refresh the list of servers that excel looks for? > 1b) is this in someway connected with the generated .pyc files? by > changing the names I am forcing the interpreter to compile it again, am > not I? > 2) what happens if I register with the same _reg_clsid_? Is my registry > irreversibly messed up? Try to split code to almost static COM and dynamic logic and then reload() logic module. Niki Spahiev From timr at probo.com Thu Apr 26 19:01:55 2007 From: timr at probo.com (Tim Roberts) Date: Thu, 26 Apr 2007 10:01:55 -0700 Subject: [python-win32] updating a registered com server In-Reply-To: <79b79e730704252324g6cc53dcdg7146109b1fd5abf3@mail.gmail.com> References: <79b79e730704252324g6cc53dcdg7146109b1fd5abf3@mail.gmail.com> Message-ID: <4630DB03.6000607@probo.com> Francesco Guerrieri wrote: > > ... > I register the server with the usual > > if __name__ == '__main__': win32com.server.register.UseCommandLine(....) > > Then I find that I want to add/change/correct something, and I > register it again. > The problem is that Excel persists in calling the OLD server. > At first I believed that it was my fault, since I hadn't changed the > _reg_clsid_ . (more on this later). But even if I changed it, Excel > persisted in calling the old server. > I've found two solutions, both of them ugly: > a) closing and restarting excel (which is way too long, and > undesiderable since maybe I've been writing something on the sheets) or > b) re-naming the .py file and re-running it. > This means that I have a directory full of mySeverXX.py for XX = 1, 2, > ... infinity :-) > > so my questions are: > 1) is there a way to refresh the list of servers that excel looks for? > 1b) is this in someway connected with the generated .pyc files? by > changing the names I am forcing the interpreter to compile it again, > am not I? > 2) what happens if I register with the same _reg_clsid_? Is my > registry irreversibly messed up? You do not have to create a new clsid every time. In fact, by doing so, you are filling your registry with dead clsid entries. The situation you describe would be the same even if you had written your component in C++. For efficiency reasons, an out-of-process COM server does not automatically die when its last object is freed. It will remain in memory until the last calling process ends, or until an app calls CoFreeUnusedLibraries. Excel never calls that, so the only way to free up the existing server instance is to kill Excel. Remember that the problem you describe only occurs during development, and we developers are used to being inconvenienced. Once your server stabilizes, you will be happy that the instance keeps running, so you don't have to pay the penalty of invoking the interpreter each time. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu Apr 26 19:38:16 2007 From: timr at probo.com (Tim Roberts) Date: Thu, 26 Apr 2007 10:38:16 -0700 Subject: [python-win32] updating a registered com server In-Reply-To: <79b79e730704261021p6fe461f0id650198b72404885@mail.gmail.com> References: <79b79e730704252324g6cc53dcdg7146109b1fd5abf3@mail.gmail.com> <4630DB03.6000607@probo.com> <79b79e730704261021p6fe461f0id650198b72404885@mail.gmail.com> Message-ID: <4630E388.4080503@probo.com> Francesco Guerrieri wrote: > > Yes I'm aware that it is not a python-related problem but rather a > COM-related problem... simply I never wrote a com server in c++ > (actually I have just begun to code under win). > Wouldn't it be possible to call something like > xl = win32com.client.dispatch("Excel.Application") > xl.CoFreeUnusedLibraries() > ?? > that would be the solution to the problem. I am sure that it is not > possible, since you don't mention it :-) do you know why it isn't? No, it's not possible. CoFreeUnusedLibraries is a Windows API that Excel must call. It is not a method in the Excel object model. > for instance I have found the method COMAddIns.Update which has a nice > name. Do you know if it could be useful? In the meanwhile I will try > to find its effect on the msdn site... Don't know. > Remember that the problem you describe only occurs during development, > and we developers are used to being inconvenienced. Once your server > stabilizes, you will be happy that the instance keeps running, so you > don't have to pay the penalty of invoking the interpreter each time. > > > ok it's not a terrible inconvenience, but it has a bad effect on my > code. For instance if I have three modules, > > server.py which imports module1.py and module2.py > > and if I change something, I must rename the corresponding AND change > the name which I am importing. This is unpractical, and I am solving > it by putting everything in the same .py. This is not a problem given > the fact that the server is small, but it would be a problem if I had > a larger python application and I decided to wrap a COM server around > it... Now, THIS problem may be solvable. Remember that Python supports the "reload" function that forces it to reload a new version of an imported module. It can't change any objects that have already been created, but it may be able to help you with this specific problem. You would have to write your main server in such a way that you could signal it to reload modules, but that's a solvable problem. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu Apr 26 22:30:20 2007 From: timr at probo.com (Tim Roberts) Date: Thu, 26 Apr 2007 13:30:20 -0700 Subject: [python-win32] updating a registered com server In-Reply-To: <79b79e730704261100k53f8544di3bd05d37283f7aa0@mail.gmail.com> References: <79b79e730704252324g6cc53dcdg7146109b1fd5abf3@mail.gmail.com> <4630DB03.6000607@probo.com> <79b79e730704261021p6fe461f0id650198b72404885@mail.gmail.com> <4630E379.9060604@probo.com> <79b79e730704261100k53f8544di3bd05d37283f7aa0@mail.gmail.com> Message-ID: <46310BDC.3040601@probo.com> Francesco Guerrieri wrote: > > On 4/26/07, *Tim Roberts* > wrote: > >> >> Now, THIS problem may be solvable. Remember that Python supports >> the "reload" function that forces it to reload a new version of >> an imported module. It can't change any objects that have >> already been created, but it may be able to help you with this >> specific problem. You would have to write your main server in >> such a way that you could signal it to reload modules, but that's >> a solvable problem. > > > yes I think that this is the same suggestion which Niki Spahiev gave > me, and in fact is the setup which I am trying to realize. I still > have to find a nice way to do it. For instance I planned to make use > of reflection (getattr....) to obtain the reference but this would > make it awkward to call the server: > In vba I would like to call something like that > > set server = CreateObject(myPythonServer) > server.myPyFunct(my arguments) > > but if I use getattr, I would find myself calling > > server.wrapper(myPyFunct my arguments) > > because in the server my idea would be to have something like > > try: > getattr(myPyFunct)(my arguments) > except: > raise COMException("You don't know how to program properly under > Win!") You don't have to expose the fact that your server is forwarding on to another object. You can still call server.myPyFunct, and have that function check to see whether the module has changed, and then call the real handler. However, NONE of this will allow to you change the behavior of an object that already exists. That's simply impossible. Once Excel has created a server object, you're locked in until you free the object. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From patter001 at gmail.com Sat Apr 28 20:32:46 2007 From: patter001 at gmail.com (Kevin Patterson) Date: Sat, 28 Apr 2007 14:32:46 -0400 Subject: [python-win32] VT_UI1 ByRef behavior Message-ID: I was curious is there a way to prevent an array of VT_UI1's from being converted to a buffer? Or perhaps a way to modify the file generated from "makepy" to prevent the conversion? I am working with a COM module that uses the VT_UI1 and ByRef for a LOT of its input/output, but it's a bit of a pain to code an extra layer that does the conversion from an array to a buffer for every function. Any ideas? Thanks, Kevin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070428/0701376e/attachment.html From mhammond at skippinet.com.au Mon Apr 30 03:53:33 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 30 Apr 2007 11:53:33 +1000 Subject: [python-win32] VT_UI1 ByRef behavior In-Reply-To: Message-ID: <000e01c78aca$5ce755c0$090a0a0a@enfoldsystems.local> > I was curious is there a way to prevent an array of VT_UI1's from being > converted to a buffer? Or perhaps a way to modify the file generated > from "makepy" to prevent the conversion? Nope, no such facility exists. Feel free to propose a patch though. Cheers, Mark From mhammond at skippinet.com.au Mon Apr 30 04:18:04 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 30 Apr 2007 12:18:04 +1000 Subject: [python-win32] Registering a Server COM to make it visible in thereference list In-Reply-To: <462F74CB.3060103@cenix-bioscience.com> Message-ID: <000f01c78acd$cc0c37b0$090a0a0a@enfoldsystems.local> > > I have made a COM server using python and > registered it using > win32com.server.register.UseCommandLine(TrackingClient). > That all works > fine and I can instantiate it using late binding, however I > now need to > reference that in C# or VBA in excel. The problem I have is > that when I > lok for the server in the refernces list in VS2005 or Excel - > the progId > of this doesn't appear in the list of availa ble COM servers. That list is of the type-libraries registered in the system, and by default, Python has no such typelib. It is possible to manually create a typelib that describes your object though - google for other posts by me on this topic. For many years, there has been interest in upgrading win32com to auto-create a typelib - let me know if you are interested in helping with that... Cheers, Mark From mc at mclaveau.com Mon Apr 30 07:12:30 2007 From: mc at mclaveau.com (Michel Claveau) Date: Mon, 30 Apr 2007 07:12:30 +0200 Subject: [python-win32] Registering a Server COM to make it visible inthereference list References: <000f01c78acd$cc0c37b0$090a0a0a@enfoldsystems.local> Message-ID: <000201c78ae6$29bb9960$0701a8c0@PORTABLES> Hi! > For many years, there has been interest in upgrading win32com > to auto-create a typelib - let me know if you are interested in > helping with that... Because dynamic COM server is a very interesting feature, I think than a external (optional) tool for generate TLB is better than the auto-create way. But it's only my personal opinion. @-salutations Michel Claveau From Amit.Arora at infogain.com Mon Apr 30 07:20:22 2007 From: Amit.Arora at infogain.com (Amit Arora) Date: Mon, 30 Apr 2007 10:50:22 +0530 Subject: [python-win32] Impersonating an Admin User using a standard User In-Reply-To: <000201c78ae6$29bb9960$0701a8c0@PORTABLES> Message-ID: Hi Members, I am trying to use the Admin Privilidges of a user , by logging into the system using a standard user...... Am using the following code for impersonation ......... Also aware of CreateProcessAsUser , guess I am not able to figure out the correct way to handle the admin user to do some admin task using a standard login ..... ________________________________________________________________________ ___________________- #!usr/local/bin/python import sys , win32api , win32net , win32security , win32con , os class Impersonate: def __init__(self,login,password): self.domain = "AARORA" self.login = "AdminLogin" self.password="top1_secret" def logon(self): self.handel=win32security.LogonUser(self.login,self.domain,self.password , win32con.LOGON32_LOGON_INTERACTIVE,win32con.LOGON32_PROVIDER_DEFAULT) win32security.ImpersonateLoggedOnUser(self.handel) def logoff(self): win32security.RevertToSelf() #terminates impersonation self.handel.Close() #guarantees cleanup a=Impersonate(self.login,'top1_secret') try: a.logon() #become the user #do whatever here print win32api.GetUserName() #show you're someone else #os.system("c:\\textpad\\setup.exe") os.chdir("c:\\Textpad") os.system("start /wait setup.exe /s/a/s /sms /f1c:\\Textpad\\settpvista.iss") a.logoff() #return to normal except: print sys.exc_type , sys.exc_value ________________________________________________________________________ ________ Please guide me on how to install any application(or use admin privilidges through a standard login ) ..... Regards, ~Amit Arora, Senior Software Engineer, Infogain India (P) Ltd. A-16, Sector-60, NOIDA - U.P. - 201301, India. Phone: +91-120-2445144, Extn.: 4210. Fax: +91-120-2580406. www.infogain.com e-mail: amit.arora at infogain.com From mhammond at skippinet.com.au Mon Apr 30 08:58:36 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 30 Apr 2007 16:58:36 +1000 Subject: [python-win32] Registering a Server COM to make it visibleinthereference list In-Reply-To: <000201c78ae6$29bb9960$0701a8c0@PORTABLES> Message-ID: <003d01c78af4$fa101600$090a0a0a@enfoldsystems.local> > Because dynamic COM server is a very interesting feature, I > think than a > external (optional) tool for generate TLB is better than the > auto-create way. Yeah - it would only be done when explicitly enabled, but the generation of the typelib itself should be as automatic as possible. If a decorator syntax was invented/borrowed to define method signatures and property types, you would get quite a powerful system. Having typelibs for your objects is also important in the .NET world, but sadly I doubt I will have the time to invent, implement and support a scheme all by my lonesome :) Cheers, Mark From mail at timgolden.me.uk Mon Apr 30 09:57:52 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 30 Apr 2007 08:57:52 +0100 Subject: [python-win32] Impersonating an Admin User using a standard User In-Reply-To: References: Message-ID: <4635A180.8000102@timgolden.me.uk> Amit Arora wrote: > Hi Members, > > I am trying to use the Admin Privilidges of a user , by logging into the > system using a standard user...... > Am using the following code for impersonation ......... Also aware of > CreateProcessAsUser , guess I am not able to figure out the correct way > to handle the admin user to do some admin task using a standard login > ..... Well you don't actually say what doesn't work. One point is that you *might* need to grant your user the "Act as part of the Operating System" privilege: http://tinyurl.com/2s5wfq (MSDN reference) but you're code's come out rather unformatted in my email reader so I can't try it out without a fair bit of rework. TJG