1,488
社区成员
发帖
与我相关
我的任务
分享Option Explicit
Private rcLast As RECT
Private EqualCount As Long
Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim hand As Long, rc As RECT
hand = FindWindow(vbNullString, "b")
If hand <> 0 Then
Debug.Print Now(), Timer1.Interval, EqualCount
Call GetWindowRect(hand, rc)
If EqualRect(rc, rcLast) = 0 Then
rcLast = rc
rc.Left = rc.Left * Screen.TwipsPerPixelX
rc.Right = rc.Right * Screen.TwipsPerPixelX
rc.Top = rc.Top * Screen.TwipsPerPixelY
rc.bottom = rc.bottom * Screen.TwipsPerPixelY
Me.Move rc.Left, rc.bottom, rc.Right - rc.Left
'有移动就减小定时间隔
EqualCount = 0
If Timer1.Interval <> 1 Then Timer1.Interval = 1
Else
If EqualCount < 100 Then
EqualCount = EqualCount + 1
If EqualCount = 100 Then '0.1 秒没移动就增大定时间隔
Timer1.Interval = 100
End If
End If
End If
Else
If Timer1.Interval <> 100 Then Timer1.Interval = 100
End If
End Sub
Private Sub Form_Load()
Dim hand, rt As Long
Dim rc As RECT
hand = FindWindow(vbNullString, "b")
If hand Then
rt = GetWindowRect(hand, rc)
rc.Left = rc.Left * Screen.TwipsPerPixelX
rc.Right = rc.Right * Screen.TwipsPerPixelX
rc.Top = rc.Top * Screen.TwipsPerPixelY
rc.Bottom = rc.Bottom * Screen.TwipsPerPixelY
If rt > 0 Then
Me.Move rc.Left, rc.Bottom, rc.Right - rc.Left
End If
End If
End Sub