VB鼠标怎么单击
我想做个跟按键精灵类似的命令,哪位VB高手能指点12,我只想会3条语句1:在VB中打上什么可以让鼠标在电脑的某个坐标单击?2:在VB中怎么让他找到某个图片则什么什么,或者...
我想做个跟按键精灵类似的命令,哪位VB高手能指点1 2, 我只想会3条语句
1:在VB中打上什么可以让鼠标在电脑的某个坐标单击?
2:在VB中怎么让他找到某个图片则什么什么,或者颜色!
3:在VB中怎么让他模拟按键盘上的键?
还希望VB高手解答下 谢谢! 展开
1:在VB中打上什么可以让鼠标在电脑的某个坐标单击?
2:在VB中怎么让他找到某个图片则什么什么,或者颜色!
3:在VB中怎么让他模拟按键盘上的键?
还希望VB高手解答下 谢谢! 展开
展开全部
m1.frm替换你的文件,然后重开工程.
因为不知道你用在哪儿,所以没法测试.马马虎虎应该没什么错啦.
------------
22:09补充:设计的是用两个按钮启动两个功能.
第一个问题你可以唯毕删除
Private Sub Command2_Click() 以及以下的几行(不跳行)
同样的程序代码,删除Private Sub Command1_Click() 以及以下的几行(不跳行)
就是完成第二个功能的代码丛念.
---------------------------------------------------------
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
Begin VB.Timer Timer2
Left = 3960
Top = 2640
End
Begin VB.CommandButton Command2
Caption = "Command2"
Height = 495
Left = 3240
TabIndex = 1
Top = 1440
Width = 1095
End
Begin VB.Timer Timer1
Interval = 50
Left = 3960
Top = 2040
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 3240
TabIndex = 0
Top = 240
Width = 1095
End
Begin VB.Line Line1
X1 = 2640
X2 = 4560
Y1 = 1080
Y2 = 1080
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
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)
Dim Option_Tag As Integer
Dim OnTest As Boolean
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
Private Sub Form_Load()
Timer1.Enabled = False
Timer2.Enabled = False
End Sub
Private Sub Command1_Click()
SendKeys "+N"渗山困, True
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 500, 500, 0, 0
mouse_event MOUSEEVENTF_RIGHTDOWN Or MOUSEEVENTF_RIGHTUP, 500, 500, 0, 0
End Sub
Private Sub Command2_Click()
Timer1.Interval = 1000
Timer1.Enabled = True
Timer2.Interval = 1500
Timer2.Enabled = True
End Sub
Private Sub Timer1_Timer()
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 253, 563, 0, 0
Timer1.Enabled = False
End Sub
Private Sub Timer2_Timer()
SendKeys "+B", True
Timer2.Enabled = False
End Sub
因为不知道你用在哪儿,所以没法测试.马马虎虎应该没什么错啦.
------------
22:09补充:设计的是用两个按钮启动两个功能.
第一个问题你可以唯毕删除
Private Sub Command2_Click() 以及以下的几行(不跳行)
同样的程序代码,删除Private Sub Command1_Click() 以及以下的几行(不跳行)
就是完成第二个功能的代码丛念.
---------------------------------------------------------
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
Begin VB.Timer Timer2
Left = 3960
Top = 2640
End
Begin VB.CommandButton Command2
Caption = "Command2"
Height = 495
Left = 3240
TabIndex = 1
Top = 1440
Width = 1095
End
Begin VB.Timer Timer1
Interval = 50
Left = 3960
Top = 2040
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 3240
TabIndex = 0
Top = 240
Width = 1095
End
Begin VB.Line Line1
X1 = 2640
X2 = 4560
Y1 = 1080
Y2 = 1080
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
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)
Dim Option_Tag As Integer
Dim OnTest As Boolean
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
Private Sub Form_Load()
Timer1.Enabled = False
Timer2.Enabled = False
End Sub
Private Sub Command1_Click()
SendKeys "+N"渗山困, True
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 500, 500, 0, 0
mouse_event MOUSEEVENTF_RIGHTDOWN Or MOUSEEVENTF_RIGHTUP, 500, 500, 0, 0
End Sub
Private Sub Command2_Click()
Timer1.Interval = 1000
Timer1.Enabled = True
Timer2.Interval = 1500
Timer2.Enabled = True
End Sub
Private Sub Timer1_Timer()
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 253, 563, 0, 0
Timer1.Enabled = False
End Sub
Private Sub Timer2_Timer()
SendKeys "+B", True
Timer2.Enabled = False
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
鼠标单击的动作在Visual Basic程序中是被分解开来的,比如鼠标单击TextBox,鼠标单击槐巧Label,鼠标单击Button按钮等动作。纳察
编写鼠标单击的动作也是针对鼠标单击某一个控件进行的,比如鼠标单击Button的动作,可以双击Button控件就直接进入了鼠标单击Button控件的动作事件编写,如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
洞明茄 msgbox("鼠标左键单击事件发生")
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询