1. Origin
To develop a cheating software, you need to take down the questions on the screen.
It is said that it is difficult to get words for IE, so it dispelled the idea of self-development, find a useful control.
Two usable files are found. One is the xdictgrb. dll file of Kingsoft, and the other is the getword File above.
1.1 Kingsoft Mac xdictgrb. dll
Here is an example of C.
The example of C # seems to be unstable. After a few words are taken, it cannot be obtained and I don't know where it is.
In addition, C # has encountered difficulties in converting to Python, mainly because it is not familiar with the mutual calls between COM and Python and will be solved later.
1.2 getword 3.3
Getword 3.3 comes with an example of VB \ Vc \ C # \ Delphi.
Let's take a look at the following principle: first, you need to create a form by yourself. A message is sent to this window as a notification every time the control word is successfully obtained. The form can be further processed after receiving the message.
1.3 getword official edition
Here is the official website http://www.textcapture.com /.
The official website version is relatively high, and the interface changes a lot. It seems that the call is more convenient than before. You don't have to implement a window like 3.3 to receive messages, just register a callback function. Unfortunately, I did not find an official example. I tried it according to the help document and gave up if I didn't succeed. 3.3 is also useful.
2. Python and getword 3.3
Getword 3.3 can be called either as an ActiveX control or by directly calling functions in a DLL. Or DLL method is relatively simple.
The following code is transferred from C #. Because there is no document, some functions do not understand what it means.
Import win32con, win32gui, win32apiimport ctypesclass mywindow (): def _ init _ (Self): Self. getword_loaded = false # register a window class WC = win32gui. wndclass () WC. lpszclassname = 'mywindow' WC. hbrbackground = win32con. color_btnface + 1 WC. lpfnwndproc = self. wndproc class_atom = win32gui. registerclass (WC) # create window self. hwnd = win32gui. createwindow (class_atom, u'window title', win32con. ws_overlappedwindow, win32con. cw_usedefault, win32con. cw_usedefault, 200,100, 0, 0, none) # display window win32gui. showwindow (self. hwnd, win32con. sw_shownormal) self. _ init_getword () def _ init_getword (Self): licenseid = "{00000000-0000-0000-0000-000000000000}" mousehook_capture_ OK _msg = "mousehook_captureok_msg-" + licenseid self. mousehook_capture_ OK = win32gui. registerwindowmessage (mousehook_capture_ OK _msg) self. iCall = ctypes. windll. loadlibrary ('icall') self. iCall. setmousehook (self. hwnd) self. iCall. mouseenablecap (true) self. iCall. getwordenablecap (true) self. getword_loaded = true def _ del_getword (Self): Self. getword_loaded = false self. iCall. removemousehook () hdll = WIN32API. getmodulehandle ('icall. dll ') WIN32API. freelibrary (hdll) def _ capture_text (Self): max_output_len= 1024
X, Y = win32gui. getcursorpos () hrwnd = self. iCall. getrealwindow (x, y) strtmp = ctypes. create_unicode_buffer ('\ 0' * max_output_len) I = ctypes. c_int (-1) OK = self. iCall. getword (hrwnd, X, Y, strtmp, max_output_len, ctypes. byref (I) If OK: Print U' all text: % s' % strtmp. value print u'word location: % s' % I. value # Message Processing def wndproc (self, hwnd, MSG, wparam, lparam): If self. getword_loaded and MSG = self. mousehook_capture_ OK: Print 'mousehook _ capture_ OK 'self. _ capture_text () If MSG = win32con. wm_close: Print 'wm _ close' self. _ del_getword () If MSG = win32con. wm_destroy: Print 'wm _ destroy 'win32gui. postquitmessage (0) return win32gui. defwindowproc (hwnd, MSG, wparam, lparam) Mw = mywindow () win32gui. pumpmessages ()