-
June 14th, 2001, 06:28 AM
#1
get text under my mouse
Hi,
when i do a left click on my mouse, i need to copy the word under my mouse into clipboard.
I saw this on babylon translater, which allows the user to click on a word (in any application) and then shows a translation of this word.
How can i do this?
I use a system wide hook do receive the click message, then i use WindowFromPoint to get the HWND.
But how do i get the word under my mouse (WM_GETTEXT doesn't work)?
Thanks
Peter
-
June 14th, 2001, 06:39 AM
#2
Re: get text under my mouse
Use the hook function on WndProc()
in this case when you receive the WM_LBUTTONDOWN you know window handle and message GetWindowText()
for example
LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{
CWPSTRUCT* pWnd = (CWPSTRUCT*)lParam;
switch(pWnd->message)
{
case WM_LBUTTONDOWN:
{
int iLen = GetWindowTextLength(pWnd->hwnd) + 1;
LPTSTR s = (LPTSTR)malloc(iLen);
GetWindowText(pWnd->hwnd, s, iLen);
////......
free(s);
}
}
return CallNextHookEx(NULL, nCode, wParam, lParam);
}
Good luck.
constructor@rambler.ru
-
June 14th, 2001, 06:44 AM
#3
Re: get text under my mouse
See AccessibleObjectFromPoint
Rating isn't important...But gurus respect it and keep high
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|