久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

Delphi編程模擬鼠標(biāo)操作

 獨(dú)孤求財(cái) 2012-03-20

Delphi編程模擬鼠標(biāo)操作

時(shí)間:2011-5-26來源:yang 作者: peng點(diǎn)擊: 126次

用Delphi編程模擬鼠標(biāo)操作
本實(shí)例介紹如何在自己的程序里面模擬鼠標(biāo)的常用操作,。
  首先啟動一個(gè)新的項(xiàng)目,,在空白的窗體上添加4個(gè)TButton組件。添加組件后的窗體如圖1所示,。

  圖1 添加組件后的窗體

  這4個(gè)按鈕分別用于模仿鼠標(biāo)的4個(gè)動作——移動鼠標(biāo)到指定位置,、左鍵單擊,、左鍵雙擊和右鍵單擊,。

  下面以鼠標(biāo)左鍵單擊為例來說明如何模擬鼠標(biāo)操作:

  procedure TForm1.btnLClickClick(Sender: TObject);
begin
 SetCursorPos(10,10);
 mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
 mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
end;

  首先需要通過SetCursorPos函數(shù)來設(shè)置需要單擊的坐標(biāo)。然后通過mouse_event (MOUSEEVENTF_LEFTDOWN,0,0,0,0)語句在(10,10)坐標(biāo)處按下鼠標(biāo)左鍵,。最后不要忘了通過mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0)語句釋放鼠標(biāo)左鍵,。

  雙擊的操作可以通過兩個(gè)連續(xù)的單擊來實(shí)現(xiàn);鼠標(biāo)移動的操作可以通過指定mouse_event 函數(shù)的第1個(gè)參數(shù)MOUSEEVENTF_MOVE,,第2個(gè)和第3個(gè)參數(shù)為左邊來實(shí)現(xiàn),;右鍵單擊和左鍵單擊的原理一致,只不過mouse_event函數(shù)中的參數(shù)分別替換為MOUSEEVENTF_RIGHTDOWN和MOUSEEVENTF_RIGHTUP,。

  程序代碼如下:

  unit Unit1;
interface
uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls;
type
 TForm1 = class(TForm)
 btnMove: TButton;
 btnLClick: TButton;
 btnLDClick: TButton;
 btnRClick: TButton;
 procedure btnMoveClick(Sender: TObject);
 procedure btnLClickClick(Sender: TObject);
 procedure btnLDClickClick(Sender: TObject);
 procedure btnRClickClick(Sender: TObject);
private
 { Private declarations }
public
 { Public declarations }
end;
var
 Form1: TForm1;
 implementation
 {$R *.dfm}
 procedure TForm1.btnMoveClick(Sender: TObject);
 begin
  mouse_event(MOUSEEVENTF_MOVE,100,100,0,0);
 end;
 procedure TForm1.btnLClickClick(Sender: TObject);
 begin
  SetCursorPos(10,10);
  mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
  mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
 end;
 procedure TForm1.btnLDClickClick(Sender: TObject);
 begin
  SetCursorPos(200,200);
  mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
  mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
  mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
  mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
 end;
 procedure TForm1.btnRClickClick(Sender: TObject);
 begin
  SetCursorPos(200,200);
  mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
  mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
 end;
end.
 

    本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲空間,,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn),。請注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多