首页 热点资讯 义务教育 高等教育 出国留学 考研考公

VB鼠标怎么单击

发布网友 发布时间:2022-04-23 07:14

我来回答

5个回答

热心网友 时间:2022-06-17 08:33

这些功能都可以通过Win32 API实现,使用VB本身的话只能实现部分功能。
1、获取屏幕对象,然后调用click事件,并传入坐标值
2、获取屏幕对象,然后获取当前图像,然后根据点可以看到颜色
3、发送键盘按键消息,或者获取对象之后调用keydown方法

热心网友 时间:2022-06-17 08:33

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 = 20
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 = 20
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

热心网友 时间:2022-06-17 08:34

    鼠标单击的动作在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

热心网友 时间:2022-06-17 08:34

是一个可视化编程软件

热心网友 时间:2022-06-17 08:35

VB是啥?

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com