Hi all.
I have found the following code which should help to stop my computer automatically locking, by moving the cursor using the Form's Timer.
I am unsure where I should place the code up until the End Type. I'm not familar with how modules work, so I don't know whether it's meant to go in a module.
Could anybody help with this please?
I have found the following code which should help to stop my computer automatically locking, by moving the cursor using the Form's Timer.
I am unsure where I should place the code up until the End Type. I'm not familar with how modules work, so I don't know whether it's meant to go in a module.
Could anybody help with this please?
Code:
Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare PtrSafe Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare PtrSafe Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Form_Timer()
Dim p As POINTAPI
' Get the current mouse position
GetCursorPos p
' Move the mouse cursor slightly to the right
SetCursorPos p.x + 1, p.y
' Wait a brief moment
Sleep 50
' Move the mouse cursor back to the original position
SetCursorPos p.x, p.y
End Sub