Re: [python-win32] win32gui.EnumWindows, documentation?
On Tue, 2008-03-11 at 16:13 -0700, Tim Roberts wrote: Julius wrote: My fault(already got that one running), i meant the win32gui.EnumChildWindows(currentHwnd, windowEnumerationHandler, childWindows) function. from what i understand the purpose of this function is to return the childwindows from a top window - if this is right why not just pass a topwindow as argument and return a list of childwindows? Windows APIs don't ever return lists of things, because it present a memory management difficulty. Who allocates, who owns, who releases, etc. Instead, they all use the enumeration callback concept. That way, if you want a list, you can construct and maintain it yourself. If you just want the list of handles, you can do something like this: childlist = [] win32ui.EnumChildWindows( hwnd, lamba hwnd,oldlist: oldlist.append( hwnd ), childlist ) Ok, havent tried it yet but im sure it will work. But why isnt there any documentation what the arguments are good for? Julius ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] win32gui.EnumWindows, documentation?
Julius wrote: On Tue, 2008-03-11 at 16:13 -0700, Tim Roberts wrote: Julius wrote: My fault(already got that one running), i meant the win32gui.EnumChildWindows(currentHwnd, windowEnumerationHandler, childWindows) function. from what i understand the purpose of this function is to return the childwindows from a top window - if this is right why not just pass a topwindow as argument and return a list of childwindows? Windows APIs don't ever return lists of things, because it present a memory management difficulty. Who allocates, who owns, who releases, etc. Instead, they all use the enumeration callback concept. That way, if you want a list, you can construct and maintain it yourself. If you just want the list of handles, you can do something like this: childlist = [] win32ui.EnumChildWindows( hwnd, lamba hwnd,oldlist: oldlist.append( hwnd ), childlist ) Ok, havent tried it yet but im sure it will work. Actually, if that's really what I typed, I made a mistake. It's win32gui, not win32ui. But why isnt there any documentation what the arguments are good for? In part, because these are simple mappings of Windows APIs. You can go to MSDN to get information on the actual parameters to EnumChildWindows in excruciating detail. In most cases, the mapping from the C API to the Python API is quite clear, and this is one such case. The C API gets a top-level window handle, a callback function, and a context parameter. That's exactly what the win32ui version wants. It would be a very large effort with a very small payback to retype all of the Windows API documentation in Python terms. -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] WABAccess help ...
Greetings ... Take two ... This time I think I found something a little better ... http://sourceforge.net/projects/wabaccess/ Another LGPL com lib to access Windows Address Book ... But this one seems to work with Python ... Okay, so I'm asking again, if anybody (maybe Roger again ... ) Could help with a basic working example of how to get just something listing out of the WAB ... Spend a whole night, with the following code, but can only put stuff into the WAB, not get a list of e-mail address ... import win32com.client objSession = win32com.client.gencache.EnsureDispatch(WABAccess.Session) print objSession objSession.Open(False) if objSession.Identities.LastIdentity == {----}: print No Identity Selected else: print The Identity + objSession.Identities(objSession.Identities.LastIdentity).Name + is selected print objSession.Identities.DefaultIdentity print objSession.Identities.Count print objSession.Containers.Count objContainer = objSession.Containers(1) objMyContact=objContainer.Elements.NewContact( False, Clinton Taylor ) # FixMe, throught all the constant things would be import somehow ... PR_EMAIL_ADDRESS = 0x3003001F PR_BUSINESS_HOME_PAGE = 0x3A51001F PR_COMPANY_NAME = 0x3A16001F PR_BUSINESS_ADDRESS_CITY = 0x3A27001F City = Paris # objCityProperty = objMyContact.Properties.Add( wabPR_BUSINESS_ADDRESS_CITY, City ) objCityProperty = objMyContact.Properties.Add( PR_BUSINESS_ADDRESS_CITY, City ) # Adding an email address objMyContact.Properties.Add (PR_EMAIL_ADDRESS, [EMAIL PROTECTED]) # Adding the Web page property objMyContact.Properties.Add (PR_BUSINESS_HOME_PAGE, http://www.mysociety.com;) # Adding the company name property objProperty = objMyContact.Properties.Add(PR_COMPANY_NAME, ) # Changing the company name property objProperty.Value = My Society Name objMyContact.ShowDetails objMyRecipients = objSession.ShowAddress() objSession.Refresh objSession.Close print Done. ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Re: WABAccess help ...
Clinton Lee Taylor wrote: Greetings ... Take two ... This time I think I found something a little better ... http://sourceforge.net/projects/wabaccess/ Another LGPL com lib to access Windows Address Book ... But this one seems to work with Python ... Okay, so I'm asking again, if anybody (maybe Roger again ... ) Could help with a basic working example of how to get just something listing out of the WAB ... Spend a whole night, with the following code, but can only put stuff into the WAB, not get a list of e-mail address ... import win32com.client objSession = win32com.client.gencache.EnsureDispatch(WABAccess.Session) print objSession objSession.Open(False) if objSession.Identities.LastIdentity == {----}: print No Identity Selected else: print The Identity + objSession.Identities(objSession.Identities.LastIdentity).Name + is selected print objSession.Identities.DefaultIdentity print objSession.Identities.Count print objSession.Containers.Count objContainer = objSession.Containers(1) objMyContact=objContainer.Elements.NewContact( False, Clinton Taylor ) # FixMe, throught all the constant things would be import somehow ... PR_EMAIL_ADDRESS = 0x3003001F PR_BUSINESS_HOME_PAGE = 0x3A51001F PR_COMPANY_NAME = 0x3A16001F PR_BUSINESS_ADDRESS_CITY = 0x3A27001F These show up in win32com.client.constants, eg win32com.client.constants.wabPR_EMAIL_ADDRESS 805503007 City = Paris # objCityProperty = objMyContact.Properties.Add( wabPR_BUSINESS_ADDRESS_CITY, City ) objCityProperty = objMyContact.Properties.Add( PR_BUSINESS_ADDRESS_CITY, City ) # Adding an email address objMyContact.Properties.Add (PR_EMAIL_ADDRESS, [EMAIL PROTECTED]) # Adding the Web page property objMyContact.Properties.Add (PR_BUSINESS_HOME_PAGE, http://www.mysociety.com;) # Adding the company name property objProperty = objMyContact.Properties.Add(PR_COMPANY_NAME, ) # Changing the company name property objProperty.Value = My Society Name objMyContact.ShowDetails objMyRecipients = objSession.ShowAddress() objSession.Refresh objSession.Close print Done. You're missing some parens from the ShowDetails and Refresh lines. With those in place, this code works for me (at least on XP, haven't tried it on Vista yet) Roger ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] WABAccess help ...
On Wed, Mar 12, 2008 at 4:28 PM, Clinton Lee Taylor [EMAIL PROTECTED] wrote: Now to figure how to get only contacts with fax numbers and print the name and fax number ... Thanks Mailed LeeT ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 Unless you're dealing with a really large number of contacts, I would probably just do the Simplest Possible Thing(tm) and read the all into a list, filter the list using a list comprehension, then print the results. But that's just me...I like to get out of COM as soon as possible :) Kevin Horn ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32