how to change DefaultKeyPressTime?

Ranorex Spy, Recorder, and Studio.
hporter
Posts: 35
Joined: Wed Jan 23, 2013 4:49 pm

how to change DefaultKeyPressTime?

Post by hporter » Mon Jan 28, 2013 4:27 pm

In each module of my testcase, the following values are specified within Run():

Mouse.DefaultMoveTime = 300;
Keyboard.DefaultKeyPressTime = 100;
Delay.SpeedFactor = 1.0;

If I edit the .cs file (e.g. change DefaultKeyPressTime to 50), save it, then re-run, the value resets back to the original. How do I make a change here that sticks? Thanks!

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: how to change DefaultKeyPressTime?

Post by Support Team » Tue Jan 29, 2013 5:28 pm

Hello,

Currently, you could not adjust these settings directly.

Right now, every recording sets the Mouse.DefaultMoveTime, Mouse.DefaultKeyPressTime and Delay.SpeedFactor right at the beginning of the generated code. That code was intended to make sure the recording works no matter what the default setting is. However, because of that code you can't just set the DefaultMoveTime once in your code to change the move time for every mouse action.

What you can do is add a user-code-item at the beginning of every recording and set the Mouse.DefaultMoveTime as well as the other values to your desired value. All mouse items should then use the default move time (unless they explicitly specify a different move time in the generated code; an explicit move time for a mouse item is generated if the DefaultMoveTime when recording the action is different to the DefaultMoveTime set when generating the code for the recording).

Regards,
Markus (T)
.
Image

hporter
Posts: 35
Joined: Wed Jan 23, 2013 4:49 pm

Re: how to change DefaultKeyPressTime?

Post by hporter » Wed Jan 30, 2013 4:55 pm

Thank you for the reply. I'm not much of a programmer, unfortunately...could you describe the steps for the solution you describe? Thanks so much in advance.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: how to change DefaultKeyPressTime?

Post by Support Team » Thu Jan 31, 2013 9:46 am

Hi,

What Markus meant was that you could add a new UserCode action at the beginning of each of your existing recordings where you can change the default mouse settings, this can be done as shown below:
Step1.jpg
Step1.jpg (109.2 KiB) Viewed 2134 times
Step2.jpg
Step2.jpg (35.81 KiB) Viewed 2134 times
Step3.jpg
Step3.jpg (24.49 KiB) Viewed 2134 times
Step4.jpg
Step4.jpg (14.45 KiB) Viewed 2134 times
In order to change the default values for the recordings you have to open the Settings window, click on the "Recorder Defaults" tab and there you can change the default timings for new recordings. These settings do not affect existing recordings just new ones.

Regards,
Markus
.
Image

hporter
Posts: 35
Joined: Wed Jan 23, 2013 4:49 pm

Re: how to change DefaultKeyPressTime?

Post by hporter » Thu Jan 31, 2013 6:23 pm

Thanks for your reply. I've done as you asked, added a UserCode action to the first recording module in my test case. The code is:

public void change_MouseKeySettings()
{
int myValue = 10;
Keyboard.DefaultKeyPressTime = myValue;
}

However, when I run the test, the value ends up consistently overwritten by the value as specified in each successive module. How to keep it from getting superseded by the other modules? How does the value persist between each module?

It also doesn't make much sense to me, if these settings are available globally (via Global Settings option), why are changes made there unavailable to an existing recording? Anyway, I appreciate any input as always.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: how to change DefaultKeyPressTime?

Post by Support Team » Fri Feb 01, 2013 3:22 pm

Hello,

You could set 'Recorder Defaults' globally in the settings for all new recordings as shown below.
For existing recordings, you would need to re-open your solution in order to use the new setting since these settings are stored in cs-files specifically for each recording.

Regards,
Markus (T)
.
Image

hporter
Posts: 35
Joined: Wed Jan 23, 2013 4:49 pm

Re: how to change DefaultKeyPressTime?

Post by hporter » Mon Feb 04, 2013 8:24 pm

I've made a change to 'Keyboard-related action time', closed out of Ranorex Studio, reopened RS, and reopened my solution. Then I did a clean/rebuild solution. Should this be sufficient to have that change propogate to the solution? I first changed it to 1 - no change in keyboard typing speed. I then changed it to 800, still no change in speed. Am I misunderstanding the purpose of that variable? My impression was that it would make the automated typing speed in my test either faster or slower. Thanks again!

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: how to change DefaultKeyPressTime?

Post by Support Team » Tue Feb 05, 2013 3:06 pm

Hello,

The setting of 'DefaultKeyPressTime' has minimal influence on the speed since it sets the default time for a key press (time-span between KeyDown and KeyUp) compared to 'Duration'.

If I understand you right, you want to speed up your keyboard actions in your test. You could just set 'Turbo Mode' in your recording to enhance the speed. This mode needs to be set on each recording separately.
Additionally, you could change the 'Duration' of your actions in your recording.

Regards,
Markus (T)
.
Image

hporter
Posts: 35
Joined: Wed Jan 23, 2013 4:49 pm

Re: how to change DefaultKeyPressTime?

Post by hporter » Tue Feb 05, 2013 3:29 pm

Thanks for the reply. I am reluctant to set Turbo Mode outright, since as I understand it, this mode will speed everything up (including mouse events), and not just typing, correct?

My situation is there's a long path that must be typed in during the test (a path to an XML file), and I was eager to speed this up. Not a huge deal, but I was hoping to be able to speed just this up. Changing the Duration would be tricky; since the app is browser-based, the time it takes for pages to load varies, so it would be potentially dangerous to change those values. Anyway, I do appreciate the help, as always!

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: how to change DefaultKeyPressTime?

Post by Support Team » Wed Feb 06, 2013 3:50 pm

Hello,

You are welcome.

You are right. The 'Turbo Mode' will speed everything up.
If you want to speed up keyboard events only you would need to modify the duration for each action.
You could select several 'Key Sequences' at one time if you use <Shift> or <Ctrl> key.

If you want to make sure that the page is loaded, you could add a 'Validation Action' before to make sure that your element is loaded (e.g. 'Validate.Exists').

Regards,
Markus (T)
.
Image