Sending Press Keys to Application

Hello all,

I am opening an application with RPA.Desktop and then I use the Press Keys keyword to send Ctrl+N to the application. This is run from vscode. The application opens but the key is send to vscode as that is still the active window and therefore opens a new file in vscode. Am I doing something wrong here?

Note that I am running on Windows and the application that I am opening is Notepad++.

Regards, Edwin

Did you try to Switch To Application keyword first

${NotepadPlusPlus}    Open Application   notepad++.exe
Switch To Application   ${NotepadPlusPlus}
Press keys    ctrl  N

Thanks for your quick reply.

I am actually using RPA.Desktop which does not have the Switch to Application command I believe. I am using RPA.Desktop library as the actual target application is a Java application. I just used Notepad++ for testing the concept. Is there a similar command for switching in RPA.Desktop? I could not find any.

Regards, Edwin.

I don’t thing that there is an similar command in RPA.Desktop.

You could try to click the title bar of your application to bring the focus on it.

I have used the following to make it work.

${Notepad}    Open Executable    C:\\Program Files\\Notepad++\\notepad++.exe    new 1 - Notepad++
Switch to Application    ${Notepad}
RPA.Desktop.Press Keys    ctrl    n

I also tried clicking certain elements in Notepad++ but it seems like the locators do not resolve. Inspecting it with Accessibility Insights for Windows revealed that none of the elements had an AutomationId. Tried to select on name but that did not work either and I am not sure what locator types you can use.

I could not open Notepad++ with Open Application. I am assuming this is because it is not a native Windows application but I am not entirely sure.

Thank you for your feedback.

To use Open Application the folder where notpad++.exe is located must be in the system
PATH
variable.

If your elements don’t have AutomationID, you can use Image template matching

Thanks Bolux and Gael for your help. Much appreciated.