# TextCaptureLib COM library python demo # # http://www.skesoft.com #
import win32com.client # http://sourceforge.net/projects/pywin32/ import win32com.client.dynamic import ctypes # http://sourceforge.net/projects/ctypes/ import win32gui
def getClassName(hwnd): resultString = ctypes.c_buffer(80) ctypes.windll.user32.GetClassNameA(hwnd, resultString, len(resultString)) return resultString.value
# We'll alter our window enumeration callback thing to get use this: def windowEnumerationHandler(hwnd, hWndList): if hwnd == 0: return 0; else: if getClassName(hwnd).startswith('Progman'): hChild = ctypes.windll.user32.GetWindow(hwnd, 5) #5 = GW_CHILD hChild = ctypes.windll.user32.GetWindow(hChild, 5) if hChild != 0 and getClassName(hChild).startswith('SysListView32'): hWndList.append(hChild)
#print hChild return 1
# # def CaptureIt(): hWndList = [] win32gui.EnumWindows(windowEnumerationHandler, hWndList) if len(hWndList) != 0: tcServer = win32com.client.dynamic.Dispatch('TextCaptureLib.TextCapture.1') tcWindow = win32com.client.dynamic.Dispatch('TextCaptureLib.Window.1')
# Please set your license info
#if tcServer.License('skesoft', '123456789'):
# #The registered version of Text Capture Library
#else:
# #The trial version of Text Capture Library
tcWindow.Handle = hWndList[0] strResult = tcServer.GetText(tcWindow)
print "Desktop list items captured by TextCatch:\n" + strResult del tcWindow del tcServer
if __name__== '__main__': CaptureIt()
|