Automatic Mouse move code every 10 mintues

Mars1702
NewLounger
Posts: 3
Joined: 01 May 2020, 19:42

Automatic Mouse move code every 10 mintues

Post by Mars1702 »

Hello,
I am new here...

My company laptop is closing every 15 minutes and it is not possible to change this in windows 10 because company blocked this.

Who can help me with a code for access to move the mouse pointer every 10 minutes?
I found this link:
https://social.msdn.microsoft.com/Forum ... m=exceldev" onclick="window.open(this.href);return false;

but this doesn't work, maybe i do something wrong

Who can help me...?

Greetings Mars

User avatar
HansV
Administrator
Posts: 78229
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Automatic Mouse move code every 10 mintues

Post by HansV »

Welcome to Eileen's Lounge!

1) In the Visual Basic Editor, insert a new module.
Copy the following code into it (this is from the MSKB article referred to in the MSDN forum topic):

Code: Select all

Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long
' Access the GetCursorPos function in user32.dll
Declare Function SetCursorPos Lib "user32" _
(ByVal x As Long, ByVal y As Long) As Long

' GetCursorPos requires a variable declared as a custom data type
' that will hold two integers, one for x value and one for y value
Type POINTAPI
   X_Pos As Long
   Y_Pos As Long
End Type
2) Back in Access, on the Create tab of the ribbon, click Form Design.
Place two command buttons on it:

a) A button named cmdStart, with caption Move Cursor. The On Click event procedure for this button:

Code: Select all

Private Sub cmdStart_Click()
    ' Move cursor every 10 minutes
    Me.TimerInterval = 10 * 60 * 1000
End Sub
b) A button named cmdStop with caption Stop Moving. The On Click event procedure for this button:

Code: Select all

Private Sub cmdStart_Click()
    ' Setting the interval to 0 stops the timer
    Me.TimerInterval = 0
End Sub

Finally, create an On Timer event procedure for the form itself:

[code]Private Sub Form_Timer()
    Dim Hold As POINTAPI
    GetCursorPos Hold
    SetCursorPos Hold.X_Pos + 30, Hold.Y_Pos
    SetCursorPos Hold.X_Pos, Hold.Y_Pos
End Sub
You won't see anything, because the cursor is moved 30 points to the right, then immediately back. But it does move.
The form should remain open.
Best wishes,
Hans

Mars1702
NewLounger
Posts: 3
Joined: 01 May 2020, 19:42

Re: Automatic Mouse move code every 10 mintues

Post by Mars1702 »

Hello Hans,

Sorry i think i do something wrong. (just amateur)
Can i send you the database with form?

greetings

Marcel

User avatar
HansV
Administrator
Posts: 78229
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Automatic Mouse move code every 10 mintues

Post by HansV »

You can attach a zipped copy of the database (without sensitive/proprietary data) to a reply (max size 250 KB).

If you'd rather not attach a file here, you can send it to hans dot vogelaar at gmail dot com.
Best wishes,
Hans