Ranorex 6.2 Keyboard.Press(Keys

Ask general questions here.
SanMan
Posts: 147
Joined: Tue Apr 13, 2010 9:59 am

Ranorex 6.2 Keyboard.Press(Keys

Post by SanMan » Mon Dec 19, 2016 9:07 am

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?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3921
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex 6.2 Keyboard.Press(Keys

Post by odklizec » Mon Dec 19, 2016 9:14 am

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
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

asdf
Posts: 174
Joined: Mon Mar 21, 2016 3:16 pm

Re: Ranorex 6.2 Keyboard.Press(Keys

Post by asdf » Mon Dec 19, 2016 9:18 am

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
2016-12-19 09_10_24-pressKey - Ranorex Studio.png (1.14 KiB) Viewed 906 times
To this:
2016-12-19 09_10_50-pressKey - Ranorex Studio.png
2016-12-19 09_10_50-pressKey - Ranorex Studio.png (987 Bytes) Viewed 906 times
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
2016-12-19 09_11_45-pressKey - Ranorex Studio.png (2.51 KiB) Viewed 906 times
I hope this helps.

Kind regards,
asdf

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3921
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex 6.2 Keyboard.Press(Keys

Post by odklizec » Mon Dec 19, 2016 9:23 am

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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

SanMan
Posts: 147
Joined: Tue Apr 13, 2010 9:59 am

Re: Ranorex 6.2 Keyboard.Press(Keys

Post by SanMan » Mon Dec 19, 2016 9:43 am

Thank you for quick help!!

:D