Skip to Content
Technical Articles
Author's profile photo Thierry GOURDIN

How to handle screen lock and disconnected VDI with SAP Intelligent RPA

Hello everyone,

My name is Thierry Gourdin and I’m a RPA addict 🙂

I’m product adoption Manager in SAP Intelligent RPA and I would like to share some best practices how to handle limitations with screen locking, which can be a very confusing topic.



SAP Intelligent RPA solution sometimes requires the user to handle applications with low-level actions such as mouse clicks or direct keystrokes simulations. But in certain circumstances, these low-level actions can cause limitations.

Even it’s mostly encountered during unattended execution, this behavior isn’t limited to this execution mode, as the user can be expected to launch attended scenarios on his machine and let it work while the screen is locked.


Let’s dive into the case.
It may happen that after having finished an automation implementation and testing on his desktop, a user notices that the automation doesn’t execute properly when the factory sends the job to a machine in particular configuration:

  • The job executes on a user’s machine with its screen locked.

  • The job executes on a VDI with no active connexion.


If one of these 2 conditions triggers an error with your automation whereas it was working before (when running in attended mode for example), then this article may help…




This kind of issue mostly comes from “low-level” mouse or keyboard simulations:

  • ctx.mouse.<any>
  • ctx.keyStroke(“not working”);

These functions literally ask the agent to simulate a mouse click or press a key. It won’t work as well when the session is locked or the VDI is disconnected.


Such issue can also occur when using UIAutomation connector even with standard action such as click, set, get. Here is why: The UIAutomation connector helps automate any kind of desktop application that implements the UIAutomation interface. But if an application does not respond correctly to the UIAutomation connector request, the connector sends mouse clicks or keystrokes as backup plan to execute the action anyway. But it’s not working with a locked screen or disconnected VDI.

To identify if an action sent through UIAutomation connector triggers a low level “backup plan” action, you can try this:

  • Check if the cursor moves to the item position when calling the click action.

  • Combine the action with a delay during which you can manually lock the screen or disconnect the session:

Surface automation relies on mouse clicks and keystrokes that require a desktop with an unlocked screen.


Best practices

Try to avoid Mouse Click and Keystroke Actions

To resolve issues with mouse click and keystroke actions, you need to track down and identify those actions. These actions may have been implemented in the project that way, to avoid complicated code or overcome improper item handling by the tool.

If you find the following keystroke action:

  • ctx.keystroke /

you can replace it with the following:


If you find the following click action:

  • / / click(true)

you can replace it with the following:


Web Application Automation

Setting a value with the standard set method may not work on every website, especially on a website with rich framework (e.g. Bootstrap, Angular …).

This behavior is related to:

  • Javascript events attached to items on the web page
  • Surface controls
  • A complex page structure

Let’s describe this on a concrete example. Below website relies on a rich JS framework that makes the following actions whenever an user sets a value in the “Component Search” search bar (highlighted in red):

  • does a surface control of the input value
  • displays a message under ‘Messages’ label when the input is accepted.

If the automation developer uses a simple call like this


The effect will be the one below:

The input ‘IRPA’ has been set but no message has been displayed under the ‘Messages’ label. This indicates that:
  • the web page has not been correctly acknowledged that an entry has been entered
  • the surface control action has not been executed.

This may be an issue if the developer needs to retrieve those messages.

The developer may use the following workaround:


As a result, the input value is set and a message is displayed.


So this previous solution using low level action (ctx.keystroke) is valid but only if you launch these automations along non screenlocked desktop or VDI. Here is the correct way to handle a robust automation of this kind of rich web application:



As a result, the tooltip and the corresponding message are displayed and this solution can be applied to desktops with a locked screen.

A more complex web page may require the user to work directly in the browser by analyzing the internal events with web developer mode.

For example, it is possible to simulate a specific event that is required on the page to proceed, here it is a mouse event: "dispatchEvent( new MouseEvent( 'mouseover', {'bubbles': true, 'cancelable': true}))");

Win32 Automations

For some Win32 applications, if standard methods oblige you to use low-level click or key stroke actions, you can try by capturing the application with UIAutomation and enable Win32 automations option (only available with version 1.0.8+ of the Desktop Studio).

This option is only available on items with the following class names:

• Button

• Edit

In the Captured Data section, each of these items must also have the capture property hWnd, different from 0x0.


Keep Screen Unlocked

A common best practice is to configure your environment to prevent the screen from locking when it’s possible.

This will allow mouse clicks and keystrokes to be used without getting stuck and sent to the screen lock instead of the targeted application.


Keep a Connection to the Virtual Desktop Infrastructure

Same idea here, if you are using a Virtual Desktop Infrastructure and mouse clicks and keystrokes are necessary, you can:

  • Configure the Virtual Desktop Infrastructure to prevent the screen from locking.

  • Directly connect to a Virtual Desktop Infrastructure from a local machine.

Eventually you may have a project that launches this connection from a local machine.


Identify Another Functional Resolution

If all the resolutions previously suggested do not work, try to find a functional workaround. Another sequence of screen, another button to click on, if any other way to validate your form may also work without needing a mouse click or a keystroke.

If none of the workarounds apply, it may become a blocker for your project.

It is important to track down those limitations early in your POC, design, or implementation. In order to do so, you can:

  • Use action + delay + manual screen lock

  • Perform regular tests on a disconnected Virtual Desktop Infrastructure or on a machine with a locked screen.


Your turn!

Here we are. If you get stuck in lock screen or VDI disconnexion issue that is often linked to the use of unattended mode execution, I hope this guide will help you. All best practices presented above are linked to a specific context you need to prior assess in order to decide which solution to try.

Thanks for your time and have a happy automation journey!


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Srinivas Rao
      Srinivas Rao

      Hi - Thanks for sharing the tips and best practices. If you could cover more in detail about the script item and how we can get the overall script to be executed using "scriptItem", it will help all.

      Thanks & Regards

      Srinivas Rao.

      Author's profile photo Thierry GOURDIN
      Thierry GOURDIN
      Blog Post Author


      ScriptItem allows you to get, set or execute a simple function against an HTML element. You can check some examples here.

      If you need to execute more complex JavaScript functions on a HTML element, you can use the more powerfull function execScript. You’ll have to inject these functions into the web page prior to invoke them on the element.

      Regards, Thierry

      Author's profile photo Steven De Baerdemaeker
      Steven De Baerdemaeker

      Useful article, however when automating ABAP WebDynpro applications, the suggestion to use "set" and "trigger("input")" fails, due to how ABAP WebDynpro is developed. The lightspeed library is causing issues, not detecting the actions taken by iRPA. If no keypress is detected, the submit is not taking place. It would be helpful if some blogposts consider more the SAP web technologies being used, as not all applications available are Fiori or SAP GUI based.

      Author's profile photo Thierry GOURDIN
      Thierry GOURDIN
      Blog Post Author

      Hi Steven,

      Thanks for your feedback. As there are plenty of frameworks/web tech, we for now concentrate on most used ones.

      Have you tried to look into the page and retrieve what event would trigger the action you want to perform (using VisualEvent, javascript traker, web developper mode from the browser) ?

      If you find which specific event is triggered when the user performs its manual action, you can try to replicate with (here for a mouseover event): "dispatchEvent( new MouseEvent( 'mouseover', {'bubbles': true, 'cancelable': true}))");


      Author's profile photo Steven De Baerdemaeker
      Steven De Baerdemaeker

      Hi Thierry


      Thanks for your reply, in S/4HANA there are still a lot of mixes (Fiori/SAPUI5, ITS WebGUI and ABAP WebDynpro).
      I indeed tried your suggestions, but without success as ABAP WebDynpro is not exactly following HTML standards and wasn’t able to exactly reproduce the manual action.
      In the meantime I opened a ticket and someone from product support is trying to look into it.

      Author's profile photo Miguel Mavo
      Miguel Mavo

      Hello Thierry first of all thanks for that important info. So I need your help with an current issue related whit this in RPA 2.0, cuestion is, I need to do a keystroke in this case to press F2 and then Enter with the screen locked to get result in a Excel cell in unnatended mode. I noticed that in attended mode be logged in the server the procedure works but as soon as I desconect, this keystroke fails because it says that can'nt unlock. then would you help me how I could resolve this issue? thanks a lot in advance, regards! 😀

      Author's profile photo Thierry GOURDIN
      Thierry GOURDIN
      Blog Post Author

      Hello Everyone !

      Time passed since this blog post has been published and I'm very happy to inform you that everything is now smoother and simpler with Intelligent RPA 2.0 and SPA...

      The activity that you use in Cloud Studio will automatically trigger a wrapped activity to unlock your locked session when it is needed (meaning if your activity requires a low level action on the UI such as mouse clicks, key strokes, etc...). The session will then relock a bunch of seconds afterwards.

      Author's profile photo FATIH ORNEK

      Hi Thierry GOURDIN ,

      We are using cloud studio. When we disconnect VDI and let the bot run on its own, it does not perform the keystroke operations. Do you have any suggestions for solving this problem?


      Author's profile photo Thierry GOURDIN
      Thierry GOURDIN
      Blog Post Author

      Hi FATIH ORNEK ,

      Please have a look on the following Help Portal documentation :

      and complementary SAP Note:

      There are a couple of parameter and checks to perform to have the session properly handled automatically. For example, the session that needs to be unlocked/locked has to be opened by IRPA Service

      Kind regards

      Author's profile photo FATIH ORNEK

      Hi ,

      Thanks for informations. But, I tried all the alternatives but unfortunately it didn't work. I updated the Desktop Agent to the latest version and it still didn't work. I will continue researching.

      Thanks for support.

      Author's profile photo Thierry GOURDIN
      Thierry GOURDIN
      Blog Post Author

      That's unfortunate... Could you create a incident in SAP ticketing tool with CA-ML-IPA component ?

      Kind regards.

      Author's profile photo Well HardWare
      Well HardWare

      Really awesome information. When I read your blog, I learn more new things thanks.