調(diào)用api
為凌源等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及凌源網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為做網(wǎng)站、網(wǎng)站建設(shè)、凌源網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
在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 '模擬鼠標(biāo)左鍵按下
Public Const MOUSEEVENTF_LEFTUP = H4 ’模擬鼠標(biāo)左鍵釋放
Public Const MOUSEEVENTF_MIDDLEDOWN = H20 '模擬鼠標(biāo)中間鍵按下
Public Const MOUSEEVENTF_MIDDLEUP = H40 '模擬鼠標(biāo)中間鍵釋放
Public Const MOUSEEVENTF_RIGHTDOWN = H8 '模擬鼠標(biāo)右鍵按下
Public Const MOUSEEVENTF_RIGHTUP = H10 '模擬鼠標(biāo)右鍵釋放
Public Const MOUSEEVENTF_MOVE = H1 '模擬鼠標(biāo)指針移動(dòng)
例:
mouse_event MOUSEEVENTF_LEFTDOWN,10,10,0,0
'在(10,10)模擬鼠標(biāo)左鍵按下
將RTF的Padding設(shè)置比較大,例如10,此時(shí)我發(fā)現(xiàn)鼠標(biāo)移動(dòng)到RTF的邊緣部分的時(shí)候(不超過(guò)Padding的范圍),滾動(dòng)條就能夠顯示,一旦鼠標(biāo)移動(dòng)到Content里面的時(shí)候,滾動(dòng)條就不顯示
1、滾動(dòng)條分為水平滾動(dòng)條(HSCROLLBAR)和垂直滾動(dòng)條(VSCROLLBAR)兩種,可以作為輸入設(shè)備或者速度、數(shù)量的指示器來(lái)使用.
2、基本屬性:object.max[=value],object.min[=value],最大最小范圍 object.value[=value],
幾乎找不到真正VB.NET的api,都是自己將VB的api改成VB.NET的api,我的理解是聲明中對(duì)應(yīng)輸入是H的地方保留Long,其他的Long改成Integer,既然VB.NET連MSDN都找不到較全的api說(shuō)明,不保證api的用法在VB.NET其他版本中適用。
給你個(gè)好玩的例子,包括鼠標(biāo)的隱藏(Ctrl_↓)、顯示(Ctrl_↑),移動(dòng)、點(diǎn)擊
在Form1上放上2個(gè)TextBox,其中TextBox1.Multiline = True,并且面積大些,2個(gè)Button,運(yùn)行后在TextBox1中點(diǎn)擊一下會(huì)記錄位置,移開(kāi)鼠標(biāo),點(diǎn)擊移動(dòng)或點(diǎn)擊Button,可模擬在TextBox1中的點(diǎn)擊
Public Class Form1
Public My_MousePosition As Point
'模擬鼠標(biāo)移動(dòng)、點(diǎn)擊
Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
'定義光標(biāo)的位置
Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Integer, ByVal y As Integer) As Integer
'鼠標(biāo)的隱藏
Declare Function ShowCursor Lib "user32" Alias "ShowCursor" (ByVal bShow As Integer) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Multiline = True
Button1.Text = "點(diǎn)擊"
Button2.Text = "移動(dòng)"
Me.KeyPreview = True
End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.Control And e.KeyCode = Keys.Down Then ShowCursor(0)
If e.Control And e.KeyCode = Keys.Up Then ShowCursor(1)
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
TextBox2.Text = MousePosition.X " " MousePosition.Y
End Sub
Private Sub TextBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseClick
My_MousePosition = MousePosition
TextBox1.Text = My_MousePosition.X " " My_MousePosition.Y vbCrLf
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SetCursorPos(My_MousePosition.X, My_MousePosition.Y)
mouse_event(H2, 0, 0, 0, 0)
mouse_event(H4, 0, 0, 0, 0)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SetCursorPos(My_MousePosition.X, My_MousePosition.Y)
End Sub
End Class
其中
mouse_event Lib "user32" (ByVal dwFlags As Long
的dwFlags的代碼是
Const MOUSEEVENTF_LEFTDOWN = H2
Const MOUSEEVENTF_LEFTUP = H4
Const MOUSEEVENTF_MIDDLEDOWN = H20
Const MOUSEEVENTF_MIDDLEUP = H40
Const MOUSEEVENTF_MOVE = H1
Const MOUSEEVENTF_ABSOLUTE = H8000
Const MOUSEEVENTF_RIGHTDOWN = H8
Const MOUSEEVENTF_RIGHTUP = H10