cancel
Showing results for 
Search instead for 
Did you mean: 

Global Send Key - Context Menu key

john.hammond
Level 6
Hi there. I'm automating a Dojo table with custom right-click menus, which can seemingly only be triggered via the keyboard using the Context Menu key (next to right CTRL). Is there a way to send this specific key as a global send key?

Unfortunately, Shift and F10 doesn't do the same effect on this particular page (probably due to the custom right-click menu). I am able to spy the element I want to click on in UI mode and then send a global mouse click 'right', however this takes a very long time due to the complexity of the table and I'm looking to make some efficiencies. Therefore, I have spied the element in Browser mode, which unfortunately doesn't allow me to specify a right-click event.

EDIT: This might actually be a moot point now, as I've tried to capture the bounds of the element spied in Browser mode and have used a 'Global Mouse Click' on the entire Window (spied in UIA) mode to the required coordinates, which does seem to be considerably quicker than the alternative method. Still interested to see if there's a way to GSK the menu key.

------------------------------
John Hammond
------------------------------
1 REPLY 1

jhogelp
Level 8
Hi, John.

Here he left the link of the BP material Send Keys and Send Key Events,
It will help you a lot, he also left you some examples of how to use those commands:

The 'Global Send Key Events' function sends keystroke 'events' to the active application, which is not necessarily the target application. Keys are processed by whatever has focus. This differs from the Global Send Keys function which sends keystrokes to the attached application (whichever object the Application Modeller is attached to).

'Global Send Key Events' uses a lower-level method of sending the keys, and therefore is more likely to work with some applications. A specific example of this is a Citrix client, which will not respond to 'Global Send Keys' but will work with 'Global Send Key Events' (see related articles about sending keys to Citrix).

Parameters:

The parameter 'Text' is used to specify the string value which corresponds to the key events to send.

The above example demonstrates pressing a CTRL+s key combination. The order of key presses is the key down signal (i.e. hold the key down), the special code for the Control key, the 's' key, the key up signal (i.e. release the key), and the Control key code as the key to be released.

The syntax for this parameter value is as follows:

  • All normal characters, e.g. "A", "9", just get sent as that key. A key down followed by a key up is sent.
  • Special keys are enclosed in {curly brackets}. This allows things such as {HOME} and {ALT} to be sent.
  • The < and > characters are used to modify the NEXT key to be just a key down < or key up > event respectively.
    • NOTE: Since "{", "}", "<" and ">" are special characters, they must be sent as follows: {{} {}, {<} and {>}

Examples:

"hello{RETURN}" – sends HELLO and presses return
"<{CTRL}A>{CTRL}" – presses the ctrl key down, then presses A, then releases the ctrl key
"<{ALT}AB>{ALT}" – presses the alt key down, then presses A, then B, then releases the alt key – i.e. does Alt-A, Alt-B
"<{ALT}A>{ALT}B" – presses the alt key down, then presses A, then releases the alt key and pressed B – i.e. does Alt-A, B
"<{CTRL}<{SHIFT}{ESCAPE}>{SHIFT}>{CTRL}" – presses ctrl and shift, then escape, then lets go of ctrl and shift

SENDING CAPITAL LETTERS using SHIFT

The format for sending capital letters via Global Send Key Events is like this:

"<{SHIFT}s>{SHIFT}"

This would send a capital "S".

The importance of focus

It is necessary for the application to have the focus in order for Global Send Key Events to work, otherwise nothing is sent. To retain the focus when the keys are being sent it may be necessary to launch the window and then immediately send the keys as the next step.

It may be necessary for you to create a completely new Business Object whose sole purpose it to connect to the target application's main window. This is especially required when working with applications such as mainframe emulators. If you are trying to send keys to a mainframe session hosted within a mainframe emulator product then you will need a Win32 object to activate the emulator window and then send keys to that window, rather than to the underlying mainframe session.

I hope I've helped


------------------------------
Jhogel Ponne
Senior RPA
Ernst & Young
America/Panama
------------------------------