Option Explicit
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpSting As String, ByVal cch As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function GetWindowlong Lib "user32" Alias "GetWindowlongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_ID = (-12)
Private Const GWL_STYLE = (-16)
Private Const GWL_EXSTYLE = (-20)
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Command1_Click()
Timer1.Interval = Text4.Text
Timer1.Enabled = True
Text4.Enabled = False
Command1.Enabled = False
Command2.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
Text4.Enabled = True
Command1.enablel = True
Command2.enablel = False
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Command2.Enabled = False
End Sub
Private Sub Timer1_Timer()
Dim hwnd As Long
Dim pt As POINTAPI
Dim st As String
st = Space(256)
GetCursorPos pt
Text2.Text = pt.x
Text3.Text = pt.y
hwnd = WindowFromPoint(pt.x, pt.y)
GetWindowText hwnd, st, 256
Text1.Text = st
GetClassName hwnd, sl, 256
Text5.Text = st
Text6.Text = GetWindowlong(hwnd, GWL_ID)
Text7.Text = GetWindowlong(hwnd, GWL, Style)
Text8.Text = GetWindowlong(hwnd, GWL_EXSTYLE)
End Sub
这段代码是我从书上抄写下来的,不知道到哪错了老是运行不起来~!