捕捉鼠标坐标.frm
来自「Windows API函数,希望大伙有用哦」· FRM 代码 · 共 37 行
FRM
37 行
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 1680
ClientLeft = 3060
ClientTop = 3795
ClientWidth = 3960
LinkTopic = "Form1"
ScaleHeight = 1680
ScaleWidth = 3960
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Type POINTAPI
X As Long
Y As Long
End Type
Dim Pt As POINTAPI
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Sub Form_Load()
SetCapture Me.hwnd
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
GetCursorPos Pt
Me.Cls
Me.Print "当前鼠标位置:" & "X= " + Str$(Pt.X) + " Y= " + Str$(Pt.Y)
If (Pt.X > 220 And Pt.X < 230) And (Pt.Y > 280 And Pt.Y < 290) Then
MsgBox " 这里有地雷 ! "
End If
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?