参考我之前的问题,现在我有这个公式:
X := Round((X * ResolutionX) / Image1.Width);
Y := Round((Y * ResolutionY) / Image1.Height); // where ResolutionX and ResolutionY is Client screen resolution.
将鼠标点击坐标发送到远程屏幕;准确且工作正常,除非我希望将点击发送到某个窗口的特定句柄,否则点击不会发生在确切的位置,例如:
var
Title: array [0 .. 255] of Char;
begin
GetWindowText(GetForegroundWindow, Title, 255);
if Title <> '' then
begin
if ContainsStr(string(Title), '- Google Chrome') then
begin
WindowHandle := FindWindow(nil, PChar(string(Title))); // works fine to this handle.
WindowHandle := FindWindowEx(WindowHandle, 0, 'Chrome_RenderWidgetHostHWND', nil); // not works with this, click have a distance of exaclty local.
end;
end;
end;
接收鼠标点击:
PostMessage(WindowHandle, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(PosX, PosY));
PostMessage(WindowHandle, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(PosX, PosY));
有什么解决办法吗?