如何获得其他程序有焦点的控件的句柄
怎么获得其他程序有焦点的控件的句柄?
我用这段代码取出来的句柄不对啊
var
HWND: DWORD;
Pid: Integer;
begin
Sleep(2000);
HWND := GetForegroundWindow;
Pid := GetWindowThreadProcessId(HWND, nil);
if AttachThreadInput(Pid, GetCurrentThreadId, True) then
begin
HWND := GetFocus;
AttachThreadInput(Pid, GetCurrentThreadId, False);
ShowMessage(IntToStr(HWND));
end
else raise Exception.Create( 'Couldn ' 't Find Window! ');
end;
------解决方案--------------------
句柄取错没?
我用这段代码取出来的句柄不对啊
var
HWND: DWORD;
Pid: Integer;
begin
Sleep(2000);
HWND := GetForegroundWindow;
Pid := GetWindowThreadProcessId(HWND, nil);
if AttachThreadInput(Pid, GetCurrentThreadId, True) then
begin
HWND := GetFocus;
AttachThreadInput(Pid, GetCurrentThreadId, False);
ShowMessage(IntToStr(HWND));
end
else raise Exception.Create( 'Couldn ' 't Find Window! ');
end;
------解决方案--------------------
句柄取错没?