Return to site

Blue Prism - KeepAlive Issue

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

  1. <dllimport("user32.dll")>
  2. 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)
  3. End Sub
  4. Private Const MOUSEEVENTF_MOVE As Integer = 1
  5. Private Const MOUSEEVENTF_LEFTDOWN As Integer = 2
  6. Private Const MOUSEEVENTF_LEFTUP As Integer = 4
  7. Private Const MOUSEEVENTF_RIGHTDOWN As Integer = 8
  8. Private Const MOUSEEVENTF_RIGHTUP As Integer = 16
  9. Private Const MOUSEEVENTF_MIDDLEDOWN As Integer = 32
  10. Private Const MOUSEEVENTF_MIDDLEUP As Integer = 64
  11. Private Const MOUSEEVENTF_ABSOLUTE As Integer = 32768
  12. Public Shared Sub Move(ByVal xDelta As Integer, ByVal yDelta As Integer)
  13.     mouse_event(MOUSEEVENTF_MOVE, xDelta, yDelta, 0, 0)
  14. End Sub
  15. </dllimport("user32.dll")>

After that you can create an action (eg. MouseMove) which randomly moves the mouse into the screen

  1. Dim Randomizer As System.Random = New System.Random()
  2. Dim x As Integer = Randomizer.Next(1, 640)
  3. Dim y As Integer = Randomizer.Next(1, 480)
  4.  Move(x, y)