WinMatchKeys

(Engine-Level Function)

Description: Returns true if the specified keyboard keys have been pressed in the sequence given, in another window.
Returns: Boolean
Usage: Steady State only.
Function Groups: Keyboard
Related to: MatchKeys
Format: WinMatchKeys(Object, Enable, Keys)
Parameters:  
Object   
Required. Any expression which gives the object value of any module instance which is running in the window.
Enable   

Required. Any numeric expression giving an enable for the function. Testing of keyboard input is enabled when this parameter is true (not 0). If this parameter is false(0), the function's value is false(0).

In addition, the Enable parameter controls the type of comparison done. If the Enable is 1, a case-sensitive match is made. If the Enable is 2, then the match is not case-sensitive.

(Any non-zero value other than 2 will cause a case-sensitive match. The use of 1 and 2 is recommended for clarity.)

Keys   

Required. A text expression giving the key sequence to watch for. The case of individual letters may be significant, depending on the Enable parameter. For example:

  PageUp    = Concat(MakeBuff(1, 253), MakeBuff(1, 0x49));
  F2        = Concat(MakeBuff(1,253), MakeBuff(1,60));
  F3        = Concat(MakeBuff(1,253), MakeBuff(1,61));
  CtrlZKey  = MakeBuff(1, 26);
Comments:

The Object is used to determine which window to watch for the keystrokes in.
The Enable is a status expression controlling the comparison. The comparison starts after the Enable becomes true. If the Enable becomes false, the function's value becomes false and the comparison starts at the beginning of the Keys string again after the Enable becomes true. This feature is useful for resetting the WinMatchKeys function after an action using the function's result has been performed.

The WinMatchKeys function is also reset automatically when it occurs in an action trigger that becomes true.
The function's result is automatically set to false(0) when the state containing the function is entered. After the function becomes true, it remains true as long as the state does not change and the Enable remains true.
Any key sequence may be used for the Keys parameters including the function keys. Note that the WinMatchKeys function is case sensitive (upper and lower case letters are treated as different characters) when the Enable is an odd number. Often only one key is included in the Keys string. Several keys may be used in the Keys string and function as a password. The keys typed are not displayed on the screen by this function. Several WinMatchKeys functions may be active at any time, each comparing the keyboard input against their own Keys parameter.

Name of Constant Contents Description
CR MakeBuff(1, 13) Carriage return
ESC MakeBuff(1, 27) Escape key
LF MakeBuff(1, 10) Line feed
NULL MakeBuff(1, 0) Null byte
TAB MakeBuff(1, 9) Tab key
CRLF Concat(MakeBuff(1, 13), MakeBuff(1, 10)) CR/LF pair
UpArrow Concat(MakeBuff(1, 253), MakeBuff(1, 0x48)) Up arrow key
DownArrow Concat(MakeBuff(1, 253), MakeBuff(1, 0x50)) Down arrow key
LeftArrow Concat(MakeBuff(1, 253), MakeBuff(1, 0x4B)) Left arrow key
RightArrow Concat(MakeBuff(1, 253), MakeBuff(1, 0x4D)) Right arrow key
AltLeftArrow Concat(MakeBuff(1, 253), MakeBuff(1, 0x9B)) Alt and left arrow
AltRightArrow Concat(MakeBuff(1, 253), MakeBuff(1, 0x9D)) Alt and right arrow
SUpArrow Concat(MakeBuff(1, 253), MakeBuff(1, 0xB8)) Shift and up arrow
SDownArrow Concat(MakeBuff(1, 253), MakeBuff(1, 0xC0)) Shift and down arrow
PageUp Concat(MakeBuff(1, 253), MakeBuff(1, 0x49)) Page up key
PageDown Concat(MakeBuff(1, 253), MakeBuff(1, 0x51)) Page down key
HomeKey Concat(MakeBuff(1, 253), MakeBuff(1, 0x47)) Home key
EndKey Concat(MakeBuff(1, 253), MakeBuff(1, 0x4F)) End key
DeleteKey Concat(MakeBuff(1, 253), MakeBuff(1, 0x53)) Delete key
SPageUp Concat(MakeBuff(1, 253), MakeBuff(1, 0xB9)) Shift and page up
SPageDown Concat(MakeBuff(1, 253), MakeBuff(1, 0xC1)) Shift and page down
SHomeKey Concat(MakeBuff(1, 253), MakeBuff(1, 0xB7)) Shift and home
SEndKey Concat(MakeBuff(1, 253), MakeBuff(1, 0xBF)) Shift and end
CtrlPageUp Concat(MakeBuff(1, 253), MakeBuff(1, 0x84)) Ctrl and page up
CtrlPageDown Concat(MakeBuff(1, 253), MakeBuff(1, 0x76)) Ctrl and page down
CtrlHome Concat(MakeBuff(1, 253), MakeBuff(1, 0x77)) Ctrl and home
CtrlEnd Concat(MakeBuff(1, 253), MakeBuff(1, 0x75)) Ctrl and end
CtrlBKey MakeBuff(1, 2) Ctrl and B
CtrlCKey MakeBuff(1, 3) Ctrl and C
CtrlDKey MakeBuff(1, 4) Ctrl and D
CtrlIKey Concat(MakeBuff(1, 253), MakeBuff(1, 0xB5)) Ctrl and I
CtrlLKey MakeBuff(1, 12) Ctrl and L
CtrlNKey MakeBuff(1, 14) Ctrl and N
CtrlOKey MakeBuff(1, 15) Ctrl and O
CtrlUKey MakeBuff(1, 21) Ctrl and U
CtrlVKey MakeBuff(1, 22) Ctrl and V
CtrlXKey MakeBuff(1, 24) Ctrl and X
CtrlYKey MakeBuff(1, 25) Ctrl and Y
CtrlZKey MakeBuff(1, 26) Ctrl and Z

Example:

If WinMatchKeys(secondaryWin, 2, "go");
[
  ... 
]

This statement will wait until the window designated by secondaryWin is active and then will further wait until the keys "go" (in any case, upper or lower) is entered at the keyboard. At that point the function will return true and the script will execute.

Latching and Resetting Functions