单击Command1时鼠标会到(500,500)这个点作鼠标左键单击动作代码如下:
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private 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)
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Sub Command1_Click()
SetCursorPos 500, 500 '这里可以改成你的位置
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 '鼠标按下
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 '鼠标弹起
End Sub
声明
Declare Function GetPrivateProfileString& Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String)
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)
Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
程序中
SetCursorPos 455, 234
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0&, 0&, 0&, 0& '模拟鼠标点击
如果要模拟键盘操作就换一个函数
换成keyboard_event
我就用baidu.com代替你的软件吧,可以吧 呵呵
Private Sub Form_Load()
Label1.Left = 455
Label1.Height = 234
Label1.Visible = True
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Shell "explorer.exe http://baidu.com"
End Sub
dgdgdg