FahadTiger
Member
- Local time
- Today, 04:55
- Joined
- Jun 20, 2021
- Messages
- 115
Hi experts.. I get some code below from CHAT-GPT to close form after 10 second when mouse not move
is there any suggest ..thanks
Private Declare PtrSafe Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Private m_x As Long
Private m_y As Long
Private m_TimeElapsed As Double
Private m_StopWatchStarted As Boolean
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
m_x = X
m_y = Y
If Not m_StopWatchStarted Then
m_StopWatchStarted = True
Timer.Enabled = True
End If
End Sub
Private Sub Timer_Timer()
m_TimeElapsed = m_TimeElapsed + Timer.Interval / 1000
If m_TimeElapsed >= 10 Then
Timer.Enabled = False
m_StopWatchStarted = False
m_TimeElapsed = 0
Me.Close
End If
End Sub
is there any suggest ..thanks
Private Declare PtrSafe Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Private m_x As Long
Private m_y As Long
Private m_TimeElapsed As Double
Private m_StopWatchStarted As Boolean
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
m_x = X
m_y = Y
If Not m_StopWatchStarted Then
m_StopWatchStarted = True
Timer.Enabled = True
End If
End Sub
Private Sub Timer_Timer()
m_TimeElapsed = m_TimeElapsed + Timer.Interval / 1000
If m_TimeElapsed >= 10 Then
Timer.Enabled = False
m_StopWatchStarted = False
m_TimeElapsed = 0
Me.Close
End If
End Sub