前邊談了模擬鍵盤,下面說說模擬鼠標(biāo)。
--------------------------------------------------------------------------------------------------------------------------------------------------------
需要vbapi函數(shù):
mouse_event←模擬一次鼠標(biāo)事件
--------------------------------------------------------------------------------------------------------------------------------------------------------
相關(guān)api聲明:
mouse_event
privatedeclaresubmouse_eventlib"user32"(byvaldwflagslong,byvalaslong,byvalaslong,byvalcbuttonslong,byvaldwextrainfolong)
--------------------------------------------------------------------------------------------------------------------------------------------------------
定義變量:
constmouseeventf_leftdown=&h2
constmouseeventf_leftup=&h4
constmouseeventf_middledown=&h20
constmouseeventf_middleup=&h40
constmouseeventf_move=&h1
constmouseeventf_absolute=&h8000
constmouseeventf_rightdown=&h8
constmouseeventf_rightup=&h10
--------------------------------------------------------------------------------------------------------------------------------------------------------
mouseeventf_leftdown'鼠標(biāo)左鍵按下
mouseeventf_leftup'鼠標(biāo)松開
mouseeventf_rightdown'鼠標(biāo)右鍵按下
mouseeventf_rightup'鼠標(biāo)右鍵松開
--------------------------------------------------------------------------------------------------------------------------------------------------------
代碼:
privatedeclaresubmouse_eventlib"user32"(byvaldwflagslong,byvalaslong,byvalaslong,byvalcbuttonslong,byvaldwextrainfolong)
constmouseeventf_leftdown=&h2
constmouseeventf_leftup=&h4
constmouseeventf_middledown=&h20
constmouseeventf_middleup=&h40
constmouseeventf_move=&h1
constmouseeventf_absolute=&h8000
constmouseeventf_rightdown=&h8
constmouseeventf_rightup=&h10
'這里是鼠標(biāo)左鍵按下和松開兩個(gè)事件的組合即一次單擊
mouse_eventmouseeventf_leftdownmouseeventf_leftup,0,0,0,0
'模擬鼠標(biāo)右鍵單擊事件
mouse_eventmouseeventf_rightdownmouseeventf_rightup,0,0,0,0
'兩次連續(xù)的鼠標(biāo)左鍵單擊事件構(gòu)成一次鼠標(biāo)雙擊事件
mouse_eventmouseeventf_leftdownmouseeventf_leftup,0,0,0,0
mouse_eventmouseeventf_leftdownmouseeventf_leftup,0,0,0,0