Issues keystrokes to an external application or to the current Newlook session.
object.SendKeys([Application], Keys [, Wait])
Where object is an object expression that evaluates to one of the items in the Applies To list below.
Newlook Smartclient
Newlook Server
This method is typically used to send Aid keys to the host from Newlook.
If you need to navigate to a field and populate it with a string the best way of doing this is to use the SetActiveControl method to position the cursor, assign the value to the Text property of the control, then use the SendKeys method to send the Enter key to the host. Typically the use of SendKeys to navigate and populate fields is not recommended. This method should be reserved for sending Aid keys to the host. In addition, this method is not recommended for sending more than a handful of characters to an external application, due to speed restrictions. A far better approach is to use an alternative communication method such as COM if the external application supports it, or a transaction.
Another method of issuing keystrokes in Newlook is to use the Transaction Recorder. This tool is preferable for extensive application navigation.
Application - (String, Optional)
A string value specifying the name of the target application for the keystrokes. Newlook attempts to find this application in two ways. It enumerates the top-level windows and will match either the first window found whose program name or window title matches the Application parameter (e.g. Notepad.exe or "Untitled - Notepad"). If no application is found, then the keystrokes are not sent.
If this parameter is left blank, then the keystrokes are sent to Newlook.
Keys - (String, Required)
String value specifying the keystrokes to issue. Non-character keystrokes can be specified by enclosing the key name in braces as follows: Shift, Control, Alt and AltGr key combinations can be specified using {Shift+}, {Ctrl+}, {Alt+} and {AltGr+} with the associated keys. For example, {Ctrl+s} will issue the Control and s key combination. You cannot send certain keys that generate interrupts rather than character codes, such as {CTRL+ALT+DEL} .
In addition, the following keys can be sent to the host:
{Attn} |
{Clear} |
{End} |
{Erase EOF} |
{Field -} |
{Help} |
{Home Field} |
{Local Help} |
{New Line} |
{Page Up} |
{Reset} |
{Sys Req} |
{Test Req} |
{F1} … {F24} |
{Back Tab} |
{Down} |
{Enter} |
{Field +} |
{Field Exit} |
{Home} |
{Left} |
{Local Print} |
{Page Down} |
{Print} |
{Right} |
{Tab} |
{Up} |
{PA1} … {PA3} |
|
|
If you are issuing a key combination via SendKeys, for instance {Ctrl+a} you will need to specify the character key in lowercase and ensure there are no spaces inside the braces.
Wait - (Boolean, Optional)
A boolean value which specifies whether the script should wait until the keystrokes have been issued before continuing. This option must be set to True if used in conjunction with silent navigation (i.e. if the app.ShowForms property has been set to False in a prior line of code).
If you are sending keys to an external application then this parameter will be ignored and Newlook will behave as though Wait is set to True.
If you are using this method with the OnReceive or OnRefresh events of a form then you will need to set the Wait argument to False.
The SendKeys method returns a Boolean value. It returns True if the method completed successfully. Otherwise, it returns False.
The following example sets the CustomerNo field as the active control, sets the value of the text property of that control and then sends the ENTER key to the host: VB SCRIPT:App.ActiveForm.SetActiveControl (App.ActiveForm.Controls.CustomerNo) App.ActiveForm.CustomerNo.Text = "1" System.SendKeys "","{Enter}",True JSCRIPT:App.ActiveForm.SetActiveControl (App.ActiveForm.Controls.CustomerNo); App.ActiveForm.CustomerNo.Text = "1"; System.SendKeys ("","{Enter}",1); VB SCRIPT:The following example runs windows Calc.exe, sends Alt+3 to the application to toggle the calculator into Programmer mode then minimizes the calc window: VB SCRIPT:Sub OpenCalc System.RunApp "C:\Windows\system32\calc.exe" System.SendKeys "Calculator", "{Alt+3}", 1 System.Minimize "Calculator" End Sub JSCRIPT:Function OpenCalc() { System.RunApp ("C:\\Windows\\system32\\calc.exe"); System.SendKeys ("Calculator", "{Alt+3}", 1); System.Minimize ("Calculator"); } |
SetActiveControl method | SetValue method | PlayTransaction method
Embedded Newlook Control Smartframe Newlook Control
© 2004-2021 looksoftware. All rights reserved.