1

I'm passing an argument X to a subroutine in UFT that will go to a dropdown control and select the Xth item

My first attempt worked, and I was basically just sending 'up' a bunch of times to get ensure I was at the top of the menu, then 'down' X times to get to the item I wanted

Win().Click 431, 548 'selecting the dropdown
        
For Iterator = 1 To 10 Step 1 'reset the selector to be on the top level
    Win().Key micUp
Next
For Iterator = 1 To X Step 1
    Win().Key micDwn
Next
Win().Key micReturn


However, the input happened very slowly, and I wanted it to happen faster, so I tried to concatenate all of the buttons I wanted to press before calling the Key function a single time:

Win().Click 431, 548 'selecting the dropdown
        
Dim KeyInput
KeyInput = ""
For Iterator = 1 To 10 Step 1 'reset the selector to be on the top level
    KeyInput = KeyInput & micUp
Next
For Iterator = 1 To X Step 1
    KeyInput = KeyInput & micDwn
Next
KeyInput = KeyInput & micReturn

Win().Key KeyInput

However, I'm not getting any key inputs at all with this - is there a different way to concatenate?

EDIT: as for other methods, it's not a standard dropdown, so I can't do anything that relies on interacting with it directly as far as I can tell.

1 Answers1

1

When you say very slowly, how slowly do you mean? I see two options:

  • The object you're identifying uses smart-identification which makes it very slow (as described in this question). In which case you can either try to solve the issue as described there, or a workaround is to capture the object in a variable with Set which will prevent it being identified every time it's being used (if it's safe to do so, further reading).
  • The steps are only a bit slow, in which case check the interval between steps in the Run Mode part of the settings Screenshot of options
Motti
  • 110,860
  • 49
  • 189
  • 262
  • That may be the issue, but I'm not confident that changing this is worth it. – seestrahseestrah May 04 '23 at 14:01
  • I'm not sure what you are referring to. Changing what? – Motti May 04 '23 at 14:28
  • @seestrahseestrah I got around to finding the settings in question and updated the answer. – Motti May 07 '23 at 06:21
  • >not confident that changing this is worth it< depends on what Win() does. If it constructs, GUI-locates a testobject, and returns it, you can speed it up by doing a Dim W: Set W=Win(), and using W instead of Win() everywhere. I.e. it would be quite easy and quick, and it eliminates the primary bottleneck you probably are experiencing. Did you try, did you solve it? – TheBlastOne Aug 22 '23 at 07:18