VB坐标问题

来源:百度知道 编辑:UC知道 时间:2024/05/30 04:21:52
如何点击Command1 鼠标就会弹到x:0 y:0 也就是屏幕的中间 加我

Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long

Private Sub Command1_Click()
SetCursorPos Screen.Width / 15 / 2, Screen.Height / 15 / 2
End Sub

提示:屏幕1024*768是像素! 1象素=15缇 转换一下 即 Screen.Width / 15

可以调用API函数
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
设置X,Y坐标位置。

Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long

Private Sub Command1_Click()
SetCursorPos Screen.Width \ Screen.TwipsPerPixelX \ 2, Screen.Height \ Screen.TwipsPerPixelY \ 2
End Sub

按command1鼠标就移动到屏幕中心,不过屏幕中心坐标不是(0,0),屏幕左上角坐标才是(0,0)