Unable to Open Application and Execute Attach Window in Sequence

I would like to perform the following simple task:

  1. Open Application (notepad on desktop)
  2. Type Into the notepad (I have done this via Attach Window and then inserting Type Into activity
    I have used Sequence for the above tasks which was recommended as part of the Tutorial.

Screenshot of my flow as follows:

image

Problem:
The notepad was opened. However, Type Into was not executed on the opened notepad. The Type Into was only executed when I closed and re-opened the notepad. There seems to be a break between the Sequence but I am unable to figure out what. Please help.What have I missed out?

For Open Application and Attach Window, selector is
“wnd app=‘notepad.exe’ cls=‘Notepad’ title=‘Test - Notepad’ /”

For Open Application, file name is
“C:\windows\system32\notepad.exe”

@Chinhian

Because your workflow started with open application Activity. That’s why.

If you want to type directly into opened notepad file then delete that open application Activity and use Attach window Activity only.

@lakshman
I would like the robot to open the notepad as well. Would this be possible?

If only Attach Window activity were used, would this mean that the Notepad has to be opened manually before the robot can type in manually?

I plan to use this Sequence as part of a workflow. A Close Application will be added to the last step of Sequence but I had the same problem as above i.e. unable to close unless i re-opened the Notepad, so i figure the root cause could be similar and I should first solve the mentioned problem.

Thanks and I am grateful for your quick response

@Chinhian

Yes for this we can use open Application or Start Process Activity to open the file.

Yes exactly.

And also for attach window make selector dynamic to replace variable part with wild cards.

wnd app=‘notepad.exe’ cls=‘Notepad’ title=‘* - Notepad’ /”

@lakshman
“Yes for this we can use open Application or Start Process Activity to open the file.”

Sorry if I misunderstood… but I did use Open Application as my first step of the Sequence - refer to screenshot in first thread. The robot executed Open Application but was not able to execute the second step Attach Window. I had to close the Notepad and re-open manually before the robot could execute the second step and Type Into activity.

Am I missing out on something in between the 2 steps within the Sequence?

1 Like

@Chinhian

Could you please post the screenshot of your Attach window selector. I guess problem here only.

@Chinhian

Have you tried putting the Type Into activity into the Do section of the Open Application?
image
It’s possible that you do not even need the attach window at all. I’m wondering what the need for both Open and Attach together, usually that is not necessary.

Let me know how that goes :slight_smile:

@lakshman

Here’s the screenshot for my Attach window

Details of Selector as below:

image

@mcicca

Yes I have tried this method as well. I faced the same problem as well. The robot was able to execute Open Application but was not able to execute Type Into. The Notepad had to be closed and then re-opened manually before the Type Into can be executed. I was wondering if perhaps there is a missing output variable/link/connection between the 2 Activities which needed to specified …

@Chinhian
Hmm that is interesting. I just tried on my end and it worked fine:


(Note that it’s only invalid because Notepad is not open).

What was the selector of your Type Into?

@Chinhian

Please find the attached workflow for your reference.

NotepadTest.xaml (6.2 KB)

@lakshman

Please ignore earlier post. I managed to have the robot execute second step Attach Window consecutively
I did so by having the Selectors in both Open Window and Attach Window replace the variable part with wild cards, as you have mentioned earlier.

wnd app=‘notepad.exe’ cls=‘Notepad’ title=’* - Notepad’ /

I noticed that if wild card was not used in either Selector (or if it were not used at all), the next step could not be executed without manually triggering it. Perhaps this was the “connector” to the next step? If I may ask, what is the effect of the “wild card”?

Many thanks in advance! Grateful for the advice!

1 Like

@lakshman

I was looking into the Selector for your Type Into. How were you able to come up with the strings of code for the Selector? This seems diffrenet from the Open Application selector which was auto-populated upon clicking on image of the Notepad window.

1 Like

@Chinhian

Actually UIpath will identify the elements based on the selector. so, selectors are place major role here. If you want to work with more reliable then we have to pass either Wild card entries like ‘*’ or we can use variables into selector.

        wnd app=‘notepad.exe’ cls=‘Notepad’ title=’Test - Notepad’ /

After indicated the screen, it took file name Test - Notepad into the selector and so it will work for the file which has name “Test” only. If you want to work with any notepad file we have to replace variable part with wildcard entries. Here, file name is the variable part.

            wnd app=‘notepad.exe’ cls=‘Notepad’ title=’* - Notepad’ /

@lakshman

I realized that a new text file was created under Open Application all along rather than the designated file, even though i had clicked on the opened Notepad when selecting image.

What if i wanted to open a specific text file? I indicated the file path of the designated file but received a error…
The file path which i indicated manually as below

The error message after running is as shown:

is there something wrong with the file path which i have inputted? How come the image capture feature did not reflect the path of the designated file?

1 Like

@mcicca

Thanks for your help. I have resolved the issue you have mentioned. Currently facing an issue with file path. The robot had been opening a new text file rather than my intended text file all along…

@Chinhian

Go to Input scetion under Open Application activity and there you can find two fields like “FileName” and “Selector”

FileName: “C:\Windows\System32\notepad.exe”

Selector: wnd app=‘notepad.exe’ cls=‘Notepad’ title=‘Untitled - Notepad’

This selector contains the actual file name and here we have to use wild card ‘*’.

Please check below screenshots.

@lakshman

Is the file name you have mentioned a generic file name for opening a new Notepad?

What if I wanted to open a specific Notepad file on my Desktop and the text file is named ‘‘test’’? The exact file path is: “C:\Users\chinhian\Desktop\test.txt”
Do I put it in the file path in the same manner as you have done (see below)?

@Chinhian

For this, use Start Process activity and specify full file path into FileName field in double quotes.

1 Like

@lakshman

Great!!! Thank you so much for your help!.

1 Like