How to wait until the application is running

Hello Guys,

I’m trying to automate a Desktop App using RPA.Windows, and I’m using the following command:
Windows Run PATH_TO_APP

This works fine, the next step is to wait until the app is running to go to the screen and do the process.
But, I can’t found any good way to wait until the process is running. I know I can use RPA.Desktop and Wait for Element, but I don’t want to use images, just if necessary.
So, what is a good way to do it?

I already tried using Click from RPA.Windows with some “name”, “class” from multiples parts of the app and I tried to use the Library Process to Run and wait, but I didn’t had sucess.

I’ve used WHILE loop to check for window, something like

Wait For Window
    [Arguments]    ${title}
    ${is_opened}    Set Variable    ${False}
    ${failsafe_counter}    Set Variable    240
    WHILE    not ${is_opened} and ${failsafe_counter} > 0
        ${windows}    List Windows
        FOR    ${window}    IN    @{windows}
            ${lines}    Get Lines Containing String    ${window}[title]    ${title}
            ${found_matches}    Get Length    ${lines}
            IF    ${found_matches} > 0
                ${is_opened}    Set Variable    ${True}
                BREAK
            END
        END
        Sleep    0.5s
        ${failsafe_counter}    Evaluate    ${failsafe_counter}-1
    END

You could add arguments for timeout and sleep to adjust it to you liking.

1 Like

You can also use Wait For Process

That While seems a really good way to do it, I will try to use it.
The Wait for Process I tried, but I didn’t had success, I don’t know why but because the app .exe is on a Network Drive the app returns a error and the Wait for Process says:

" The process to wait for must have been started earlier with Start Process. If handle is not given, uses the current active process."

1 Like

Alright buddy, I was waiting to see if someone had another option, but your code is good, much better then wait for a image of the first page to appears. I just made some changes to adapt to my situations:

Wait For Window
  [Arguments]   ${window_element}   ${value}  ${max_iterations}
  ${is_opened}    Set Variable    ${False}

  WHILE    not ${is_opened} and ${max_iterations} > 0
      ${windows}    List Windows
      FOR    ${window}    IN    @{windows}
          ${lines}    Get Lines Containing String    ${window}[${window_element}]    ${value}
          ${found_matches}    Get Length    ${lines}
          IF    ${found_matches} > 0
              ${is_opened}    Set Variable    ${True}
              BREAK
          END
      END
      Sleep    0.5s
      ${max_iterations}    Evaluate    ${max_iterations}-1
  END

  IF    ${max_iterations} == 0
       Fail   msg= The ${window_element} == ${value} was not found.
  END

Thanks bro!

1 Like