cancel
Showing results for 
Search instead for 
Did you mean: 

How do I simulate holding "UP" key

Highlighted
Occasional Contributor

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-space....

 

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

10 REPLIES 10
Highlighted
Community Hero

Re: How do I simulate holding "UP" key

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

Highlighted
Occasional Contributor

Re: How do I simulate holding "UP" key

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

 

Highlighted
Occasional Contributor

Re: How do I simulate holding "UP" key

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
Highlighted
Community Hero

Re: How do I simulate holding "UP" key

Hi Alicya,

 

As per https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-sys-deskto..., what if you try something like this:

<object>.Keys("[Hold]a[P2000][Release]");

<object>.Keys("[Hold][Up][P2000][Release]");

Does it help?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
Highlighted
Occasional Contributor

Re: How do I simulate holding "UP" key

Hello, 

The code given

<object>.Keys("[Hold]a[P2000][Release]"); => nothing

<object>.Keys("[Hold][Up][P2000][Release]"); => increase one unit

 

If I tried this :

Sys.Desktop.Keys("[Hold][Up]");
aqUtils.Delay(5000);
Sys.Desktop.Keys("[Up][Release]");
aqUtils.Delay(3000);
Sys.Desktop.Keys("[Hold][Up]");

 

I will have 3 unit increasement, one for each 'Keys' command lines

 

Thanks 

Highlighted
Community Hero

Re: How do I simulate holding "UP" key

What's the test case that you are trying to implement here?

Highlighted
Occasional Contributor

Re: How do I simulate holding "UP" key

When I'm pressing continuously on a key, I will expect a result like this : 'aaaaaaaaaaaaaaa' and not like that 'a'.

Highlighted
Community Hero

Re: How do I simulate holding "UP" key

How many "up" presses are you looking for?  The test case has to have some type of comparison.

Highlighted
Occasional Contributor

Re: How do I simulate holding "UP" key

It's not about a number it's about the possibility to do it, let's say :

As a user of my application, I want to have an increase of several digits when I'm continuously pressing on UP key. By opposition, when I'm pressing one time on UP key, I want an increase of one and only one digit.

 

Do you have the solution ?

 

Thanks 

 

Alicya

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors