我现一点头绪都没?望高手能指点一下. 急!!
解决方案 »
- 公司买了很多套Delphi2006
- 急救
- 关于AddItem的问题,在线等,成功立即结帖!
- 登錄窗口與主窗口的問題:
- 请问锁屏技术如何实现?请高手指点。
- 怎样让程序最小化后到状态栏中?************************************************************************
- 请问怎么禁止屏保的运行
- ---->还是关于DVD的问题---->有关心DVD播放和VOD点播系统的大侠请进-->分少我可再加
- zswang(伴水)(需要充充电),KingRong群侠们请进! 送上红包!
- 用sql统计的问题
- 提个简单的问题,动态数组初始化,马上给分
- 跪求GIF处理方法……
现想用delphi做一个新软件,想用上面捕获的内容来激活这个新软件,并做相关的查询.就像类似金山词霸的功能.
var
pos :Tpoint;
handle:hwnd;
begin
GetCursor(pos);
handle:=windowfrompoint(pos);//得到坐标点句柄
end;
接下来用WM_GetText消息就可以了,具体我懒的打了,自己看消息的用法!
Hook就更强了
问:
如何取得鼠标位置的文字
比如鼠标在记事本窗口上,并且在WORD的位置,我怎么得到"word"
我知道可以得到NOTEPAD窗口的文字,但是如果打开的是10M的文件,难道
我还要先复制到内存然后来找?
即使我知道了哪个缓冲区,又怎么知道鼠标指的是哪个字呢
DOS到好办,WINDOWS下突然不知道咋办了
________________________________
|无标题-1 |
--------------------------------
| how to get the word ... |
| $ |
| |
|______________________________|
答:Enabling Your Wish and the Needs of Others, Too
Dear Dr. GUI,
How can I grab the text that lies beneath the cursor, independent of the application that the text occurs in?I am using Visual C++, and, ideally, I would like functionality similar to that found in VC's debugger: When the cursor is placed over a variable, information relevant to the variable is displayed in a box after a short delay, rather like a tool tip.I have seen translation software give an immediate translation of the word under the cursor, irrespective of the application in which the word resides. How are they doing it? Is it done by using Optical Character Recognition (OCR)? Or is there a more elegant method using the Win32 API?Thanks in advance,Henry BrightonDr. GUI replies:
Wow, Henry. This turns out to be really interesting because currently there is no single Microsoft Win32® API to get the text underneath the cursor for all Windows-based applications. However, you can get this information for most Windows applications by using the Microsoft Active Accessibility Software Development Kit (SDK).
.....
var
X, Y, L: Integer;
S: string;
begin
Result := '';
if not Assigned(mEdit) then Exit;
with mEdit do try
S := Text;
L := Length(S);
X := SendMessage(Handle, EM_CHARFROMPOS, 0, MAKELPARAM(2, 2));
X := X and $0000FFFF;
Y := SendMessage(Handle, EM_CHARFROMPOS, 0, MAKELPARAM(ClientWidth - 4, 2));
Y := Y and $0000FFFF;
for X := X to Y - 1 do if (Y >= 0) and (X < L) then
Result := Result + S[X + 1];
except
Result := '';
end;
end;
{--------------------------------------------------------------------}
function MemoVisibleText(mMemo: TMemo; mStrings: TStrings): Boolean;
var
I, X, Y: Integer;
L, H, W: Integer;
S: string;
T: string;
begin
Result := False;
if (not Assigned(mMemo)) or (not Assigned(mStrings)) then Exit;
with TControlCanvas.Create do try
Control := mMemo;
H := TextHeight('|');
finally
Free;
end;
mStrings.Clear;
with mMemo do try
S := Text;
L := Length(S);
W := ClientWidth;
for I := 0 to (ClientHeight div H) - 1 do
begin
X := SendMessage(Handle, EM_CHARFROMPOS, 0, MAKELPARAM(3, I * H + 2));
X := X and $0000FFFF;
Y := SendMessage(Handle, EM_CHARFROMPOS, 0, MAKELPARAM(5, I * H + 2));
Y := Y and $0000FFFF; if Abs(Y - X) > 1 then Inc(X);
if not ((X = 0) or ((X < L) and (S[X - 1] in [#13, #10]))) then Inc(X); Y := SendMessage(Handle, EM_CHARFROMPOS, 0, MAKELPARAM(W - 2, I * H + 2));
Y := Y and $0000FFFF;
T := '';
for X := X to Y - 1 do if (Y >= 0) and (X < L) then
T := T + S[X + 1];
mStrings.Add(T);
end;
except
Exit;
end;
Result := True;
{--------------------------------------------------------------------}//调用示例
procedure TForm1.Button1Click(Sender: TObject);
begin
MemoVisibleText(Memo1, Memo2.Lines);
end;
{--------------------------------------------------------------------}
procedure TForm1.Button2Click(Sender: TObject);
begin
Caption := EditVisibleText(Edit1);
end;
随便写的,你看看用的上不?
至于挂钩子的问题另外说
钩子 扑捉鼠标消息 主要是这个POSTION 然后跟你的目标去比较 如果满足条件 则获取其内容......