一个应用软件,已经可以用autohotkey 知道里面的控件名字ahk_class TMainForm>>>>>>>>>>>>( Mouse Position )<<<<<<<<<<<<<
On Screen: 249, 321 (less often used)
In Active Window: 240, 250>>>>>>>>>( Now Under Mouse Cursor )<<<<<<<<
ClassNN: TBitBtn1
Text: 测试
怎样在 setforegroundwindow(findwindow(‘TMainForm’,NIL)); 切换到该应用后,将输入焦点设置在 classNN = TBitBtn1 的控件上?
On Screen: 249, 321 (less often used)
In Active Window: 240, 250>>>>>>>>>( Now Under Mouse Cursor )<<<<<<<<
ClassNN: TBitBtn1
Text: 测试
怎样在 setforegroundwindow(findwindow(‘TMainForm’,NIL)); 切换到该应用后,将输入焦点设置在 classNN = TBitBtn1 的控件上?
var
SrcThread, DstThread: Cardinal;
begin
SrcThread := GetCurrentThreadId;
DstThread := GetWindowThreadProcessId(hWnd); AttachThreadInput(SrcThread, DstThread, LongBool(True));
Result := (Windows.SetFocus(hWnd) <> 0);
AttachThreadInput(SrcThread, DstThread, LongBool(False));
end;
begin
if (Components[i] is TCSEdit) then
begin
if (Components[i] as TCSEdit).Name <> errStr then Continue;
if (Trim((Components[i] as TCSEdit).AsString) = '') and (Components[i] as TCSEdit).Visible then
begin
errStr := (Components[i] as TCSEdit).MsgLabel.Caption;
try
(Components[i] as TCSEdit).SetFocus;
except
ShowInfoEx('不能定位焦点-->'+errStr);
end;
errStr := errStr + ' 不能为空。';
msgBool := True;
Break;
end;
end;
end;