Sometimes, you just cannot ask to the IT department to disable screensaver or user lock screen, and personally i never understood why if we are dealing with virtualized machines, so you have to solve the problem somehow.
You can rely for sure on the LoginAgent VBO, which helps you to understand if the screen is locked and so you can login again, but if the screen is not locked, you can just move the mouse on the screen so the session remains alive.
I've tried some methods but only this worked, so in the global code you have to insert this piece of code
- <dllimport("user32.dll")>
- Private Shared Sub mouse_event(ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal dwData As Integer, ByVal dwExtraInfo As Integer)
- End Sub
- Private Const MOUSEEVENTF_MOVE As Integer = 1
- Private Const MOUSEEVENTF_LEFTDOWN As Integer = 2
- Private Const MOUSEEVENTF_LEFTUP As Integer = 4
- Private Const MOUSEEVENTF_RIGHTDOWN As Integer = 8
- Private Const MOUSEEVENTF_RIGHTUP As Integer = 16
- Private Const MOUSEEVENTF_MIDDLEDOWN As Integer = 32
- Private Const MOUSEEVENTF_MIDDLEUP As Integer = 64
- Private Const MOUSEEVENTF_ABSOLUTE As Integer = 32768
- Public Shared Sub Move(ByVal xDelta As Integer, ByVal yDelta As Integer)
- mouse_event(MOUSEEVENTF_MOVE, xDelta, yDelta, 0, 0)
- End Sub
- </dllimport("user32.dll")>
After that you can create an action (eg. MouseMove) which randomly moves the mouse into the screen
- Dim Randomizer As System.Random = New System.Random()
- Dim x As Integer = Randomizer.Next(1, 640)
- Dim y As Integer = Randomizer.Next(1, 480)
- Move(x, y)