Save As Dialog Issue

Ask general questions here.
User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Save As Dialog Issue

Post by Ciege » Thu Apr 09, 2009 8:11 pm

I am using the following code to find a Save As dialog and enter the name of the file to save in the File Name field.

Code: Select all

Ranorex.Form HDReportSaveAsForm;
HDReportSaveAsForm = WaitForWindow("Save As", 30);
HDReportSaveAsForm.EnsureVisible();
Keyboard.Press("{Alt down}n{Alt up}");
Keyboard.Press("foo");
I have also tried the follwoing with the same results:

Code: Select all

Keyboard.Down(Keys.LMenu);
Keyboard.Press("n");
Keyboard.Up(Keys.LMenu);
The issue is that the text that is entered in the File Name field is always missing the first character (I.e. in my example above the text entered is "oo" instead of "foo"). It appears that the {Alt up} is not actually release the alt key as expected. If my text to exter has a space as the first character it opens the Save As dialog's Move menu as you would get from Alt-SPACE.

NOTE: WaitForWindow is just my own method for waiting for a window to appear and returning the Ranorex.Form object

Code: Select all

Host.Local.FindChild<Ranorex.Form>(WindowName);
Alt-n should verify that the cursor is in the File Name text filed since N is the hotkey.

You can verify this issue using the Notepad Save As dialog. (I.e. start Notepad and select File -> Save As)

This is using v2.0.2.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Fri Apr 10, 2009 9:47 am

The problem is that your keyboard string is not correct. If you try to record the shortcut using the V2.0.2 recorder, the following code line is generated (LMenu and Alt are equivalent):

Code: Select all

Keyboard.Press("{LMenu down}{Nkey}{LMenu up}");
The "{Nkey}" group means that modifiers are not changed, whereas writing just "n" resets the modifiers to really press the "N" key without the Alt/Shift/Ctrl keys being pressed.

The same is true for the other code lines:

Code: Select all

Keyboard.Down(Keys.LMenu);
Keyboard.Press(Keys.N);
Keyboard.Up(Keys.LMenu);
Regards,
Alex
Ranorex Support Team

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Post by Ciege » Fri Apr 10, 2009 4:48 pm

Thank you. That worked.