你已經(jīng)有了“鼠標右鍵點擊的事件”
我們提供的服務有:網(wǎng)站設計制作、成都網(wǎng)站建設、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認證、武義ssl等。為成百上千企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務,是有科學管理、有技術(shù)的武義網(wǎng)站制作公司
說明你肯定已經(jīng)有了if e.button=windows.forms.mousebuttons.right then
你只需要找到這條語句,通常這句話應該在你的mouseclick事件中。
這條語句改成
if e.button=windows.forms.mousebuttons.left or e.button=windows.forms.mousebuttons.right then
就可以了!
^_^
Private Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private Const MOUSEEVENTF_LEFTDOWN = H2 ' 左鍵按下Private Const MOUSEEVENTF_LEFTUP = H4 ' 左鍵抬起
Private Const MOUSEEVENTF_MOVE = H1 ' 鼠標移動 在需要操作鼠標的地方調(diào)用如下兩句
Call Mouse_Event(MOUSEEVENTF_LEFTDown,10,10,0,0) '讓鼠標在10,10位置按下 Call Mouse_Event(MOUSEEVENTF_LEFTUP,10,10,0,0) '讓鼠標在10,10位置抬起這兩句代碼的操作就相當于我們單擊一次鼠標(先按下然后抬起)如果你需要做移動鼠標到某個位置的話,可以用這個API來實現(xiàn)(用Mouse_Event里的MOUSEEVENTF_MOVE需要將你的相對屏幕的坐標按屏幕65535X65535的比例進行轉(zhuǎn)換成絕對座標才可以) Private Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Long, ByVal y As Long) As Long
在需要移動鼠標的地方調(diào)用如下:Call SetCursorPos(10,10) '這里的10,10就是屏幕相對當前分辨率而言的絕對坐標
調(diào)用api
在Visual Baisc.net中的聲明:
Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Const MOUSEEVENTF_LEFTDOWN = H2 '模擬鼠標左鍵按下
Public Const MOUSEEVENTF_LEFTUP = H4 ’模擬鼠標左鍵釋放
Public Const MOUSEEVENTF_MIDDLEDOWN = H20 '模擬鼠標中間鍵按下
Public Const MOUSEEVENTF_MIDDLEUP = H40 '模擬鼠標中間鍵釋放
Public Const MOUSEEVENTF_RIGHTDOWN = H8 '模擬鼠標右鍵按下
Public Const MOUSEEVENTF_RIGHTUP = H10 '模擬鼠標右鍵釋放
Public Const MOUSEEVENTF_MOVE = H1 '模擬鼠標指針移動
例:
mouse_event MOUSEEVENTF_LEFTDOWN,10,10,0,0
'在(10,10)模擬鼠標左鍵按下
直接把消息發(fā)送給TextBox。
Dim x As Integer, y As Integer
x = 100
y = 100
PostMessage(TextBox1.Handle.ToInt32, WM_LBUTTONDOWN, MK_LBUTTON, MakeInteger(x, y))
PostMessage(TextBox1.Handle.ToInt32, WM_LBUTTONUP, MK_LBUTTON, MakeInteger(x, y))