Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old March 25th, 2004, 05:04 PM
eries eries is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 1 eries User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
help with ctypes and COM

I'm trying to use the win32 api function AccessibleObjectFromWindow() from python. So far, I've managed to use ctypes to actually call it with proper arguments via the oleacc.dll

The way AccessibleObjectFromWindow works in C is it fills in a void ** buffer which points to a IAccessible pointer. Now, I have been to call AccessibleObjectFromWindow and get a pointer value for the IAccessible stored in a c_int (or c_buffer). And I also know how to use Makepy to parse the Accessibility tlb to get access to the IAccessible interface itself.

What I can't seem to figure out is how do I transform this 4-bytes pointer value into an actual python object that I can treat as an IAccessible (or IDispatch or IUnknown) pointer?

Here is some sample code:

Code:

oleAccDll = ctypes.oledll.oleacc
AccessibleObjectFromWindow = oleAccDll.AccessibleObjectFromWindow
IID_IAccessible = ctypes.c_int.in_dll(oleAccDll, "IID_IAccessible")
OBJID_WINDOW = 0

# you could also say: IID_IAccessible = ctypes.com.GUID( "{618736E0-3C3D-11CF-810C-00AA00389B71}" )


def callback(hwnd, extra):
  acc = ctypes.c_int()
  hr = AccessibleObjectFromWindow(hwnd, OBJID_WINDOW, ctypes.byref(IID_IAccessible), ctypes.pointer(acc))
  print("hr is %s, acc is %x" % (hr, acc))

win32gui.EnumWindows(callback, None)



More info about AccessibleObjectFromWindow is available here:
URL

Thanks so much for your help! Feel free to email me for more info...

Eric

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > help with ctypes and COM


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway