Connecting to an already running application


I’m trying to determine if an application is already open when my bot runs and then connect to that window rather than try to open another process.

I can get the application PID using ‘Process Exists’ from the RPA.Desktop.OperatingSystem library, but when I try to use ‘Connect By PID’ from the RPA.Desktop.Windows library I get a warning telling me that the library is deprecated and to use RPA.Windows. However, when I try to do that it seems ‘Connect By PID’ hasn’t been migrated to that library.

Does anyone know how I can use ‘Connect By PID’ now? Or know of an alternative way I can detect if an application is running and then connect to it?


You can use List Windows and Control Window to achieve this.

*** Settings ***
Library     String
Library     RPA.Windows

*** Tasks ***
Run Examples
    ${calc_is_running}=    Set Variable    ${False}
    ${windows}=    List Windows
    FOR    ${window}    IN    @{windows}
       IF    "${window}[title]" == "Calculator"
       ${calc_is_running}=    Set Variable    ${True}
    IF    not ${calc_is_running}    Windows Run    calc.exe
    Control Window    name:Calculator
    Click    id:clearButton
    Send Keys    keys=96+4=
    ${result}=    Get Attribute    id:CalculatorResults    Name
    Log To Console    ${res

Excellent, thanks @linkraivo that’s really helpful!