Forum Discussion

Alicya619's avatar
Alicya619
Occasional Contributor
5 years ago

How do I simulate holding "UP" key

Hello all,

 

I'm trying to simulate a press key continuously on "UP" keys but I expected to have the UP key press until it release (and so my value going up for several unit) but it's not the case, it's only one unit by one. I'm doing this :

 

Sys.Desktop.KeyDown(VK_UP);
aqUtils.Delay(TIMEOUT_DELAY, "Step 7 - Wait for 1.5s");
Sys.Desktop.KeyUp(VK_UP);

 

I have a look at these topics (not helpful):

- https://community.smartbear.com/t5/TestComplete-Desktop-Testing/Press-and-hold-2-keys/m-p/182354

- https://community.smartbear.com/t5/TestComplete-Desktop-Testing/How-do-I-simulate-holding-down-spacebar/m-p/113668.

 

I tried also to record the test, to use different objects, different application ... but nothing works.

 

Does someone have the answer :

- How to do it ?

- Why it's not working ?

 

Thank you in advance 

 

Alicya

  • What code did you get when you recorded the Up action that you wanted?

    • Alicya619's avatar
      Alicya619
      Occasional Contributor

      I tried it and I get this : 

      Aliases.MainTabControl.rowHeaderContent.Click(5, 12);
      NameMapping.Sys.Wdh_Digisharp_UI_Shell.MainWindow.MainRegion.ThresholdsView.PhysicalTab.PhysicalTableRight.Keys("[Up][Up][Up][Up][Up][Up][Up][Up][Up][Up][Up][Up][Up]");
      Aliases.MainTabControl.rowHeaderContent2.Click(5, 11);
      NameMapping.Sys.Wdh_Digisharp_UI_Shell.MainWindow.MainRegion.ThresholdsView.PhysicalTab.PhysicalTableLeft.Keys("[Up][Up]");

       

      The 1rst part (with many Up) corresponds to press 'Up' continiously and the second part is when I press 'Up' two distinct times.

       

      Alicya

       

      • Alicya619's avatar
        Alicya619
        Occasional Contributor

        I tried this 

        Sys.Desktop.KeyDown(VK_CONTROL);
        item1.Click();
        item2.Click();
        item3.Click();
        Sys.Desktop.KeyUp(VK_CONTROL);
         
        And I get the expected for behavior, my 3 items are correctly selected..
         
        The issue it really to press continuously on a key, if I'm pressing during two seconds on 'a' I will expect a result like this : 'aaaaaaaaaaaaaaa' but what I get is 'a'.
         
        Alicya