在窗体上放个标签label1程序运行的时候移动鼠标,在鼠标的位置上显示出鼠标的坐标来。代码如下:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.Caption = "x=" & X & "y" & Y
Label1.Left = X
Label1.Top = Y
End Sub
上面的是在VB中的
我这个可以显示鼠标在桌面上的位置! 在VB窗口外也可以
你新建个模块 加入
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Type POINTAPI
x As Long
y As Long
End Type
加个timer控件 interval你自己看着办吧
添加下面代码到form1.frm
Private Sub Timer1_Timer()
Dim a As POINTAPI
GetCursorPos a
Label1.Caption = a.x
Label2.Caption = a.y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Cls
Print "x:" & X, "y:" & Y
End Sub