delphi 后台模拟鼠标点击
procedureTForm1.Timer1Timer(Sender:TObject);varWindow:HWND;PHND:THandle;beginWindow:=...
procedure TForm1.Timer1Timer(Sender: TObject);
var
Window: HWND;
PHND: THandle;
begin
Window := findwindow(nil, pchar('未命名 - 画图'));
if Window <> 0 then
begin
SendMessage(Window, WM_LBUTTONDOWN, MK_LBUTTON, makelparam(300,300));
SendMessage(Window, WM_LBUTTONUP, MK_LBUTTON, makelparam(300,300));
end;
end;
这段代码怎么对画板窗口没反映了,错再哪里了?、 展开
var
Window: HWND;
PHND: THandle;
begin
Window := findwindow(nil, pchar('未命名 - 画图'));
if Window <> 0 then
begin
SendMessage(Window, WM_LBUTTONDOWN, MK_LBUTTON, makelparam(300,300));
SendMessage(Window, WM_LBUTTONUP, MK_LBUTTON, makelparam(300,300));
end;
end;
这段代码怎么对画板窗口没反映了,错再哪里了?、 展开
2个回答
展开全部
procedure TForm1.FormCreate(Sender:TObject);
function MyFindWindow:THandle;
const
A_szClassName:array[0..2] of PChar=(
'MSPaintApp',
'AfxFrameOrView42u',
'Afx:1000000:8'
);
var
i:Integer;
hLastWin:THandle;
begin
hLastWin:=FindWindow(A_szClassName[0],nil);
for i:=1 to 2 do
begin
hLastWin:=FindWindowEx(hLastWin,THandle(nil),
A_szClassName[i],nil);
end;
result:=hLastWin;
end;
var
h:THandle;
begin
h:=MyFindWindow();
SendMessage(h, WM_LBUTTONDOWN, MK_LBUTTON, makelparam(300,300));
SendMessage(h, WM_LBUTTONUP, MK_LBUTTON, makelparam(300,300));
end;
function MyFindWindow:THandle;
const
A_szClassName:array[0..2] of PChar=(
'MSPaintApp',
'AfxFrameOrView42u',
'Afx:1000000:8'
);
var
i:Integer;
hLastWin:THandle;
begin
hLastWin:=FindWindow(A_szClassName[0],nil);
for i:=1 to 2 do
begin
hLastWin:=FindWindowEx(hLastWin,THandle(nil),
A_szClassName[i],nil);
end;
result:=hLastWin;
end;
var
h:THandle;
begin
h:=MyFindWindow();
SendMessage(h, WM_LBUTTONDOWN, MK_LBUTTON, makelparam(300,300));
SendMessage(h, WM_LBUTTONUP, MK_LBUTTON, makelparam(300,300));
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询