Page 1 of 1

Strange behavior when entering text

Posted: Wed Jun 10, 2015 9:37 pm
by jackrabbit
I need to write a Ranorex test to launch and application from the VmWare console. Basically, what I do, is to select a VM, open its WmWare console, make sure the Desktop is already visible and launch an application by pressing Windows+R followed by my command followed by a RETURN.

I am experiencing strange behaviors when using some characters in my command. It looks like when I enter any character formed using the SHIFT, CTRL, ALT, WINDOWS key, I must manually reset those keys after each character, otherwise I get junk, other characters of nothing in some cases.

Here is an example, I attempt to run the script "C:\Temp\hello.bat":

Code: Select all

// Set focus to the WmWare Console windos
MyRepo.MyForm.MyScreen.Self.Click();

// Press the WINDOWS+R sequence to open the EXECUTE box in Windows
Keyboard.Down(System.Windows.Forms.Keys.LWin, Keyboard.DefaultScanCode, true);
Keyboard.Press(System.Windows.Forms.Keys.R, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, 1, true);
Keyboard.Up(System.Windows.Forms.Keys.LWin, Keyboard.DefaultScanCode, true);

// Enter command to execute
Delay.Milliseconds(500);
Keyboard.Press(Cmd);
When I run this test, I only get "C:" in the input box. After a LOT of fooling around to figure out why some specific characters could not by typed in, I came up with the following ugly solution:

Code: Select all

// Set focus to the WmWare Console windos
MyRepo.MyForm.MyScreen.Self.Click();

// Press the WINDOWS+R sequence to open the EXECUTE box in WIndows
Keyboard.Down(System.Windows.Forms.Keys.LWin, Keyboard.DefaultScanCode, true);
Keyboard.Press(System.Windows.Forms.Keys.R, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, 1, true);
Keyboard.Up(System.Windows.Forms.Keys.LWin, Keyboard.DefaultScanCode, true);

// Enter command to execute
Delay.Milliseconds(500);
for (int Pos=0; Pos<Cmd.Length; Pos++) {
	Keyboard.Press(Cmd[Pos], false);
       	Keyboard.Up(System.Windows.Forms.Keys.ControlKey, Keyboard.DefaultScanCode, true);
       	Keyboard.Up(System.Windows.Forms.Keys.ShiftKey, Keyboard.DefaultScanCode, true);
       	Keyboard.Up(System.Windows.Forms.Keys.Alt, Keyboard.DefaultScanCode, true);
       	Keyboard.Up(System.Windows.Forms.Keys.LControlKey, Keyboard.DefaultScanCode, true);
       	Keyboard.Up(System.Windows.Forms.Keys.LShiftKey, Keyboard.DefaultScanCode, true);
       	Keyboard.Up(System.Windows.Forms.Keys.LWin, Keyboard.DefaultScanCode, true);
       	Keyboard.Up(System.Windows.Forms.Keys.RControlKey, Keyboard.DefaultScanCode, true);
       	Keyboard.Up(System.Windows.Forms.Keys.RShiftKey, Keyboard.DefaultScanCode, true);
       	Keyboard.Up(System.Windows.Forms.Keys.RWin, Keyboard.DefaultScanCode, true);
}
This works, however it is very slow and ugly, can anyone can explain me why I get this weird behavior in this input box, and not in other places?

Re: Strange behavior when entering text

Posted: Thu Jun 11, 2015 1:11 pm
by lucian.teodorescu
How do you pass Cmd?
What is it's value? I mean, if you pass it as a string parameter, with value "C:\Temp\hello.bat" it's OK.
If you assign the value in your code, then it should be like Cmd="C:\\Temp\\hello.bat";

Anyway, I've copy-pasted your first (nice and clean) code in one empty module and it worked (directly on my Windows OS).

Re: Strange behavior when entering text

Posted: Thu Jun 11, 2015 1:29 pm
by krstcs
Yeah, you need to remember that the backslash ("\") in a string is used to escape the next character. If you want a LITERAL backslash, then you need to escape it with another backslash like: "\\". If you have:

C:\Test\MyApp.exe

Windows will type "C:" and then hit "\T" and think that is a 'TAB' character, so it will move your focus to the next tab target.

Re: Strange behavior when entering text

Posted: Thu Jun 11, 2015 3:16 pm
by jackrabbit
My \ was part of a parameter, so I did not have to escape it.

To experience the problem, you must run this test either thru the console of WmWare ou thru a RDP connection. If you try to launch an application locally on your computer, it will work fine.

Trick: manually open a WmWare console window, or a Remote Desktop, make sure you see new new desktop. Make sure the first action in your test is a click to the new Console window to set the focus to it. When you attempt to "execute" a command on this remote machine, you should see the bug.

Re: Strange behavior when entering text

Posted: Fri Jun 12, 2015 8:22 am
by Support Team
Hi Jackrabbit,

Your first code works as expected on my environment.
I'm connected to a VM using mRemoteNG and my Solution is built as shown in the following screenshots
screen1.png
screen2.png
May I ask you to provide your complete solution to debug the problem in more detail?
Thank you,

Regards,
Markus (S)

Re: Strange behavior when entering text

Posted: Mon Jun 15, 2015 3:42 pm
by jackrabbit
I retried using your exact example and I get the same result.

If line 1 selects my local desktop, the C:\Temp is correctly opened.

However, if line 1 selects the Console of an opened VM in vSphere from VmWare, only "C:" is written, so it opens the root folder of drive C.

Anyone has access to vSphere from VmWare to see if they get the same results using Support Team's code?

Re: Strange behavior when entering text

Posted: Fri Jun 19, 2015 12:59 pm
by Support Team
Hi Jackrabbit,

I'm afraid that this problem is related to the VMWare application. I found a posting in an German forum that the ALT GR key is not correctly mapped in the virtual environment.

May I ask you if it is possible to use another application for your vm's?

Regards,

Markus (S)

Re: Strange behavior when entering text

Posted: Fri Jun 19, 2015 2:15 pm
by jackrabbit
Unfortunately no, I guess I will need to use my special function to send any text to the VM.