hot key support : General Questions

hot key support

Ask general questions here.

hot key support

Postby chris » Wed Apr 01, 2009 12:22 am

How do you press hot keys like alt+f? I noticed a post that mentioned you could use {ALTDOWN} to hole the alt key down, but that doesn't seem to work in version 2. Any suggestions?
Thanks.
chris
 
Posts: 17
Joined: Fri Mar 27, 2009 7:10 pm

Postby Ciege » Wed Apr 01, 2009 12:28 am

In my c# code I use the following to issue an Alt-F O to trigger the File -> Open menu...

Keyboard.Press("{ALT}fo");
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Postby chris » Wed Apr 01, 2009 1:16 am

Thanks for the quick reply. For some reason, that doesn't seem to work for me. I am trying to access a text box and type something in it, so I thought it might be easier to just use the hot key for the text box and then start typing since the only thing different about the text boxes are the controlID. Is the controlID going to be the same every time on every machine?
Thanks.
chris
 
Posts: 17
Joined: Fri Mar 27, 2009 7:10 pm

Postby Ciege » Wed Apr 01, 2009 1:32 am

I guess that kind of depends. What does the spy tool tell you?
Can you click and set focus to the text box based on it's name or a unique ID?
Is the text box getting focus before you start typing in it?

The Keyboard.Press method should be issuing the keys you tell it to. What is you code for setting focus to the text box before you start typing?
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Postby Support Team » Wed Apr 01, 2009 11:13 am

The code for the Keyboard.Press should look like the following:
Code: Select all
Keyboard.Press("{Alt down}{fkey}{Alt up}");
// or
Keyboard.Down(Keys.LMenu);
Keyboard.Press(Keys.F);
Keyboard.Up(Keys.LMenu);


Please consult the API documentation of the Keyboard.Press method for more information on the valid syntax for that method.
Usually, you can also try to record your keystrokes using the RanorexRecorder, however, in this special case (combinations of Alt/Ctrl and another key) the Recorder in V2.0 generates a buggy string. This error will be fixed in the upcoming V2.0.2.

Regards,
Alex
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4843
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Postby Ciege » Wed Apr 01, 2009 6:41 pm

Are you suggesting that what I am using should not work? It does...
Code: Select all
Keyboard.Press("{ALT}fo");


Visiting the API Documentation for the Keyboard.Press method in turn takes you to the MSDN Keys Enumeration documentation http://msdn.microsoft.com/en-us/library/system.windows.forms.keys.aspx.

This documentation clearly states that the Alt key modified is {Alt}. So it would appear that we are both right, but the method you describe with the {Alt down} and {Alt up} is just a longer way of doing it.
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Postby chris » Wed Apr 01, 2009 8:02 pm

Thanks for all the suggestions. I did the following:
Code: Select all
textBox.EnsureVisible();
Keyboard.Press("{Alt down}{fkey}{Alt up}");


That works now. Thanks for all the quick responses.
chris
 
Posts: 17
Joined: Fri Mar 27, 2009 7:10 pm

Postby Support Team » Thu Apr 02, 2009 9:29 am

Ciege wrote:Are you suggesting that what I am using should not work? It does...
Code: Select all
Keyboard.Press("{ALT}fo");


I bet your code works as well for most shortcuts, but sometimes you need to hold down the ALT key while pressing the shortcut key. Your code means:
- press the ALT key
- release the ALT key
- press and release the F key
- press and release the O key

The code I posted holds down the ALT key while pressing/releasing the F key. It's just two ways to invoke shortcuts :-)

Regards,
Alex
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4843
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Postby Ciege » Thu Apr 02, 2009 6:33 pm

Support Team wrote:Your code means:
- press the ALT key
- release the ALT key
- press and release the F key
- press and release the O key


Hmmm, interesting. If that what it truly means then I wonder why it works like Alt+F. If it was just doing Alt-down, Alt-Up, F I would expect that the file menu in the AUT would not actually open since it requires an Alt+F.
Regardless, I'll keep this info in mind incase it comes back to haunt me in the future.
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Postby Support Team » Fri Apr 03, 2009 9:24 am

If you press (and release) ALT, in most applications the focus moves to the menu and the following character determines the menu that is opened. However, with some applications that's not true and you need to hold down the ALT key while pressing the right character. Usually, the second way (holding down ALT while pressing character) is the safer one that should work almost evertime :-)

Regards,
Alex
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4843
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Postby Ciege » Fri Apr 03, 2009 5:13 pm

I see, and yes you are correct. I bow to your greatness! Thanks for describing it for me.
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Re: hot key support

Postby omayer » Wed Jul 27, 2011 8:27 pm

what will be the shortcut key for {TAB}
Thank you
Beginner
omayer
 
Posts: 239
Joined: Thu Oct 28, 2010 7:14 pm

Re: hot key support

Postby Ciege » Wed Jul 27, 2011 9:03 pm

omayer wrote:what will be the shortcut key for {TAB}
Thank you
Beginner


What do you mean by shortcut key for {TAB}? Do you mean, how do you type tab? If yes... use
Code: Select all
{TAB}
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA


Return to General Questions

Who is online

Users browsing this forum: No registered users and 1 guest