From greeder221 at gmail.com Wed Apr 1 01:18:30 2009 From: greeder221 at gmail.com (Gerald Reeder) Date: Tue, 31 Mar 2009 16:18:30 -0700 Subject: [python-win32] Excel -- Range() not working Message-ID: <9d256afc0903311618i3b59b9dfmdb55fa2ca56ff3c0@mail.gmail.com> Hello, I'm trying to get values from a non-contiguous range, specifically "E5:E10,E35" Range("E5:E10,E35").Value -- only returns the values for "E5:E10", ignoring "E35" Range("E5:E10,E35").Address -- however returns "E5:E10,E35" Range("E5:E10,E35").Count -- returns 7, which is correct I'm early-binding and using Python 2.6 and Pywin2.6.1 from win32com.client import Dispatch xl = Dispatch('Excel.Application') xl.Visible = 0 xl.DisplayAlerts = 0 xl.Workbooks.Open(xl_file) wrkbk = xl.ActiveWorkbook sht = wrkbk.Worksheets(1) print sht.Range("E5:E10,E35").Value print sht.Range("E5:E10,E35").Address wrkbk.Close() xl.Quit() Any ideas? I've searched the complete archive and I've read Mark and Andy's (excellent) book. A VBA Macro works with this Range syntax. Thank you, JR -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Wed Apr 1 04:07:00 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 01 Apr 2009 13:07:00 +1100 Subject: [python-win32] d:\python25\lib\site-packages\pytz\__init__.py:29: UserWarning: Module pythoncom was already imported from C:\WINDOWS\system32\pythoncom25.dll, but d:\python25\lib\site-packages\pywin32-210-py2.5-win32.egg is being added to sys.path In-Reply-To: <877572.95442.qm@web50902.mail.re2.yahoo.com> References: <877572.95442.qm@web50902.mail.re2.yahoo.com> Message-ID: <49D2CC44.4030007@gmail.com> On 31/03/2009 12:24 AM, jo wrote: > What is the best way to solve this conflict ? > > from pylab import * > d:\python25\lib\site-packages\pytz\__init__.py:29: UserWarning: Module pywintypes was already imported from C:\WINDOWS\system32\pywintypes25.dll, but d:\python25\lib\site-packages\pywin32-210-py2.5-win32.egg is being added to sys.path > from pkg_resources import resource_stream > d:\python25\lib\site-packages\pytz\__init__.py:29: UserWarning: Module pythoncom was already imported from C:\WINDOWS\system32\pythoncom25.dll, but d:\python25\lib\site-packages\pywin32-210-py2.5-win32.egg is being added to sys.path > from pkg_resources import resource_stream What pywin32 build? If 213, it might be worth seeing if 212 works - there have been some reports of 213's win32api not loading on old windows 2000 builds, but given a suitably old/broken IE its possible the same problem exists. The other alternative is to look for the free 'depends' tool from sysinternals to identify exactly which symbol can't be loaded. Cheers, Mark From rwupole at msn.com Thu Apr 2 14:59:51 2009 From: rwupole at msn.com (Roger Upole) Date: Thu, 2 Apr 2009 08:59:51 -0400 Subject: [python-win32] Re: Excel -- Range() not working Message-ID: Gerald Reeder wrote: > Hello, > > I'm trying to get values from a non-contiguous range, specifically > "E5:E10,E35" > > Range("E5:E10,E35").Value -- only returns the values for "E5:E10", > ignoring > "E35" > Range("E5:E10,E35").Address -- however returns "E5:E10,E35" > Range("E5:E10,E35").Count -- returns 7, which is correct > > I'm early-binding and using Python 2.6 and Pywin2.6.1 > > from win32com.client import Dispatch > > xl = Dispatch('Excel.Application') > xl.Visible = 0 > xl.DisplayAlerts = 0 > xl.Workbooks.Open(xl_file) > wrkbk = xl.ActiveWorkbook > sht = wrkbk.Worksheets(1) > print sht.Range("E5:E10,E35").Value > print sht.Range("E5:E10,E35").Address > wrkbk.Close() > xl.Quit() > > Any ideas? I've searched the complete archive and I've read Mark and > Andy's > (excellent) book. > A VBA Macro works with this Range syntax. > > Thank you, > JR > Using some VBScript, I also get 6 items for Range.Value. Dim xl, r, s set xl = GetObject( "z:\\tempxp\\tmp.xls") set r = xl.Worksheets(1).Range ("E5:E10,E35") Wscript.Echo (LBound(r.Value)) Wscript.Echo (UBound(r.Value)) Looks like you can still access the extra item using sht.Range("E5:E10,E35").Cells[6].Value Roger From whatyoulookin at yahoo.com Fri Apr 3 08:58:12 2009 From: whatyoulookin at yahoo.com (Alec Bennett) Date: Thu, 2 Apr 2009 23:58:12 -0700 (PDT) Subject: [python-win32] How to enumerate com ports? Message-ID: <441634.63156.qm@web54607.mail.re2.yahoo.com> I'd like to get a list of available com ports on a Windows machine. I've seen some reference to a function EnumSerialPorts but can't find any documentation. Thanks for any help. From mail at timgolden.me.uk Fri Apr 3 09:25:26 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 03 Apr 2009 08:25:26 +0100 Subject: [python-win32] How to enumerate com ports? In-Reply-To: <441634.63156.qm@web54607.mail.re2.yahoo.com> References: <441634.63156.qm@web54607.mail.re2.yahoo.com> Message-ID: <49D5B9E6.4010903@timgolden.me.uk> Alec Bennett wrote: > I'd like to get a list of available com ports on a Windows machine. > I've seen some reference to a function EnumSerialPorts but can't > find any documentation. You can get it from WMI via the Win32_SerialPort class TJG From dynamicbit at gmail.com Sun Apr 5 04:13:59 2009 From: dynamicbit at gmail.com (DynamicBit) Date: Sun, 05 Apr 2009 04:13:59 +0200 Subject: [python-win32] Might be a easy problem. Message-ID: <49D813E7.4010700@googlemail.com> Hi! Got this problem, http://rafb.net/p/Ra3GRf40.html Read he description. - DynamicBit From fleurisseur at gmail.com Sun Apr 5 13:49:09 2009 From: fleurisseur at gmail.com (Fleu Risseur) Date: Sun, 5 Apr 2009 13:49:09 +0200 Subject: [python-win32] Welcome to the "python-win32" mailing list In-Reply-To: References: Message-ID: Heloooooooooodespite all my efforts and 3 weeks searching/installing/cleaning etc I can not import win32 in APTANA +pydev my source : print ("fff") import os import win32 the last line produces permanently ImportError: No module named win32 As I travel a lot, please send me a mail to fleurisseur at gmail.com thank you -- ----------------- I love love I love life Live is hard, but life is beautifull ----------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Sun Apr 5 16:01:02 2009 From: vernondcole at gmail.com (Vernon Cole) Date: Sun, 5 Apr 2009 08:01:02 -0600 Subject: [python-win32] Might be a easy problem. In-Reply-To: <49D813E7.4010700@googlemail.com> References: <49D813E7.4010700@googlemail.com> Message-ID: Dear dynamicbit: Your example contains numerous errors in tabs and spelling, and shows a total lack of understanding of Python. Try reading the tutorial http://docs.python.org/3.0/tutorial/ and working simple examples to learn the basics. Python is a great language, and you would be much better off to actually learn it rather than have someone else do your homework assignments. -- VC On Sat, Apr 4, 2009 at 8:13 PM, DynamicBit wrote: > Hi! > > Got this problem, > > http://rafb.net/p/Ra3GRf40.html > > Read he description. > > > > - DynamicBit > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fleurisseur at gmail.com Sun Apr 5 16:54:12 2009 From: fleurisseur at gmail.com (Fleu Risseur) Date: Sun, 5 Apr 2009 16:54:12 +0200 Subject: [python-win32] Might be a easy problem. In-Reply-To: References: <49D813E7.4010700@googlemail.com> Message-ID: Hello Thank you for your anwser May I say that this answer "gives no solution" and mocks the author, a developper with some 35 years of experience ? With APTANA I have built some some hundreds of internet sites, and I may perfectly be ignorant in a lot of things. When one of my students (I am in international professor, teaching complex things, in 12 countries and in 7 languages) says "I do this, it does not work " I dont smile saying "read the documentation", even if his error/stupidity is for me evident. Humbly I "say do this, do that". So, again the question, expecting some usefull answer In APTANA, despite all efforts, all installations, all PYTHON scripts correctly written, all docs I could read, this very simple instruction does not work : import win32 (and of course all instructions like : from win32 import xxx) Could you please be so kind to give me some indications ? TARGET of the project : import/export EXCEL datasheets, and build ExtJS scripts in several languages. Only PYTHON seems to achieve it better/faster than PHP, BUT import win32 is mandatory. PYTHON used is V3 Thank you in advance for a usefull answer Jean 2009/4/5 Vernon Cole > Dear dynamicbit: > Your example contains numerous errors in tabs and spelling, and shows a > total lack of understanding of Python. > Try reading the tutorial http://docs.python.org/3.0/tutorial/ and working > simple examples to learn the basics. > Python is a great language, and you would be much better off to actually > learn it rather than have someone else do your homework assignments. > -- > VC -- ----------------- I love love I love life Live is hard, but life is beautifull ----------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From gerdusvanzyl at gmail.com Sun Apr 5 17:47:46 2009 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Sun, 5 Apr 2009 17:47:46 +0200 Subject: [python-win32] Might be a easy problem. In-Reply-To: <49D813E7.4010700@googlemail.com> References: <49D813E7.4010700@googlemail.com> Message-ID: <91882ea90904050847k33f7e005m95ae603070f0a055@mail.gmail.com> see http://rafb.net/p/7WVngC64.html I modified it till it worked and fixed some style issues. As suggested there are many excellent python tutorials available which may be of use. On Sun, Apr 5, 2009 at 4:13 AM, DynamicBit wrote: > Hi! > > Got this problem, > > http://rafb.net/p/Ra3GRf40.html > > Read he description. > > > > - DynamicBit > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From gerdusvanzyl at gmail.com Sun Apr 5 18:49:24 2009 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Sun, 5 Apr 2009 18:49:24 +0200 Subject: [python-win32] Welcome to the "python-win32" mailing list In-Reply-To: References: Message-ID: <91882ea90904050949g67c35c83rc41a958caa7e0c10@mail.gmail.com> Firstly there is no module called win32; only things like win32api or win32gui, etc. (May have changed in py3k version?) Otherwise check your python path in pydev: Go Window -> Preferences -> Pydev -> Interpreter - Python On my system there is an entry for c:\python25\lib\site-packages\win32; if a win32 entry does not exist click new folder and select the folder where win32 was installed. For pydev/aptana specific questions like these you might get faster/better response from their respective mailing lists. Also if you are just starting to learn python i would suggest sticking to 2.5/2.6 as it's the most widely installed version with the most module support. ~Gerdus On Sun, Apr 5, 2009 at 1:49 PM, Fleu Risseur wrote: > Heloooooooooo > despite all my efforts > and 3 weeks searching/installing/cleaning etc > I can not import ?win32 in APTANA +pydev > my ?source : > print ("fff") > import os > import win32 > the last line produces permanently > ImportError: No module named win32 > > As I travel a lot, please send me a mail to fleurisseur at gmail.com > thank you > -- > ----------------- > I love love > I love life > Live is hard, but life is beautifull > ----------------- > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From fleurisseur at gmail.com Sun Apr 5 20:13:42 2009 From: fleurisseur at gmail.com (Fleu Risseur) Date: Sun, 5 Apr 2009 20:13:42 +0200 Subject: [python-win32] Might be a easy problem. In-Reply-To: <91882ea90904050847k33f7e005m95ae603070f0a055@mail.gmail.com> References: <49D813E7.4010700@googlemail.com> <91882ea90904050847k33f7e005m95ae603070f0a055@mail.gmail.com> Message-ID: Hello Thank you for your anwser May I say that this answer "gives no solution" and mocks the author, a developper with some 35 years of experience ? With APTANA I have built some some hundreds of internet sites, and I may perfectly be ignorant in a lot of things. When one of my students (I am in international professor, teaching complex things, in 12 countries and in 7 languages) says "I do this, it does not work " I dont smile saying "read the documentation", even if his error/stupidity is for me evident. Humbly I "say do this, do that". So, again the question, expecting some usefull answer In APTANA IDE , despite all efforts, all installations, all PYTHON scripts correctly written, all docs I could read, this very simple instruction does not work : import win32 (and of course all instructions like : from win32 import xxx) Could you please be so kind to give me some indications ? TARGET of the project : import/export EXCEL datasheets, and build ExtJS scripts in several languages. Only PYTHON seems to achieve it better/faster than PHP, BUT import win32 is mandatory. PYTHON used is V3 Thank you in advance for a usefull answer Jean -- ----------------- I love love I love life Live is hard, but life is beautifull ----------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From drobinow at gmail.com Sun Apr 5 20:16:39 2009 From: drobinow at gmail.com (David Robinow) Date: Sun, 5 Apr 2009 14:16:39 -0400 Subject: [python-win32] Might be a easy problem. In-Reply-To: References: <49D813E7.4010700@googlemail.com> Message-ID: <4eb0089f0904051116o2b7b9dcaxb9cadbc398395537@mail.gmail.com> On Sun, Apr 5, 2009 at 10:54 AM, Fleu Risseur wrote: > With APTANA I have built some some hundreds of internet sites, and I may > perfectly be ignorant in a lot of things. I'd never heard of APTANA. It looks interesting. Thanks for mentioning it. > So, again the question, expecting some usefull answer > In APTANA, despite all efforts, all installations, all PYTHON scripts > correctly written, ?all docs I could read, this very simple instruction does > not work : > import win32 > (and of course all instructions like : from win32 import xxx) "import win32" is not a supported operation. What made you think that it was? You may directly import modules under win32 and win32\lib because those directories are listed in pywin32.pth in the site-packages directory. win32com is a module because it contains an __init__.py file. Therefore it can be imported directly. I have no desire to insult you, but if the above does not make sense to you, I suggest that you check the Python documentation. From timr at probo.com Mon Apr 6 19:42:51 2009 From: timr at probo.com (Tim Roberts) Date: Mon, 06 Apr 2009 10:42:51 -0700 Subject: [python-win32] Might be a easy problem. In-Reply-To: References: <49D813E7.4010700@googlemail.com> <91882ea90904050847k33f7e005m95ae603070f0a055@mail.gmail.com> Message-ID: <49DA3F1B.6080004@probo.com> Fleu Risseur wrote: > > Thank you for your anwser > May I say that this answer "gives no solution" and mocks the author, > a developper with some 35 years of experience ? It is very difficult to discern attitude and intent through email. I agree he was impatient, but I don't think you can necessarily say he was mocking. > In APTANA IDE , despite all efforts, all installations, all PYTHON > scripts correctly written, all docs I could read, this very simple > instruction does not work : > > import win32 > (and of course all instructions like : from win32 import xxx) Can you describe where you saw instructions that said exactly that? As has been pointed out earlier, the "pywin32" package does not contain an import package called win32. For example, if you want to launch Excel as a COM object, you say: import win32com.client xxx = win32com.client.Dispatch( "Excel.Application" ) Have you actually installed the PyWin32 extensions to Python? They aren't included in the raw distributions. > TARGET of the project : import/export EXCEL datasheets, and build > ExtJS scripts in several languages. > Only PYTHON seems to achieve it better/faster than PHP, BUT import > win32 is mandatory. The Win32 extensions to Python live in import packages that are not called "win32". Now, it is QUITE possible that the IDE you are using has its own extension called "win32". If so, we wouldn't know anything about that in this forum. You'd have to check the IDE's documentation. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jay009id at gmail.com Tue Apr 7 03:28:09 2009 From: jay009id at gmail.com (Indrajaya :)) Date: Tue, 7 Apr 2009 08:28:09 +0700 Subject: [python-win32] compile context_menu.py into context_menu.exe doesn't work Message-ID: Hello, I'm trying to compile example comes from pywin32 in win32comext\shell\demos\servers\context_menu.py with py2exe. My setup.py describes below. ---------------------------- import time import sys try: # if this doesn't work, try import modulefinder import py2exe.mf as modulefinder import win32com for p in win32com.__path__[1:]: modulefinder.AddPackagePath("win32com", p) for extra in ["win32com.shell"]: #,"win32com.mapi" __import__(extra) m = sys.modules[extra] for p in m.__path__[1:]: modulefinder.AddPackagePath(extra, p) except ImportError: # no build path setup, no worries. pass from distutils.core import setup import py2exe sys.argv.append("py2exe") setup( console = [{'script':'context_menu.py'}] ) ---------------------------- If I run this context_menu.py from command line then I do right-click, I get what I want. But after I compile run the context_menu.exe, I don't get added menu. What happen? How to fix it? Thank you for helping me. Sincerely, -indrajaya- From skippy.hammond at gmail.com Tue Apr 7 07:34:54 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 07 Apr 2009 15:34:54 +1000 Subject: [python-win32] compile context_menu.py into context_menu.exe doesn't work In-Reply-To: References: Message-ID: <49DAE5FE.3090400@gmail.com> Context menus are implemented in DLLs, so you need to get py2exe to create a COM DLL for you then run "regsvr32.exe your.dll" to register the extension - see the py2exe docs for more details. Cheers, Mark On 7/04/2009 11:28 AM, Indrajaya :) wrote: > Hello, > > I'm trying to compile example comes from pywin32 in > win32comext\shell\demos\servers\context_menu.py with py2exe. My > setup.py describes below. > ---------------------------- > import time > import sys > > try: > # if this doesn't work, try import modulefinder > import py2exe.mf as modulefinder > import win32com > for p in win32com.__path__[1:]: > modulefinder.AddPackagePath("win32com", p) > for extra in ["win32com.shell"]: #,"win32com.mapi" > __import__(extra) > m = sys.modules[extra] > for p in m.__path__[1:]: > modulefinder.AddPackagePath(extra, p) > except ImportError: > # no build path setup, no worries. > pass > > from distutils.core import setup > import py2exe > > sys.argv.append("py2exe") > > setup( > console = [{'script':'context_menu.py'}] > ) > ---------------------------- > > If I run this context_menu.py from command line then I do right-click, > I get what I want. But after I compile run the context_menu.exe, I > don't get added menu. What happen? How to fix it? Thank you for > helping me. > > Sincerely, > -indrajaya- > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From mhammond at skippinet.com.au Tue Apr 7 11:10:02 2009 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 7 Apr 2009 19:10:02 +1000 Subject: [python-win32] Move to mercurial? Message-ID: <003901c9b760$a3530440$e9f90cc0$@com.au> Hi all, As some of you might be aware, pywin32 is still using CVS for source control. Initially it was simply too hard to move to svn (ie, if there was a button I could have clicked that said 'move the project to svn' I would have clicked it), but over the last couple of years I've put that off in the hope of skipping svn in favour of a distributed VCS. I'll cut a long story short and say that given Python has decided to move to Mercurial, I'm more than happy for pywin32 to move to Mercurial too. I'd prefer to avoid having this turn into a debate of the relative merits of the various DVCS systems, but I'd welcome any concerns or objections anyone has with this. Are there any timing issues? (If anyone has changes pending, I'm fairly confident this can be managed simply by doing "cvs diff" from the cvs repo and using path to bring it into hg; from that moment things are looking up; you can commit locally without pushing to the trunk!) All comments welcome! Thanks, Mark From mail at timgolden.me.uk Tue Apr 7 11:22:50 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 07 Apr 2009 10:22:50 +0100 Subject: [python-win32] Move to mercurial? In-Reply-To: <003901c9b760$a3530440$e9f90cc0$@com.au> References: <003901c9b760$a3530440$e9f90cc0$@com.au> Message-ID: <49DB1B6A.20402@timgolden.me.uk> Mark Hammond wrote: > I'll cut a long story short and say that given Python has decided to move to > Mercurial, I'm more than happy for pywin32 to move to Mercurial too. I'd > prefer to avoid having this turn into a debate of the relative merits of the > various DVCS systems, but I'd welcome any concerns or objections anyone has > with this. Are there any timing issues? (If anyone has changes pending, > I'm fairly confident this can be managed simply by doing "cvs diff" from the > cvs repo and using path to bring it into hg; from that moment things are > looking up; you can commit locally without pushing to the trunk!) For me, the problem with the variety of dvcs is precisely that there is a variety. I don't especially want to have to juggle Git, Mercurial & Bzr (as well as svn & CVS) so I'd far rather you went with Mercurial if only because it makes my Python life easier! TJG From skippy.hammond at gmail.com Tue Apr 7 13:37:12 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 07 Apr 2009 21:37:12 +1000 Subject: [python-win32] Move to mercurial? In-Reply-To: <49DB1B6A.20402@timgolden.me.uk> References: <003901c9b760$a3530440$e9f90cc0$@com.au> <49DB1B6A.20402@timgolden.me.uk> Message-ID: <49DB3AE8.8000306@gmail.com> > I don't especially want to have to juggle > Git, Mercurial & Bzr (as well as svn & CVS) so I'd far rather you > went with Mercurial if only because it makes my Python life easier! Ain't that the truth! So far I've managed to avoid all but Git, but sadly I fear that sooner or later that too will end up locally... Mark From skippy.hammond at gmail.com Tue Apr 7 13:39:02 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 07 Apr 2009 21:39:02 +1000 Subject: [python-win32] Move to mercurial? In-Reply-To: <49DB3AE8.8000306@gmail.com> References: <003901c9b760$a3530440$e9f90cc0$@com.au> <49DB1B6A.20402@timgolden.me.uk> <49DB3AE8.8000306@gmail.com> Message-ID: <49DB3B56.3010509@gmail.com> I wrote: > So far I've managed to avoid all but Git Obviously I meant the exact opposite of that... time-for-bed, ly Mark From fuzzyman at gmail.com Fri Apr 10 20:18:24 2009 From: fuzzyman at gmail.com (Michael Foord) Date: Fri, 10 Apr 2009 19:18:24 +0100 Subject: [python-win32] IronPython in Action Out! Message-ID: <6f4025010904101118y42b0e49bs7955871509a48b1c@mail.gmail.com> Hello all, *Finally* IronPython in Action is out. This is the first English language book on IronPython and is now in stock with Manning and Amazon.com and on the Safari bookshelf. You can get all the details from: * http://www.ironpythoninaction.com It covers a whole range of topics, with introductions to Python and .NET, using various Python libraries and .NET framework classes, web development with ASP.NET, Silverlight and web services, plus topics like WPF, testing, metaprogramming, system administration, embedding IronPython in .NET applications and so on. The foreword is by Jim Hugunin and Dino Viehland is the technical editor. Many thanks to all those who helped, including those who gave feedback during the early access program. All the best, Michael Foord -- http://www.ironpythoninaction.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From kfadnis at gmail.com Fri Apr 10 20:26:43 2009 From: kfadnis at gmail.com (Kapil fadnis) Date: Fri, 10 Apr 2009 14:26:43 -0400 Subject: [python-win32] Trying to implement an third-party interface in COM for events Message-ID: <1e00d00b0904101126lddcef81hab5a608275cfc10c@mail.gmail.com> I think this has been talked about on a previous thread but its an old thread here but I am hoping to get some feedback that will help me understand the issue, http://mail.python.org/pipermail/python-win32/2006-September/005044.html I have an interface MBTQUOTELib. IMbtQuotesNotify which has four methods to be implemented, each of which is an event on the server side i.e. my broker. One of the methods is "OnQuoteData(QUOTERECORD). The way I have seen it being implemented (in the thread above) is run makepy - i on the interface definition, i use PythonWin for this which gives me a .py file. 13F76618-D199-4485-8C95-DC524958686Cx0x2x0.py The implementation is ------------------------------------------------------------------------------------------- from win32com import universal universal.RegisterInterfaces('{13F76618-D199-4485-8C95-DC524958686C}',0,2,0,["IMbtQuotesNotify"]) class Q: _com_interfaces_ = ['IMbtQuotesNotify'] _typelib_guid_ = '{13F76618-D199-4485-8C95-DC524958686C}' _typelib_version_ = 2, 0 def OnQuoteData(self,pQuote): print "got onquote!" print type(pQuote) print "%s" % pQuote import win32com.server.util qnotify = win32com.server.util.wrap(Q(),useDispatcher=1) import win32com.client as com mbtCom = com.Dispatch("MBTrading.MbtComMgr") mbtCom.DoLogin(9,"myusername","mypassword","") quote = mbtCom.Quotes quote.AdviseSymbol(qnotify,'AAPL',1) --------------------------------------------------------------------- This produces no output. I am sure the login is succesful. Also, I have implemented this in C# and i have some output there using the exact same interface. My question is, is there a way to debug this ? i.e if the callback function is actually called or anything else. The 'useDispatcher' option does not produce legible output. I think there might a problem with the implementation. Should i attach the interface generated file ? Any assistance would be appreciated. Thanks, K. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nirp42 at walla.com Fri Apr 10 22:10:46 2009 From: nirp42 at walla.com (=?windows-1255?Q?=4E=69=72=20=50?=) Date: Fri, 10 Apr 2009 23:10:46 +0300 Subject: [python-win32] =?windows-1255?q?Monitoring_the_active_window?= Message-ID: <1239394246.431000-61484547-25485@walla.com> An HTML attachment was scrubbed... URL: From timr at probo.com Fri Apr 10 23:19:27 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 10 Apr 2009 14:19:27 -0700 Subject: [python-win32] Monitoring the active window In-Reply-To: <1239394246.431000-61484547-25485@walla.com> References: <1239394246.431000-61484547-25485@walla.com> Message-ID: <49DFB7DF.9000509@probo.com> Nir P wrote: > > > I'm trying to monitor the application on a window machine - I want to > know when they start, finish, and when the user switch between them. I > managed to monitor the creation and deletion of processes using > Win32_Process.watch_for("creation") and > Win32_Process.watch_for("deletion"), but didn't manage to monitor the > times when the user switch the active window. I know I can get the > current active window with > win32gui.GetWindowText(win32gui.GetForegroundWindow()), but testing > for changed for it in a loop doesn't sound like a good idea for > performance, so I assume there is some event I can monitor? Any help, > suggestions or reference to relevant reading material will be appreciated. > You can install a windows hook to do this. A WH_CBT hook receives WM_ACTIVATE and WM_DEACTIVATE messages, which are the messages sent when a window receives and loses focus. However, I don't think you'll be able to stick to straight Python for this. You might look at the pyAA library at http://www.cs.unc.edu/assist/doc/pyaa to see if they could help. > Walla! Mail - Get your free unlimited mail today That's amazing. When someone uses the term "Walla!" like that, in virtually every case it is an ignorant rendition of the French word "Voila!" I'm amazed that a real company would choose that as a name. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mail at timgolden.me.uk Sat Apr 11 10:34:30 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Sat, 11 Apr 2009 09:34:30 +0100 Subject: [python-win32] IronPython in Action Out! In-Reply-To: <6f4025010904101118y42b0e49bs7955871509a48b1c@mail.gmail.com> References: <6f4025010904101118y42b0e49bs7955871509a48b1c@mail.gmail.com> Message-ID: <49E05616.5050801@timgolden.me.uk> Michael Foord wrote: > Hello all, > > *Finally* IronPython in Action is out. This is the first English language > book on IronPython and is now in stock with Manning and Amazon.com and on > the Safari bookshelf. Excellent news. Must be great to see it in the flesh after so much preparation! I look forward to getting my hands on a copy. TJG From greg.ewing at canterbury.ac.nz Sat Apr 11 13:10:51 2009 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sat, 11 Apr 2009 23:10:51 +1200 Subject: [python-win32] ANN: PyGUI 2.0 Message-ID: <49E07ABB.7070803@canterbury.ac.nz> PyGUI 2.0 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ Highlights of this release: * Native Windows implementation, based on pywin32 and ctypes. * Full set of Postscript-style path construction operators available on all platforms. * Mouse and keyboard events can be intercepted for all component classes. Plus numerous minor improvements, see CHANGES on the website for details. What is PyGUI? -------------- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. Acknowledgements ---------------- Thanks are due to Patrick Forget and Erez-Sh for getting me started on the Windows implementation. Even though I didn't use much of their code in the end, I appreciate their efforts and may draw more from it in the future. -- Gregory Ewing greg.ewing at canterbury.ac.nz http://www.cosc.canterbury.ac.nz/greg.ewing/ From greg.ewing at canterbury.ac.nz Sun Apr 12 02:02:14 2009 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sun, 12 Apr 2009 12:02:14 +1200 Subject: [python-win32] PyGUI 2.0 setup.py fixes In-Reply-To: <49E0A7DF.8090401@promotux.it> References: <49E07ABB.7070803@canterbury.ac.nz> <49E0A7DF.8090401@promotux.it> Message-ID: <49E12F86.6040705@canterbury.ac.nz> francesco at promotux.it wrote: > error: package directory 'Gtk' does not exist Smeg, there's a bug in the installer. I'll release a fix soon. In the meantime, try replacing the following line in setup.py: packages.append("Gtk") with packages.append("GUI.Gtk") I've also noticed another problem that could affect Windows installations. If anyone is having trouble installing on Windows, try copying the __init__.py file from GUI/Gtk to GUI/Win32. -- Greg From stef.mientki at gmail.com Sun Apr 12 11:23:38 2009 From: stef.mientki at gmail.com (Stef Mientki) Date: Sun, 12 Apr 2009 11:23:38 +0200 Subject: [python-win32] video capture in Python ? Message-ID: <49E1B31A.5020806@gmail.com> hello, has anyone got video capturing (from a webcam) successful running in a wxPython application under winXP ? I got some links, but it seems quit complicated to get everything installed, and all the packages you need don't describe which versions of the other parts you need, so a lot trial and error I expect. thanks, Stef Mientki From greg.ewing at canterbury.ac.nz Mon Apr 13 03:26:20 2009 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Mon, 13 Apr 2009 13:26:20 +1200 Subject: [python-win32] ANN: PyGUI 2.0.1 Message-ID: <49E294BC.8070807@canterbury.ac.nz> PyGUI 2.0.1 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ Fixes some problems in setup.py affecting installation on Linux and Windows. What is PyGUI? -------------- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. -- Gregory Ewing greg.ewing at canterbury.ac.nz http://www.cosc.canterbury.ac.nz/greg.ewing/ From skippy.hammond at gmail.com Mon Apr 13 09:09:55 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Mon, 13 Apr 2009 17:09:55 +1000 Subject: [python-win32] Trying to implement an third-party interface in COM for events In-Reply-To: <1e00d00b0904101126lddcef81hab5a608275cfc10c@mail.gmail.com> References: <1e00d00b0904101126lddcef81hab5a608275cfc10c@mail.gmail.com> Message-ID: <49E2E543.3040209@gmail.com> On 11/04/2009 4:26 AM, Kapil fadnis wrote: > I think this has been talked about on a previous thread but its an old > thread here but I am hoping to get some feedback that will help me > understand the issue, > > http://mail.python.org/pipermail/python-win32/2006-September/005044.html > > > I have an interface > MBTQUOTELib. > IMbtQuotesNotify > which has four methods to be implemented, each of which is an event on > the server side i.e. my broker. > One of the methods is "OnQuoteData(QUOTERECORD). The way I have seen it > being implemented (in the thread above) is > run makepy - i on the interface definition, i use PythonWin for this > which gives me a .py file. > 13F76618-D199-4485-8C95-DC524958686Cx0x2x0.py > > The implementation is > ------------------------------------------------------------------------------------------- > from win32com import universal > universal.RegisterInterfaces('{13F76618-D199-4485-8C95-DC524958686C}',0,2,0,["IMbtQuotesNotify"]) > class Q: > _com_interfaces_ = ['IMbtQuotesNotify'] > _typelib_guid_ = '{13F76618-D199-4485-8C95-DC524958686C}' > _typelib_version_ = 2, 0 > > def OnQuoteData(self,pQuote): > print "got onquote!" > print type(pQuote) > print "%s" % pQuote > > import win32com.server.util > qnotify = win32com.server.util.wrap(Q(),useDispatcher=1) > > import win32com.client as com > mbtCom = com.Dispatch("MBTrading.MbtComMgr") > mbtCom.DoLogin(9,"myusername","mypassword","") > quote = mbtCom.Quotes > quote.AdviseSymbol(qnotify,'AAPL',1) See if adding a call to pythoncom.PumpMessages() at the very end makes a difference... Cheers, Mark From kfadnis at gmail.com Mon Apr 13 19:38:13 2009 From: kfadnis at gmail.com (Kapil fadnis) Date: Mon, 13 Apr 2009 13:38:13 -0400 Subject: [python-win32] Trying to implement an third-party interface in COM for events In-Reply-To: <49E2E543.3040209@gmail.com> References: <1e00d00b0904101126lddcef81hab5a608275cfc10c@mail.gmail.com> <49E2E543.3040209@gmail.com> Message-ID: <1e00d00b0904131038y5db41945kfc1e5de186817b9b@mail.gmail.com> Quick follow-up question, you mention threading in the post and how it might hinder some of the messaging. Could this be a potential problem since in the C# or MFC application there is essentially a mainloop which is a perpetual loop ? There is no such thing in the implementation below, and thus does not fire events. On Mon, Apr 13, 2009 at 3:09 AM, Mark Hammond wrote: > On 11/04/2009 4:26 AM, Kapil fadnis wrote: > >> I think this has been talked about on a previous thread but its an old >> thread here but I am hoping to get some feedback that will help me >> understand the issue, >> >> http://mail.python.org/pipermail/python-win32/2006-September/005044.html >> >> >> I have an interface >> MBTQUOTELib. >> IMbtQuotesNotify >> which has four methods to be implemented, each of which is an event on >> the server side i.e. my broker. >> One of the methods is "OnQuoteData(QUOTERECORD). The way I have seen it >> being implemented (in the thread above) is >> run makepy - i on the interface definition, i use PythonWin for this >> which gives me a .py file. >> 13F76618-D199-4485-8C95-DC524958686Cx0x2x0.py >> >> The implementation is >> >> ------------------------------------------------------------------------------------------- >> from win32com import universal >> >> universal.RegisterInterfaces('{13F76618-D199-4485-8C95-DC524958686C}',0,2,0,["IMbtQuotesNotify"]) >> class Q: >> _com_interfaces_ = ['IMbtQuotesNotify'] >> _typelib_guid_ = '{13F76618-D199-4485-8C95-DC524958686C}' >> _typelib_version_ = 2, 0 >> >> def OnQuoteData(self,pQuote): >> print "got onquote!" >> print type(pQuote) >> print "%s" % pQuote >> >> import win32com.server.util >> qnotify = win32com.server.util.wrap(Q(),useDispatcher=1) >> >> import win32com.client as com >> mbtCom = com.Dispatch("MBTrading.MbtComMgr") >> mbtCom.DoLogin(9,"myusername","mypassword","") >> quote = mbtCom.Quotes >> quote.AdviseSymbol(qnotify,'AAPL',1) >> > > See if adding a call to pythoncom.PumpMessages() at the very end makes a > difference... > > Cheers, > > Mark > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kfadnis at gmail.com Mon Apr 13 18:13:06 2009 From: kfadnis at gmail.com (Kapil fadnis) Date: Mon, 13 Apr 2009 12:13:06 -0400 Subject: [python-win32] Trying to implement an third-party interface in COM for events In-Reply-To: <49E2E543.3040209@gmail.com> References: <1e00d00b0904101126lddcef81hab5a608275cfc10c@mail.gmail.com> <49E2E543.3040209@gmail.com> Message-ID: <1e00d00b0904130913vdc2f77fwe959343a30e22481@mail.gmail.com> Thanks Mark. It did not make a difference. Also, when i wrap a class using win32.server.util.wrap what does it do,internally ? Is there somewhere I can read about this ? Here is the *.py generated file. Please let me know if the implementation is correct based on this file. ---------------------------------------------------------------------------------------------------------------------------------------------------- # -*- coding: mbcs -*- # Created by makepy.py version 0.4.98 # By python version 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] # From type library 'MbtQuote.dll' # On Fri Apr 10 11:15:24 2009 """MbtQuote 2.0 Type Library""" makepy_version = '0.4.98' python_version = 0x20504f0 import win32com.client.CLSIDToClass, pythoncom import win32com.client.util from pywintypes import IID from win32com.client import Dispatch # The following 3 lines may need tweaking for the particular server # Candidates are pythoncom.Missing, .Empty and .ArgNotFound defaultNamedOptArg=pythoncom.Empty defaultNamedNotOptArg=pythoncom.Empty defaultUnnamedArg=pythoncom.Empty CLSID = IID('{13F76618-D199-4485-8C95-DC524958686C}') MajorVersion = 2 MinorVersion = 0 LibraryFlags = 8 LCID = 0x0 class constants: csConnected =0x2 # from enum enumConnectionState csConnecting =0x1 # from enum enumConnectionState csDisconnected =0x0 # from enum enumConnectionState csILG =-1 # from enum enumConnectionState csIndeterminate =0x5 # from enum enumConnectionState csLoggedIn =0x4 # from enum enumConnectionState csLoggingIn =0x3 # from enum enumConnectionState csMAX =0x6 # from enum enumConnectionState msAsk =0x2 # from enum enumMarketSide msBid =0x1 # from enum enumMarketSide pcBoth =0x2 # from enum enumPutCall pcCall =0x0 # from enum enumPutCall pcPut =0x1 # from enum enumPutCall qsfLevelOne =0x1 # from enum enumQuoteServiceFlags qsfLevelTwo =0x2 # from enum enumQuoteServiceFlags qsfOptions =0x8 # from enum enumQuoteServiceFlags qsfTimeAndSales =0x4 # from enum enumQuoteServiceFlags tickDown =0x1 # from enum enumTick tickEvenUp =0x0 # from enum enumTick tcQuote_Closing =0x69 # from enum enumTickCondition tcQuote_DueToRelated =0x70 # from enum enumTickCondition tcQuote_FastMarket =0x6b # from enum enumTickCondition tcQuote_Halted =0x80 # from enum enumTickCondition tcQuote_NewsDistribution =0x6a # from enum enumTickCondition tcQuote_NewsPending =0x6f # from enum enumTickCondition tcQuote_NoOpenResume =0x73 # from enum enumTickCondition tcQuote_NonFirm =0x6e # from enum enumTickCondition tcQuote_OfferDepth =0x65 # from enum enumTickCondition tcQuote_Opening =0x68 # from enum enumTickCondition tcQuote_OrderImbalance =0x72 # from enum enumTickCondition tcQuote_OutOfSequence =0x89 # from enum enumTickCondition tcQuote_QuoteRequest =0x95 # from enum enumTickCondition tcQuote_QuoteResume =0x96 # from enum enumTickCondition tcQuote_RegularQuote =0x64 # from enum enumTickCondition tcQuote_Restricted =0x8a # from enum enumTickCondition tcQuote_Suspended =0x88 # from enum enumTickCondition tcQuote_TradeResume =0x97 # from enum enumTickCondition tcTrade_Acquistion =0x1 # from enum enumTickCondition tcTrade_AutoExecute =0x1f # from enum enumTickCondition tcTrade_AveragePrice =0x35 # from enum enumTickCondition tcTrade_BasketIndexClose =0x37 # from enum enumTickCondition tcTrade_Bunched =0x16 # from enum enumTickCondition tcTrade_BunchedSold =0x17 # from enum enumTickCondition tcTrade_CapElectionTrade =0x2e # from enum enumTickCondition tcTrade_Cash_Sale =0x5 # from enum enumTickCondition tcTrade_ClosePrice =0x2f # from enum enumTickCondition tcTrade_DerivativelyPriced =0x2d # from enum enumTickCondition tcTrade_DirectPlus =0x2a # from enum enumTickCondition tcTrade_Distribution =0x2 # from enum enumTickCondition tcTrade_FormT =0x1d # from enum enumTickCondition tcTrade_IntermarketSweep =0x2c # from enum enumTickCondition tcTrade_IntradayDetail =0x20 # from enum enumTickCondition tcTrade_LateOpen =0x1e # from enum enumTickCondition tcTrade_MidPrice =0x1b # from enum enumTickCondition tcTrade_NextDaySale =0x6 # from enum enumTickCondition tcTrade_OpenSale =0xa # from enum enumTickCondition tcTrade_OpeningDetail =0x21 # from enum enumTickCondition tcTrade_OutOfSequence =0xb # from enum enumTickCondition tcTrade_PriorReferencePrice =0x29 # from enum enumTickCondition tcTrade_RegularSale =0x0 # from enum enumTickCondition tcTrade_Reopen =0x11 # from enum enumTickCondition tcTrade_Rule127 =0x22 # from enum enumTickCondition tcTrade_Rule155 =0x8 # from enum enumTickCondition tcTrade_SellerSale =0x7 # from enum enumTickCondition tcTrade_Settlement =0x1c # from enum enumTickCondition tcTrade_SoldLastSale =0x9 # from enum enumTickCondition tcTrade_Split =0x3 # from enum enumTickCondition tcTrade_Stopped =0x15 # from enum enumTickCondition tcTrade_YellowFlag =0x2b # from enum enumTickCondition tsDeleted =0x3 # from enum enumTickStatus tsFiltered =0x1 # from enum enumTickStatus tsNormal =0x0 # from enum enumTickStatus tsOutOfSeq =0x2 # from enum enumTickStatus ttAskTick =0x2 # from enum enumTickType ttBidTick =0x1 # from enum enumTickType ttTradeTick =0x0 # from enum enumTickType from win32com.client import DispatchBaseClass class IMbtQuotes(DispatchBaseClass): """IMbtQuotes Interface""" CLSID = IID('{7DEAC3B3-CA70-4E48-8552-E5CCA5493B71}') coclass_clsid = IID('{A58A9CE8-7681-46FB-8064-35D6DF9CEA0C}') def AdviseSymbol(self, pNotify=defaultNamedNotOptArg, bstrSymbol=defaultNamedNotOptArg, lServiceFlags=defaultNamedNotOptArg): """Adds given symbol to interest list and registers callback interface to receive its quotes.""" return self._oleobj_.InvokeTypes(2, LCID, 1, (24, 0), ((13, 1), (8, 0), (3, 0)),pNotify , bstrSymbol, lServiceFlags) def Connect(self): """Forces a reconnection to quote servers.""" return self._oleobj_.InvokeTypes(1, LCID, 1, (3, 0), (),) def Disconnect(self): """Disconnects from quote servers.""" return self._oleobj_.InvokeTypes(5, LCID, 1, (24, 0), (),) def GetCachedAggregateLevel2Size(self, bstrSymbol=defaultNamedNotOptArg, dPrice=defaultNamedNotOptArg, side=defaultNamedNotOptArg): """Returns the cached aggregate Level II size at the given price/side.""" return self._oleobj_.InvokeTypes(13, LCID, 1, (3, 0), ((8, 1), (5, 0), (3, 0)),bstrSymbol , dPrice, side) def GetCachedOptionsRecord(self, bstrSymbol=defaultNamedNotOptArg): """Returns a cached options record for the given options symbol if one exists.""" return self._ApplyTypes_(12, 1, (36, 0), ((8, 1),), u'GetCachedOptionsRecord', None,bstrSymbol ) def GetCachedQuote(self, bstrSymbol=defaultNamedNotOptArg): """Returns a cached level 1/fundamental quote for the given symbol if one exists.""" return self._ApplyTypes_(6, 1, (36, 0), ((8, 1),), u'GetCachedQuote', None,bstrSymbol ) def GetSingleQuote(self, bstrSymbol=defaultNamedNotOptArg, lTimeout=defaultNamedNotOptArg): """Blocks and returns a level one quote for the given symbol subject to timeout.""" return self._ApplyTypes_(14, 1, (36, 0), ((8, 1), (3, 0)), u'GetSingleQuote', None,bstrSymbol , lTimeout) def UnadviseAll(self, pNotify=defaultNamedNotOptArg): """Removes interest for ALL symbols that were registered to the given callback interface.""" return self._oleobj_.InvokeTypes(4, LCID, 1, (24, 0), ((13, 1),),pNotify ) def UnadviseSymbol(self, pNotify=defaultNamedNotOptArg, bstrSymbol=defaultNamedNotOptArg, lServiceFlags=defaultNamedNotOptArg): """Removes given symbol from interest list (for the given callback interface only).""" return self._oleobj_.InvokeTypes(3, LCID, 1, (24, 0), ((13, 1), (8, 0), (3, 0)),pNotify , bstrSymbol, lServiceFlags) _prop_map_get_ = { "ConnectionState": (11, 2, (3, 0), (), "ConnectionState", None), "RemoteAddress": (17, 2, (8, 0), (), "RemoteAddress", None), "ServerName": (16, 2, (8, 0), (), "ServerName", None), } _prop_map_put_ = { } class _IMbtQuotesEvents: """_IMbtQuotesEvents Interface""" CLSID = CLSID_Sink = IID('{C13BD25A-B87F-4EFF-924C-F7109261A394}') coclass_clsid = IID('{A58A9CE8-7681-46FB-8064-35D6DF9CEA0C}') _public_methods_ = [] # For COM Server support _dispid_to_func_ = { 2 : "OnClose", 3 : "OnLogonSucceed", 1 : "OnConnect", } def __init__(self, oobj = None): if oobj is None: self._olecp = None else: import win32com.server.util from win32com.server.policy import EventHandlerPolicy cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContainer) cp=cpc.FindConnectionPoint(self.CLSID_Sink) cookie=cp.Advise(win32com.server.util.wrap(self, usePolicy=EventHandlerPolicy)) self._olecp,self._olecp_cookie = cp,cookie def __del__(self): try: self.close() except pythoncom.com_error: pass def close(self): if self._olecp is not None: cp,cookie,self._olecp,self._olecp_cookie = self._olecp,self._olecp_cookie,None,None cp.Unadvise(cookie) def _query_interface_(self, iid): import win32com.server.util if iid==self.CLSID_Sink: return win32com.server.util.wrap(self) # Event Handlers # If you create handlers, they should have the following prototypes: # def OnClose(self, lErrorCode=defaultNamedNotOptArg): # """Event raised when a quote server connection has been dropped.""" # def OnLogonSucceed(self): # """Event raised when successful login to a quote server has occurred.""" # def OnConnect(self, lErrorCode=defaultNamedNotOptArg): # """Event raised when a new connection has been made to a quote server.""" from win32com.client import CoClassBaseClass # This CoClass is known by the name 'MBTrading.MbtQuotes.1' class MbtQuotes(CoClassBaseClass): # A CoClass # Provides realtime quote services. CLSID = IID('{A58A9CE8-7681-46FB-8064-35D6DF9CEA0C}') coclass_sources = [ _IMbtQuotesEvents, ] default_source = _IMbtQuotesEvents coclass_interfaces = [ IMbtQuotes, ] default_interface = IMbtQuotes IMbtQuotes_vtables_dispatch_ = 1 IMbtQuotes_vtables_ = [ (( u'Connect' , u'plRetVal' , ), 1, (1, (), [ (16387, 10, None, None) , ], 1 , 1 , 4 , 0 , 28 , (3, 0, None, None) , 0 , )), (( u'AdviseSymbol' , u'pNotify' , u'bstrSymbol' , u'lServiceFlags' , ), 2, (2, (), [ (13, 1, None, "IID('{C8323838-B094-4E3C-B9BE-D08B5C06E6BE}')") , (8, 0, None, None) , (3, 0, None, None) , ], 1 , 1 , 4 , 0 , 32 , (3, 0, None, None) , 0 , )), (( u'UnadviseSymbol' , u'pNotify' , u'bstrSymbol' , u'lServiceFlags' , ), 3, (3, (), [ (13, 1, None, "IID('{C8323838-B094-4E3C-B9BE-D08B5C06E6BE}')") , (8, 0, None, None) , (3, 0, None, None) , ], 1 , 1 , 4 , 0 , 36 , (3, 0, None, None) , 0 , )), (( u'UnadviseAll' , u'pNotify' , ), 4, (4, (), [ (13, 1, None, "IID('{C8323838-B094-4E3C-B9BE-D08B5C06E6BE}')") , ], 1 , 1 , 4 , 0 , 40 , (3, 0, None, None) , 0 , )), (( u'Disconnect' , ), 5, (5, (), [ ], 1 , 1 , 4 , 0 , 44 , (3, 0, None, None) , 0 , )), (( u'GetCachedQuote' , u'bstrSymbol' , u'pRec' , ), 6, (6, (), [ (8, 1, None, None) , (36, 10, None, None) , ], 1 , 1 , 4 , 0 , 48 , (3, 0, None, None) , 0 , )), (( u'ConnectionState' , u'pVal' , ), 11, (11, (), [ (16387, 10, None, None) , ], 1 , 2 , 4 , 0 , 52 , (3, 0, None, None) , 0 , )), (( u'GetCachedOptionsRecord' , u'bstrSymbol' , u'pRec' , ), 12, (12, (), [ (8, 1, None, None) , (36, 10, None, None) , ], 1 , 1 , 4 , 0 , 56 , (3, 0, None, None) , 0 , )), (( u'GetCachedAggregateLevel2Size' , u'bstrSymbol' , u'dPrice' , u'side' , u'pVal' , ), 13, (13, (), [ (8, 1, None, None) , (5, 0, None, None) , (3, 0, None, None) , (16387, 10, None, None) , ], 1 , 1 , 4 , 0 , 60 , (3, 0, None, None) , 0 , )), (( u'GetSingleQuote' , u'bstrSymbol' , u'lTimeout' , u'pRec' , ), 14, (14, (), [ (8, 1, None, None) , (3, 0, None, None) , (36, 10, None, None) , ], 1 , 1 , 4 , 0 , 64 , (3, 0, None, None) , 0 , )), (( u'ServerName' , u'pVal' , ), 16, (16, (), [ (16392, 10, None, None) , ], 1 , 2 , 4 , 0 , 68 , (3, 0, None, None) , 0 , )), (( u'RemoteAddress' , u'pVal' , ), 17, (17, (), [ (16392, 10, None, None) , ], 1 , 2 , 4 , 0 , 72 , (3, 0, None, None) , 0 , )), ] IMbtQuotesNotify_vtables_dispatch_ = 0 IMbtQuotesNotify_vtables_ = [ (( u'OnQuoteData' , u'pRec' , ), 1610678272, (1610678272, (), [ (36, 1, None, None) , ], 1 , 1 , 4 , 0 , 12 , (3, 0, None, None) , 0 , )), (( u'OnLevel2Data' , u'pRec' , ), 1610678273, (1610678273, (), [ (36, 1, None, None) , ], 1 , 1 , 4 , 0 , 16 , (3, 0, None, None) , 0 , )), (( u'OnTSData' , u'pRec' , ), 1610678274, (1610678274, (), [ (36, 1, None, None) , ], 1 , 1 , 4 , 0 , 20 , (3, 0, None, None) , 0 , )), (( u'OnOptionsData' , u'pRec' , ), 1610678275, (1610678275, (), [ (36, 1, None, None) , ], 1 , 1 , 4 , 0 , 24 , (3, 0, None, None) , 0 , )), ] RecordMap = { u'LEVEL2RECORD': '{6CE8D5AD-1352-4ECC-B9E3-145E796FE4D1}', u'TSRECORD': '{9B55F875-A3A7-476E-8D18-55961A7AF0ED}', u'OPTIONSRECORD': '{345495FA-527D-4A50-A8C4-4A1C4A9C2D46}', u'QUOTERECORD': '{9BE86BB5-99D4-4F03-AC5A-C115128573C0}', } CLSIDToClassMap = { '{A58A9CE8-7681-46FB-8064-35D6DF9CEA0C}' : MbtQuotes, '{7DEAC3B3-CA70-4E48-8552-E5CCA5493B71}' : IMbtQuotes, '{C13BD25A-B87F-4EFF-924C-F7109261A394}' : _IMbtQuotesEvents, } CLSIDToPackageMap = {} win32com.client.CLSIDToClass.RegisterCLSIDsFromDict( CLSIDToClassMap ) VTablesToPackageMap = {} VTablesToClassMap = { '{C8323838-B094-4E3C-B9BE-D08B5C06E6BE}' : 'IMbtQuotesNotify', '{7DEAC3B3-CA70-4E48-8552-E5CCA5493B71}' : 'IMbtQuotes', } NamesToIIDMap = { 'IMbtQuotesNotify' : '{C8323838-B094-4E3C-B9BE-D08B5C06E6BE}', 'IMbtQuotes' : '{7DEAC3B3-CA70-4E48-8552-E5CCA5493B71}', '_IMbtQuotesEvents' : '{C13BD25A-B87F-4EFF-924C-F7109261A394}', } win32com.client.constants.__dicts__.append(constants.__dict__) ---------------------------------------------------------------------------------------------------------------------------------------------------- On Mon, Apr 13, 2009 at 3:09 AM, Mark Hammond wrote: > On 11/04/2009 4:26 AM, Kapil fadnis wrote: > >> I think this has been talked about on a previous thread but its an old >> thread here but I am hoping to get some feedback that will help me >> understand the issue, >> >> http://mail.python.org/pipermail/python-win32/2006-September/005044.html >> >> >> I have an interface >> MBTQUOTELib.IMbtQuotesNotify >> which has four methods to be implemented, each of which is an event on >> the server side i.e. my broker. >> One of the methods is "OnQuoteData(QUOTERECORD). The way I have seen it >> being implemented (in the thread above) is >> run makepy - i on the interface definition, i use PythonWin for this >> which gives me a .py file. >> 13F76618-D199-4485-8C95-DC524958686Cx0x2x0.py >> >> The implementation is >> >> ------------------------------------------------------------------------------------------- >> from win32com import universal >> >> universal.RegisterInterfaces('{13F76618-D199-4485-8C95-DC524958686C}',0,2,0,["IMbtQuotesNotify"]) >> class Q: >> _com_interfaces_ = ['IMbtQuotesNotify'] >> _typelib_guid_ = '{13F76618-D199-4485-8C95-DC524958686C}' >> _typelib_version_ = 2, 0 >> >> def OnQuoteData(self,pQuote): >> print "got onquote!" >> print type(pQuote) >> print "%s" % pQuote >> >> import win32com.server.util >> qnotify = win32com.server.util.wrap(Q(),useDispatcher=1) >> >> import win32com.client as com >> mbtCom = com.Dispatch("MBTrading.MbtComMgr") >> mbtCom.DoLogin(9,"myusername","mypassword","") >> quote = mbtCom.Quotes >> quote.AdviseSymbol(qnotify,'AAPL',1) >> > > See if adding a call to pythoncom.PumpMessages() at the very end makes a > difference... > > Cheers, > > Mark > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ckkart at hoc.net Thu Apr 16 14:45:06 2009 From: ckkart at hoc.net (Christian K.) Date: Thu, 16 Apr 2009 12:45:06 +0000 (UTC) Subject: [python-win32] ANN: PyGUI 2.0 References: <49E07ABB.7070803@canterbury.ac.nz> Message-ID: Hi, I get the following traceback when running any demo. This is on XP using PyGUI 2.0.1 with pythonxy 2.1.12, pywin32 2.13 Christian $ python nag_box.py File "nag_box.py", line 1, in from GUI import ModalDialog, Label, Button, Task, application File "c:\pythonxy\python\Lib\site-packages\GUI\__init__.py", line 78, in __getattr__ traceback.print_stack() Failed to import 'ModalDialog' from ModalDialogs Traceback (most recent call last): File "c:\pythonxy\python\Lib\site-packages\GUI\__init__.py", line 69, in __getattr__ module = __import__(modname, self.__dict__, locals(), [name]) File "c:\pythonxy\python\Lib\site-packages\GUI\Generic\ModalDialogs.py", line 6, in from Dialogs import Dialog File "c:\pythonxy\python\lib\site-packages\GUI\Win32\Dialogs.py", line 7, in from GDialogs import Dialog File "c:\pythonxy\python\Lib\site-packages\GUI\Generic\GDialogs.py", line 8, in from Windows import Window File "c:\pythonxy\python\Lib\site-packages\GUI\Win32\Windows.py", line 15, in from Components import Component, _win_event_messages File "c:\pythonxy\python\Lib\site-packages\GUI\Win32\Components.py", line 12, in from Win32 import win_none File "c:\pythonxy\python\lib\site-packages\GUI\Win32\__init__.py", line 2, in raise ImportError("This should not be imported.") ImportError: This should not be imported. From juky.liu at gmail.com Fri Apr 17 02:22:34 2009 From: juky.liu at gmail.com (wensi liu) Date: Thu, 16 Apr 2009 17:22:34 -0700 Subject: [python-win32] win32gui.GetMenu() return 0 Message-ID: <257139540904161722y6b4ee647nf7ccd3e0719da375@mail.gmail.com> Hi, I am a novice of Python. I tried writing code for handle IE but failed. I list simple code below: import win32com.client import win32api import win32gui ie = win32com.client.Dispatch('InternetExplorer.Application') ie.Navigate('www.msn.com') ie.Visible = 1 while ie.Busy == True: win32api.Sleep(1000) win32gui.SetForegroundWindow(ie.HWND) m = win32gui.GetMenu(ie.HWND) However, function GetMeun() return 0. Any help or suggestion would be appreciated. Thanks Vince -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Apr 17 02:38:22 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 16 Apr 2009 17:38:22 -0700 Subject: [python-win32] win32gui.GetMenu() return 0 In-Reply-To: <257139540904161722y6b4ee647nf7ccd3e0719da375@mail.gmail.com> References: <257139540904161722y6b4ee647nf7ccd3e0719da375@mail.gmail.com> Message-ID: <49E7CF7E.2060601@probo.com> wensi liu wrote: > > I am a novice of Python. > > I tried writing code for handle IE but failed. > > I list simple code below: > > import win32com.client > import win32api > import win32gui > ie = win32com.client.Dispatch('InternetExplorer.Application') > ie.Navigate('www.msn.com ') > ie.Visible = 1 > while ie.Busy == True: That would be better written as: while ie.Busy: > m = win32gui.GetMenu(ie.HWND) > > However, function GetMeun() return 0. Right. That's because Internet Explorer does not have a main menu in the traditional Windows API sense. Instead, it creates a whole series of movable "toolbars", one of which happens to look like a menu. What are you actually trying to do? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Apr 17 03:02:49 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 16 Apr 2009 18:02:49 -0700 Subject: [python-win32] win32gui.GetMenu() return 0 In-Reply-To: <257139540904161749j30f1e915q53af85192e40db26@mail.gmail.com> References: <257139540904161722y6b4ee647nf7ccd3e0719da375@mail.gmail.com> <49E7CF7E.2060601@probo.com> <257139540904161749j30f1e915q53af85192e40db26@mail.gmail.com> Message-ID: <49E7D539.9010806@probo.com> wensi liu wrote: > Thanks for your quick response! > > Actually, I am trying to click Menu even SubMenu > > like: > Tools->Internet Options > Tools->SmartScreen Filter->Check This Websit Most of the things in Internet Options can be controlled through COM and normal APIs. What, specifically, are you trying to tweak? Smart Screen Filter must be an add-on. You can get to these by enumerating through the list of subwindows to find all the toolbars, but it will be a pain. You could also send keystrokes to the app, but that's also a bit tacky. It would be better for you to try to find out about the Internet Explorer object model, to see if you can use that COM object you already created to access the tools through function call instead. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From greg.ewing at canterbury.ac.nz Fri Apr 17 03:10:01 2009 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Fri, 17 Apr 2009 13:10:01 +1200 Subject: [python-win32] ANN: PyGUI 2.0 In-Reply-To: References: <49E07ABB.7070803@canterbury.ac.nz> Message-ID: <49E7D6E9.1000202@canterbury.ac.nz> Christian K. wrote: > File "c:\pythonxy\python\lib\site-packages\GUI\Win32\__init__.py", line 2, in > > raise ImportError("This should not be imported.") > ImportError: This should not be imported. I'll be releasing a fix for this soon. In the meantime, remove GUI/Win32/__init__.py. -- Greg From greg.ewing at canterbury.ac.nz Fri Apr 17 03:27:03 2009 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Fri, 17 Apr 2009 13:27:03 +1200 Subject: [python-win32] ANN: PyGUI 2.0.2 Message-ID: <49E7DAE7.9070901@canterbury.ac.nz> PyGUI 2.0.2 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ Fixes problem on Windows causing "This file should not be imported" error. What is PyGUI? -------------- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. -- Gregory Ewing greg.ewing at canterbury.ac.nz http://www.cosc.canterbury.ac.nz/greg.ewing/ From juky.liu at gmail.com Fri Apr 17 19:35:11 2009 From: juky.liu at gmail.com (wensi liu) Date: Fri, 17 Apr 2009 10:35:11 -0700 Subject: [python-win32] win32gui.GetMenu() return 0 In-Reply-To: <49E7D539.9010806@probo.com> References: <257139540904161722y6b4ee647nf7ccd3e0719da375@mail.gmail.com> <49E7CF7E.2060601@probo.com> <257139540904161749j30f1e915q53af85192e40db26@mail.gmail.com> <49E7D539.9010806@probo.com> Message-ID: <257139540904171035w61180e2bw302ebaf40acfff4b@mail.gmail.com> Thanks for your kindly explanation. In fact I am focus on Automation Testing for our product around IE. So I need access IE by menu, toolbar, even split button for to simulate all user's action which may affect our product. I just looking for a way to deal with that. Thanks again. On Thu, Apr 16, 2009 at 6:02 PM, Tim Roberts wrote: > wensi liu wrote: > > Thanks for your quick response! > > > > Actually, I am trying to click Menu even SubMenu > > > > like: > > Tools->Internet Options > > Tools->SmartScreen Filter->Check This Websit > > Most of the things in Internet Options can be controlled through COM and > normal APIs. What, specifically, are you trying to tweak? > > Smart Screen Filter must be an add-on. You can get to these by > enumerating through the list of subwindows to find all the toolbars, but > it will be a pain. You could also send keystrokes to the app, but > that's also a bit tacky. It would be better for you to try to find out > about the Internet Explorer object model, to see if you can use that COM > object you already created to access the tools through function call > instead. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Apr 17 19:54:34 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 17 Apr 2009 10:54:34 -0700 Subject: [python-win32] win32gui.GetMenu() return 0 In-Reply-To: <257139540904171035w61180e2bw302ebaf40acfff4b@mail.gmail.com> References: <257139540904161722y6b4ee647nf7ccd3e0719da375@mail.gmail.com> <49E7CF7E.2060601@probo.com> <257139540904161749j30f1e915q53af85192e40db26@mail.gmail.com> <49E7D539.9010806@probo.com> <257139540904171035w61180e2bw302ebaf40acfff4b@mail.gmail.com> Message-ID: <49E8C25A.8060509@probo.com> wensi liu wrote: > > In fact I am focus on Automation Testing for our product around IE. > > So I need access IE by menu, toolbar, even split button for to > simulate all user's action which may affect our product. > > I just looking for a way to deal with that. Oh, you should have said that! I suggest you take a look at the pyAA project from the University of North Carolina. This is a Python-based project from a group whose charter is to improve access to applications for the handicapped, but what they have actually produced is a pretty good framework for automating other applications. This is a Python wrapper around the Microsoft Active Accessibility library. http://www.cs.unc.edu/Research/assist/developer.shtml -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From johnrandolph at gmail.com Fri Apr 17 22:59:51 2009 From: johnrandolph at gmail.com (John Randolph) Date: Fri, 17 Apr 2009 16:59:51 -0400 Subject: [python-win32] AddMembershipRule(SMS_CollectionRuleDirect): Generic failure Message-ID: Hi list: I've been beating my head against this problem for 2 days and can't figure it out. Searching the archives produced a semi-relevant thread from the past but the former fixes haven't worked for me. Using wmi 1.3.2, I've got the following simple code: system = wmih.SMS_R_System(NetbiosName=hostname) new_rule = wmih.SMS_CollectionRuleDirect.new() new_rule.ResourceID = system[0].ResourceID new_rule.RuleName = '%s (%d)' % (hostname, system[0].ResourceID) new_rule.ResourceClassName = 'SMS_R_System' query_id, rv = c.AddMembershipRule(new_rule) I've also tried getting the method InParameters, populating them and calling the method directly as previous list traffic experimented with. However, neither method allows me to add the rule. The code above produces the following exception: File "remotewmi.py", line 115, in PolicyInstall query_id, rv = c.AddMembershipRule(new_rule) File "C:\Documents and Settings\jrand\wmi.py", line 396, in __call__ handle_com_error (error_info) File "C:\Documents and Settings\jrand\wmi.py", line 189, in handle_com_error raise x_wmi, "\n".join (exception_string) wmi.x_wmi: -0x7ffdfff7 - Exception occurred. Error in: SWbemObjectEx -0x7ffbefff - Generic failure From amnorvend at gmail.com Fri Apr 17 23:16:39 2009 From: amnorvend at gmail.com (Jason Baker) Date: Fri, 17 Apr 2009 16:16:39 -0500 Subject: [python-win32] Restarting Python interpreter used by Classic ASP? Message-ID: <816c4abb0904171416h5d87ac4ar38e861ec9f5e6088@mail.gmail.com> I've got some Python code that needs to interact with some Classic ASP code. So I've got some Python Classic ASP files that import other Python modules. What I would like to do is find a way to restart the Python interpreter so that I can force it to reload all loaded modules. However, I don't really seem to be able to find any way to do this without restarting all of IIS. Is there any way to do what I want to do? Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnrandolph at gmail.com Fri Apr 17 23:19:40 2009 From: johnrandolph at gmail.com (John Randolph) Date: Fri, 17 Apr 2009 17:19:40 -0400 Subject: [python-win32] AddMembershipRule(SMS_CollectionRuleDirect): Generic failure In-Reply-To: References: Message-ID: On Fri, Apr 17, 2009 at 4:59 PM, John Randolph wrote: snip > wmi.x_wmi: -0x7ffdfff7 - Exception occurred. > ?Error in: SWbemObjectEx > ?-0x7ffbefff - Generic failure > (er, message got cut off) anyway, enabling verbose WMI logging didn't produce anything revealing. anyone have any tips? Regards John From mail at timgolden.me.uk Fri Apr 17 23:28:15 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 17 Apr 2009 22:28:15 +0100 Subject: [python-win32] AddMembershipRule(SMS_CollectionRuleDirect): Generic failure In-Reply-To: References: Message-ID: <49E8F46F.4050204@timgolden.me.uk> John Randolph wrote: > Hi list: > > I've been beating my head against this problem for 2 days and can't > figure it out. Searching the archives produced a semi-relevant thread > from the past but the former fixes haven't worked for me. > > Using wmi 1.3.2, I've got the following simple code: > > system = wmih.SMS_R_System(NetbiosName=hostname) > new_rule = wmih.SMS_CollectionRuleDirect.new() > new_rule.ResourceID = system[0].ResourceID > new_rule.RuleName = '%s (%d)' % (hostname, system[0].ResourceID) > new_rule.ResourceClassName = 'SMS_R_System' > query_id, rv = c.AddMembershipRule(new_rule) > > I've also tried getting the method InParameters, populating them and > calling the method directly as previous list traffic experimented > with. > > However, neither method allows me to add the rule. The code above > produces the following exception: > > File "remotewmi.py", line 115, in PolicyInstall > query_id, rv = c.AddMembershipRule(new_rule) > File "C:\Documents and Settings\jrand\wmi.py", line 396, in __call__ > handle_com_error (error_info) > File "C:\Documents and Settings\jrand\wmi.py", line 189, in handle_com_error > raise x_wmi, "\n".join (exception_string) > wmi.x_wmi: -0x7ffdfff7 - Exception occurred. > Error in: SWbemObjectEx > -0x7ffbefff - Generic failure Don't you love those "Generic failure" messages? I need to put some better conversion code in there to help you search for the error code. -0x7ffbefff is 0x80041001 when you twiddle the bits around, and that throws up this kind of post: http://myitforum.com/cs2/blogs/scassells/archive/2007/02/07/2147217407-error-or-80041001-how-to-avoid-progromatically.aspx and this: http://www.myitforum.com/forums/m_52995/mpage_1/key_gathering%252Ccollection%252Call%252Cworkstation%252Cdomain/tm.htm#52995 The first suggests a delay might help. The second doesn't come to any conclusion except that if the last poster got it working then it's something a bit environmental. Try the delay, perhaps. FWIW, the WMI code probably isn't calling Put_ on your newly-created object, because it (probably) doesn't have a Path_ -- it hasn't come off the WMI database. According to the example at: http://msdn.microsoft.com/en-us/library/ms815919.aspx that's correct. But just in case it makes a difference you can try calling new_rule.Put_ () before you add it to the collection. My feeling is that it will fail but YMMV. I'm afraid I'm not at all familiar with SMS and I'm certainly nowhere near an installation, so it's hard for me to test or reproduce the issue. Feel free to post back and I'm happy to diagnose at a distance or to produce debug probes in the WMI code itself. TJG From juky.liu at gmail.com Sat Apr 18 00:54:32 2009 From: juky.liu at gmail.com (wensi liu) Date: Fri, 17 Apr 2009 15:54:32 -0700 Subject: [python-win32] Uninstall program form Registry Message-ID: <257139540904171554q545329b5wd0db8cf2326ded0c@mail.gmail.com> Hi, I wrote code blow for trying uninstall program form the control panel. Somehow the code doesn't work. def CollectChildWindows(hwnd, childWindows): print win32gui.GetWindowText(hwnd) #childWindows.append((hwnd, win32gui.GetWindowText(hwnd), win32gui.getClassName(hwnd))) if __name__ == '__main__': import os import win32com.client import win32api import win32gui os.system('control.exe appwiz.cpl') Currenthwnd = win32gui.FindWindow('NativeHWNDHost','Add or Remove Programs') childWindows = [] if Currenthwnd: windows = win32gui.EnumChildWindows(Currenthwnd,CollectChildWindows,childWindows) else: print 'NG' It seems I can not get the child windows. Thanks Vince -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Sat Apr 18 01:29:07 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 17 Apr 2009 16:29:07 -0700 Subject: [python-win32] Uninstall program form Registry In-Reply-To: <257139540904171554q545329b5wd0db8cf2326ded0c@mail.gmail.com> References: <257139540904171554q545329b5wd0db8cf2326ded0c@mail.gmail.com> Message-ID: <49E910C3.7050107@probo.com> wensi liu wrote: > > I wrote code blow for trying uninstall program form the control panel. > Somehow the code doesn't work. Right. This is doomed to failure, for reasons very similar to your IE troubles. The Add/Remove Programs control panel does not use child windows to host its controls. Almost all of the window, including the thing that looks like a big combo box, is just drawn onto the window background at WM_PAINT time. The only real control in the whole window is the combo box for choosing the sort order. Don't you have a tool line WinSpectre or SpyXX for looking at window structure? They would help you find out things like this. In this particular case, this wouldn't be the right way to do this task, anyway. That control panel gets its information from the Uninstall key in the registry, and you can go read that just as easily as it can. Go check here: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall Every subkey represents an app or update that can be uninstalled, and each key contains an UninstallString value that gives you the command to execute to do the uninstall. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From juky.liu at gmail.com Sat Apr 18 01:38:50 2009 From: juky.liu at gmail.com (wensi liu) Date: Fri, 17 Apr 2009 16:38:50 -0700 Subject: [python-win32] Uninstall program form Registry In-Reply-To: <49E910C3.7050107@probo.com> References: <257139540904171554q545329b5wd0db8cf2326ded0c@mail.gmail.com> <49E910C3.7050107@probo.com> Message-ID: <257139540904171638se26f674w2340b7e7ab8e60bc@mail.gmail.com> I am using AccExplorer to identify the Name and Class Name. Actually, I did uninstall program via Registry, however, the behavior could be a little difference between them, like: If I uninstall program from Registry, the program won't delete it's folder itself. That the reason why I am trying to do so that way. Thanks again. Vince On Fri, Apr 17, 2009 at 4:29 PM, Tim Roberts wrote: > wensi liu wrote: > > > > I wrote code blow for trying uninstall program form the control panel. > > Somehow the code doesn't work. > > Right. This is doomed to failure, for reasons very similar to your IE > troubles. The Add/Remove Programs control panel does not use child > windows to host its controls. Almost all of the window, including the > thing that looks like a big combo box, is just drawn onto the window > background at WM_PAINT time. The only real control in the whole window > is the combo box for choosing the sort order. > > Don't you have a tool line WinSpectre or SpyXX for looking at window > structure? They would help you find out things like this. > > In this particular case, this wouldn't be the right way to do this task, > anyway. That control panel gets its information from the Uninstall key > in the registry, and you can go read that just as easily as it can. Go > check here: > HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall > Every subkey represents an app or update that can be uninstalled, and > each key contains an UninstallString value that gives you the command to > execute to do the uninstall. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Sat Apr 18 01:50:10 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 17 Apr 2009 16:50:10 -0700 Subject: [python-win32] Uninstall program form Registry In-Reply-To: <257139540904171638se26f674w2340b7e7ab8e60bc@mail.gmail.com> References: <257139540904171554q545329b5wd0db8cf2326ded0c@mail.gmail.com> <49E910C3.7050107@probo.com> <257139540904171638se26f674w2340b7e7ab8e60bc@mail.gmail.com> Message-ID: <49E915B2.8060802@probo.com> wensi liu wrote: > I am using AccExplorer to identify the Name and Class Name. > > Actually, I did uninstall program via Registry, however, the behavior > could be a little difference between them, like: > > If I uninstall program from Registry, the program won't delete it's > folder itself. That the reason why I am trying to do so that way. Believe me when I say that the Add/Remove Programs wizard is doing exactly what I described: it runs the UninstallString from the registry. It CAN'T do anything else. It doesn't know which folders to delete. Only the uninstall app knows that. You probably had extra files in the folder that weren't installed by the installer. Most uninstall apps will not delete the root folder if it contains files that were created after installation time. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From johnrandolph at gmail.com Sat Apr 18 02:03:53 2009 From: johnrandolph at gmail.com (John Randolph) Date: Fri, 17 Apr 2009 20:03:53 -0400 Subject: [python-win32] AddMembershipRule(SMS_CollectionRuleDirect): Generic failure In-Reply-To: <49E8F46F.4050204@timgolden.me.uk> References: <49E8F46F.4050204@timgolden.me.uk> Message-ID: On Fri, Apr 17, 2009 at 5:28 PM, Tim Golden wrote: > > The first suggests a delay might help. The second doesn't come to > any conclusion except that if the last poster got it working then > it's something a bit environmental. Try the delay, perhaps. > FWIW, the WMI code probably isn't calling Put_ on your > newly-created object, because it (probably) doesn't > have a Path_ -- it hasn't come off the WMI database. > According to the example at: > > ?http://msdn.microsoft.com/en-us/library/ms815919.aspx > > that's correct. But just in case it makes a difference > you can try calling new_rule.Put_ () before you add it > to the collection. My feeling is that it will fail but > YMMV. Hi, thanks for your reply. Actually I had previously placed a delay between the new_rule creation and calling AddMembershipRule for another reason -- to make a clear break in the timestamps on the server side wmi logs. Unfortunately the delay doesn't help. Adding a Put_ gave me a different error, "Attempt to put an instance with no defined key." Sensible enough error. Not sure where to go from here, really. I've been unable to cough up anything interesting on the server side, and I'm not very windows or sms savvy. Regards, John > > I'm afraid I'm not at all familiar with SMS and I'm certainly > nowhere near an installation, so it's hard for me to test or > reproduce the issue. Feel free to post back and I'm happy > to diagnose at a distance or to produce debug probes in the > WMI code itself. > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From juky.liu at gmail.com Sat Apr 18 02:12:35 2009 From: juky.liu at gmail.com (wensi liu) Date: Fri, 17 Apr 2009 17:12:35 -0700 Subject: [python-win32] Uninstall program form Registry In-Reply-To: <49E915B2.8060802@probo.com> References: <257139540904171554q545329b5wd0db8cf2326ded0c@mail.gmail.com> <49E910C3.7050107@probo.com> <257139540904171638se26f674w2340b7e7ab8e60bc@mail.gmail.com> <49E915B2.8060802@probo.com> Message-ID: <257139540904171712m456d146fpf70f2b6f064286eb@mail.gmail.com> I implemented a test case for verifying functionality of our program, one of the feature is some folders would be deleted after uninstall. Somehow, those folder still exist after I uninstall via Registry like your mentioned. Instead, the folder would be deleted as expected when I uninstall it manually from Control Panel. Thanks On Fri, Apr 17, 2009 at 4:50 PM, Tim Roberts wrote: > wensi liu wrote: > > I am using AccExplorer to identify the Name and Class Name. > > > > Actually, I did uninstall program via Registry, however, the behavior > > could be a little difference between them, like: > > > > If I uninstall program from Registry, the program won't delete it's > > folder itself. That the reason why I am trying to do so that way. > > Believe me when I say that the Add/Remove Programs wizard is doing > exactly what I described: it runs the UninstallString from the > registry. It CAN'T do anything else. It doesn't know which folders to > delete. Only the uninstall app knows that. > > You probably had extra files in the folder that weren't installed by the > installer. Most uninstall apps will not delete the root folder if it > contains files that were created after installation time. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ckkart at hoc.net Sat Apr 18 15:39:38 2009 From: ckkart at hoc.net (Christian K.) Date: Sat, 18 Apr 2009 15:39:38 +0200 Subject: [python-win32] ANN: PyGUI 2.0.2 In-Reply-To: <49E7DAE7.9070901@canterbury.ac.nz> References: <49E7DAE7.9070901@canterbury.ac.nz> Message-ID: Greg Ewing schrieb: > PyGUI 2.0.2 is available: > > http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ > > Fixes problem on Windows causing "This file should not > be imported" error. Now I get this traceback: $ python main.py File "main.py", line 9, in from sheetapp import MatSheetApp File "d:\PyGUI-2.0.3\Demos\MatSheet\sheetapp.py", line 8, in from sheetdoc import SheetDoc, mash_type File "d:\PyGUI-2.0.3\Demos\MatSheet\sheetdoc.py", line 8, in from GUI import Document, FileType File "c:\pythonxy\python\Lib\site-packages\GUI\__init__.py", line 78, in __getattr__ traceback.print_stack() Failed to import 'Document' from Documents Traceback (most recent call last): File "c:\pythonxy\python\Lib\site-packages\GUI\__init__.py", line 69, in __getattr__ module = __import__(modname, self.__dict__, locals(), [name]) File "c:\pythonxy\python\lib\site-packages\GUI\Generic\Documents.py", line 6, in from AlertFunctions import confirm, confirm_or_cancel File "c:\pythonxy\python\Lib\site-packages\GUI\Generic\AlertFunctions.py", line 1, in import BaseAlertFunctions File "c:\pythonxy\python\lib\site-packages\GUI\Generic\BaseAlertFunctions.py", line 5, in from Alerts import Alert, Alert2, Alert3 File "c:\pythonxy\python\lib\site-packages\GUI\Win32\Alerts.py", line 7, in from GAlerts import Alert, Alert2, Alert3 File "c:\pythonxy\python\Lib\site-packages\GUI\Generic\GAlerts.py", line 5, in from BaseAlerts import BaseAlert File "c:\pythonxy\python\Lib\site-packages\GUI\Win32\BaseAlerts.py", line 10, in from Views import View File "c:\pythonxy\python\Lib\site-packages\GUI\Win32\Views.py", line 9, in from Canvases import Canvas File "c:\pythonxy\python\lib\site-packages\GUI\Win32\Canvases.py", line 14, in from StdFonts import application_font File "c:\pythonxy\python\lib\site-packages\GUI\Win32\StdFonts.py", line 34, in system_font = Font("Tahoma", _win_pts_to_pixels(8)) File "c:\pythonxy\python\lib\site-packages\GUI\Win32\Fonts.py", line 73, in __init__ pitch_and_family = 0) ###win_family_map.get(family, win_default_pf)) File "c:\pythonxy\python\lib\site-packages\GUI\Win32\Fonts.py", line 34, in win_create_font return ui.CreateFont(kwds) TypeError: 'pitch_and_family' is an invalid keyword argument for this function Christian From mail at timgolden.me.uk Sat Apr 18 21:09:58 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Sat, 18 Apr 2009 20:09:58 +0100 Subject: [python-win32] AddMembershipRule(SMS_CollectionRuleDirect): Generic failure In-Reply-To: References: <49E8F46F.4050204@timgolden.me.uk> Message-ID: <49EA2586.6060101@timgolden.me.uk> John Randolph wrote: > Actually I had previously placed a delay between the new_rule creation > and calling AddMembershipRule for another reason -- to make a clear > break in the timestamps on the server side wmi logs. Unfortunately > the delay doesn't help. Shame. > Adding a Put_ gave me a different error, "Attempt to put an instance > with no defined key." As I expected. > Not sure where to go from here, really. Me neither, I'm afraid. I'm more than happy to help on the Python-WMI front, but outside that I'd be playing guessing games with the SMS side of things. TJG From greg.ewing at canterbury.ac.nz Sun Apr 19 11:33:57 2009 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sun, 19 Apr 2009 21:33:57 +1200 Subject: [python-win32] ANN: PyGUI 2.0.2 In-Reply-To: References: <49E7DAE7.9070901@canterbury.ac.nz> Message-ID: <49EAF005.2030603@canterbury.ac.nz> Christian K. wrote: > TypeError: 'pitch_and_family' is an invalid keyword argument for this > function Looking at the source of pywin32, I can see why this happens -- it really is expecting 'pitch and family' with spaces (and it's abusing ParseTupleAndKeywords to unpack a dict, which is why it's reporting a keyword argument error even though it's not really a keyword). What's really puzzling is why I *don't* get this error on my system! Anyway, since that parameter isn't being used any more, just take it out and let me know if it fixes the problem. Thanks, Greg From skippy.hammond at gmail.com Mon Apr 20 01:15:45 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Mon, 20 Apr 2009 09:15:45 +1000 Subject: [python-win32] Restarting Python interpreter used by Classic ASP? In-Reply-To: <816c4abb0904171416h5d87ac4ar38e861ec9f5e6088@mail.gmail.com> References: <816c4abb0904171416h5d87ac4ar38e861ec9f5e6088@mail.gmail.com> Message-ID: <49EBB0A1.5000805@gmail.com> Jason Baker wrote: > I've got some Python code that needs to interact with some Classic ASP > code. So I've got some Python Classic ASP files that import other > Python modules. What I would like to do is find a way to restart the > Python interpreter so that I can force it to reload all loaded modules. > However, I don't really seem to be able to find any way to do this > without restarting all of IIS. > > Is there any way to do what I want to do? No - although the 'reload' builtin still works in an ASP environment. Cheers, Mark From greg.ewing at canterbury.ac.nz Mon Apr 20 02:44:34 2009 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Mon, 20 Apr 2009 12:44:34 +1200 Subject: [python-win32] ANN: PyGUI 2.0.2 In-Reply-To: <49EAF2C4.5060704@hoc.net> References: <49E7DAE7.9070901@canterbury.ac.nz> <49EAF005.2030603@canterbury.ac.nz> <49EAF2C4.5060704@hoc.net> Message-ID: <49EBC572.4090305@canterbury.ac.nz> Christian K. wrote: > "c:\pythonxy\python\Lib\site-packages\GUI\Win32\ScrollableViews.py", > line 31, in __init__ > GScrollableView.__init__(self, _win = win) > win32ui.error: The object has been destroyed. Do you have any problem running Tests/12-scroll.py? -- Greg From ckkart at hoc.net Mon Apr 20 09:38:16 2009 From: ckkart at hoc.net (Christian K.) Date: Mon, 20 Apr 2009 07:38:16 +0000 (UTC) Subject: [python-win32] ANN: PyGUI 2.0.2 References: <49E7DAE7.9070901@canterbury.ac.nz> <49EAF005.2030603@canterbury.ac.nz> <49EAF2C4.5060704@hoc.net> <49EBC572.4090305@canterbury.ac.nz> Message-ID: Greg Ewing canterbury.ac.nz> writes: > > Christian K. wrote: > > > "c:\pythonxy\python\Lib\site-packages\GUI\Win32\ScrollableViews.py", > > line 31, in __init__ > > GScrollableView.__init__(self, _win = win) > > win32ui.error: The object has been destroyed. > > Do you have any problem running Tests/12-scroll.py? Yes, same error. Christian From whatyoulookin at yahoo.com Tue Apr 21 00:04:14 2009 From: whatyoulookin at yahoo.com (Alec Bennett) Date: Mon, 20 Apr 2009 15:04:14 -0700 (PDT) Subject: [python-win32] problem getting printer status in Windows Message-ID: <960652.27403.qm@web54606.mail.re2.yahoo.com> I'm having trouble getting the printer status in Windows. Ideally I'd like to get the info contained in the "Status" column when you open a printer from the Windows control panel --> printers. I've been using the routine pasted at the end of this email, which works for some printers, but not others. All I really need is the info in that window that opens when you click a printer in Windows control panel --> printers, under status. Does anyone know how to get this? Here's the win32print routine I'm using. import win32print printer_name = "Sony UP-DR150" s = win32print.OpenPrinter(printer_name) # List the printer's jobs (in range 0 to 999): raw = win32print.EnumJobs(s, 0, 999) # If there are any jobs, lets analyze them: if len(raw) > 0: results = raw[0] print results win32print.ClosePrinter(s) ''' {'Status': 1, 'pPrinterName': 'Sony UP-DR150', 'pDocument': 'C:\\photoboof\\strips\\104375.jpg', 'Submitted': , 'JobId': 31, 'Priority': 1, 'pUserName': 'Administrator', 'pStatus': None, 'PagesPrinted': 0, 'Position': 1, 'TotalPages': 0, 'pDatatype': 'RAW', 'pMachineName': '\\\\ASDF'} ''' From neisen at linbox.com Mon Apr 20 16:56:26 2009 From: neisen at linbox.com (EISEN Nicolas) Date: Mon, 20 Apr 2009 16:56:26 +0200 Subject: [python-win32] Extract icon from exe files Message-ID: <49EC8D1A.9000909@linbox.com> Hi, After search, I found many function to get Handler from exe (or dll) file icons . But I don?t understand how use the Handler ? For example: />>> Import win32gui > >> i= win32gui.ExtractIcon(0,'e:\\dxdiag.exe',0) > >> icon = win32gui.LoadIcon ( i , 0)/ Or with ExtractIconEx to get a list of all icons, I?m always with many Handlers without knowing how to save or write it in file. The finality is to extract the exe file icon, and next, save the picture on the disk. Thanks for your help. From timr at probo.com Tue Apr 21 01:37:22 2009 From: timr at probo.com (Tim Roberts) Date: Mon, 20 Apr 2009 16:37:22 -0700 Subject: [python-win32] Extract icon from exe files In-Reply-To: <49EC8D1A.9000909@linbox.com> References: <49EC8D1A.9000909@linbox.com> Message-ID: <49ED0732.6050608@probo.com> EISEN Nicolas wrote: > Hi, > > After search, I found many function to get Handler from exe (or dll) > file icons . But I don?t understand how use the Handler ? > > For example: > > />>> Import win32gui >> >> i= win32gui.ExtractIcon(0,'e:\\dxdiag.exe',0) >> >> icon = win32gui.LoadIcon ( i , 0)/ > > > Or with ExtractIconEx to get a list of all icons, I?m always with many > Handlers without knowing how to save or write it in file. > > The finality is to extract the exe file icon, and next, save the > picture on the disk. Why do you want to do this? Icons are intellectual property. Unless it's an open source app, you can't just scrape a bunch of icons from existing applications and gather them into a library. It's not legal. Having said that, a few minutes with Google and MSDN would have answered this question. LoadIcon returns an HICON. You can pass that to GetIconInfo to return an ICONINFO structure, which includes the two bitmaps that you need to draw an icon. An icon always includes two bitmaps: one is a monochrome bitmap that digs the hole for the color image, and the other is the color image. Those are HBITMAP handles. You can then use GetBitmapBits to get the actual pixels. It's possible this might be easier in C. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mail at timgolden.me.uk Tue Apr 21 12:19:06 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 21 Apr 2009 11:19:06 +0100 Subject: [python-win32] problem getting printer status in Windows In-Reply-To: <960652.27403.qm@web54606.mail.re2.yahoo.com> References: <960652.27403.qm@web54606.mail.re2.yahoo.com> Message-ID: <49ED9D9A.3040605@timgolden.me.uk> Alec Bennett wrote: > I'm having trouble getting the printer status in Windows. > Ideally I'd like to get the info contained in the "Status" column > when you open a printer from the Windows control panel --> printers. Generally, altho' not always, questions like this have an answer which starts with "WMI". In this case I'm not absolutely convinced, but it looks quite good. Guessing that the Win32_Printer class is what you want leads to this: http://msdn.microsoft.com/en-us/library/aa394363(VS.85).aspx and the PrinterStatus or ExtendedPrinterStatus attributes which looks handy. So... import wmi c = wmi.WMI () for p in c.Win32_Printer (): print p.Caption, p.Printerstatus Frankly I've no idea if it's any more or less reliable than your other method; maybe someone who's done more printer-related work can chip in here. But it at least opens an alternative avenue for you to look at. TJG From greg.ewing at canterbury.ac.nz Tue Apr 21 14:05:51 2009 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Wed, 22 Apr 2009 00:05:51 +1200 Subject: [python-win32] ANN: PyGUI 2.0.4 Message-ID: <49EDB69F.7070901@canterbury.ac.nz> PyGUI 2.0.4 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ Fixes a few more bugs and hopefully improves things on Windows, although I can't be sure it will fix all the Windows problems people are having, because I haven't been able to reproduce some of them. What is PyGUI? -------------- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. -- Gregory Ewing greg.ewing at canterbury.ac.nz http://www.cosc.canterbury.ac.nz/greg.ewing/ From bbbscarter at gmail.com Tue Apr 21 15:20:29 2009 From: bbbscarter at gmail.com (Simon Carter) Date: Tue, 21 Apr 2009 14:20:29 +0100 Subject: [python-win32] COM and retrieving records/structures Message-ID: Hullo! I'm having a problem interfacing with a proprietary COM library on Windows, and I was hoping someone could help. I'm no COM guru, so apologies in advance if my terminology gets a little muddled... I'm accessing the COM library via gencache.EnsureModule. It was all working as expected until I needed to access a property of a COM interface that returns a variant. So: my_object.SomeMethod() # works fine val = my_object.RunningProcessInfo #throws a 'The parameter is incorrect' com_error val = my_object.RunningProcessInfo() #tried that just in case, but it also throws a 'The parameter is incorrect' com_error val = my_object.get_RunningProcessInfo() #nope, "object has no attribute 'get_RunningProcessInfo()'" Looking at the generated interface python file, although RunningProcessInfo exists, there is no reference to the PROCESS_INFO structure it is meant to return. If I browse the library using the pythonwin COM browser I can see that the relevant structure exists, flagged as a 'Record' in the browser, although I can't inspect its members. Thinking that maybe structures are generated on the fly, I tried forcing the creation of the given record type: val = win32com.client.Record("PROCESS_INFO", my_object) #The structure "PROCESS_INFO" is not defined in the module As such, from my point of view of almost total ignorance, it seems that my problem is being caused by the PROCESS_INFO structure not being generated/accessible. More likely, of course, it that I'm being an arse and doing it wrong. Some other notes: - I've tried similar things using the late binding 'Dispatch' interface, but without any luck. - I've tried the same thing with various other properties that return structures, with the same result. - It may not be related, but I've also had a look at some other libraries, such as the "DirectX Transforms Core Type Library", and there are lots of structures in there that appear in the COM browser, but don't appear in the generated interface file. - I'm running 32bit python 2.6 and pywin32 build 213, on Vista 64. Any help much appreciated. Thanks! Simon -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnrandolph at gmail.com Tue Apr 21 17:12:53 2009 From: johnrandolph at gmail.com (John Randolph) Date: Tue, 21 Apr 2009 16:12:53 +0100 Subject: [python-win32] AddMembershipRule(SMS_CollectionRuleDirect): Generic failure In-Reply-To: <49EA2586.6060101@timgolden.me.uk> References: <49E8F46F.4050204@timgolden.me.uk> <49EA2586.6060101@timgolden.me.uk> Message-ID: On Sat, Apr 18, 2009 at 8:09 PM, Tim Golden wrote: > John Randolph wrote: > >> Actually I had previously placed a delay between the new_rule creation >> and calling AddMembershipRule for another reason -- to make a clear >> break in the timestamps on the server side wmi logs. ?Unfortunately >> the delay doesn't help. > > Shame. > >> Adding a Put_ gave me a different error, "Attempt to put an instance >> with no defined key." > > As I expected. > >> Not sure where to go from here, really. > > Me neither, I'm afraid. I'm more than happy to help > on the Python-WMI front, but outside that I'd be > playing guessing games with the SMS side of things. > > TJG > Tim, is there any more debugging info I can gain on the python wmi side? I tried setting debug=True but that gives minimal info, mostly wsql queries during object selection, etc. Regards John From mvilas at gmail.com Tue Apr 21 18:26:54 2009 From: mvilas at gmail.com (Mario Alejandro Vilas Jerez) Date: Tue, 21 Apr 2009 18:26:54 +0200 Subject: [python-win32] Python winappdbg module v1.0 is out! In-Reply-To: <3fbf862f0904210922i2c97da60j1a80ed7a917ff18e@mail.gmail.com> References: <3fbf862f0904210922i2c97da60j1a80ed7a917ff18e@mail.gmail.com> Message-ID: <3fbf862f0904210926p106c85a2s51f9a046f6d6c206@mail.gmail.com> What is winappdbg? ================== The winappdbg python module allows developers to quickly code instrumentation scripts in Python under a Windows environment. It uses ctypes to wrap many Win32 API calls related to debugging, and provides an object-oriented abstraction layer to manipulate threads, libraries and processes, attach your script as a debugger, trace execution, hook API calls, handle events in your debugee and set breakpoints of different kinds (code, hardware and memory). Additionally it has no native code at all, making it easier to maintain or modify than other debuggers on Windows. The intended audience are QA engineers and software security auditors wishing to test / fuzz Windows applications with quickly coded Python scripts. Several ready to use utilities are shipped and can be used for this purposes. Current features also include disassembling x86 native code (using the open source diStorm project, see http://ragestorm.net/distorm/), debugging multiple processes simultaneously and produce a detailed log of application crashes, useful for fuzzing and automated testing. Where can I find winappdbg? =========================== The winappdbg project is currently hosted at Sourceforge, and can be found at: ??? http://winappdbg.sourceforge.net/ From rwupole at msn.com Tue Apr 21 19:29:50 2009 From: rwupole at msn.com (Roger Upole) Date: Tue, 21 Apr 2009 13:29:50 -0400 Subject: [python-win32] problem getting printer status in Windows Message-ID: Just to clarify, the code is asking for job status rather than printer status. According to the docs: http://msdn.microsoft.com/en-us/library/dd145019(VS.85).aspx the status can be returned either as a string in the pStatus member, or as an int in Status. You'll probably need to change the JOB_STATUS_* value into a human-readable string when the pStatus string isn't given. Roger From ckkart at hoc.net Tue Apr 21 21:02:09 2009 From: ckkart at hoc.net (Christian K.) Date: Tue, 21 Apr 2009 19:02:09 +0000 (UTC) Subject: [python-win32] ANN: PyGUI 2.0.4 References: <49EDB69F.7070901@canterbury.ac.nz> Message-ID: Hi Greg, Greg Ewing canterbury.ac.nz> writes: > on Windows, although I can't be sure it will fix all > the Windows problems people are having, because I > haven't been able to reproduce some of them. > > What is PyGUI? > -------------- > > PyGUI is a cross-platform GUI toolkit designed to be lightweight > and have a highly Pythonic API. > I'm afraid, that error is stil there: $ python 12-scroll.py Traceback (most recent call last): File "12-scroll.py", line 38, in win = TestWindow() File "12-scroll.py", line 9, in __init__ width = 300, height = 300, scrolling = 'hv') File "d:\PyGUI-2.0.4\Tests\TestScrollableViews.py", line 16, in __init__ ScrollableView.__init__(self, **kwds) File "c:\pythonxy\python\Lib\site-packages\GUI\Win32\ScrollableViews.py", line 31, in __init__ GScrollableView.__init__(self, _win = win) win32ui.error: The object has been destroyed. Please tell me if I can help, regards, Christian From mail at timgolden.me.uk Tue Apr 21 21:52:42 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 21 Apr 2009 20:52:42 +0100 Subject: [python-win32] AddMembershipRule(SMS_CollectionRuleDirect): Generic failure In-Reply-To: References: <49E8F46F.4050204@timgolden.me.uk> <49EA2586.6060101@timgolden.me.uk> Message-ID: <49EE240A.2090900@timgolden.me.uk> John Randolph wrote: > On Sat, Apr 18, 2009 at 8:09 PM, Tim Golden wrote: >> John Randolph wrote: >> >>> Actually I had previously placed a delay between the new_rule creation >>> and calling AddMembershipRule for another reason -- to make a clear >>> break in the timestamps on the server side wmi logs. Unfortunately >>> the delay doesn't help. >> Shame. >> >>> Adding a Put_ gave me a different error, "Attempt to put an instance >>> with no defined key." >> As I expected. >> >>> Not sure where to go from here, really. >> Me neither, I'm afraid. I'm more than happy to help >> on the Python-WMI front, but outside that I'd be >> playing guessing games with the SMS side of things. >> >> TJG >> > > Tim, > > is there any more debugging info I can gain on the python wmi side? > I tried setting debug=True but that gives minimal info, mostly wsql > queries during object selection, etc. > > Regards > John There's nothing else built-in, I'm afraid. I'm perfectly happy to produce an instrumented version of the current release if it'll help -- or you could just run: python -mtrace --trace --ignore-dir c:\python26\lib your-prog.py > your-prog.trace.log In my case, wmi is run out of a subversion checkout somewhere outside site-packages; excluding c:\python26\lib misses out all the underlying win32com stuff. This will at least show you the code path in all its rawness. I honestly expect that this will just confirm that the problem is outside the Python bit, but I'm very happy to be proved wrong. If you want to, run with this and send me the output so I can at least see what happens. TJG From greg.ewing at canterbury.ac.nz Wed Apr 22 02:45:01 2009 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Wed, 22 Apr 2009 12:45:01 +1200 Subject: [python-win32] ANN: PyGUI 2.0.4 In-Reply-To: References: <49EDB69F.7070901@canterbury.ac.nz> Message-ID: <49EE688D.3060804@canterbury.ac.nz> Christian K. wrote: > I'm afraid, that error is stil there: > > File "c:\pythonxy\python\Lib\site-packages\GUI\Win32\ScrollableViews.py", line > 31, in __init__ > GScrollableView.__init__(self, _win = win) > win32ui.error: The object has been destroyed. That's a bit of a problem, since it works for me on all the Windows systems I have readily available. > Please tell me if I can help, If you can do any debugging and find out more about what's causing the problem, that would be helpful. Thanks, Greg From skippy.hammond at gmail.com Wed Apr 22 05:45:16 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 22 Apr 2009 13:45:16 +1000 Subject: [python-win32] [Fwd: Would you support adding UNC support to os.path on Windows?] Message-ID: <49EE92CC.1030603@gmail.com> From python-list, and I thought it might be of interest here... Cheers, Mark -------------- next part -------------- An embedded message was scrubbed... From: Larry Hastings Subject: Would you support adding UNC support to os.path on Windows? Date: Tue, 21 Apr 2009 18:17:35 -0700 Size: 5179 URL: From skippy.hammond at gmail.com Wed Apr 22 06:35:09 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 22 Apr 2009 14:35:09 +1000 Subject: [python-win32] Extract icon from exe files In-Reply-To: <49EC8D1A.9000909@linbox.com> References: <49EC8D1A.9000909@linbox.com> Message-ID: <49EE9E7D.2070907@gmail.com> EISEN Nicolas wrote: > Hi, > > After search, I found many function to get Handler from exe (or dll) > file icons . But I don?t understand how use the Handler ? > > For example: > > />>> Import win32gui >> >> i= win32gui.ExtractIcon(0,'e:\\dxdiag.exe',0) >> >> icon = win32gui.LoadIcon ( i , 0)/ > > > Or with ExtractIconEx to get a list of all icons, I?m always with many > Handlers without knowing how to save or write it in file. > > The finality is to extract the exe file icon, and next, save the picture > on the disk. Check out the win32\Demos directory, particularly win32gui_menu.py which converts an icon to a bitmap (although probably not very well!) Mark From mhammond at skippinet.com.au Wed Apr 22 12:08:47 2009 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 22 Apr 2009 20:08:47 +1000 Subject: [python-win32] COM and retrieving records/structures In-Reply-To: References: <49EE9B54.8080000@gmail.com> Message-ID: <001c01c9c332$56a9cec0$03fd6c40$@com.au> [please keep on-list for the sake of others. I've not trimmed things accordingly...] > -----Original Message----- > From: Simon Carter [mailto:bbbscarter at gmail.com] > Sent: Wednesday, 22 April 2009 7:15 PM > To: mhammond at skippinet.com.au > Subject: Re: [python-win32] COM and retrieving records/structures > > Hi Mark, many thanks for the reply. > > > That seems a little strange - for a property-getter I wouldn't expect > any args - just a result type. ?If it returned a struct, I'd expect the > COM object to allocate and return it in a new variant. > > Well, the getter method looks like this: > HRESULT get_RunningProcessInfo( PXBOX_PROCESS_INFO ProcessInfo ); > > which looks sane to my eyes. > > And the full traceback is: > File "", line 1, in > File "c:\Python26\lib\site-packages\win32com\client\__init__.py", > line 502, in __getattr__ > if d is not None: return getattr(d, attr) > File "c:\Python26\lib\site-packages\win32com\client\__init__.py", > line 463, in __getattr__ > return self._ApplyTypes_(*args) > File "c:\Python26\lib\site-packages\win32com\client\__init__.py", > line 456, in _ApplyTypes_ > self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, > *args), > pywintypes.com_error: (-2147024809, 'The parameter is incorrect.', > None, None) > > > What does the method say exactly? ?It will list the 'variant type' of > objects it knows. > The C function definition is above. In the generated py file there's a > reference to RunningProcessInfo in the _prop_map_get_ table in the > class definition I'm using: > > class IXboxConsole(DispatchBaseClass): > """Xbox Console""" > CLSID = IID('{75DD80A9-5A33-42D4-8A39-AB07C9B17CC3}') > coclass_clsid = IID('{3ED2B073-99A1-42DB-80CC-295E9FFBA18F}') > > > _prop_map_get_ = { > > "RunningProcessInfo": (102, 2, (36, 0), (), > "RunningProcessInfo", None), > > } > > and also in the vtables section: > (( u'RunningProcessInfo' , u'ProcessInfo' , ), 102, (102, (), [ > (36, > 10, None, None) , ], 1 , 2 , 4 , 0 , 96 , (3, 0, None, None) , 0 , )), > > IXboxConsole_vtables_ = [ > > (( u'RunningProcessInfo' , u'ProcessInfo' , ), 102, (102, (), [ > (36, > 10, None, None) , ], 1 , 2 , 4 , 0 , 96 , (3, 0, None, None) , 0 , )), > > ] > > I can't find any other reference to that 'ProcessInfo' string > anywhere, so I'm not sure what that's doing. > > > > > I'd also expect all referenced records to be written to the generated > .py file - eg, the VB tests in the test suite write: > > > > RecordMap = { > > ? ? ? ?u'SubSubStruct': '{CB2C0086-0FCC-4350-93A3-E5C85CF53FE6}', > > ? ? ? ?u'VBStruct': '{69A22CFE-4269-4131-8C50-E54CA915E310}', > > ? ? ? ?u'SubStruct': '{CB58821D-CAEC-43C0-B801-7C137B32C598}', > > } > > Yeah, this may be the root of the problem. There is a RecordMap in the > generated .py file, but it contains only one record. The library has > 10 or 15 such record types in it, so it's curious that only one is > appearing: > > RecordMap = { > u'XBOX_AUTOMATION_GAMEPAD': '{00000000-0000-0000-0000- > 000000000000}', > } I suspect the fact these objects are using a NULL IID is the cause of this problem. Does the COM browser also reflect this IID? Are you in contact with the author of the object such that you can ask why that is the case? Cheers, Mark > > The curious thing is that all these structures *do* appear in the > pythonwin COM browser. Also I'm not sure if it helps narrows things > down, but I've used this library via C# and it seemed to work okay, > but I don't know if .Net handles COM marshalling differently... > > > Not much help, but it might edge us towards the answer... > > Well, any help is very much appreciated! Thanks for your time - if > there's anything else I can send to help track this down, let me know. > > Thanks! > > Simon From bbbscarter at gmail.com Wed Apr 22 12:54:17 2009 From: bbbscarter at gmail.com (Simon Carter) Date: Wed, 22 Apr 2009 11:54:17 +0100 Subject: [python-win32] COM and retrieving records/structures In-Reply-To: <001c01c9c332$56a9cec0$03fd6c40$@com.au> References: <49EE9B54.8080000@gmail.com> <001c01c9c332$56a9cec0$03fd6c40$@com.au> Message-ID: >> RecordMap = { >> ? ? ? u'XBOX_AUTOMATION_GAMEPAD': '{00000000-0000-0000-0000- >> 000000000000}', >> } > > I suspect the fact these objects are using a NULL IID is the cause of this > problem. ?Does the COM browser also reflect this IID? ?Are you in contact > with the author of the object such that you can ask why that is the case? > > Cheers, > Hmm, I can't get any information out of any record types in the pythonwin COM browser, for any library I've tried. All the other types can be explored, but not records. For example, the "Visual Studio 8.0 Deployment Plugins Type Library" has entries like 'tagARRAYDESC - Record' which don't do anything when clicked on. Should I be getting the IID some other way? If I generate an interface file for such a library, there's a one line entry for the RecordMap which has a null IID, in the same way as the library I'm having problems with. I don't know if it's related, but every library that *has* these records has a load of entries "The type info can not be loaded" at the top. Most libraries that don't have these records don't have these entries. On a whim I've just tried this on 32 bit vista and on XP, with the same results. Ta! Simon From belasalwa at yahoo.fr Thu Apr 23 12:56:24 2009 From: belasalwa at yahoo.fr (belaqziz salwa) Date: Thu, 23 Apr 2009 10:56:24 +0000 (GMT) Subject: [python-win32] activate an opened window Message-ID: <653514.76292.qm@web26001.mail.ukl.yahoo.com> Hi, how I can activate a window that is already opened, through its PID of process thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Apr 23 19:22:04 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 23 Apr 2009 10:22:04 -0700 Subject: [python-win32] activate an opened window In-Reply-To: <653514.76292.qm@web26001.mail.ukl.yahoo.com> References: <653514.76292.qm@web26001.mail.ukl.yahoo.com> Message-ID: <49F0A3BC.30804@probo.com> belaqziz salwa wrote: > > how I can activate a window that is already opened, through its PID of > process > Are you saying you have the PID of a process, and you want to bring its window to the top? I don't know of any shortcut way to do that, but you could certainly enumerate through all of the top-level windows using EnumWindows, then call GetWindowThreadProcessId until you find a window that matches. Remember that an application can have several top-level windows. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From belasalwa at yahoo.fr Thu Apr 23 19:47:17 2009 From: belasalwa at yahoo.fr (belaqziz salwa) Date: Thu, 23 Apr 2009 17:47:17 +0000 (GMT) Subject: [python-win32] activate an opened window Message-ID: <860508.73464.qm@web26008.mail.ukl.yahoo.com> it works with findTopWindow and _windowEnumerationHandler but only through the Command Prompt and I can not access it through my server by launching a URL Thanks ? --- En date de?: Jeu 23.4.09, Tim Roberts a ?crit?: De: Tim Roberts Objet: Re: [python-win32] activate an opened window ?: "Python-Win32 List" Date: Jeudi 23 Avril 2009, 18h22 belaqziz salwa wrote: > > how I can activate a window that is already opened, through its PID of > process > Are you saying you have the PID of a process, and you want to bring its window to the top? I don't know of any shortcut way to do that, but you could certainly enumerate through all of the top-level windows using EnumWindows, then call GetWindowThreadProcessId until you find a window that matches. Remember that an application can have several top-level windows. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Apr 23 22:35:57 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 23 Apr 2009 13:35:57 -0700 Subject: [python-win32] activate an opened window In-Reply-To: <860508.73464.qm@web26008.mail.ukl.yahoo.com> References: <860508.73464.qm@web26008.mail.ukl.yahoo.com> Message-ID: <49F0D12D.8020504@probo.com> belaqziz salwa wrote: > it works with findTopWindow and _windowEnumerationHandler but only > through the Command Prompt and I can not access it through my server > by launching a URL > I have no idea what that means. How is a URL involved? Perhaps you should describe exactly what you are trying to do, in detail. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From belasalwa at yahoo.fr Thu Apr 23 23:45:28 2009 From: belasalwa at yahoo.fr (belaqziz salwa) Date: Thu, 23 Apr 2009 21:45:28 +0000 (GMT) Subject: [python-win32] activate an opened window through the server Message-ID: <938870.73782.qm@web26002.mail.ukl.yahoo.com> I try to run a program in an interface that is already opened, all works well through the Command Prompt but when I run my python script in the server e.g http://localhost/MyScript.py it gives me the following message: pywintypes.error: (0, 'EnumWindows', 'No error message is available') thanks for help --- En date de?: Jeu 23.4.09, Tim Roberts a ?crit?: De: Tim Roberts Objet: Re: [python-win32] activate an opened window ?: "Python-Win32 List" Date: Jeudi 23 Avril 2009, 21h35 belaqziz salwa wrote: > it works with findTopWindow and _windowEnumerationHandler but only > through the Command Prompt and I can not access it through my server > by launching a URL > I have no idea what that means.? How is a URL involved? Perhaps you should describe exactly what you are trying to do, in detail. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Apr 23 23:59:55 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 23 Apr 2009 14:59:55 -0700 Subject: [python-win32] activate an opened window through the server In-Reply-To: <938870.73782.qm@web26002.mail.ukl.yahoo.com> References: <938870.73782.qm@web26002.mail.ukl.yahoo.com> Message-ID: <49F0E4DB.9030207@probo.com> belaqziz salwa wrote: > I try to run a program in an interface that is already opened, all > works well through the Command Prompt but when I run my python script > in the server e.g http://localhost/MyScript.py it gives me the > following message: > pywintypes.error: (0, 'EnumWindows', 'No error message is available') > > Are you trying to run this as a CGI script through IIS? CGI scripts run in a very different and very restricted environment. They cannot access the list of windows. It's just not possible. Why do you want to run this through a web server? What is your overall plan here? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From belasalwa at yahoo.fr Fri Apr 24 00:37:23 2009 From: belasalwa at yahoo.fr (belaqziz salwa) Date: Thu, 23 Apr 2009 22:37:23 +0000 (GMT) Subject: [python-win32] activate an opened window through the server Message-ID: <312989.28081.qm@web26007.mail.ukl.yahoo.com> I want, through a python script, to run a program that is written in another language (IDL: Interactive Data Language), I tried to execute a .bat file where I put my command which runs the program but I get the error message: permission denied, then I thought to another method with python-win32 but it is not possible is there a solution ?? thanks for help ? --- En date de?: Jeu 23.4.09, Tim Roberts a ?crit?: De: Tim Roberts Objet: Re: [python-win32] activate an opened window through the server ?: "Python-Win32 List" Date: Jeudi 23 Avril 2009, 22h59 belaqziz salwa wrote: > I try to run a program in an interface that is already opened, all > works well through the Command Prompt but when I run my python script > in the server e.g http://localhost/MyScript.py it gives me the > following message: > pywintypes.error: (0, 'EnumWindows', 'No error message is available') >? ? ? ??? > Are you trying to run this as a CGI script through IIS?? CGI scripts run in a very different and very restricted environment.? They cannot access the list of windows.? It's just not possible. Why do you want to run this through a web server?? What is your overall plan here? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Apr 24 00:54:21 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 23 Apr 2009 15:54:21 -0700 Subject: [python-win32] activate an opened window through the server In-Reply-To: <312989.28081.qm@web26007.mail.ukl.yahoo.com> References: <312989.28081.qm@web26007.mail.ukl.yahoo.com> Message-ID: <49F0F19D.6040301@probo.com> belaqziz salwa wrote: > I want, through a python script, to run a program that is written in > another language (IDL: Interactive Data Language), I tried to execute > a .bat file where I put my command which runs the program but I get > the error message: permission denied, then I thought to another method > with python-win32 but it is not possible > > is there a solution ?? > Well, you can run an IDL file from a command line by saying something like idlde.exe @commands and then putting the IDL commands in commands.pro, like this: . RUN mycode I still don't understand how this all relates to a web server. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From belasalwa at yahoo.fr Fri Apr 24 01:58:46 2009 From: belasalwa at yahoo.fr (belaqziz salwa) Date: Thu, 23 Apr 2009 23:58:46 +0000 (GMT) Subject: [python-win32] activate an opened window through the server Message-ID: <510020.58519.qm@web26002.mail.ukl.yahoo.com> I work on a PyWPS project and I need to run an IDL program , after the user completed a form, if I create a program .pro with the command that launches my program, like this idlde.exe -minimized -nodemowarn -noconfirmexit -nosplash @"C:\SAMIR\soil.run" how can I run it through my server? thanks for help. --- En date de?: Jeu 23.4.09, Tim Roberts a ?crit?: De: Tim Roberts Objet: Re: [python-win32] activate an opened window through the server ?: "Python-Win32 List" Date: Jeudi 23 Avril 2009, 23h54 belaqziz salwa wrote: > I want, through a python script, to run a program that is written in > another language (IDL: Interactive Data Language), I tried to execute > a .bat file where I put my command which runs the program but I get > the error message: permission denied, then I thought to another method > with python-win32 but it is not possible > > is there a solution ?? > Well, you can run an IDL file from a command line by saying something like ? ? idlde.exe @commands and then putting the IDL commands in commands.pro, like this: ? ? . RUN mycode I still don't understand how this all relates to a web server. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Apr 24 02:09:25 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 23 Apr 2009 17:09:25 -0700 Subject: [python-win32] activate an opened window through the server In-Reply-To: <510020.58519.qm@web26002.mail.ukl.yahoo.com> References: <510020.58519.qm@web26002.mail.ukl.yahoo.com> Message-ID: <49F10335.7060708@probo.com> belaqziz salwa wrote: > I work on a PyWPS project and I need to run an IDL program , after the > user completed a form, > if I create a program .pro with the command that launches my program, > like this > > idlde.exe -minimized -nodemowarn -noconfirmexit -nosplash > @"C:\SAMIR\soil.run" > > how can I run it through my server? > PyWPS ships HTML data, just like a web server. If your IDL script only produces output in a window, then there is no way to do it. But if your IDL script produces an image file, then I think you could grab that file and send it back as an HTML image. It would take a lot of experimentation, but it might be possible. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From belasalwa at yahoo.fr Fri Apr 24 02:22:38 2009 From: belasalwa at yahoo.fr (belaqziz salwa) Date: Fri, 24 Apr 2009 00:22:38 +0000 (GMT) Subject: [python-win32] activate an opened window through the server Message-ID: <690733.51104.qm@web26003.mail.ukl.yahoo.com> yes my IDL script produces an image file, i want just execute this progmam, and not to send an HTML image. how can i do that ? thanks for help. ? --- En date de?: Ven 24.4.09, Tim Roberts a ?crit?: De: Tim Roberts Objet: Re: [python-win32] activate an opened window through the server ?: "Python-Win32 List" Date: Vendredi 24 Avril 2009, 1h09 belaqziz salwa wrote: > I work on a PyWPS project and I need to run an IDL program , after the > user completed a form, > if I create a program .pro with the command that launches my program, > like this > > idlde.exe -minimized -nodemowarn -noconfirmexit -nosplash > @"C:\SAMIR\soil.run" > > how can I run it through my server? > PyWPS ships HTML data, just like a web server.? If your IDL script only produces output in a window, then there is no way to do it.? But if your IDL script produces an image file, then I think you could grab that file and send it back as an HTML image.? It would take a lot of experimentation, but it might be possible. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Apr 24 02:34:14 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 23 Apr 2009 17:34:14 -0700 Subject: [python-win32] activate an opened window through the server In-Reply-To: <690733.51104.qm@web26003.mail.ukl.yahoo.com> References: <690733.51104.qm@web26003.mail.ukl.yahoo.com> Message-ID: <49F10906.5050105@probo.com> belaqziz salwa wrote: > yes my IDL script produces an image file, i want just execute this > progmam, and not to send an HTML image. how can i do that ? > You'll have to dig into PyWPS for the details, but I think your PyWPS script just needs to run idlde.exe as a separate process, using that command you already showed. You can use subprocess.call to run that command and wait for the result. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From belasalwa at yahoo.fr Fri Apr 24 11:37:48 2009 From: belasalwa at yahoo.fr (belaqziz salwa) Date: Fri, 24 Apr 2009 09:37:48 +0000 (GMT) Subject: [python-win32] activate an opened window through the server Message-ID: <119508.53581.qm@web26002.mail.ukl.yahoo.com> I used subprocess.call but I had the following message: Could not import process : (-2147217405, 'OLE error 0x80041003', None, None) ??? ??? I added this code to my process: cmd = 'idlde.exe -minimized -nodemowarn -noconfirmexit -nosplash @C:\SAMIR\soil.run' retval = subprocess.call(cmd, 0, None, None) And I run it with: http://localhost/wps/wps.py?version=1.0.0&service=Wps&request=Execute&Identifier=soil_process but it does not works thanks for help --- En date de?: Ven 24.4.09, Tim Roberts a ?crit?: De: Tim Roberts Objet: Re: [python-win32] activate an opened window through the server ?: "python-win32" Date: Vendredi 24 Avril 2009, 1h34 belaqziz salwa wrote: > yes my IDL script produces an image file, i want just execute this > progmam, and not to send an HTML image. how can i do that ? > You'll have to dig into PyWPS for the details, but I think your PyWPS script just needs to run idlde.exe as a separate process, using that command you already showed.? You can use subprocess.call to run that command and wait for the result. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From neisen at linbox.com Fri Apr 24 16:56:55 2009 From: neisen at linbox.com (EISEN Nicolas) Date: Fri, 24 Apr 2009 16:56:55 +0200 Subject: [python-win32] Extract icon from exe files In-Reply-To: <49ED0732.6050608@probo.com> References: <49EC8D1A.9000909@linbox.com> <49ED0732.6050608@probo.com> Message-ID: <49F1D337.8070303@linbox.com> Tim Roberts wrote: > EISEN Nicolas wrote: > >> Hi, >> >> After search, I found many function to get Handler from exe (or dll) >> file icons . But I don?t understand how use the Handler ? >> >> For example: >> >> />>> Import win32gui >> >>>>> i= win32gui.ExtractIcon(0,'e:\\dxdiag.exe',0) >>>>> icon = win32gui.LoadIcon ( i , 0)/ >>>>> >> Or with ExtractIconEx to get a list of all icons, I?m always with many >> Handlers without knowing how to save or write it in file. >> >> The finality is to extract the exe file icon, and next, save the >> picture on the disk. >> > > Why do you want to do this? Icons are intellectual property. Unless > it's an open source app, you can't just scrape a bunch of icons from > existing applications and gather them into a library. It's not legal. > > Having said that, a few minutes with Google and MSDN would have answered > this question. LoadIcon returns an HICON. You can pass that to > GetIconInfo to return an ICONINFO structure, which includes the two > bitmaps that you need to draw an icon. An icon always includes two > bitmaps: one is a monochrome bitmap that digs the hole for the color > image, and the other is the color image. Those are HBITMAP handles. > You can then use GetBitmapBits to get the actual pixels. > > It's possible this might be easier in C. > > Thanks you I understand I will use these functions, but my problem is to found how? I have difficulties to understand how use the arguments : I try some combinations and it's doesn't work. Two big problems: 1 ? When I read MSDN?s API for LoadIcon, How I designed which exe Files I will use ? The first argument is ?handle to an instance of the module whose executable file contains the icon to be loaded?: How I can instantiate the handle, I didn?t found any constructor. I think the second argument will be: win32con.|IDI_APPLICATION| 2 ? My current script: > >> import win32gui,win32con hicon = LoadIcon(0, win32con.IDI_APPLICATION) inconinfo = GetIconInfo(hicon) But my last problem is I didn?t found the python module for GetBitmapBits() function ... Again, Thanks you for help me From Manuel.Baehr at comsoft.aero Fri Apr 24 16:58:49 2009 From: Manuel.Baehr at comsoft.aero (Baehr, Manuel) Date: Fri, 24 Apr 2009 16:58:49 +0200 Subject: [python-win32] Formatting parts of an excel cell Message-ID: <737A64DEB003704788E5CE515ED146054B6D4A@CSMAIL.comsoft.de> Hi all, I want to format parts of a cell, i.e. change the color of some characters of the cell's content. Does anyone know how to do that? Thanks a lot, Manuel From timr at probo.com Fri Apr 24 18:19:10 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 24 Apr 2009 09:19:10 -0700 Subject: [python-win32] activate an opened window through the server In-Reply-To: <119508.53581.qm@web26002.mail.ukl.yahoo.com> References: <119508.53581.qm@web26002.mail.ukl.yahoo.com> Message-ID: <49F1E67E.7090007@probo.com> belaqziz salwa wrote: > I used subprocess.call but I had the following message: > > Could not import process : (-2147217405, 'OLE error 0x80041003', None, > None) > > ** I added this code to my process: > > cmd = 'idlde.exe -minimized -nodemowarn -noconfirmexit -nosplash > @C:\SAMIR\soil.run' > retval = subprocess.call(cmd, 0, None, None) > That looks like almost the right code, but 80041003 is "WBEM_E_ACCESS_DENIED". If "idlde.exe" is a GUI app that opens a window, it may be that there is simply no way to do this from a CGI process. I said "almost" because you have a backslash problem there. You either need to double the backslashes: cmd = 'idlede.exe ... -nosplash @C:\\SAMIR\\soil.run' or use the "r" syntax: cmd = r'idlede.exe ... @C:\SAMIR\soil.run' -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Apr 24 19:00:37 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 24 Apr 2009 10:00:37 -0700 Subject: [python-win32] Extract icon from exe files In-Reply-To: <49F1D337.8070303@linbox.com> References: <49EC8D1A.9000909@linbox.com> <49ED0732.6050608@probo.com> <49F1D337.8070303@linbox.com> Message-ID: <49F1F035.3020308@probo.com> EISEN Nicolas wrote: > > I understand I will use these functions, but my problem is to found > how? I have difficulties to understand how use the arguments : I try > some combinations and it's doesn't work. > > Two big problems: > > 1 ? When I read MSDN?s API for LoadIcon, How I designed which exe > Files I will use ? The first argument is ?handle to an instance of the > module whose executable file contains the icon to be loaded?: How I > can instantiate the handle, I didn?t found any constructor. > > I think the second argument will be: win32con.|IDI_APPLICATION| I believe you actually want ExtractIcon, not LoadIcon. LoadIcon is mostly used by an EXE or DLL that needs to fetch its own icons. ExtractIcon lets you specify the name of another executable. You could use LoadLibrary to load the executable, then pass that handle to LoadIcon, but that's probably not the best way. > But my last problem is I didn?t found the python module for > GetBitmapBits() function ... How much looking have you done? Did you know that the PyWin32 win32\Demos directory contains several example of programs that manipulate icons, including one that calls ExtractIconEx and draws the icon to a bitmap? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Manuel.Baehr at comsoft.aero Sat Apr 25 09:28:27 2009 From: Manuel.Baehr at comsoft.aero (Baehr, Manuel) Date: Sat, 25 Apr 2009 09:28:27 +0200 Subject: [python-win32] Formatting parts of an excel cell References: <737A64DEB003704788E5CE515ED146054B6D4A@CSMAIL.comsoft.de> <49F1E419.7010800@lexicon.net> Message-ID: <737A64DEB003704788E5CE515ED146054B6D5A@CSMAIL.comsoft.de> Hi John, > Check out the thread "Multiple formats in a cell" in this > group around 2009-03-06. thanks for the link! However, I can't use xlwt (and xlrd) because I have to modify an existing excel sheet containing macros. Therefore I used the "win32com" module in python under Windows. This works pretty fine except for my original problem. Any idea how to do it using win32com? So far I only know how to set properties of an entire cell. cell.Font.ColorIndex = 6 But as I said, I would like to do it for parts of the text of the cell content. Cheers, Manuel From metolone+gmane at gmail.com Sat Apr 25 15:00:47 2009 From: metolone+gmane at gmail.com (Mark Tolonen) Date: Sat, 25 Apr 2009 06:00:47 -0700 Subject: [python-win32] Formatting parts of an excel cell References: <737A64DEB003704788E5CE515ED146054B6D4A@CSMAIL.comsoft.de><49F1E419.7010800@lexicon.net> <737A64DEB003704788E5CE515ED146054B6D5A@CSMAIL.comsoft.de> Message-ID: "Baehr, Manuel" wrote in message news:737A64DEB003704788E5CE515ED146054B6D5A at CSMAIL.comsoft.de... > Hi John, > >> Check out the thread "Multiple formats in a cell" in this >> group around 2009-03-06. > > thanks for the link! However, I can't use xlwt (and xlrd) because I have > to modify an existing excel sheet containing macros. Therefore I used > the "win32com" module in python under Windows. This works pretty fine > except for my original problem. > > Any idea how to do it using win32com? So far I only know how to set > properties of an entire cell. > > cell.Font.ColorIndex = 6 > > But as I said, I would like to do it for parts of the text of the cell > content. > > Cheers, > Manuel I recorded an Excel macro to color parts of a cell to find the correct syntax. This should work, but I get an error: >>> xl.ActiveCell.Characters(1,5).ColorIndex Traceback (most recent call last): File "", line 1, in AttributeError: Characters instance has no __call__ method The Excel documentation says Characters is a method that should support Start and Length parameters. Anybody know how to call this correctly? -Mark From andrea.gavana at gmail.com Sat Apr 25 15:28:21 2009 From: andrea.gavana at gmail.com (Andrea Gavana) Date: Sat, 25 Apr 2009 14:28:21 +0100 Subject: [python-win32] Formatting parts of an excel cell In-Reply-To: References: <737A64DEB003704788E5CE515ED146054B6D4A@CSMAIL.comsoft.de> <49F1E419.7010800@lexicon.net> <737A64DEB003704788E5CE515ED146054B6D5A@CSMAIL.comsoft.de> Message-ID: ---------- Forwarded message ---------- From: Andrea Gavana Date: Sat, Apr 25, 2009 at 2:28 PM Subject: Re: [python-win32] Formatting parts of an excel cell To: Mark Tolonen Hi, On Sat, Apr 25, 2009 at 2:00 PM, Mark Tolonen wrote: > > "Baehr, Manuel" wrote in message > news:737A64DEB003704788E5CE515ED146054B6D5A at CSMAIL.comsoft.de... >> >> Hi John, >> >>> Check out the thread "Multiple formats in a cell" in this >>> group around 2009-03-06. >> >> thanks for the link! However, I can't use xlwt (and xlrd) because I have >> to modify an existing excel sheet containing macros. Therefore I used >> the "win32com" module in python under Windows. This works pretty fine >> except for my original problem. >> >> Any idea how to do it using win32com? So far I only know how to set >> properties of an entire cell. >> >> cell.Font.ColorIndex = 6 >> >> But as I said, I would like to do it for parts of the text of the cell >> content. >> >> Cheers, >> Manuel > > I recorded an Excel macro to color parts of a cell to find the correct > syntax. ?This should work, but I get an error: > >>>> xl.ActiveCell.Characters(1,5).ColorIndex > > Traceback (most recent call last): > ?File "", line 1, in > AttributeError: Characters instance has no __call__ method > > The Excel documentation says Characters is a method that should support > Start and Length parameters. > > Anybody know how to call this correctly? You may try to use the FlagAsMethod method like this: from win32com.client.dynamic import DumbDispatch yourCell.Select() s = DumbDispatch(self.xlsapp.Selection) s._FlagAsMethod('Characters') s.Characters(1,5).ColorIndex = whatever Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.alice.it/infinity77/ -- Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.alice.it/infinity77/ From metolone+gmane at gmail.com Sat Apr 25 16:26:02 2009 From: metolone+gmane at gmail.com (Mark Tolonen) Date: Sat, 25 Apr 2009 07:26:02 -0700 Subject: [python-win32] Formatting parts of an excel cell References: <737A64DEB003704788E5CE515ED146054B6D4A@CSMAIL.comsoft.de><49F1E419.7010800@lexicon.net><737A64DEB003704788E5CE515ED146054B6D5A@CSMAIL.comsoft.de> Message-ID: "Andrea Gavana" wrote in message news:d5ff27200904250628g433ae546xb0b683b1f32f42f9 at mail.gmail.com... > On Sat, Apr 25, 2009 at 2:00 PM, Mark Tolonen wrote: > > > > "Baehr, Manuel" wrote in message > > news:737A64DEB003704788E5CE515ED146054B6D5A at CSMAIL.comsoft.de... > >> > >> Hi John, > >> > >>> Check out the thread "Multiple formats in a cell" in this > >>> group around 2009-03-06. > >> > >> thanks for the link! However, I can't use xlwt (and xlrd) because I > >> have > >> to modify an existing excel sheet containing macros. Therefore I used > >> the "win32com" module in python under Windows. This works pretty fine > >> except for my original problem. > >> > >> Any idea how to do it using win32com? So far I only know how to set > >> properties of an entire cell. > >> > >> cell.Font.ColorIndex = 6 > >> > >> But as I said, I would like to do it for parts of the text of the cell > >> content. > >> > >> Cheers, > >> Manuel > > > > I recorded an Excel macro to color parts of a cell to find the correct > > syntax. This should work, but I get an error: > > > >>>> xl.ActiveCell.Characters(1,5).ColorIndex > > > > Traceback (most recent call last): > > File "", line 1, in > > AttributeError: Characters instance has no __call__ method > > > > The Excel documentation says Characters is a method that should support > > Start and Length parameters. > > > > Anybody know how to call this correctly? > > You may try to use the FlagAsMethod method like this: > > from win32com.client.dynamic import DumbDispatch > > yourCell.Select() > > s = DumbDispatch(self.xlsapp.Selection) > s._FlagAsMethod('Characters') > s.Characters(1,5).ColorIndex = whatever I got an error with that as well, but I figured out the correct way: import win32com.client xl = win32com.client.gencache.EnsureDispatch('Excel.Application') xl.Visible = True xl.Workbooks.Add() c = xl.ActiveCell c.FormulaR1C1 = 'Hello World' c.GetCharacters(1,5).Font.ColorIndex = 3 c.GetCharacters(7,5).Font.ColorIndex = 4 Characters is a "property that takes parameters", not a method, so it is treated differently. -Mark From Manuel.Baehr at comsoft.aero Sun Apr 26 13:10:51 2009 From: Manuel.Baehr at comsoft.aero (Baehr, Manuel) Date: Sun, 26 Apr 2009 13:10:51 +0200 Subject: [python-win32] Formatting parts of an excel cell References: <737A64DEB003704788E5CE515ED146054B6D4A@CSMAIL.comsoft.de><49F1E419.7010800@lexicon.net><737A64DEB003704788E5CE515ED146054B6D5A@CSMAIL.comsoft.de> Message-ID: <737A64DEB003704788E5CE515ED146054B6D5E@CSMAIL.comsoft.de> Hi Mark, > I got an error with that as well, but I figured out the correct way: > > import win32com.client > xl = win32com.client.gencache.EnsureDispatch('Excel.Application') > xl.Visible = True > xl.Workbooks.Add() > c = xl.ActiveCell > c.FormulaR1C1 = 'Hello World' > c.GetCharacters(1,5).Font.ColorIndex = 3 > c.GetCharacters(7,5).Font.ColorIndex = 4 thanks for your answer, works like a charm! I tried the macro-way as well but stopped because that didn't work. How/where did you find out the correct way to use this feature (GetCharacters instead of Characters)? This answer may prevent me from asking further questions of this kind ;-) Cheers, Manuel From greg.ewing at canterbury.ac.nz Sun Apr 26 11:21:14 2009 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sun, 26 Apr 2009 21:21:14 +1200 Subject: [python-win32] ANN: PyGUI 2.0.5 Message-ID: <49F4278A.7010402@canterbury.ac.nz> PyGUI 2.0.5 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ More bug fixes for various platforms. Still no idea what's causing the "object has been destroyed" error on Windows XP, though. Does this happen for everyone? Is there anyone who *has* got 12-scroll.py working for them on XP? What is PyGUI? -------------- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. -- Gregory Ewing greg.ewing at canterbury.ac.nz http://www.cosc.canterbury.ac.nz/greg.ewing/ From randy at rcs-comp.com Sun Apr 26 23:24:30 2009 From: randy at rcs-comp.com (Randy Syring) Date: Sun, 26 Apr 2009 17:24:30 -0400 Subject: [python-win32] ANN: PyGUI 2.0.5 In-Reply-To: <49F4278A.7010402@canterbury.ac.nz> References: <49F4278A.7010402@canterbury.ac.nz> Message-ID: <2d07a6f90904261424g77872ff6kf798e784f5f1f8bd@mail.gmail.com> Greg, Could you tell me briefly how this project differs from something like wxPython? Thanks. -- -------------------------------------- Randy Syring RCS Computers & Web Solutions 502-644-4776 http://www.rcs-comp.com "Whether, then, you eat or drink or whatever you do, do all to the glory of God." 1 Cor 10:31 On Sun, Apr 26, 2009 at 5:21 AM, Greg Ewing wrote: > PyGUI 2.0.5 is available: > > http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ > > More bug fixes for various platforms. > > Still no idea what's causing the "object has been destroyed" > error on Windows XP, though. Does this happen for everyone? > Is there anyone who *has* got 12-scroll.py working for them > on XP? > > > What is PyGUI? > -------------- > > PyGUI is a cross-platform GUI toolkit designed to be lightweight > and have a highly Pythonic API. > > -- > Gregory Ewing > greg.ewing at canterbury.ac.nz > http://www.cosc.canterbury.ac.nz/greg.ewing/ > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From randy at rcs-comp.com Mon Apr 27 00:10:31 2009 From: randy at rcs-comp.com (Randy Syring) Date: Sun, 26 Apr 2009 18:10:31 -0400 Subject: [python-win32] ANN: PyGUI 2.0.5 In-Reply-To: <49F4278A.7010402@canterbury.ac.nz> References: <49F4278A.7010402@canterbury.ac.nz> Message-ID: <2d07a6f90904261510yd821f8aifc392e55674faae2@mail.gmail.com> Greg, I have tested 12-scroll.py on both Vista Professional and Windows XP Pro SP3 both with Python 2.5.4 and pywin build 213. Said test fails with the "the object has been destroyed" exception. -- -------------------------------------- Randy Syring RCS Computers & Web Solutions 502-644-4776 http://www.rcs-comp.com "Whether, then, you eat or drink or whatever you do, do all to the glory of God." 1 Cor 10:31 On Sun, Apr 26, 2009 at 5:21 AM, Greg Ewing wrote: > PyGUI 2.0.5 is available: > > http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ > > More bug fixes for various platforms. > > Still no idea what's causing the "object has been destroyed" > error on Windows XP, though. Does this happen for everyone? > Is there anyone who *has* got 12-scroll.py working for them > on XP? > > > What is PyGUI? > -------------- > > PyGUI is a cross-platform GUI toolkit designed to be lightweight > and have a highly Pythonic API. > > -- > Gregory Ewing > greg.ewing at canterbury.ac.nz > http://www.cosc.canterbury.ac.nz/greg.ewing/ > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From randy at rcs-comp.com Mon Apr 27 00:16:26 2009 From: randy at rcs-comp.com (Randy Syring) Date: Sun, 26 Apr 2009 18:16:26 -0400 Subject: [python-win32] ANN: PyGUI 2.0.5 In-Reply-To: <2d07a6f90904261510yd821f8aifc392e55674faae2@mail.gmail.com> References: <49F4278A.7010402@canterbury.ac.nz> <2d07a6f90904261510yd821f8aifc392e55674faae2@mail.gmail.com> Message-ID: <2d07a6f90904261516v37ee0e49r4c4d703ba575e79c@mail.gmail.com> Greg, I have done some testing and reverting to pywin build 212 allows the demo to run without the previously seen exception. -- -------------------------------------- Randy Syring RCS Computers & Web Solutions 502-644-4776 http://www.rcs-comp.com "Whether, then, you eat or drink or whatever you do, do all to the glory of God." 1 Cor 10:31 On Sun, Apr 26, 2009 at 6:10 PM, Randy Syring wrote: > Greg, > > I have tested 12-scroll.py on both Vista Professional and Windows XP Pro > SP3 both with Python 2.5.4 and pywin build 213. Said test fails with the > "the object has been destroyed" exception. > > -- > -------------------------------------- > Randy Syring > RCS Computers & Web Solutions > 502-644-4776 > http://www.rcs-comp.com > > "Whether, then, you eat or drink or whatever you do, do all to the glory of > God." 1 Cor 10:31 > > > On Sun, Apr 26, 2009 at 5:21 AM, Greg Ewing wrote: > >> PyGUI 2.0.5 is available: >> >> http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ >> >> More bug fixes for various platforms. >> >> Still no idea what's causing the "object has been destroyed" >> error on Windows XP, though. Does this happen for everyone? >> Is there anyone who *has* got 12-scroll.py working for them >> on XP? >> >> >> What is PyGUI? >> -------------- >> >> PyGUI is a cross-platform GUI toolkit designed to be lightweight >> and have a highly Pythonic API. >> >> -- >> Gregory Ewing >> greg.ewing at canterbury.ac.nz >> http://www.cosc.canterbury.ac.nz/greg.ewing/ >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.ewing at canterbury.ac.nz Mon Apr 27 03:25:58 2009 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Mon, 27 Apr 2009 13:25:58 +1200 Subject: [python-win32] ANN: PyGUI 2.0.5 In-Reply-To: <2d07a6f90904261424g77872ff6kf798e784f5f1f8bd@mail.gmail.com> References: <49F4278A.7010402@canterbury.ac.nz> <2d07a6f90904261424g77872ff6kf798e784f5f1f8bd@mail.gmail.com> Message-ID: <49F509A6.5000405@canterbury.ac.nz> Randy Syring wrote: > Could you tell me briefly how this project differs from something like > wxPython? It wraps platform-specific libraries directly, rather than being a wrapper around another cross-platform library. This means less bloat and less dependencies. Chances are you already have the necessary libraries installed. The API is designed to be very straightforward and Pythonic, and it's fully documented in its own terms, so you don't have to consult the documentation for some other library in some other language and translate into Python. -- Greg From ckkart at hoc.net Mon Apr 27 07:59:02 2009 From: ckkart at hoc.net (Christian K.) Date: Mon, 27 Apr 2009 07:59:02 +0200 Subject: [python-win32] py2exe and com server again Message-ID: Hi, despite all the information on this list and on the wiki I can't get my com server up from the py2exe created dll. As it is a outlook com server I followed the approach taken in the spambayes project, i.e. in the addin I have: bValidateGencache = not hasattr(sys, "frozen") gencache.EnsureModule('{00062FFF-0000-0000-C000-000000000046}', 0, 9, 0, bForDemand=True, bValidateFile=bValidateGencache) # Outlook 9 gencache.EnsureModule('{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}', 0, 2, 1, bForDemand=True, bValidateFile=bValidateGencache) # Office 9 gencache.EnsureModule('{AC0714F2-3D04-11D1-AE7D-00A0C90F26F4}', 0, 1, 0, bForDemand=True, bValidateFile=bValidateGencache) universal.RegisterInterfaces('{AC0714F2-3D04-11D1-AE7D-00A0C90F26F4}', 0, 1, 0,["_IDTExtensibility2"]) and I added the typelib information to the py2exe options in the setup file: "typelibs": [('{00062FFF-0000-0000-C000-000000000046}', 0, 9, 1), ('{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}', 0, 2, 2), ('{AC0714F2-3D04-11D1-AE7D-00A0C90F26F4}', 0, 1, 0)] ] This works on my developer machine but on any other I get the following traceback: File "win32com\client\__init__.pyc", line 260, in DispatchWithEvents AttributeError: 'NoneType' object has no attribute 'CLSID' I also tried omitting the typelibs in setup.py, removed win32com\gen_py so that the typelib information would be generated in %temp% but still, anything runs on my machine but not on any other. Any hints are highly appreciated! Regards, Christian From metolone+gmane at gmail.com Mon Apr 27 17:06:17 2009 From: metolone+gmane at gmail.com (Mark Tolonen) Date: Mon, 27 Apr 2009 08:06:17 -0700 Subject: [python-win32] Formatting parts of an excel cell References: <737A64DEB003704788E5CE515ED146054B6D4A@CSMAIL.comsoft.de><49F1E419.7010800@lexicon.net><737A64DEB003704788E5CE515ED146054B6D5A@CSMAIL.comsoft.de> <737A64DEB003704788E5CE515ED146054B6D5E@CSMAIL.comsoft.de> Message-ID: "Baehr, Manuel" wrote in message news:737A64DEB003704788E5CE515ED146054B6D5E at CSMAIL.comsoft.de... > Hi Mark, > >> I got an error with that as well, but I figured out the correct way: >> >> import win32com.client >> xl = win32com.client.gencache.EnsureDispatch('Excel.Application') >> xl.Visible = True >> xl.Workbooks.Add() >> c = xl.ActiveCell >> c.FormulaR1C1 = 'Hello World' >> c.GetCharacters(1,5).Font.ColorIndex = 3 >> c.GetCharacters(7,5).Font.ColorIndex = 4 > > thanks for your answer, works like a charm! > > I tried the macro-way as well but stopped because that didn't work. > How/where did you find out the correct way to use this feature > (GetCharacters instead of Characters)? This answer may prevent me from > asking further questions of this kind ;-) > > Cheers, > Manuel I couldn't find where it was documented, although I recalling reading about it years ago and had forgotten about it. In this case I was using PythonWin as the editor, and with the EnsureDispatch call popup tooltips are enabled. Typing "c." listed the "GetCharacters" and "SetCharacters" methods, but I didn't notice it immediately. Too bad the convention wasn't "CharactersGet" and "CharactersSet" or I would have found it quicker in the sorted tooltip list :^) -Mark From iurisilvio at gmail.com Mon Apr 27 17:22:32 2009 From: iurisilvio at gmail.com (Iuri) Date: Mon, 27 Apr 2009 12:22:32 -0300 Subject: [python-win32] Error 500 on IIS Message-ID: <789aac5a0904270822j5fdc19dcwf9162c3b254bac49@mail.gmail.com> I installed Python + win32all and tried to run an ASP page (with Python language) on IIS. I got this error: "HTTP/1.1 500 Server Error". I tried to install on a Windows Vista and a Windows Server 2007. On Vista, I'm fixed removing the user ASP.NET and using "asp_iisreg -i" (it's a tip from MSDN). On Windows Server, Python/ASP files works in old paths, but I created a new app to put my *.py files and it didn't works. Anyone knows how to fix this problem? I tried to set permissions to IUSR and to _IUSRS to the new app, but didn't solve my problem. Searches on google return just very old topics, with this same problem in Win2k, but I installed in 2 computers and have the same problem. Thanks, Iuri -------------- next part -------------- An HTML attachment was scrubbed... URL: From neisen at linbox.com Mon Apr 27 17:40:48 2009 From: neisen at linbox.com (EISEN Nicolas) Date: Mon, 27 Apr 2009 17:40:48 +0200 Subject: [python-win32] Extract icon from exe files In-Reply-To: <49F1F035.3020308@probo.com> References: <49EC8D1A.9000909@linbox.com> <49ED0732.6050608@probo.com> <49F1D337.8070303@linbox.com> <49F1F035.3020308@probo.com> Message-ID: <49F5D200.3030704@linbox.com> Tim Roberts wrote: > EISEN Nicolas wrote: > >> I understand I will use these functions, but my problem is to found >> how? I have difficulties to understand how use the arguments : I try >> some combinations and it's doesn't work. >> >> Two big problems: >> >> 1 ? When I read MSDN?s API for LoadIcon, How I designed which exe >> Files I will use ? The first argument is ?handle to an instance of the >> module whose executable file contains the icon to be loaded?: How I >> can instantiate the handle, I didn?t found any constructor. >> >> I think the second argument will be: win32con.|IDI_APPLICATION| >> > > I believe you actually want ExtractIcon, not LoadIcon. LoadIcon is > mostly used by an EXE or DLL that needs to fetch its own icons. > ExtractIcon lets you specify the name of another executable. > > You could use LoadLibrary to load the executable, then pass that handle > to LoadIcon, but that's probably not the best way. > > > >> But my last problem is I didn?t found the python module for >> GetBitmapBits() function ... >> > > How much looking have you done? Did you know that the PyWin32 > win32\Demos directory contains several example of programs that > manipulate icons, including one that calls ExtractIconEx and draws the > icon to a bitmap? > > / from win32gui import * import win32con listHicon = ExtractIconEx("c:\OpenOffice.exe",0) test = LoadImage(listHicon[0],"c:\OpenOffice.exe",0,0,0,win32con.LR_DEFAULTSIZE) tupleIcon = GetIconInfo(test)/ To use GetIconInfo argument should be pyHandle. listHicon is array of Hicon. LoadImage return Handle, but the last argument must be an pyHandle (by the interpretor error) But normally is good by this API : http://docs.activestate.com/activepython/2.4/pywin32/win32gui.html I use LoadImage because LoadIcon is depreacted and it return an hicon. I doesn't have more idea ... Thanks. PS : the demo menu and taskbar use icon only to display it in another module, but i want get bitmapBit of icon to send it to an inventory server. From vernondcole at gmail.com Mon Apr 27 17:49:42 2009 From: vernondcole at gmail.com (Vernon Cole) Date: Mon, 27 Apr 2009 09:49:42 -0600 Subject: [python-win32] Iron Python integration. Message-ID: This is an opinion poll... The portion of pywin32 which I maintain, adodbapi, will work in either CPython or IronPython. That was (relatively) easy, since it is written in pure Python. Is there any interest in forking the pywin32 C code into C# so that the entire package can be run in a .NET environment using IronPython? -- Vernon Cole -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Mon Apr 27 18:37:28 2009 From: vernondcole at gmail.com (Vernon Cole) Date: Mon, 27 Apr 2009 10:37:28 -0600 Subject: [python-win32] Error 500 on IIS In-Reply-To: <789aac5a0904270822j5fdc19dcwf9162c3b254bac49@mail.gmail.com> References: <789aac5a0904270822j5fdc19dcwf9162c3b254bac49@mail.gmail.com> Message-ID: "win32all" is a very old name which is still hanging around in some documentation. The package is now referred to as "pywin32". http://sourceforge.net/projects/pywin32/ Which versions of Python and pywin32 are you using? -- Vernon Cole On Mon, Apr 27, 2009 at 9:22 AM, Iuri wrote: > I installed Python + win32all and tried to run an ASP page (with Python > language) on IIS. I got this error: "HTTP/1.1 500 Server Error". > I tried to install on a Windows Vista and a Windows Server 2007. On Vista, > I'm fixed removing the user ASP.NET and using "asp_iisreg -i" (it's a tip > from MSDN). On Windows Server, Python/ASP files works in old paths, but I > created a new app to put my *.py files and it didn't works. > > Anyone knows how to fix this problem? I tried to set permissions to IUSR > and to _IUSRS to the new app, but didn't solve my problem. > > Searches on google return just very old topics, with this same problem in > Win2k, but I installed in 2 computers and have the same problem. > > Thanks, > Iuri > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From iurisilvio at gmail.com Mon Apr 27 18:51:46 2009 From: iurisilvio at gmail.com (Iuri) Date: Mon, 27 Apr 2009 13:51:46 -0300 Subject: [python-win32] Error 500 on IIS In-Reply-To: References: <789aac5a0904270822j5fdc19dcwf9162c3b254bac49@mail.gmail.com> Message-ID: <789aac5a0904270951y5d21a22bkfc7d5198c9499df4@mail.gmail.com> Oh, sorry. I'm using pywin32-212.win32-py2.6.exe and Python 2.6. I did some tests. Calling a new object with Python Interpreter (Server.CreateObject("Python.Interpreter")), I got this error: Server object error 'ASP 0178 : 80070005' Server.CreateObject Access Error /teste.asp, line 3 The call to Server.CreateObject failed while checking permissions. Access is denied to this object. I don't know which permission I need to change. Iuri On Mon, Apr 27, 2009 at 1:37 PM, Vernon Cole wrote: > "win32all" is a very old name which is still hanging around in some > documentation. The package is now referred to as "pywin32". > http://sourceforge.net/projects/pywin32/ > > Which versions of Python and pywin32 are you using? > -- > Vernon Cole > > On Mon, Apr 27, 2009 at 9:22 AM, Iuri wrote: > >> I installed Python + win32all and tried to run an ASP page (with Python >> language) on IIS. I got this error: "HTTP/1.1 500 Server Error". >> I tried to install on a Windows Vista and a Windows Server 2007. On Vista, >> I'm fixed removing the user ASP.NET and using "asp_iisreg -i" (it's a tip >> from MSDN). On Windows Server, Python/ASP files works in old paths, but I >> created a new app to put my *.py files and it didn't works. >> >> Anyone knows how to fix this problem? I tried to set permissions to IUSR >> and to _IUSRS to the new app, but didn't solve my problem. >> >> Searches on google return just very old topics, with this same problem in >> Win2k, but I installed in 2 computers and have the same problem. >> >> Thanks, >> Iuri >> >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Apr 27 19:07:18 2009 From: timr at probo.com (Tim Roberts) Date: Mon, 27 Apr 2009 10:07:18 -0700 Subject: [python-win32] Extract icon from exe files In-Reply-To: <49F5D200.3030704@linbox.com> References: <49EC8D1A.9000909@linbox.com> <49ED0732.6050608@probo.com> <49F1D337.8070303@linbox.com> <49F1F035.3020308@probo.com> <49F5D200.3030704@linbox.com> Message-ID: <49F5E646.3060109@probo.com> EISEN Nicolas wrote: >> > / from win32gui import * > import win32con > > listHicon = ExtractIconEx("c:\OpenOffice.exe",0) > > test = > LoadImage(listHicon[0],"c:\OpenOffice.exe",0,0,0,win32con.LR_DEFAULTSIZE) > > tupleIcon = GetIconInfo(test)/ > > To use GetIconInfo argument should be pyHandle. listHicon is array of > Hicon. LoadImage return Handle, but the last argument must be an pyHandle > (by the interpretor error) import pywintypes ph = pywintypes.HANDLE( listHicon[0] ) Now you have a PyHANDLE. > PS : the demo menu and taskbar use icon only to display it in another > module, but i want get bitmapBit of icon to send it to an inventory > server. The demo fetches the icon and then uses BitBlt to draw it to a bitmap. Why is that not EXACTLY what you need? That saves you all the trouble of trying to extract the bitmaps from the icon and manipulate them in somewhat to get a usable image. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From neisen at linbox.com Tue Apr 28 11:18:46 2009 From: neisen at linbox.com (EISEN Nicolas) Date: Tue, 28 Apr 2009 11:18:46 +0200 Subject: [python-win32] Extract icon from exe files In-Reply-To: <49F5E646.3060109@probo.com> References: <49EC8D1A.9000909@linbox.com> <49ED0732.6050608@probo.com> <49F1D337.8070303@linbox.com> <49F1F035.3020308@probo.com> <49F5D200.3030704@linbox.com> <49F5E646.3060109@probo.com> Message-ID: <49F6C9F6.9090907@linbox.com> Tim Roberts wrote: > EISEN Nicolas wrote: > >>> >>> >> / from win32gui import * >> import win32con >> >> listHicon = ExtractIconEx("c:\OpenOffice.exe",0) >> >> test = >> LoadImage(listHicon[0],"c:\OpenOffice.exe",0,0,0,win32con.LR_DEFAULTSIZE) >> >> tupleIcon = GetIconInfo(test)/ >> >> To use GetIconInfo argument should be pyHandle. listHicon is array of >> Hicon. LoadImage return Handle, but the last argument must be an pyHandle >> (by the interpretor error) >> > > import pywintypes > ph = pywintypes.HANDLE( listHicon[0] ) > > Now you have a PyHANDLE. > > > >> PS : the demo menu and taskbar use icon only to display it in another >> module, but i want get bitmapBit of icon to send it to an inventory >> server. >> > > The demo fetches the icon and then uses BitBlt to draw it to a bitmap. > Why is that not EXACTLY what you need? That saves you all the trouble > of trying to extract the bitmaps from the icon and manipulate them in > somewhat to get a usable image. > > My Source : /from win32gui import * import win32con from pywintypes import HANDLE listHicon = ExtractIconEx("c:\OpenOffice.exe",0) tupleIcon = GetIconInfo (HANDLE ( listHicon[0][0] ) ) bitmapColor = tupel [4] buffer = PyCBitmap.GetBitmapBits ( bitmapColor, 32 ) / My last problem (I hope) is to found what to import to get PyCBitmap class. I found it's in win32ui module but /from win32ui import */ doesn't give me the PyCBitmap class. I want to get the picture of executable's icon, to re-use it on web site for example. I list all program on the pc, and I return some information. I want add program's icon. Thanks a lot. From costin.gament at gmail.com Tue Apr 28 11:29:45 2009 From: costin.gament at gmail.com (=?utf-8?B?Q29zdGluIEdhbWVuxaM=?=) Date: Tue, 28 Apr 2009 12:29:45 +0300 Subject: [python-win32] AutoCAD automation with COM. Message-ID: Hi, everybody! I'm trying to automate some tasks in AutoCAD (version 16.2 -- 2006) with Python and COM. Apparently there is a long standind bug with either win32com or AutoCAD: http://mail.python.org/pipermail/python-win32/2005-December/004075.html and I am having the same problem. Does anybody know a solution for this problem? I must specify that this is my first time doing anything COM-related (and, in fact, coding in windows). Thanks, Costin From theller at ctypes.org Tue Apr 28 14:04:05 2009 From: theller at ctypes.org (Thomas Heller) Date: Tue, 28 Apr 2009 14:04:05 +0200 Subject: [python-win32] AutoCAD automation with COM. In-Reply-To: References: Message-ID: Costin Gamen? schrieb: > Hi, everybody! > > I'm trying to automate some tasks in AutoCAD (version 16.2 -- 2006) with > Python and COM. Apparently there is a long standind bug with either > win32com or AutoCAD: > http://mail.python.org/pipermail/python-win32/2005-December/004075.html > and I am having the same problem. Does anybody know a solution for this > problem? > > I must specify that this is my first time doing anything COM-related (and, > in fact, coding in windows). You could try comtypes, it allows to specify the exact parameters that are passed as VARIANTs. There is even a sample snippet for autocad in the docs: http://starship.python.net/crew/theller/comtypes/ > > Thanks, > Costin Thomas From tehflash at gmail.com Tue Apr 28 15:52:51 2009 From: tehflash at gmail.com (Robert Robinson) Date: Tue, 28 Apr 2009 09:52:51 -0400 Subject: [python-win32] Python Service Won't Start, But Does Debug Message-ID: I'm new to using the win32 module and I've written a little service in python for myself. It runs fine and without errors when I use debug: >python myService.py debug Debugging service myService - press Ctrl+C to stop. This works and prints to a log file I set up just fine, so I know it's working properly However when I try using the start command on the same service It says it's started, but hasn't: >python myService.py start Starting service myService Then after any amount of time: >python myService.py stop Stopping service myService Error stopping service: The service has not been started. (1062) If I use a wait command: >python myService.py --wait=30 start Starting service myService Error starting service: The service did not respond to the start or control request in a timely fashion. I'm using python 2.5 and the win32module. My main class is a subclass of win32serviceutil.ServiceFramework with all the appropriate function overridden (__init__, SvcStop, SvcDoRun) the init function calls the init function of the ServiceFramework directly (not using super). When debugging it will continually run it's main loop and does everything in it I would expect, but seems to not to want to run when using start. Obviously no exceptions are thrown when I run it in debug mode. Any suggestions, or should I be posting more info? From neisen at linbox.com Tue Apr 28 17:08:28 2009 From: neisen at linbox.com (EISEN Nicolas) Date: Tue, 28 Apr 2009 17:08:28 +0200 Subject: [python-win32] Extract icon from exe files In-Reply-To: <49F5E646.3060109@probo.com> References: <49EC8D1A.9000909@linbox.com> <49ED0732.6050608@probo.com> <49F1D337.8070303@linbox.com> <49F1F035.3020308@probo.com> <49F5D200.3030704@linbox.com> <49F5E646.3060109@probo.com> Message-ID: <49F71BEC.4010608@linbox.com> Tim Roberts wrote: > EISEN Nicolas wrote: > >>> >>> >> / from win32gui import * >> import win32con >> >> listHicon = ExtractIconEx("c:\OpenOffice.exe",0) >> >> test = >> LoadImage(listHicon[0],"c:\OpenOffice.exe",0,0,0,win32con.LR_DEFAULTSIZE) >> >> tupleIcon = GetIconInfo(test)/ >> >> To use GetIconInfo argument should be pyHandle. listHicon is array of >> Hicon. LoadImage return Handle, but the last argument must be an pyHandle >> (by the interpretor error) >> > > import pywintypes > ph = pywintypes.HANDLE( listHicon[0] ) > > Now you have a PyHANDLE. > > > >> PS : the demo menu and taskbar use icon only to display it in another >> module, but i want get bitmapBit of icon to send it to an inventory >> server. >> > > The demo fetches the icon and then uses BitBlt to draw it to a bitmap. > Why is that not EXACTLY what you need? That saves you all the trouble > of trying to extract the bitmaps from the icon and manipulate them in > somewhat to get a usable image. > > I'm lucky, I found ... My Source : /from win32gui import * import win32con from pywintypes import HANDLE import win32ui listHicon = ExtractIconEx("c:\OpenOffice.exe",0) tupleIcon = GetIconInfo (HANDLE ( listHicon[0][0] ) ) bitmapColor = tupel [4] picture = win32ui.CreateBitmap() buffer = picture.GetBitmapBits ( bitmapColor ) / Python return : /win32ui.error: GetObject failed on bitmap/ for the last line win32ui have CreateBitmap with 0 argument and GetBitmapBits with 1 arguments but win32gui have CreateBitmap with 5 arguments and GetBitmapBits have 2 arguments With win32gui, the two last line will be : / picture = CreateBitmap(tupel[1],tupel[2],1, 256, None) buffer = picture.GetBitmapBits( bitmapColor, 32) / but picture will be an pyHANDLE and i can't use GetBitmapBits ... I need take Stringbit for write it on file to display on the website (bmp, jpeg, ...). On the demo, hicon is use ton create the variable nid and re use it to display on the screen, but i want get only the bitmap bits. Thanks From kxroberto at googlemail.com Tue Apr 28 18:41:10 2009 From: kxroberto at googlemail.com (Robert) Date: Tue, 28 Apr 2009 18:41:10 +0200 Subject: [python-win32] PythonWin IDE: how to assign a function/code to key F1 etc. ? Message-ID: want to put new functions (short python code) on keys like F1, F12, Ctrl-F1 and other keys. Is there a mechanism/recipe ? From timr at probo.com Tue Apr 28 19:17:37 2009 From: timr at probo.com (Tim Roberts) Date: Tue, 28 Apr 2009 10:17:37 -0700 Subject: [python-win32] Extract icon from exe files In-Reply-To: <49F71BEC.4010608@linbox.com> References: <49EC8D1A.9000909@linbox.com> <49ED0732.6050608@probo.com> <49F1D337.8070303@linbox.com> <49F1F035.3020308@probo.com> <49F5D200.3030704@linbox.com> <49F5E646.3060109@probo.com> <49F71BEC.4010608@linbox.com> Message-ID: <49F73A31.2050206@probo.com> EISEN Nicolas wrote: >> >> > I'm lucky, I found ... > > My Source : > > /from win32gui import * > import win32con > from pywintypes import HANDLE > import win32ui > listHicon = ExtractIconEx("c:\OpenOffice.exe",0) > tupleIcon = GetIconInfo (HANDLE ( listHicon[0][0] ) ) > > bitmapColor = tupel [4] > > picture = win32ui.CreateBitmap() > buffer = picture.GetBitmapBits ( bitmapColor ) > / > > Python return : > /win32ui.error: GetObject failed on bitmap/ > for the last line > > win32ui have CreateBitmap with 0 argument and GetBitmapBits with 1 > arguments > but win32gui have CreateBitmap with 5 arguments and GetBitmapBits have > 2 arguments Yes. Can't you see why? win32gui is just a thin wrapper around the actual Win32 APIs. win32ui is an attempt to turn those APIs into something more like Python objects. Objects have access to additional state, so you don't have to specify as many parameters. When you call picture.GetBitmapBits( bitmapColor ) That's getting the pixels from the bitmap you just created. The parameter it takes is the number of bytes is should copy (so you're passing garbage). Your bitmap doesn't contain anything yet -- you haven't even set the size -- so naturally the GetBitmapBits call fails. You need to do EXACTLY what the demo does. Create a bitmap, set its size, then draw the icon on the bitmap, THEN pull the bits from the bitmap. The icon doesn't actually contain bitmaps. It contains arrays of pixels, but you need them to be a bitmap. > On the demo, hicon is use ton create the variable nid and re use it to > display on the screen, but i want get only the bitmap bits. I'm not sure why you think these two things are different. The way you get the bitmap bits is to draw the icon on a bitmap. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From costin.gament at gmail.com Tue Apr 28 21:26:20 2009 From: costin.gament at gmail.com (=?utf-8?B?Q29zdGluIEdhbWVuyJs=?=) Date: Tue, 28 Apr 2009 22:26:20 +0300 Subject: [python-win32] AutoCAD automation with COM. In-Reply-To: References: Message-ID: On Tue, 28 Apr 2009 15:04:05 +0300, Thomas Heller wrote: > > You could try comtypes, it allows to specify the exact parameters that > are passed as VARIANTs. There is even a sample snippet for autocad > in the docs: > > http://starship.python.net/crew/theller/comtypes/ > > Thomas > Thank you, Thomas! comtypes works exactly as advertised and I can finally interact with AutoCAD correctly. Have a great day, Costin From farplagek at gmail.com Wed Apr 29 18:36:36 2009 From: farplagek at gmail.com (Khalid Moulfi) Date: Wed, 29 Apr 2009 20:36:36 +0400 Subject: [python-win32] Retrieve informations from NIST file. Message-ID: <7ad508500904290936u254edb17g80b0ede64400f0ca@mail.gmail.com> Hello all, hope you'r all fine. Actually, I'm a little bit blocked. I have, let's say, thousands of file (NIST file). In the first line of all of them I have tag numbers plus many informations, even sometimes strange chararcters (Maybe Hexadecimal). A line can look like : 1.001:nnnn1.002:xxxx...2.083:Strange character2.087:Strange character First, when I read the 1st line of each of these files and do a len(line), I do not have the same number of chararcters between the return of len(line) and the number returned by the editor Scite (It gives the number of column). In the meantime, I have to remove some tags in different places and add some other tags also in different places. If anyone can help. Thks, KM -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Apr 29 19:07:37 2009 From: timr at probo.com (Tim Roberts) Date: Wed, 29 Apr 2009 10:07:37 -0700 Subject: [python-win32] Retrieve informations from NIST file. In-Reply-To: <7ad508500904290936u254edb17g80b0ede64400f0ca@mail.gmail.com> References: <7ad508500904290936u254edb17g80b0ede64400f0ca@mail.gmail.com> Message-ID: <49F88959.3010308@probo.com> Khalid Moulfi wrote: > > Actually, I'm a little bit blocked. > > I have, let's say, thousands of file (NIST file). In the first line of > all of them I have tag numbers plus many informations, even sometimes > strange chararcters (Maybe Hexadecimal). > A line can look like : > > 1.001:nnnn1.002:xxxx character>...2.083:Strange character2.087:Strange > character > > First, when I read the 1st line of each of these files and do a > len(line), I do not have the same number of chararcters between the > return of len(line) and the number returned by the editor Scite (It > gives the number of column). Your description is too sketchy to come with a real analysis, but if you're reading a file that contains more than just simple text characters, you probably need to open the file in binary mode: f = open( 'xxxx.bin', 'rb' ) You probably need to examine this file with a hex editor to figure out what it really contains. If you want, you could send me one of the files, and a detailed description of what you want out of them. Perhaps we can come with a data structure that's easier to work with. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skippy.hammond at gmail.com Thu Apr 30 02:06:11 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 30 Apr 2009 10:06:11 +1000 Subject: [python-win32] Python Service Won't Start, But Does Debug In-Reply-To: References: Message-ID: <49F8EB73.8030803@gmail.com> Robert Robinson wrote: > I'm new to using the win32 module and I've written a little service in > python for myself. It runs fine and without errors when I use debug: >> python myService.py debug > Debugging service myService - press Ctrl+C to stop. > > This works and prints to a log file I set up just fine, so I know it's > working properly > > However when I try using the start command on the same service It says > it's started, but hasn't: >> python myService.py start > Starting service myService > > Then after any amount of time: >> python myService.py stop > Stopping service myService > Error stopping service: The service has not been started. (1062) Your code is probably hitting some error when run as a service - check the Windows event log for tracebacks etc... Mark From skippy.hammond at gmail.com Thu Apr 30 02:06:38 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 30 Apr 2009 10:06:38 +1000 Subject: [python-win32] PythonWin IDE: how to assign a function/code to key F1 etc. ? In-Reply-To: References: Message-ID: <49F8EB8E.80809@gmail.com> Robert wrote: > want to put new functions (short python code) on keys like F1, F12, > Ctrl-F1 and other keys. > Is there a mechanism/recipe ? Look for the *.cfg files in the pythonwin directory. Mark From jeparg at aim.com Thu Apr 30 05:20:47 2009 From: jeparg at aim.com (J) Date: Wed, 29 Apr 2009 23:20:47 -0400 Subject: [python-win32] Single-instance, only when invoked COM localserver Message-ID: <8CB9759CA2CB6C2-1684-282C@WEBMAIL-MC06.sysops.aol.com> Hi all.? First post, and I did try to do due diligence on browsing the mailing list and googling, but I could not find an answer to this (? hopefully I tried hard enough... ;->? ). I have a setup where I want a COM LocalServer to only be available when the application has been manually started. Basically my COM server gets enabled when the user starts an application that loads my application as a dll.? My COM server is useless without the application. In standard COM, this is achieved by registering a dummy dll and then using CoRegisterClassObject(CLSID_SOME,&ei,CLSCTX_LOCAL_SERVER,REGCLS_MULTIPLEUSE,&pdwReg) in the executable, making it available when the process is running. The python win32com examples all perform a single registration which allows other com clients to use it at arbitrary times, which will not work for me.? I would need to either: 1. Be able to register the COM server at installation time with a "dummy" dll and only have it be available when the process is running and my dll is loaded into it or 2. Register/unregister the COM server on demand - once at the entry point into my dll and once on exit, but do so without administrative privelidges since that would be unworkable for the user. Could someone give me a hint how I might be able to achieve this with python win32com? Thanks Johan -------------- next part -------------- An HTML attachment was scrubbed... URL: From mc at mclaveau.com Thu Apr 30 08:18:44 2009 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 30 Apr 2009 08:18:44 +0200 Subject: [python-win32] Single-instance, only when invoked COM localserver In-Reply-To: <8CB9759CA2CB6C2-1684-282C@WEBMAIL-MC06.sysops.aol.com> References: <8CB9759CA2CB6C2-1684-282C@WEBMAIL-MC06.sysops.aol.com> Message-ID: <3DE49E5B849545EA92AC28E736A44EB6@MCI1330> Hi! A Python-COM-server contain, essentially, a class. This class can have a method __init__(self, ...) This methode is called for each "opening" of the COM server. You can use that for control if your COM-server must, or no, continue. @-salutations -- Michel Claveau From whatyoulookin at yahoo.com Thu Apr 30 09:14:35 2009 From: whatyoulookin at yahoo.com (Alec Bennett) Date: Thu, 30 Apr 2009 00:14:35 -0700 (PDT) Subject: [python-win32] Programatically activating secondary monitor? Message-ID: <10055.52276.qm@web54606.mail.re2.yahoo.com> I'm wondering if there's a way to enable a second monitor in Windows from Python or otherwise programatically? Currently I use the utility UltraMon, which works, but it sure would be nice to be able to do this from Python. From mail at timgolden.me.uk Thu Apr 30 09:49:58 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 30 Apr 2009 08:49:58 +0100 Subject: [python-win32] Programatically activating secondary monitor? In-Reply-To: <10055.52276.qm@web54606.mail.re2.yahoo.com> References: <10055.52276.qm@web54606.mail.re2.yahoo.com> Message-ID: <49F95826.1040208@timgolden.me.uk> Alec Bennett wrote: > I'm wondering if there's a way to enable a second monitor in Windows > from Python or otherwise programatically? Currently I use the utility UltraMon, > which works, but it sure would be nice to be able to do this from Python. I'm not quite sure I understand what "enable a second monitor" means here. But (since I have no specific expertise to offer in this area) I will offer my usual response: can you find out how to do what you want on Windows in general, eg from an MS Group or a codeproject.com example, etc.? Once we've got the technique nailed then it's a question of how best to translate that into Python -- if it's feasible. TJG From whatyoulookin at yahoo.com Thu Apr 30 10:40:15 2009 From: whatyoulookin at yahoo.com (Alec Bennett) Date: Thu, 30 Apr 2009 01:40:15 -0700 (PDT) Subject: [python-win32] Programatically activating secondary monitor? In-Reply-To: <49F95826.1040208@timgolden.me.uk> Message-ID: <80591.23237.qm@web54607.mail.re2.yahoo.com> As always, good point, and I'm embarassed to admit its the same point as usual. I'll dig around and post my findings. And fyi, by "enable the secondary monitor", I mean enabling the output from a second video card, such as the VGA port in a laptop. The equivalent of going to windows control panel --> display --> settings and clicking on that second monitor. --- On Thu, 4/30/09, Tim Golden wrote: > From: Tim Golden > Subject: Re: [python-win32] Programatically activating secondary monitor? > To: > Cc: python-win32 at python.org > Date: Thursday, April 30, 2009, 3:49 AM > Alec Bennett wrote: > > I'm wondering if there's a way to enable a > second monitor in Windows from Python or otherwise > programatically? Currently I use the utility UltraMon, which > works, but it sure would be nice to be able to do this from > Python. > > I'm not quite sure I understand what "enable a > second monitor" means here. > But (since I have no specific expertise to offer in this > area) I will > offer my usual response: can you find out how to do what > you want on > Windows in general, eg from an MS Group or a > codeproject.com example, etc.? > Once we've got the technique nailed then it's a > question of how best to > translate that into Python -- if it's feasible. > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From neisen at linbox.com Thu Apr 30 17:11:39 2009 From: neisen at linbox.com (Nicolas EISEN) Date: Thu, 30 Apr 2009 17:11:39 +0200 Subject: [python-win32] Extract icon from exe files In-Reply-To: <49F73A31.2050206@probo.com> References: <49EC8D1A.9000909@linbox.com> <49ED0732.6050608@probo.com> <49F1D337.8070303@linbox.com> <49F1F035.3020308@probo.com> <49F5D200.3030704@linbox.com> <49F5E646.3060109@probo.com> <49F71BEC.4010608@linbox.com> <49F73A31.2050206@probo.com> Message-ID: <49F9BFAB.7020508@linbox.com> Tim Roberts a ?crit : > EISEN Nicolas wrote: > >>> >>> >> I'm lucky, I found ... >> >> My Source : >> >> /from win32gui import * >> import win32con >> from pywintypes import HANDLE >> import win32ui >> listHicon = ExtractIconEx("c:\OpenOffice.exe",0) >> tupleIcon = GetIconInfo (HANDLE ( listHicon[0][0] ) ) >> >> bitmapColor = tupel [4] >> >> picture = win32ui.CreateBitmap() >> buffer = picture.GetBitmapBits ( bitmapColor ) >> / >> >> Python return : >> /win32ui.error: GetObject failed on bitmap/ >> for the last line >> >> win32ui have CreateBitmap with 0 argument and GetBitmapBits with 1 >> arguments >> but win32gui have CreateBitmap with 5 arguments and GetBitmapBits have >> 2 arguments >> > > Yes. Can't you see why? win32gui is just a thin wrapper around the > actual Win32 APIs. win32ui is an attempt to turn those APIs into > something more like Python objects. Objects have access to additional > state, so you don't have to specify as many parameters. When you call > picture.GetBitmapBits( bitmapColor ) > > That's getting the pixels from the bitmap you just created. The > parameter it takes is the number of bytes is should copy (so you're > passing garbage). Your bitmap doesn't contain anything yet -- you > haven't even set the size -- so naturally the GetBitmapBits call fails. > > You need to do EXACTLY what the demo does. Create a bitmap, set its > size, then draw the icon on the bitmap, THEN pull the bits from the > bitmap. The icon doesn't actually contain bitmaps. It contains arrays > of pixels, but you need them to be a bitmap. > > > >> On the demo, hicon is use ton create the variable nid and re use it to >> display on the screen, but i want get only the bitmap bits. >> > > I'm not sure why you think these two things are different. The way you > get the bitmap bits is to draw the icon on a bitmap. > > With demo_menu, I script it : /from win32gui import */ /import win32con/ /from win32api import GetSystemMetrics/ /ico_x = GetSystemMetrics(win32con.SM_CXSMICON)/ /ico_y = GetSystemMetrics(win32con.SM_CYSMICON)/ /large, small = ExtractIconEx("c:\dxdiag.exe",0)/ /hicon = small[0]/ /print type(hicon)/ /DestroyIcon(large[0])/ /#creating a source memory DC and selecting a icon in it/ /srcDC = CreateCompatibleDC(0)/ /SelectObject(srcDC,hicon);/ /#creating a destination memory DC and selecting a memory bitmap to it/ /hdcBitmap = CreateCompatibleDC(0)/ /hdcScreen = GetDC(0)/ /hbm = CreateCompatibleBitmap(hdcScreen, ico_x, ico_y)/ /SelectObject(hdcBitmap, hbm)/ /# copies source DC to memory DC resulting in a copy of hicon in hbm/ /BitBlt(hdcBitmap,0,0,ico_x,ico_y,srcDC,0,0,win32con.SRCCOPY);/ /bitmap = CreateBitmapFromHandle(hbm)/ /hbm.SaveBitmapFile()/ /DeleteDC(srcDC);/ /DeleteDC(hdcBitmap); / I suppose, I have my icon picture on the Bitmap /hbm/ but how I get file's bits or how I save it ? There are SaveBitmapFile or GetBitmapBits methods on win32ui (PyCBitmap) but I test many disposition, I have always type problem between win32gui and win32ui objects. I try to use win32gui DC with icon and win32ui DC with bitmap, but always the type doesn't work : PyHandle (win32gui) is different from PyBitmap (win32ui). Please Help ! I 'm tired ... From kxroberto at googlemail.com Thu Apr 30 17:37:48 2009 From: kxroberto at googlemail.com (Robert) Date: Thu, 30 Apr 2009 17:37:48 +0200 Subject: [python-win32] PythonWin IDE: how to assign a function/code to key F1 etc. ? In-Reply-To: <49F8EB8E.80809@gmail.com> References: <49F8EB8E.80809@gmail.com> Message-ID: Mark Hammond wrote: > Robert wrote: >> want to put new functions (short python code) on keys like F1, F12, >> Ctrl-F1 and other keys. >> Is there a mechanism/recipe ? > > > Look for the *.cfg files in the pythonwin directory. > Thanks. maybe some of the following stuff is useful for somebody, or for future PythonWin default: In attachment a patch for pywin/default.cfg, which does context (word) sensitive help from editor into Python Help and PythonWin Help F1 = HelpPy Ctrl+F1 = HelpPyWin .. and allows for faster edit-run cycle: running/interacting with (auto-unindented) selected code lines from editor Ctrl+K = Interact_SelectedLines Ctrl+E = ExecGlobal_SelectedLines ( the little patch of scintilla/config.py enables correct line numbers for traceback and debugging of code in default.cfg ) - Also CtrlEnter.patch (-> framework/interact.py), which enables ad-hoc debugging from interactive pane (Ctrl-Enter) into an interactive statement (without long-winded F5 running into breakpoints etc). I did not put the code into default.cfg, because a lot of pre-processing code is shared with normal interactive statement execution. Robert -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: cfg.patch URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: CtrlEnter.patch URL: From le.dahut at laposte.net Thu Apr 30 17:30:48 2009 From: le.dahut at laposte.net (le dahut) Date: Thu, 30 Apr 2009 17:30:48 +0200 Subject: [python-win32] gpedit reload method in python Message-ID: <49F9C428.3080509@laposte.net> Hello, "gpedit.msc" can change several parameters in system for example items in start menu or hidden drives in explorer. The changes made in "gpedit" are immediately applied, if you have "My computer" opened you can see selected letters disappear. I know that "gpedit" modifies HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDrives. But I don't know how "gpedit" updates the system, what sort of system call is done. I've already tried : win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SETTINGCHANGE, 0, 'Environment') and the commande : RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters ,1 ,True without success. Does someone know more about this ? Are there other API calls that update the system ? K. From timr at probo.com Thu Apr 30 18:46:19 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 30 Apr 2009 09:46:19 -0700 Subject: [python-win32] Retrieve informations from NIST file. In-Reply-To: <7ad508500904300918p684a1a27h5a2a73eb351bdd9@mail.gmail.com> References: <7ad508500904300918p684a1a27h5a2a73eb351bdd9@mail.gmail.com> Message-ID: <49F9D5DB.6040305@probo.com> Khalid Moulfi wrote: > > thanks for your quick answer. > Here is a sample of the first line of the NIST file : > > 1.001:0000000245 1.002:3000 1.003:119 20 41 42 43 44 45 46 47 48 49 410 411 412 413 414 1515 1516 1517 1518 1.004:NPS 1.005:20081029 1.006:4 1.007:51/Live > Scan 1.008:51/Live Scan 1.009:0844251404U 1.011:19.6850 1.012:19.6850 2.001:0000000188 2.002:0 2.003:3000 2.010:1005000190 2.019:20081029 2.029:0 2.054:Civilian 2.083:01NA 02NA 03NA 04NA 05NA 06NA 07NA 08NA 09NA 10NA 2.233:???? 2.235:1011973400606 > > but as the end of the line is not displayed, I send you a copy of the > file with all the line. That's because your file contains null bytes ('\x00'). The string you display above shows everything up to the first null. > The thing is even if I take the number of character from let's say > 2.001 to the end of the line I do not get the real number of charatcer. What do you mean by that? Where did the numbers come from? The file contains one line of 471 bytes, including the newline. Does that agree with either of your sources? > My goal is to modify this first line by adding new tag (with special > character), suppress some of them, get the real number of length and > after all this update to modify it in the original nst file. > > I'll try as you said to open it with rb parameters and see. You will have to show me your code, along with what numbers you expect. The file you sent is 471 bytes long, and that's exactly what I read, in both text and binary modes: C:\tmp>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> x = open('sample_1005000190.nst') >>> y = open('sample_1005000190.nst', 'rb') >>> x1 = x.read() >>> y1 = y.read() >>> len(x1) 471 >>> len(y1) 471 >>> x1.find('2.001') 245 >>> x1[-2:] '\x00\n' >>> y1[-2:] '\x00\n' >>> x.seek(0,0) >>> x2 = x.readlines() >>> len(x2) 1 >>> len(x2[0]) 471 >>> The "2.001" is located at byte 245, so there should are 126 bytes from there to the end of the line. However, there are zero bytes (meaning '\x00') in this file, which might be confusing you. You have to know something about this data format to know how to modify it. It looks like the file consists of two major sections, separated by 0x1C characters. The major sections are then divided into records separated by 0x1D characters. Some of the records have fields in them, separated by 0x1E. There are 38 bytes of what look like garbage after the last field. So, you could parse it into records like this: Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> x = open('sample_1005000190.nst','rb').read() >>> sections = x.split('\x1c') >>> len(sections) 3 >>> [len(k) for k in sections] [244, 187, 38] >>> rec1 = sections[0].split('\x1d') >>> rec2 = sections[1].split('\x1d') >>> len(rec1) 11 >>> len(rec2) 10 >>> rec1 ['1.001:0000000245', '1.002:3000', '1.003:1\x1f19\x1e2\x1f0\x1e4\x1f1\x1e4\x1f2\ x1e4\x1f3\x1e4\x1f4\x1e4\x1f5\x1e4\x1f6\x1e4\x1f7\x1e4\x1f8\x1e4\x1f9\x1e4\x1f10 \x1e4\x1f11\x1e4\x1f12\x1e4\x1f13\x1e4\x1f14\x1e15\x1f15\x1e15\x1f16\x1e15\x1f17 \x1e15\x1f18', '1.004:NPS', '1.005:20081029', '1.006:4', '1.007:51/Live Scan', ' 1.008:51/Live Scan', '1.009:0844251404U', '1.011:19.6850', '1.012:19.6850'] >>> rec2 ['2.001:0000000188', '2.002:0', '2.003:3000', '2.010:1005000190', '2.019:2008102 9', '2.029:0', '2.054:Civilian', '2.083:01\x1fNA\x1e02\x1fNA\x1e03\x1fNA\x1e04\x 1fNA\x1e05\x1fNA\x1e06\x1fNA\x1e07\x1fNA\x1e08\x1fNA\x1e09\x1fNA\x1e10\x1fNA', ' 2.233:\xc8\xcf\xe6\xe4', '2.235:1011973400606'] >>> Here, "sections" contains the three major sections. "rec1" contains the records from the first section. If you wanted to add a "1.013" record to the first section, you could say: rec1.append( "1.013:Cool Beans" ) and then rebuild the file by saying: newsections = ['\x1d'.join(rec1), '\x1d'.join(rec2), sections[2]] open('newfile.nst','wb').write ('\x1c'.join(newsections) ) But that assumes there's nothing in that garbage 3rd section that needs to be changed. It's just a matter of dividing the problem up into smaller problems until the solution pops out. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From cappy2112 at gmail.com Thu Apr 30 18:55:15 2009 From: cappy2112 at gmail.com (Tony Cappellini) Date: Thu, 30 Apr 2009 09:55:15 -0700 Subject: [python-win32] Programatically activating secondary monitor? Message-ID: <8249c4ac0904300955k50fb5d40x46e55114817938cb@mail.gmail.com> Message: 1 Date: Thu, 30 Apr 2009 08:49:58 +0100 From: Tim Golden Subject: Re: [python-win32] Programatically activating secondary monitor? Cc: python-win One can enable/disable a mutli-head monitor by right clicking on the desktop and selecting the Settings Tab. Of course, you need to have a multi-head video card and driver installed first. but there are times when you want to disable the second montior/desktop. When you connect to a system via Remote Desktop which has both monitors/desktops enabled, you cannot access the applications that are displayed on the secondary monitor. This is extremely irritating. If you close those applications and re-open them, they automatically re-ope on the secondary display. The only way to prevent this is to disable the secondary video card,and re-open the monitor on the primary display. Some very old applications (Lotus Notes for example) which happen to be running on the scondary display, cannot be dragged back to the primary display. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Apr 30 20:10:03 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 30 Apr 2009 11:10:03 -0700 Subject: [python-win32] Extract icon from exe files In-Reply-To: <49F9BFAB.7020508@linbox.com> References: <49EC8D1A.9000909@linbox.com> <49ED0732.6050608@probo.com> <49F1D337.8070303@linbox.com> <49F1F035.3020308@probo.com> <49F5D200.3030704@linbox.com> <49F5E646.3060109@probo.com> <49F71BEC.4010608@linbox.com> <49F73A31.2050206@probo.com> <49F9BFAB.7020508@linbox.com> Message-ID: <49F9E97B.3040704@probo.com> Nicolas EISEN wrote: > Tim Roberts a ?crit : >> EISEN Nicolas wrote: >> >>>> >>>> >>> I'm lucky, I found ... >>> >>> My Source : >>> >>> /from win32gui import * >>> import win32con >>> from pywintypes import HANDLE >>> import win32ui listHicon = ExtractIconEx("c:\OpenOffice.exe",0) >>> tupleIcon = GetIconInfo (HANDLE ( listHicon[0][0] ) ) >>> >>> bitmapColor = tupel [4] >>> >>> picture = win32ui.CreateBitmap() >>> buffer = picture.GetBitmapBits ( bitmapColor ) >>> / >>> >>> Python return : >>> /win32ui.error: GetObject failed on bitmap/ >>> for the last line >>> >>> win32ui have CreateBitmap with 0 argument and GetBitmapBits with 1 >>> arguments >>> but win32gui have CreateBitmap with 5 arguments and GetBitmapBits have >>> 2 arguments >>> >> >> Yes. Can't you see why? win32gui is just a thin wrapper around the >> actual Win32 APIs. win32ui is an attempt to turn those APIs into >> something more like Python objects. Objects have access to additional >> state, so you don't have to specify as many parameters. When you call >> picture.GetBitmapBits( bitmapColor ) >> >> That's getting the pixels from the bitmap you just created. The >> parameter it takes is the number of bytes is should copy (so you're >> passing garbage). Your bitmap doesn't contain anything yet -- you >> haven't even set the size -- so naturally the GetBitmapBits call fails. >> >> You need to do EXACTLY what the demo does. Create a bitmap, set its >> size, then draw the icon on the bitmap, THEN pull the bits from the >> bitmap. The icon doesn't actually contain bitmaps. It contains arrays >> of pixels, but you need them to be a bitmap. >> >> >> >>> On the demo, hicon is use ton create the variable nid and re use it to >>> display on the screen, but i want get only the bitmap bits. >>> >> >> I'm not sure why you think these two things are different. The way you >> get the bitmap bits is to draw the icon on a bitmap. >> >> > > With demo_menu, I script it : > > /from win32gui import */ > /import win32con/ > /from win32api import GetSystemMetrics/ > > > /ico_x = GetSystemMetrics(win32con.SM_CXSMICON)/ > /ico_y = GetSystemMetrics(win32con.SM_CYSMICON)/ > > /large, small = ExtractIconEx("c:\dxdiag.exe",0)/ > /hicon = small[0]/ > /print type(hicon)/ > /DestroyIcon(large[0])/ > > /#creating a source memory DC and selecting a icon in it/ > /srcDC = CreateCompatibleDC(0)/ > /SelectObject(srcDC,hicon);/ > > /#creating a destination memory DC and selecting a memory bitmap to > it/ > /hdcBitmap = CreateCompatibleDC(0)/ > /hdcScreen = GetDC(0)/ > /hbm = CreateCompatibleBitmap(hdcScreen, ico_x, ico_y)/ > /SelectObject(hdcBitmap, hbm)/ > > /# copies source DC to memory DC resulting in a copy of hicon in hbm/ > /BitBlt(hdcBitmap,0,0,ico_x,ico_y,srcDC,0,0,win32con.SRCCOPY);/ > > /bitmap = CreateBitmapFromHandle(hbm)/ > /hbm.SaveBitmapFile()/ > > /DeleteDC(srcDC);/ > /DeleteDC(hdcBitmap); > / > > > I suppose, I have my icon picture on the Bitmap /hbm/ but how I get > file's bits or how I save it ? > > There are SaveBitmapFile or GetBitmapBits methods on win32ui > (PyCBitmap) but I test many disposition, I have always type problem > between win32gui and win32ui objects. > I try to use win32gui DC with icon and win32ui DC with bitmap, but > always the type doesn't work : PyHandle (win32gui) is different from > PyBitmap (win32ui). > > Please Help ! I 'm tired ... I think you're making this a lot harder than it needs to be. import win32ui import win32gui import win32con import win32api ico_x = win32api.GetSystemMetrics(win32con.SM_CXICON) ico_y = win32api.GetSystemMetrics(win32con.SM_CYICON) large, small = win32gui.ExtractIconEx("c:/windows/system32/shell32.dll",0) win32gui.DestroyIcon(large[0]) hdc = win32ui.CreateDCFromHandle( win32gui.GetDC(0) ) hbmp = win32ui.CreateBitmap() hbmp.CreateCompatibleBitmap( hdc, ico_x, ico_x ) hdc = hdc.CreateCompatibleDC() hdc.SelectObject( hbmp ) hdc.DrawIcon( (0,0), small[0] ) hbmp.SaveBitmapFile( hdc, "save.bmp" ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mail at timgolden.me.uk Thu Apr 30 21:04:40 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 30 Apr 2009 20:04:40 +0100 Subject: [python-win32] gpedit reload method in python In-Reply-To: <49F9C428.3080509@laposte.net> References: <49F9C428.3080509@laposte.net> Message-ID: <49F9F648.1080204@timgolden.me.uk> le dahut wrote: > Hello, > > "gpedit.msc" can change several parameters in system for example items > in start menu or hidden drives in explorer. The changes made in "gpedit" > are immediately applied, if you have "My computer" opened you can see > selected letters disappear. > I know that "gpedit" modifies > HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDrives. > But I don't know how "gpedit" updates the system, what sort of system > call is done. > > I've already tried : > win32gui.SendMessage(win32con.HWND_BROADCAST, > win32con.WM_SETTINGCHANGE, 0, 'Environment') > and the commande : > RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters ,1 ,True > without success. > > Does someone know more about this ? > Are there other API calls that update the system ? You might need to call SHChangeNotify http://msdn.microsoft.com/en-us/library/bb762118(VS.85).aspx TJG From rdahlstrom at directedge.com Thu Apr 30 18:57:19 2009 From: rdahlstrom at directedge.com (Dahlstrom, Roger) Date: Thu, 30 Apr 2009 12:57:19 -0400 Subject: [python-win32] Programatically activating secondary monitor? In-Reply-To: <8249c4ac0904300955k50fb5d40x46e55114817938cb@mail.gmail.com> References: <8249c4ac0904300955k50fb5d40x46e55114817938cb@mail.gmail.com> Message-ID: <70D9B06B9E99EE4E98E4893703ADA141146BE239C0@EXCHANGE1.global.knight.com> Or if it were something that you were doing while RDP?d in, you could just select the window, hit alt-space, select move, then use the cursor keys to place the app where you want it. Or use restore first if it?s in a maximized state. I?m not sure that this is something that even requires python. From: python-win32-bounces+rdahlstrom=directedge.com at python.org [mailto:python-win32-bounces+rdahlstrom=directedge.com at python.org] On Behalf Of Tony Cappellini Sent: Thursday, April 30, 2009 12:55 PM To: python-win32 at python.org Subject: Re: [python-win32] Programatically activating secondary monitor? Message: 1 Date: Thu, 30 Apr 2009 08:49:58 +0100 From: Tim Golden > Subject: Re: [python-win32] Programatically activating secondary monitor? Cc: python-win One can enable/disable a mutli-head monitor by right clicking on the desktop and selecting the Settings Tab. Of course, you need to have a multi-head video card and driver installed first. but there are times when you want to disable the second montior/desktop. When you connect to a system via Remote Desktop which has both monitors/desktops enabled, you cannot access the applications that are displayed on the secondary monitor. This is extremely irritating. If you close those applications and re-open them, they automatically re-ope on the secondary display. The only way to prevent this is to disable the secondary video card,and re-open the monitor on the primary display. Some very old applications (Lotus Notes for example) which happen to be running on the scondary display, cannot be dragged back to the primary display. DISCLAIMER: This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. NOTICE REGARDING PRIVACY AND CONFIDENTIALITY Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications. www.directedge.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From farplagek at gmail.com Thu Apr 30 21:12:08 2009 From: farplagek at gmail.com (Khalid Moulfi) Date: Thu, 30 Apr 2009 23:12:08 +0400 Subject: [python-win32] python-win32 Digest, Vol 73, Issue 32 In-Reply-To: References: Message-ID: <7ad508500904301212u22f53defyf6d0947621e63be4@mail.gmail.com> Thks Tim Roberts for your explanation, I'll try it with version 2.2.1 Regards KM On Thu, Apr 30, 2009 at 8:46 PM, wrote: > Send python-win32 mailing list submissions to > python-win32 at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-win32 > or, via email, send a message with subject or body 'help' to > python-win32-request at python.org > > You can reach the person managing the list at > python-win32-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of python-win32 digest..." > > > Today's Topics: > > 1. Re: Extract icon from exe files (Nicolas EISEN) > 2. Re: PythonWin IDE: how to assign a function/code to key F1 > etc. ? (Robert) > 3. gpedit reload method in python (le dahut) > 4. Re: Retrieve informations from NIST file. (Tim Roberts) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 30 Apr 2009 17:11:39 +0200 > From: Nicolas EISEN > Subject: Re: [python-win32] Extract icon from exe files > To: Python-Win32 List > Message-ID: <49F9BFAB.7020508 at linbox.com> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Tim Roberts a ?crit : > > EISEN Nicolas wrote: > > > >>> > >>> > >> I'm lucky, I found ... > >> > >> My Source : > >> > >> /from win32gui import * > >> import win32con > >> from pywintypes import HANDLE > >> import win32ui > >> listHicon = ExtractIconEx("c:\OpenOffice.exe",0) > >> tupleIcon = GetIconInfo (HANDLE ( listHicon[0][0] ) ) > >> > >> bitmapColor = tupel [4] > >> > >> picture = win32ui.CreateBitmap() > >> buffer = picture.GetBitmapBits ( bitmapColor ) > >> / > >> > >> Python return : > >> /win32ui.error: GetObject failed on bitmap/ > >> for the last line > >> > >> win32ui have CreateBitmap with 0 argument and GetBitmapBits with 1 > >> arguments > >> but win32gui have CreateBitmap with 5 arguments and GetBitmapBits have > >> 2 arguments > >> > > > > Yes. Can't you see why? win32gui is just a thin wrapper around the > > actual Win32 APIs. win32ui is an attempt to turn those APIs into > > something more like Python objects. Objects have access to additional > > state, so you don't have to specify as many parameters. When you call > > picture.GetBitmapBits( bitmapColor ) > > > > That's getting the pixels from the bitmap you just created. The > > parameter it takes is the number of bytes is should copy (so you're > > passing garbage). Your bitmap doesn't contain anything yet -- you > > haven't even set the size -- so naturally the GetBitmapBits call fails. > > > > You need to do EXACTLY what the demo does. Create a bitmap, set its > > size, then draw the icon on the bitmap, THEN pull the bits from the > > bitmap. The icon doesn't actually contain bitmaps. It contains arrays > > of pixels, but you need them to be a bitmap. > > > > > > > >> On the demo, hicon is use ton create the variable nid and re use it to > >> display on the screen, but i want get only the bitmap bits. > >> > > > > I'm not sure why you think these two things are different. The way you > > get the bitmap bits is to draw the icon on a bitmap. > > > > > > With demo_menu, I script it : > > /from win32gui import */ > /import win32con/ > /from win32api import GetSystemMetrics/ > > > /ico_x = GetSystemMetrics(win32con.SM_CXSMICON)/ > /ico_y = GetSystemMetrics(win32con.SM_CYSMICON)/ > > /large, small = ExtractIconEx("c:\dxdiag.exe",0)/ > /hicon = small[0]/ > /print type(hicon)/ > /DestroyIcon(large[0])/ > > /#creating a source memory DC and selecting a icon in it/ > /srcDC = CreateCompatibleDC(0)/ > /SelectObject(srcDC,hicon);/ > > /#creating a destination memory DC and selecting a memory bitmap to it/ > /hdcBitmap = CreateCompatibleDC(0)/ > /hdcScreen = GetDC(0)/ > /hbm = CreateCompatibleBitmap(hdcScreen, ico_x, ico_y)/ > /SelectObject(hdcBitmap, hbm)/ > > /# copies source DC to memory DC resulting in a copy of hicon in hbm/ > /BitBlt(hdcBitmap,0,0,ico_x,ico_y,srcDC,0,0,win32con.SRCCOPY);/ > > /bitmap = CreateBitmapFromHandle(hbm)/ > /hbm.SaveBitmapFile()/ > > /DeleteDC(srcDC);/ > /DeleteDC(hdcBitmap); > / > > > I suppose, I have my icon picture on the Bitmap /hbm/ but how I get > file's bits or how I save it ? > > There are SaveBitmapFile or GetBitmapBits methods on win32ui (PyCBitmap) > but I test many disposition, I have always type problem between win32gui > and win32ui objects. > I try to use win32gui DC with icon and win32ui DC with bitmap, but > always the type doesn't work : PyHandle (win32gui) is different from > PyBitmap (win32ui). > > Please Help ! I 'm tired ... > > > ------------------------------ > > Message: 2 > Date: Thu, 30 Apr 2009 17:37:48 +0200 > From: Robert > Subject: Re: [python-win32] PythonWin IDE: how to assign a > function/code to key F1 etc. ? > To: python-win32 at python.org > Message-ID: > Content-Type: text/plain; charset="iso-8859-1"; Format="flowed" > > Mark Hammond wrote: > > Robert wrote: > >> want to put new functions (short python code) on keys like F1, F12, > >> Ctrl-F1 and other keys. > >> Is there a mechanism/recipe ? > > > > > > Look for the *.cfg files in the pythonwin directory. > > > > Thanks. > > maybe some of the following stuff is useful for somebody, or for > future PythonWin default: > > In attachment a patch for pywin/default.cfg, which does context > (word) sensitive help from editor into Python Help and PythonWin Help > > F1 = HelpPy > Ctrl+F1 = HelpPyWin > .. > > and allows for faster edit-run cycle: running/interacting with > (auto-unindented) selected code lines from editor > > Ctrl+K = Interact_SelectedLines > Ctrl+E = ExecGlobal_SelectedLines > > ( the little patch of scintilla/config.py enables correct line > numbers for traceback and debugging of code in default.cfg ) > > - > > Also CtrlEnter.patch (-> framework/interact.py), which enables > ad-hoc debugging from interactive pane (Ctrl-Enter) into an > interactive statement (without long-winded F5 running into > breakpoints etc). I did not put the code into default.cfg, because > a lot of pre-processing code is shared with normal interactive > statement execution. > > > Robert > -------------- next part -------------- > An embedded and charset-unspecified text was scrubbed... > Name: cfg.patch > URL: < > http://mail.python.org/pipermail/python-win32/attachments/20090430/c26cfe43/attachment-0002.txt > > > -------------- next part -------------- > An embedded and charset-unspecified text was scrubbed... > Name: CtrlEnter.patch > URL: < > http://mail.python.org/pipermail/python-win32/attachments/20090430/c26cfe43/attachment-0003.txt > > > > ------------------------------ > > Message: 3 > Date: Thu, 30 Apr 2009 17:30:48 +0200 > From: le dahut > Subject: [python-win32] gpedit reload method in python > To: python-win32 at python.org > Message-ID: <49F9C428.3080509 at laposte.net> > Content-Type: text/plain; charset=ISO-8859-15; format=flowed > > Hello, > > "gpedit.msc" can change several parameters in system for example items > in start menu or hidden drives in explorer. The changes made in "gpedit" > are immediately applied, if you have "My computer" opened you can see > selected letters disappear. > I know that "gpedit" modifies > HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDrives. > But I don't know how "gpedit" updates the system, what sort of system > call is done. > > I've already tried : > win32gui.SendMessage(win32con.HWND_BROADCAST, > win32con.WM_SETTINGCHANGE, 0, 'Environment') > and the commande : > RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters ,1 ,True > without success. > > Does someone know more about this ? > Are there other API calls that update the system ? > > > K. > > > > ------------------------------ > > Message: 4 > Date: Thu, 30 Apr 2009 09:46:19 -0700 > From: Tim Roberts > Subject: Re: [python-win32] Retrieve informations from NIST file. > To: Python-Win32 List > Message-ID: <49F9D5DB.6040305 at probo.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Khalid Moulfi wrote: > > > > thanks for your quick answer. > > Here is a sample of the first line of the NIST file : > > > > 1.001:0000000245 1.002:3000 1.003:1 19 2 0 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 > 8 4 9 4 10 4 11 4 12 4 13 4 14 15 15 15 16 15 17 15 18 1.004:NPS > 1.005:20081029 1.006:4 1.007:51/Live > > Scan 1.008:51/Live Scan 1.009:0844251404U 1.011:19.6850 1.012:19.6850 > 2.001:0000000188 2.002:0 2.003:3000 2.010:1005000190 2.019:20081029 2.029:0 > 2.054:Civilian 2.083:01 NA 02 NA 03 NA 04 NA 05 NA 06 NA 07 NA 08 NA 09 NA > 10 NA 2.233:???? 2.235:1011973400606 > > > > but as the end of the line is not displayed, I send you a copy of the > > file with all the line. > > That's because your file contains null bytes ('\x00'). The string you > display above shows everything up to the first null. > > > > The thing is even if I take the number of character from let's say > > 2.001 to the end of the line I do not get the real number of charatcer. > > What do you mean by that? Where did the numbers come from? The file > contains one line of 471 bytes, including the newline. Does that agree > with either of your sources? > > > > My goal is to modify this first line by adding new tag (with special > > character), suppress some of them, get the real number of length and > > after all this update to modify it in the original nst file. > > > > I'll try as you said to open it with rb parameters and see. > > You will have to show me your code, along with what numbers you expect. > The file you sent is 471 bytes long, and that's exactly what I read, in > both text and binary modes: > > C:\tmp>python > Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit > (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> x = open('sample_1005000190.nst') > >>> y = open('sample_1005000190.nst', 'rb') > >>> x1 = x.read() > >>> y1 = y.read() > >>> len(x1) > 471 > >>> len(y1) > 471 > >>> x1.find('2.001') > 245 > >>> x1[-2:] > '\x00\n' > >>> y1[-2:] > '\x00\n' > >>> x.seek(0,0) > >>> x2 = x.readlines() > >>> len(x2) > 1 > >>> len(x2[0]) > 471 > >>> > > The "2.001" is located at byte 245, so there should are 126 bytes from > there to the end of the line. However, there are zero bytes (meaning > '\x00') in this file, which might be confusing you. > > You have to know something about this data format to know how to modify > it. It looks like the file consists of two major sections, separated by > 0x1C characters. The major sections are then divided into records > separated by 0x1D characters. Some of the records have fields in them, > separated by 0x1E. There are 38 bytes of what look like garbage after > the last field. So, you could parse it into records like this: > > Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit > (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> x = open('sample_1005000190.nst','rb').read() > >>> sections = x.split('\x1c') > >>> len(sections) > 3 > >>> [len(k) for k in sections] > [244, 187, 38] > >>> rec1 = sections[0].split('\x1d') > >>> rec2 = sections[1].split('\x1d') > >>> len(rec1) > 11 > >>> len(rec2) > 10 > >>> rec1 > ['1.001:0000000245', '1.002:3000', > '1.003:1\x1f19\x1e2\x1f0\x1e4\x1f1\x1e4\x1f2\ > > x1e4\x1f3\x1e4\x1f4\x1e4\x1f5\x1e4\x1f6\x1e4\x1f7\x1e4\x1f8\x1e4\x1f9\x1e4\x1f10 > > \x1e4\x1f11\x1e4\x1f12\x1e4\x1f13\x1e4\x1f14\x1e15\x1f15\x1e15\x1f16\x1e15\x1f17 > \x1e15\x1f18', '1.004:NPS', '1.005:20081029', '1.006:4', > '1.007:51/Live Scan', ' > 1.008:51/Live Scan', '1.009:0844251404U', '1.011:19.6850', > '1.012:19.6850'] > >>> rec2 > ['2.001:0000000188', '2.002:0', '2.003:3000', '2.010:1005000190', > '2.019:2008102 > 9', '2.029:0', '2.054:Civilian', > '2.083:01\x1fNA\x1e02\x1fNA\x1e03\x1fNA\x1e04\x > > 1fNA\x1e05\x1fNA\x1e06\x1fNA\x1e07\x1fNA\x1e08\x1fNA\x1e09\x1fNA\x1e10\x1fNA', > ' > 2.233:\xc8\xcf\xe6\xe4', '2.235:1011973400606'] > >>> > > > Here, "sections" contains the three major sections. "rec1" contains the > records from the first section. If you wanted to add a "1.013" record > to the first section, you could say: > rec1.append( "1.013:Cool Beans" ) > and then rebuild the file by saying: > newsections = ['\x1d'.join(rec1), '\x1d'.join(rec2), sections[2]] > open('newfile.nst','wb').write ('\x1c'.join(newsections) ) > > But that assumes there's nothing in that garbage 3rd section that needs > to be changed. > > It's just a matter of dividing the problem up into smaller problems > until the solution pops out. > > -- > 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 > > > End of python-win32 Digest, Vol 73, Issue 32 > ******************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: