SendKeyObject

The function SendKeyObject sends a key event code to objects in the currently displayed project screen. You can use this function to trigger Command animations on those objects.

Function Group Execution Windows Embedded Thin Client Mobile Access
SendKeyObject Module Activity Synchronous Supported Supported Supported Not supported

Syntax

  SendKeyObject(numEvent,strMainKey,numShift,numCtrl,numAlt,strTargetScreen,optNumID)  
Web Studio Help oduleactivity sendkeyobject.xml d163892e122 SendKeyObject

numEvent
A numeric value that indicates the type of key event to send to the screen. The following values are accepted:
Value Description
0 On Down
1 On While
2 On Up

For more information about these key events, see Command animation.

Note: If the “On While” event is specified, the “On While” script on the Command animation is executed just once for each time this function is executed. It is not continuously executed as if the key is pressed and held down, because this function does not have a parameter for specifying duration. If you want to cause that sort of behavior, you can include this function in an appropriately configured FOR loop.
strMainKey
The key to be sent to the screen. The following values are accepted:
Value Description
"A""Z" alphabetic characters A through Z
"+" plus symbol
"-" minus symbol
"*" multiply symbol
"/" divide symbol
"LEFT" left arrow (←)
"UP" up arrow (↑)
"RIGHT" right arrow (→)
"DOWN" down arrow (↓)
"HOME" Home key
"END" End key
"PAGEUP" Page Up key
"PAGEDOWN" Page Down key
"INSERT" Insert key
"DELETE" Delete key
"SPACE" Space key
"RETURN" Return key
"BACKSPACE" Backspace key (if different from Delete key)
"ESCAPE" Escape key
"F1""F20" function keys F1 through F20

The key must be enclosed in quotes, as shown.

numShift
A numeric value that indicates whether to include Shift with the specified key (e.g., Shift+R). The following values are accepted: 0 is no, 1 is yes.

This parameter is optional; if no value is specified, the default value is 0.

numCtrl
A numeric value that indicates whether to include Ctrl with the specified key (e.g., Ctrl+R). The following values are accepted: 0 is no, 1 is yes.

This parameter is optional; if no value is specified, the default value is 0.

numAlt
A numeric value that indicates whether to include Alt with the specified key (e.g., Alt+R). The following values are accepted: 0 is no, 1 is yes.

This parameter is optional; if no value is specified, the default value is 0.

strTargetScreen
The name of the screen that will receive the key event code.

This parameter is optional; if no value is specified, the currently active screen is used.

optNumID
The specific ID number of the screen. (The ID number is assigned when the screen is opened with the function Open.)

This parameter is optional; if no value is specified, the default value is 0.

Returned value

This function does not return any value.

Notes

If the option Enforce Web functionality equivalence is selected in the project settings, this function cannot be called from Global Procedures or Script worksheets. This is because the function is meaningful only when it is executed on stations that display project screens; it might cause unexpected behavior if it is called from background tasks that are executed on the project runtime server. For more information, see Preferences tab.

Also, the parameters numShift, numCtrl, numAlt and strTargetScreen are all optional, but if you configure one of them, you must configure the others as well.

Examples

Send R to the currently active screen:
  SendKeyObject(0,"R")  
Send Ctrl+Shift+R to the screen named “main” with ID 10:
  SendKeyObject(0,"R",1,1,0,"main",10)  

SendKeyObject