vb 如何点击某按钮,鼠标移动到窗体内某位置?

2024-10-30 07:34:33
推荐回答(3个)
回答1:

如果不嫌麻烦的话,可以这样:
1、读取窗体内部宽度W1、高度H1。
2、获取当前屏幕分辨率Xp、Yp。
3、读取需要跳转的X、Y坐标。
4、X1=(W1/Xp)*x
5、求的Y1
6、执行光标设置命令,就可以设置到你窗体的指定位置了

回答2:

Option Explicit

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 Text1.Text +Me.left\15, Text2.Text+me.top\15
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub

回答3:

我不知道写代码,不过用录制的办法,又快又好啊