Page 1 of 1

Ranorex 6.2 Keyboard.Press(Keys

Posted: Mon Dec 19, 2016 9:07 am
by SanMan
Hi,

I have this code (a lot) in my solution.

Report.Info("Key 'Return' Press.");
Keyboard.Press(Keys.Return, 28, Keyboard.DefaultKeyPressTime, 1, false);

Now I updated to 6.2 and cannot build solution:

The name 'Keys' does not exist in the current context(CS0103)

What could be the problem and how to fix it?

Re: Ranorex 6.2 Keyboard.Press(Keys

Posted: Mon Dec 19, 2016 9:14 am
by odklizec
Hi,

You need to add keyword WinForms. in front of Keys keyword, like this:

Code: Select all

Keyboard.Press(WinForms.Keys.Return, 28, Keyboard.DefaultKeyPressTime, 1, false);
See the breaking changes in Ranorex 6.2 Release notes:
http://www.ranorex.com/release-notes.html#c15287

Re: Ranorex 6.2 Keyboard.Press(Keys

Posted: Mon Dec 19, 2016 9:18 am
by asdf
Hi SanMan,

In order to get this working again, just delete the "Winforms" in the using directive like in the following screenshots.

Change this:
2016-12-19 09_10_24-pressKey - Ranorex Studio.png
To this:
2016-12-19 09_10_50-pressKey - Ranorex Studio.png
You could also use the namespace directly in the keyboard.press method like in the screenshot below.
2016-12-19 09_11_45-pressKey - Ranorex Studio.png
I hope this helps.

Kind regards,
asdf

Re: Ranorex 6.2 Keyboard.Press(Keys

Posted: Mon Dec 19, 2016 9:23 am
by odklizec
Hi asdf,

I'm afraid, that's not exactly correct solution. Using WinForms is forced from 6.2 and any reference of using System.Windows.Forms; is automatically deleted from UserCode.cs files. Please see the Breaking Changes section of Ranorex 6.2 Release notes.

Re: Ranorex 6.2 Keyboard.Press(Keys

Posted: Mon Dec 19, 2016 9:43 am
by SanMan
Thank you for quick help!!

:D