cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bouillons
Helper IV
Helper IV

UI Flow open a file in Word

I'm trying to automate something very simple with UI Flow.

I'm launching Word, the <Alt>O <Alt>O to show the browse file dialog. Then I want to enter the filename using an Insert Text, for example c:\temp\file.xml in the file name box, but whatever I do, the filename does not appear in the dialog and my following actions (<CTRL>P to print, then Enter, and then <Alt>F4 to exit. Don't execute correctly.

 

Capture.JPG

The selector looks to correctly point at the File Name:  input field 

 

{
"type": "WinUIA",
"parameters": {
"elementStack": [
{
"automationId": "1148",
"boundingRectangle": "287,759,547,25",
"className": "Edit",
"controlType": "50004",
"frameworkId": "Win32",
"name": "File name:",
"localizedControlType": "Edit"
},
{
"automationId": "1148",
"boundingRectangle": "283,754,580,34",
"className": "ComboBox",
"controlType": "50003",
"frameworkId": "Win32",
"name": "File name:",
"localizedControlType": "ComboBox"
},
{
"automationId": "",
"boundingRectangle": "0,0,1200,864",
"className": "#32770",
"controlType": "50032",
"frameworkId": "Win32",
"name": "Open",
"localizedControlType": "Window"
},
{
"automationId": "",
"boundingRectangle": "-11,-11,1942,1042",
"className": "OpusApp",
"controlType": "50032",
"frameworkId": "Win32",
"name": "Word",
"localizedControlType": "Window"
}
],
"elementXPath": "/Window[@ClassName=\"OpusApp\"][@Name=\"Word\"]/Window[@ClassName=\"#32770\"][@Name=\"Open\"]/ComboBox[@ClassName=\"ComboBox\"][@Name=\"File name:\"]/Edit[@ClassName=\"Edit\"][@Name=\"File name:\"][@AutomationId=\"1148\"]",
"desktopNodeXPath": "/Pane[@ClassName=\"#32769\"][@Name=\"Desktop 1\"]",
"applicationInfo": {
"applicationId": "AQfwRBpklkSMWDBgtGNk1Q=="
}
}
}

1 ACCEPTED SOLUTION

Accepted Solutions

I finally managed to stumble upon the right syntax - it helps to know about well-formed XML...

 

The following sequence does what I need

  • Open Word
  • Click to set focus
  • <Alt>O for Open: SendKeys <VK_LMENU><VK_O/></VK_LMENU>
  • O for Browse: SendKeys <VK_O/>
  • Enter FileName: Sendkeys Filename parameter
  • <Alt>O to Open: SendKeys <VK_LMENU><VK_O/></VK_LMENU>
  • <Ctrl>P to Print: SendKeys <VK_CONTROL><VK_P/></VK_CONTROL>
  • <Enter> to Print with defaults: <VK_RETURN/>
  • Close Word

I'm also wondering about a youtube video by Phil Topness at https://www.youtube.com/watch?v=Bc8cZOABFdQ on UI Flow of just a couple of months ago where instead of the <VK_LMENU><VK_O/></VK_LMENU> syntax another syntax <Keys.Alt>o<Keys.Alt> is used. When I tried this I got a "not well-formed" syntax error. Is this a deprecated syntax or is it a preview of a future version ?

 

Anyway, I'm happy to have got through it and help anyone else in the community who might need to do this.

View solution in original post

6 REPLIES 6
bouillons
Helper IV
Helper IV

It looks like when I type <Alt>O, this is recorded as <VK_LMENU><VK_O> and then the second O is recorded as </VK_O> (notice the / in front of VK_O. If I remove the / the screens moves to the Browse files as expected. However, it seems that for some reason the <Alt> is stuck, because the filename is not entering and after the flow ends with errors, I notice that the keyboard behaves strangely until I press <Alt> again to "unstuck" it.

I tried another approach. There is also a shortcut to open a file using <CTRL>F12

Unfortunately, this time it's the <CTRL> key that is stuck. <CTRL>F12 is recorded as <VK_LCONTROL><VK_F12>, so far so good. The File Open dialog appears, but my filename parameter isn't filled in in the File Name field. After the flow ends, the file open dialog is still open, and when I press a letter, it does not appear until I press <CTRL> to unstuck it.

Thanks @bouillons for the details. Can you attach screenshots of the Replay keystrokes actions expanded in your recording so we can see the values? This will help us figure out what the problem may be. 

 

From your description, It is  possible the Key Up event (closing key tag) was not recorded properly at the end  for some reason i.e.: </VK_LCONTROL>.  Adding the closing key tag (prefixed with the slash) at end of the Replay keystrokes value may correct the problem for you.

 

Also, what version of Ui flows installer are you using?

This is the sequence:

 

I open Word, and then I press <CTRL><F12> the file browse dialog opens and I attempt to send the filename parameter into the Filename text box. It fails, because the CTRL key is stuck. I use the UI Flows version 1.0.500.20113.

 

It would be good to have some clear instruction on the correct syntax of how to enter keystrokes into applications. I also tried to use click events, but when I click the browse button after clicking the open button, it consistently clicks the New button instead.

 

Capture.JPG

I finally managed to stumble upon the right syntax - it helps to know about well-formed XML...

 

The following sequence does what I need

  • Open Word
  • Click to set focus
  • <Alt>O for Open: SendKeys <VK_LMENU><VK_O/></VK_LMENU>
  • O for Browse: SendKeys <VK_O/>
  • Enter FileName: Sendkeys Filename parameter
  • <Alt>O to Open: SendKeys <VK_LMENU><VK_O/></VK_LMENU>
  • <Ctrl>P to Print: SendKeys <VK_CONTROL><VK_P/></VK_CONTROL>
  • <Enter> to Print with defaults: <VK_RETURN/>
  • Close Word

I'm also wondering about a youtube video by Phil Topness at https://www.youtube.com/watch?v=Bc8cZOABFdQ on UI Flow of just a couple of months ago where instead of the <VK_LMENU><VK_O/></VK_LMENU> syntax another syntax <Keys.Alt>o<Keys.Alt> is used. When I tried this I got a "not well-formed" syntax error. Is this a deprecated syntax or is it a preview of a future version ?

 

Anyway, I'm happy to have got through it and help anyone else in the community who might need to do this.

View solution in original post

Thanks for the feedback @bouillons and posting your solution.  Yes the<Keys.Alt> syntax is the old format from the Preview release and is a deprecated syntax. The syntax with virtual key prefix is the updated syntax for raw keystroke recording and playback.

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (915)