My corporate environment imposes a 10 min inactivity timeout which wastes my time as I run both a production and a test computer. A few years ago I wrote a simple Excel VBA macro to jiggle the mouse one pixel every 5 min which worked great, but stopped working when I was moved from Windows 7 to Windows 10.

I'm now running Excel 2013 32 bit on Win 10 Pro 64 bit.

I'm using Windows API calls in my macro to simulate mouse and keyboard events, but Windows still locks my screen after 10 min. In addition to mouse moves, I've added mouse clicks and keyboard presses to my code.
I even have one version that does all of the following in a loop: visibly drags the current Excel window around the desktop, visibly toggles the caps lock key (my Dell keyboard has a lighted caps lock key that goes on and off), and visibly opens the Windows Start menu on my computer by placing the cursor on the Windows icon and sending a click. But Windows still locks my screen while this is running due to "inactivity".

The windows api calls I am using are:

Private Declare PtrSafe Function GetCursorPos Lib "user32.dll" (Point As POINTAPI) As Long

Private Declare PtrSafe Function SetCursorPos Lib "user32.dll" (ByVal x As Integer, ByVal y As Integer) As Long

Private Declare PtrSafe Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

Private Declare PtrSafe Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As LongPtr, ByVal dwExtraInfo As LongPtr)

Private Declare PtrSafe Function GetKeyboardState Lib "user32.dll" (ByVal lpKeyState As LongPtr) As Boolean

Private Declare PtrSafe Function SetKeyboardState Lib "user32.dll" (ByVal lpKeyState As LongPtr) As Boolean

Declare PtrSafe Function SetWindowPos Lib "user32" ( _
ByVal hwnd As LongPtr, _
ByVal hWndInsertAfter As LongPtr, _
ByVal x As Long, _
ByVal y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long

Declare PtrSafe Function FindWindow Lib "user32" _
Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As LongPtr

Private Sub SingleClick()
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub

Private Sub ToggleCapsLock(enabled As Boolean)
'Poll current keyboard state.
GetKeyboardState (VarPtr(keystate(0)))
If (Not keystate(VK_CAPSLOCK) And enabled) Or (keystate(VK_CAPSLOCK) And Not enabled) Then
'Send a keydown
keybd_event VK_CAPSLOCK, CapsLockScanCode, KEYEVENTF_EXTENDEDKEY, 0&
'Send a keyup
keybd_event VK_CAPSLOCK, CapsLockScanCode, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0&
End If
End Sub