mous.bas

来自「星子行主机控制系统用于主机管理,方便远程操作,通信等功能.更 方便用于局域网」· BAS 代码 · 共 77 行

BAS
77
字号
Attribute VB_Name = "shubiao"
Public Type POINTAPI
       X As Long
       Y As Long
End Type
Private Type RECT
      left As Long
      top As Long
      right As Long
      bottom As Long
End Type
Public Declare Function SwapMouseButton Lib "user32" (ByVal bSwap As Long) As Long
'交换按钮
'bswap为True时正常,为False时,互换
Public Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
'隐藏指针
'bShow为False时隐藏,为True时复原
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Public Declare Function ClientToScreen Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long
Public Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long

Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public 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)

Public Sub clipto(toctl As Object)
On Error Resume Next
Dim tmprect As RECT
Dim pt As POINTAPI
With toctl
     If TypeOf toctl Is Form Then
     tmprect.left = (.left \ Screen.TwipsPerPixelX)
     tmprect.top = (.top \ Screen.TwipsPerPixelY)
     tmprect.right = (.left + .Width) \ Screen.TwipsPerPixelX
     tmprect.bottom = (.top + .Height) \ Screen.TwipsPerPixelY
     ElseIf TypeOf toctl Is Screen Then
      tmprect.left = 0
      tmprect.top = 0
      tmprect.right = (.Width \ Screen.TwipsPerPixelX)
      tmprect.bottom = (.Height \ Screen.TwipsPerPixelY)
    Else
     pt.X = 0
     Call ClientToScreen(.hWnd, pt)
     tmprect.left = pt.X
     tmprect.top = pt.Y
     pt.X = .Width
     pt.Y = .Height
     Call ClientToScreen(.hWnd, pt)
     tmprect.bottom = pt.Y
     tmprect.right = pt.X
     End If
     
End With
Call ClipCursor(tmprect)

End Sub
'两点间移动
Public Sub movecursor(fromp As POINTAPI, top As POINTAPI)
Dim stepx As Long
Dim stepy As Long
Dim i, j As Long
stepx = stepy = 1
i = (top.X - fromp.X)
If i < 0 Then stepx = -1
i = (top.Y - fromp.Y)
If i < 0 Then stepy = -1
For i = fromp.X To top.X Step stepx
Call SetCursorPos(i, fromp.Y)
Sleep (1)
Next i
For i = fromp.Y To top.Y Step stepy
Call SetCursorPos(top.X, i)
Sleep (1)
Next i
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?