AW: Userform / Arbeitsmappe bei Inaktivität schließen
22.06.2024 23:58:57
volti
Hallo,
hier eine Idee dazu....
Code:
' In ein allgemeines Modul
Public Declare PtrSafe Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Declare PtrSafe Function SetTimer Lib "user32" ( _
ByVal hwnd As LongPtr, ByVal nIDEvent As LongPtr, _
ByVal uElapse As Long, ByVal lpTimerFunc As LongPtr) As LongPtr
Public Declare PtrSafe Function KillTimer Lib "user32" ( _
ByVal hwnd As LongPtr, ByVal nIDEvent As LongPtr) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Public PT As POINTAPI, PTOLD As POINTAPI
Public hTimer As LongPtr
Public Sub UFCallback()
GetCursorPos PT
If (PT.x + PT.y) = (PTOLD.x + PTOLD.y) Then Unload UserForm1
PTOLD = PT
End Sub
Sub Test()
UserForm1.Show
End Sub
' In Userformmodul
Private Sub UserForm_Initialize()
GetCursorPos PTOLD
hTimer = SetTimer(0&, 0&, 60000, AddressOf UFCallback)
End Sub
Private Sub UserForm_Terminate()
KillTimer 0&, hTimer
MsgBox "Jetzt die Mappe schließen!"
End Sub
_________________________
viele Grüße aus Freigericht 😊
Karl-Heinz