CN102043623A - Screen word snatching realization method with word dragging function - Google Patents

Screen word snatching realization method with word dragging function Download PDF

Info

Publication number
CN102043623A
CN102043623A CN2010105905346A CN201010590534A CN102043623A CN 102043623 A CN102043623 A CN 102043623A CN 2010105905346 A CN2010105905346 A CN 2010105905346A CN 201010590534 A CN201010590534 A CN 201010590534A CN 102043623 A CN102043623 A CN 102043623A
Authority
CN
China
Prior art keywords
mouse
function
speech
hook
clipbook
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN2010105905346A
Other languages
Chinese (zh)
Other versions
CN102043623B (en
Inventor
姚敏
尹建伟
吕方敏
阙杭宁
沈正伟
吴朝晖
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang University ZJU
Original Assignee
Zhejiang University ZJU
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang University ZJU filed Critical Zhejiang University ZJU
Priority to CN 201010590534 priority Critical patent/CN102043623B/en
Publication of CN102043623A publication Critical patent/CN102043623A/en
Application granted granted Critical
Publication of CN102043623B publication Critical patent/CN102043623B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • User Interface Of Digital Computer (AREA)

Abstract

The invention discloses a screen word snatching realization method with a word dragging function, comprising the following steps: 1. loading a global mouse hook by a SetWindowsHookEx API (Application Programming Interface) function in the dll program of the Windows operating system of computer equipment; 2. when mouse hovering time exceeds dwell time set by a user, after the mouse hook captures mouse dwell information WM_MOUSEHOVER, performing the following operations by the program: redrawing the window; mounting an API hook to intercept an API function; matching position; 3. when the mouse hook captures left mouse button up information WM_LBUTTON UP, performing the following operation by the program: saving content on a clipboard; simulating Ctrl+C operation; obtaining the snatched word content; and restoring the content on the clipboard. Compared with the prior art, the invention is convenient for users to use and guarantees the popularity and the accuracy of word snatching.

Description

A kind of screen word-selecting implementation method of drawing the speech function that has
Technical field
The present invention relates to the speech method of getting on the screen, especially a kind of screen word-selecting implementation method of drawing the speech function that has under Windows operating system.
Background technology
Along with the arriving of information age, Word message miscellaneous is full of on people's computer.Sometimes, in order to obtain the word on the screen, the user have to by duplicate, a series of loaded down with trivial details operations such as stickup obtain this speech, this brings very big inconvenience to the user.People wish and can extract word on the screen by shirtsleeve operation more.So the speech technology of getting on the screen is arisen at the historic moment.The speech method of getting on the existing screen mainly contains two kinds:
The one, screen word-selecting, this method is directly extracted the word of mouse position on the screen by rolling mouse, adopt this method, the mode of operation that the user obtains word is simple, quick, weak point has two, 1. because participle technique is not mature enough, thereby cause the word got not accurate enough, be not inconsistent with user's idea, 2. some application software has adopted some special literal way of outputs (as the picture format that is of pdf reader output), cause the screen word-selecting function to completely lose therein, make troubles for user's use;
The 2nd, draw speech and get speech, being the user draws the word of getting on the screen and obtains word by pulling mouse, compares with screen word-selecting, and this method can be got the word on the screen more accurately, can some screen word-selectings get less than the place get speech, but it is loaded down with trivial details than screen word-selecting to get speech operation.
For overcoming screen word-selecting and draw the deficiency that speech got in speech, we propose to draw speech and get the method that speech and screen word-selecting combine use, get the advantage that both get speech.To draw that speech got in speech and screen word-selecting combines, traditional understanding is irrealizable.Yet our find through research, with screen word-selecting with draw a speech and get speech and combine technically and can realize fully.Because, under Windows operating system, literal great majority on the screen all are by the ExtTextOutW among the dynamic base GDI32.dll, ExtTextOutA, TextOutW, four function outputs of TextOutA, wherein ExtTextOutW and TextOutW are used for the output of Unicode character, and ExtTextOutA and TextOutA are used for the output of ANSI character, therefore, the word of wanting to grasp on the screen only needs by API HOOK technical intercept system calling above api function, and therefrom intercept and capture these function parameters and get final product, this is the universal method that realizes screen word-selecting.The present invention states conventional screen in realization and gets on the basis of speech, has creationaryly incorporated the method that speech got in stroke speech, has realized the combination that speech and screen word-selecting got in stroke speech.
Summary of the invention
The objective of the invention is to: a kind of screen word-selecting implementation method of drawing the speech function that has is provided, can be user-friendly to, can guarantee to get the versatility and the accuracy of speech again.
The technical scheme that the present invention is adopted for the technical solution problem is:
A kind of screen word-selecting implementation method of drawing the speech function that has of the present invention may further comprise the steps:
Step 1: overall mouse hook is installed
In the dll program of computer equipment Windows operating system, utilize the SetWindowsHookEx api function to load overall mouse hook, be used to catch each message of mouse; When the mouse hook captured mouse stop message WM_MOUSEHOVER, program was carried out the screen word-selecting operation, wherein, the residence time of described WM_MOUSEHOVER, can set according to user's custom; When the mouse hook captured left mouse button and upsprings message WM_LBUTTONUP, program was carried out and is drawn a speech and get the speech operation;
Step 2: screen word-selecting
Surpass the residence time that the user sets when the time of mouse-over, after the mouse hook of installation captured mouse stop message WM_MOUSEHOVER, program was carried out following operation,
A. repaint window
Obtain the coordinate data of mouse pointer current location on display by described mouse hook, and these data are saved in the internal memory of computer equipment, according to coordinate data, under mouse position, choose the micro rectangle frame of a 1px * 1px, utilize api function InvalidateRect to send and repaint message, repaint window to this rectangle frame;
B. carry API hook is intercepted and captured api function
When the Windows of computer equipment system receives when repainting message, the operating system of bottom ExtTextOutW, ExtTextOutA, these api functions of TextOutW, TextOutA among the calling system dynamic link library GDI32.dll is immediately carried out literal output, this seasonal program carry API hook, intercept and capture process calling by the API hook to above-mentioned api function, obtain the parameter of this api function, thereby realize seizure output string;
C. location matches
After capturing output string, calculate the coordinate figure on the border of this character string place rectangle frame, then the current mouse coordinates position of storing in the calculator memory and the boundary coordinate of this rectangle frame are compared, if mouse position is in rectangle frame, prove that this character string is exactly the current character string pointed of mouse, directly output gets final product; Otherwise will not export;
Step 3: draw speech and get speech
When the mouse hook captured left mouse button and upsprings message WM_LBUTTONUP, program was carried out following operation,
A. preserve the content on the clipbook
In program, use the OpenClipboard function and open system clipboard, obtain content of text data on the clipbook by the GetClipboardData function again, and it is saved in the internal memory of computing machine, define its variable g_oldString by name, call CloseClipboard functional relationships closed system clipbook again;
B. simulate the Ctrl+C operation
After the content of having preserved on the clipbook, routine call keybd_event function is simulated " Ctrl " and " C " key respectively and is pressed, the operation of promptly once duplicating, and the word content data that mouse is drawn speech replace original content-data on the clipbook;
C. obtain to get the speech content
With above-mentioned step 3 a, use described OpenClipboard function once more and open clipbook, utilize the GetClipboardData function that content of text data wherein are saved in the internal memory of computing machine, so that in application program, use; Call described CloseClipboard functional relationships closed system clipbook again;
D. recover Contents of clipboard
Use described OpenClipboard function and open clipbook, utilize the SetClipboardData function that the g_oldString variate-value that is kept among the step 3 a in the calculator memory is write in the clipbook, be used to recover original content on the clipbook; Call described CloseClipboard functional relationships closed system clipbook at last.
Beneficial effect of the present invention: the present invention has adopted overall mouse hook, and replace and obtain by simulating keyboard operation " Ctrl+C " (replicate run) and get the speech content on the clipbook, realized the combination that speech and screen word-selecting got in stroke speech, but also can in time reply original content-data in the shear plate, compare with the speech method of getting on the existing screen, has following beneficial effect
One, the processing border wall is broken, in most of programs, all can normally get speech (as the picture format of pdf reader output), even in the certain applications program, the screen word-selecting function limitation, but there is stroke speech to get replenishing of speech, still can ensures the normal realization of getting the speech function;
Two, only move the word that just can obtain on the screen by mouse, convenient and swift, save duplicate, troublesome operation such as stickup;
Three, conveniently simultaneously, get the assurance that speech more has accuracy;
Four, two kinds to get the speech mode available, the user can select according to personal habits, hobby.
Description of drawings
Fig. 1 is the implementation method schematic flow sheet of screen word-selecting of the present invention;
Fig. 2 is the implementation method schematic flow sheet that speech got in of the present invention stroke of speech.
Embodiment
As depicted in figs. 1 and 2, a kind of screen word-selecting implementation method of drawing the speech function that has of the present invention, its concrete enforcement may further comprise the steps:
Step 1: overall mouse hook is installed
In the dll program of computer equipment Windows operating system, utilize the SetWindowsHookEx api function to load overall mouse hook.About the detailed directions of SetWindowsHookEx function, all mention in a lot of books, and this is not emphasis of the present invention place, therefore repeat no more here.
The pre-service function that setting captures after the mouse information is GetMsgProc.Need handle following several message of mouse at GetMsgProc:
WINAPI?GetMsgProc(MSG*msg)
{
if(msg->message==WM_MOUSEMOVE){
g_ptCurrentPoint.x=msg->pt.x;
G_ptCurrentPoint.y=msg->pt.y; // obtain the current coordinate of mouse
}
else?if(msg->message==WM_MOUSEHOVER)
ScreeGetWord();
else?if(msg->message==WM_LBUTTONUP)
DrugGetWord();
}
When the mouse hook captures mouse stop message WM_MOUSEHOVER, can think that mouse is just hovering in getting the speech place, carries out the screen word-selecting operation this moment, wherein, the mouse hook captures the residence time that mouse stops message WM_MOUSEHOVER, can set according to user's custom; When the mouse hook captures left mouse button and upsprings message WM_LBUTTONUP, can think that the user has drawn speech and finished, program is carried out and is drawn a speech and get the speech operation;
Step 2: screen word-selecting
In the process that the mouse hook is installed, the api function of using has SetWindowsHookEx, and when the mouse hook of installing captured mouse stop message WM_MOUSEHOVER, program was carried out following operation,
A. repaint window
Utilize the mouse hook to obtain the current location of mouse, the little rectangle frame of choosing a 1px * 1px then under mouse position is (if rectangle frame is chosen excessive, can cause screen flicker), utilize api function InvalidateRect to send and repaint message to rectangle frame, repaint window;
RECT?rc;
rc.left=g_ptCurrentPoint.x;
rc.top=g_ptCurrentPoint.y;
rc.right=g_ptCurrentPoint.x+1;
rc.bottom=g_ptCurrentPoint.y+1;
InvalidateRect (g_hwndCurrentWnd , ﹠amp; Rc, TRUE); // transmission repaints message
B. carry API hook is intercepted and captured api function
In the interception api function, adopt the general rewriting Import Address Table of prior art to realize.Concrete step is as follows:
1) find the base address of gdi32.dll module:
HMODULE?hmodule=GetModuleHandle(“gdi32.dll”);
2) obtaining the address of api function, is example with TextOutA:
FARPROC?m_pfnRawProc=GetProcAddress(hmodule,”TextOutA”);
3) call the ImageDirectoryEntryToData function and check whether certain application program has input joint (promptly whether needing to load dynamic base).Illustrate that this program do not import joint if return NULL, then do not do any operation and directly return.
4) if the input joint is arranged, ImageDirectoryEntryToData will return the pointer that points to input joint information.Scanning all input joint information, whether wherein have gdi32.dll module, if do not have, then do not do any operation and directly return if checking.
5) if find the gdi32.dll module just can obtain the group address of an IMAGE-THUNK-DATA structure, in this address, comprise incoming symbol information.Scan this group address successively, search the api function address that whether has and will tackle and want the address of mating.
6), then change the entry address of AP prototype function into alternative functions address that we write ourselves with the WriteProcessMemory function if find the address of these api functions.
7) in alternative functions, the parameter that can obtain wherein is that program is used, after using, must call the prototype api function, in order to avoid influence system's operate as normal.With TextOutA is example, and its alternative functions is:
BOOL?WINAPI?Hook_TextOutA(HDC?hdc,intx,int?y,LPCSTR?IpString,int?c)
{
// carry out processing here to IpString
……
// call the prototype api function
int?iResult=((pfnTextOutA)(PROC)g_TextOutA)(hdc,x,y,IpString,c);
return?iResult;
}
C. location matches
In the parameter of alternative functions Hook_TextOutA, lpString is the literal of wanting output screen.And x, y are x, the y coordinate figure in the upper left corner of this character string.Utilize the GetTextExtentPoint32W function can obtain the size of single character in the current string, thereby can calculate the rectangle frame coordinate of whole character string.Code is as follows:
if(g_ptCurrentPoint.x>=RectWord.left?&&?g_ptCurrentPoint.x<=
RectWord.right?&&?g_ptCurrentPoint.y>=RectWord.top&&
g_ptCurrentPoint.x<=RectWord.bottom)
{
// mouse is in the current string, can export or other operations it
}
It more than is the specific implementation process of screen word-selecting.
Step 3: draw speech and get speech
Drawing speech generally has three actions, and promptly left mouse button is pressed, pulled, left button upsprings.Drawing that speech gets in the speech mainly is exactly operation to clipbook.When the mouse hook captured left mouse button and upsprings message WM_LBUTTONUP, program was carried out following operation,
A. preserve the content on the clipbook
Use some system functions and can realize the extraction of Contents of clipboard.
If (OpenClipboard (NULL)) // open clipbook
{
HANDLE hClipboardData=GetClipboardData (CF_TEXT); // obtain content
Char*tempc=(char*) GlobalLock (hClipboardData); // locking
G_oldString=tempc; // preservation content
GlobalUnlock (hClipboardData); // unlock
CloseClipboard();
}
B. simulate the Ctrl+C operation
Call the keybd_event function and can realize the button simulated operation:
keybd_event(VK_CONTROL,MapVirtualKey(VK_CONTROL,0),0,0);
keybd_event(′C′,MapVirtualKey(′C′,0),0,0);
keybd_event(′C′,MapVirtualKey(′C′,0),KEYEVENTF_KEYUP,0);
keybd_event(VK_CONTROL,MapVirtualKey(VK_CONTROL,0),
KEYEVENTF_KEYU?P,0);
C. obtain to get the speech content
Here the same with the operation of the preservation Contents of clipboard of step 3 a, preserve and get the speech content, get speech and finish.
D. recover Contents of clipboard
After opening clipbook with OpenClipboard (), calling system function S etClipboardData () realizes the recovery of Contents of clipboard.
If (OpenClipboard (NULL)) // open clipbook
{
EmptyClipboard (); // empty clipbook
SetClipboardData (g_oldString); // be provided with and be all original content in the clipbook
CloseClipboard();
}
Above step must be carried out rapidly after receiving mouse WM_LBUTTONUP message, too much all the other operations can not intert in the centre, otherwise recover the Contents of clipboard overlong time, might cause the user to duplicate, paste operation is too fast and situation that Contents of clipboard does not also have enough time to be recovered occurs, paste functionality is affected.

Claims (1)

1. one kind has the screen word-selecting implementation method of drawing the speech function, it is characterized in that may further comprise the steps:
Step 1: overall mouse hook is installed
In the dll program of computer equipment Windows operating system, utilize the SetWindowsHookEx api function to load overall mouse hook, be used to catch each message of mouse; When the mouse hook captured mouse stop message WM_MOUSEHOVER, program was carried out the screen word-selecting operation, wherein, the residence time of described WM_MOUSEHOVER, can set according to user's custom; When the mouse hook captured left mouse button and upsprings message WM_LBUTTONUP, program was carried out and is drawn a speech and get the speech operation;
Step 2: screen word-selecting
Surpass the residence time that the user sets when the time of mouse-over, after the mouse hook of installation captured mouse stop message WM_MOUSEHOVER, program was carried out following operation,
A. repaint window
Obtain the coordinate data of mouse pointer current location on display by described mouse hook, and these data are saved in the internal memory of computer equipment, according to coordinate data, under mouse position, choose the micro rectangle frame of a 1px * 1px, utilize api function InvalidateRect to send and repaint message, repaint window to this rectangle frame;
B. carry API hook is intercepted and captured api function
When the Windows of computer equipment system receives when repainting message, the operating system of bottom ExtTextOutW, ExtTextOutA, these api functions of TextOutW, TextOutA among the calling system dynamic link library GDI32.dll is immediately carried out literal output, this seasonal program carry API hook, intercept and capture process calling by the API hook to above-mentioned api function, obtain the parameter of this api function, thereby realize seizure output string;
C. location matches
After capturing output string, calculate the coordinate figure on the border of this character string place rectangle frame, then the current mouse coordinates position of storing in the calculator memory and the boundary coordinate of this rectangle frame are compared, if mouse position is in rectangle frame, prove that this character string is exactly the current character string pointed of mouse, directly output gets final product; Otherwise will not export;
Step 3: draw speech and get speech
When the mouse hook captured left mouse button and upsprings message WM_LBUTTONUP, program was carried out following operation,
A. preserve the content on the clipbook
In program, use the OpenClipboard function and open system clipboard, obtain content of text data on the clipbook by the GetClipboardData function again, and it is saved in the internal memory of computing machine, define its variable g_oldString by name, call CloseClipboard functional relationships closed system clipbook again;
B. simulate the Ctrl+C operation
After the content of having preserved on the clipbook, routine call keybd_event function is simulated " Ctrl " and " C " key respectively and is pressed, the operation of promptly once duplicating, and the word content data that mouse is drawn speech replace original content-data on the clipbook;
C. obtain to get the speech content
With above-mentioned step 3 a, use described OpenClipboard function once more and open clipbook, utilize the GetClipboardData function that content of text data wherein are saved in the internal memory of computing machine, so that in application program, use; Call described CloseClipboard functional relationships closed system clipbook again;
D. recover Contents of clipboard
Use described OpenClipboard function and open clipbook, utilize the SetClipboardData function that the g_oldString variate-value that is kept among the step 3 a in the calculator memory is write in the clipbook, be used to recover original content on the clipbook; Call described CloseClipboard functional relationships closed system clipbook at last.
CN 201010590534 2010-12-07 2010-12-07 Screen word snatching realization method with word dragging function Active CN102043623B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 201010590534 CN102043623B (en) 2010-12-07 2010-12-07 Screen word snatching realization method with word dragging function

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 201010590534 CN102043623B (en) 2010-12-07 2010-12-07 Screen word snatching realization method with word dragging function

Publications (2)

Publication Number Publication Date
CN102043623A true CN102043623A (en) 2011-05-04
CN102043623B CN102043623B (en) 2013-05-29

Family

ID=43909782

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 201010590534 Active CN102043623B (en) 2010-12-07 2010-12-07 Screen word snatching realization method with word dragging function

Country Status (1)

Country Link
CN (1) CN102043623B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103440193A (en) * 2013-09-12 2013-12-11 广东电子工业研究院有限公司 Method for quickly recording selected information
CN106250374A (en) * 2016-08-05 2016-12-21 Tcl集团股份有限公司 One takes word interpretation method and system
CN106940847A (en) * 2017-03-10 2017-07-11 福建升腾资讯有限公司 A kind of method for the business information and expanded application for obtaining business simulating system
CN109684113A (en) * 2018-12-30 2019-04-26 深圳钱客多信息科技有限公司 A kind of cash register system interconnection method based on windows message and Hook mechanism
CN111866254A (en) * 2020-07-31 2020-10-30 广东佳米科技有限公司 Speed dialing system for intelligently identifying word stroke and implementation method thereof

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1691006A (en) * 2004-04-23 2005-11-02 千乡万才科技(中国)有限公司 Method and system for inquiring word explanation of literal information
CN101266534A (en) * 2008-03-26 2008-09-17 宇龙计算机通信科技(深圳)有限公司 Mobile terminal screen word-selecting method, system and mobile terminal

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1691006A (en) * 2004-04-23 2005-11-02 千乡万才科技(中国)有限公司 Method and system for inquiring word explanation of literal information
CN101266534A (en) * 2008-03-26 2008-09-17 宇龙计算机通信科技(深圳)有限公司 Mobile terminal screen word-selecting method, system and mobile terminal

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103440193A (en) * 2013-09-12 2013-12-11 广东电子工业研究院有限公司 Method for quickly recording selected information
CN103440193B (en) * 2013-09-12 2016-07-13 广东电子工业研究院有限公司 A kind of fast recording chooses the method for information
CN106250374A (en) * 2016-08-05 2016-12-21 Tcl集团股份有限公司 One takes word interpretation method and system
CN106250374B (en) * 2016-08-05 2021-05-18 Tcl科技集团股份有限公司 Word-taking translation method and system
CN106940847A (en) * 2017-03-10 2017-07-11 福建升腾资讯有限公司 A kind of method for the business information and expanded application for obtaining business simulating system
CN109684113A (en) * 2018-12-30 2019-04-26 深圳钱客多信息科技有限公司 A kind of cash register system interconnection method based on windows message and Hook mechanism
CN111866254A (en) * 2020-07-31 2020-10-30 广东佳米科技有限公司 Speed dialing system for intelligently identifying word stroke and implementation method thereof
CN111866254B (en) * 2020-07-31 2021-08-31 广东佳米科技有限公司 Speed dialing system for intelligently identifying word stroke and implementation method thereof

Also Published As

Publication number Publication date
CN102043623B (en) 2013-05-29

Similar Documents

Publication Publication Date Title
JP6431119B2 (en) System and method for input assist control by sliding operation in portable terminal equipment
US11061661B2 (en) Image based method and system for building object model and application states comparison and graphic-based interoperability with an application
KR102309175B1 (en) Scrapped Information Providing Method and Apparatus
US10740123B2 (en) Method and system for accessing table content in a digital image of the table
US20150123988A1 (en) Electronic device, method and storage medium
CN102043623B (en) Screen word snatching realization method with word dragging function
EP3113009A1 (en) Continuous recognition of multi-touch gestures
US20140359538A1 (en) Systems and methods for moving display objects based on user gestures
US20110252316A1 (en) Translating text on a surface computing device
CN111857508B (en) Task management method and device and electronic equipment
US20160321238A1 (en) Electronic device, method and storage medium
CN112954046B (en) Information transmission method, information transmission device and electronic equipment
EP4030749A1 (en) Image photographing method and apparatus
US20210311723A1 (en) Method and system for providing image-based interoperability with an application
CN106919326A (en) A kind of image searching method and device
WO2023087934A1 (en) Voice control method, apparatus, device, and computer storage medium
CN104102704A (en) System control displaying method and system control displaying device
CN104020853A (en) Kinect-based system and method for controlling network browser
CN103593052A (en) Gesture capture method based on Kinect and OpenNI
Singh et al. Data capturing process for online Gurmukhi script recognition system
CN107402673A (en) A kind of global search method, terminal and computer-readable recording medium
WO2016101768A1 (en) Terminal and touch operation-based search method and device
CN112287131A (en) Information interaction method and information interaction device
CN105072099B (en) One checks electronic graph-text approaches to IM and system
CN110378841A (en) Display processing method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant