程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> Visual Basic語言 >> VB綜合教程 >> VB從零開始編外掛(五)

VB從零開始編外掛(五)

編輯:VB綜合教程
前邊談了模擬鍵盤,下面說說模擬鼠標。
  --------------------------------------------------------------------------------------------------------------------------------------------------------
  需要VBAPI函數:
  mouse_event←模擬一次鼠標事件
  --------------------------------------------------------------------------------------------------------------------------------------------------------
  相關API聲明:
  mouse_event
  ↓
  PrivateDeclareSubmouse_eventLib"user32"(ByValdwFlagsAsLong,ByValdxAsLong,ByValdyAsLong,ByValcButtonsAsLong,ByValdwExtraInfoAsLong)
  --------------------------------------------------------------------------------------------------------------------------------------------------------
  定義變量:
  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"(ByValdwFlagsAsLong,ByValdxAsLong,ByValdyAsLong,ByValcButtonsAsLong,ByValdwExtraInfoAsLong)
  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_LEFTDOWNOrMOUSEEVENTF_LEFTUP,0,0,0,0
  '模擬鼠標右鍵單擊事件
  mouse_eventMOUSEEVENTF_RIGHTDOWNOrMOUSEEVENTF_RIGHTUP,0,0,0,0
  '兩次連續的鼠標左鍵單擊事件構成一次鼠標雙擊事件
  mouse_eventMOUSEEVENTF_LEFTDOWNOrMOUSEEVENTF_LEFTUP,0,0,0,0
  mouse_eventMOUSEEVENTF_LEFTDOWNOrMOUSEEVENTF_LEFTUP,0,0,0,0->

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved