vb 从零开始(五)
前边谈了模拟键盘,下面说说模拟鼠标。
--------------------------------------------------------------------------------------------------------------------------------------------------------
需要vbapi函数:
mouse_event←模拟一次鼠标事件
--------------------------------------------------------------------------------------------------------------------------------------------------------
相关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'鼠标左键按下
mouseeventf_leftup'鼠标松开
mouseeventf_rightdown'鼠标右键按下
mouseeventf_rightup'鼠标右键松开
--------------------------------------------------------------------------------------------------------------------------------------------------------
代码:
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
'这里是鼠标左键按下和松开两个事件的组合即一次单击
mouse_eventmouseeventf_leftdownmouseeventf_leftup,0,0,0,0
'模拟鼠标右键单击事件
mouse_eventmouseeventf_rightdownmouseeventf_rightup,0,0,0,0
'两次连续的鼠标左键单击事件构成一次鼠标双击事件
mouse_eventmouseeventf_leftdownmouseeventf_leftup,0,0,0,0
mouse_eventmouseeventf_leftdownmouseeventf_leftup,0,0,0,0