Console Commands

  Knozall AutomationWizard console_controls.htm

Console Controls

CLRCON

Keycon

mousecon

$System[Screen, List, num ]

$System[Screen, Read, Mouse]

Writecon message.

%System[WinCtrl, EnumWindows, options]

%System[WinCtrl, FreeEnum, enumid]

%System[WinCtrl, EnumInfo, enumid, enuminfo]

$System[WinCtrl, WindowInfo, WindowID, WindowInfo]

$System[WinCtrl, Snapshot, WindowID, path, options]

%System[WinCtrl, MoveWindow, WindowID, x, y]

%System[WinCtrl, SizeWindow, WindowID, width, height]

%System[WinCtrl, ShowWindow, WindowID, ShowState]

 

Description

This command clears the command console screen of the Target Agent.(the DOS window that the MJB script opens).

The Target Agent is set by using the $Tagent identifier.

Syntax

CLRCONxe "CLRCON"xe "KSI BASIC Commands:CLRCON"xe "clearing the console screen"

Remarks

This command duplicates the action of CLS (clear screen) in DOS.

Example

Rem CLRCON example

$AbortOnError = "no"

Writecon "This is the console screen message"

Pause 5

Clrcon

Pause 5

Writecon "See, I told you I would clear the screen!"

Pause 5

This example script is run without logging output, so that the console screen  (Dos window) is displayed.  First you will see the message: This is the console screen message.  The script then pauses for 5 seconds.  Then the clrcon command will clear the window, then pause for 5 seconds, then display the message: See, I told you I would clear the screen!   The script then pauses for another 5 seconds and the job ends.

Description

This command sends keystrokes to the console screen of the Target Agent.  To redirect keys to an active application screen, specify the screen name followed by a double colon '::'.  Then, specify the keys to be sent.. If no screen name is specified, the keystrokes are sent to the default screen which is specified by $SetScreen.  The default screen is the System Console.  

Syntax

Keycon "Screen Name::string"xe "KEYCON"xe "KSI BASIC Commands:KEYCON"xe "sending keystrokes to the console screen"

Remarks

If Keycon is used to execute a batch file it will not execute it until the script ends unless you execute it in another DOS window.   A better alternitive is to use the LOAD or SLOAD command.

The screen name may contain wildcards such as * or ?.

A literal quote is represented by the grave accent key (`) that is located beneath the tilde (~) on most keyboards.

You can use Keycon to send up to 512 characters on one line.

Commands


 

Keystrokes

Function

<A_A>-<A_Z>

Alt A through Alt Z

<A_F1> <A_F0>

Alt F1 through Alt F10

<A1>-<A0>

Alt 1 through Alt 10

<AD>

Arrow Down

<AL>

Arrow Left

<AR>

Arrow Right

<AU>

Arrow Up

<BS>

Backspace

<C_F1> <C_F0>

Ctrl F1 through Ctrl F10

<Capital>

Toggles Caps lock on and off

<CR>

Carriage Return/Enter

<DL>

Delete

<ED>

End

<ES>

Escape

<F1>-<F0>

F1 through F10

<HM>

Home

<IN>

Insert

<Lcontrol>

Left Control key

<LF>

Line Feed

<Lshift>

Left Shift key

<NumLock>

Toggles Number lock on and off

<PD>

Page Down

<PU>

Page Up

<Rcontrol>

Right Control key

<Rshift>

Right Shift key

<S_F1> <S_F0>

Shift F1 through F10

<S_TB>

Shift Tab (back Tab)

<Scroll>

Toggles Scroll lock on and off

<Sound>wavefile

Plays a Wav file

<SP>

Space Bar

<SW>

Switches to the specified screen

<TB>

Tab

 

It is not necessary to use the <SW> command to send keystrokes to a screen.  It is used only if you want the screen to be displayed.

For example, SBACKUP::<SW><AD><CR><ES> switches the display to the specified screen, and then issues an arrow down, a carriage return, and an escape.

A literal colon ':' such as in a directory path is indicated as a single colon and a screen keystroke redirection is indicated with a double colon '::'. 

Example

Example 1.

This example will send keystrokes to open Notepad, open a file log.txt, print the file and then close notepad.

Rem print LogFile

Sload "notepad"

Writecon "notepad should now be open"

Keycon "Untitled - Notepad::<A_F><p1>o"

Writecon "should have opened the file menu"

Keycon "Open::log.txt<CR><p2>"

Keycon "log.txt - Notepad::<A_F><p9>P<p9>"

Keycon "log.txt - Notepad::<A_F>X"

 

Example 2.

Keycon “NetWare 4.10 Monitor Console::Yes<CR>” This will send keystrokes Yes and a carriage return to the Monitor console screen.

Keycon “@5::Yes<CR>” 

Rem  This will send keystrokes Yes and a carriage return to console screen number 5.

Keycon “*Monitor*::Yes<CR>”

Rem  This will send keystrokes Yes and a carriage return to the first screen with a Monitor screen name.

See Also

MouseCon           Load       Sload


 

Description

Sends commands to the mouse for the entire screen or to a specific window. (to move or click the mouse).

Syntax

MOUSECON “Window Name::<commands> ”

Commands

Actions

Function

<Ldouble>

Double click the Left mouse button

<Ldown>

Left mouse button is pressed down

<Left>

Left mouse button is pressed down and released

<Lup>

Left mouse button is released

<Mdouble>

Double click the Middle mouse button

<Mdown>

Middle mouse button is pressed down

<Middle>

Middle mouse button is pressed down and released

<Move> [R] x,y

Moves the mouse from its current position by the specified units in the x and y directions 0-64k pixels.  

To move the mouse Relative to it’s current position place the direction in which to move such as <move>R –20;20  which would move the mouse 20 pixels down and to the left from it’s current position.

<Mup>

Middle mouse button is released

<P##>

Pause 1/10 th of a second.  

<Rdouble>

Double click the Right mouse button

<Rdown>

Right mouse button is pressed down

<Right>

Right mouse button is pressed down and released

<Rup>

Right mouse button is released

<Wheel> #

Number of units to move the mouse up or down

[R] Indicates a relative position

[x] Indicates the horizontal axis     

[y] Indicates the vertical axis

Remarks

On some faster machines thing such as 2 left mouse clicks are being used it may be necessary to pause a few tenths of a second between click i.e.

Mousecon “<left><p5><left>”

When sending commands to a specific Window the position 0;0 is the upper left corner of that window

Example

This will select a card and drag it to another deck then double click on the card.

MouseCon "<move>18513,16602 <ldown><move> 31948,17257 <lup>"

See Also

Keycon

$System[“System,Read,Mouse”]

Description

Reads Agent screen information

Syntax

$System[Screen, List, Number]

$System[Screen, List, Name]

Options

To display available Screen names on the active Agent

$System[Screen, List, Number]

To returns Screen name if found or returns Not_Found

$System[Screen,List,-1]

To returns Active Screen name

Wild cards are supported.

$System[Screen, List, Name]

In the screen name is not active then Not_Found is returned.

Remarks

When Number is minus one (-1) the current screen is displayed.

Examples

For x = 0 TO 10

Writecon "screen name ",x,"  ",$system["screen, list,", x]

Next

Reports current Mouse position.

Description

Reads the mouse position on the screen or relative to the active screen.

Syntax

$System[Screen, Read, Mouse, <Screen Name>]

Options

When used without the Screen Name it will return the Mouse position, in pixels, from the upper left corner of your screen.

When used with the Screen Name it will return the Mouse position, in pixels, from the upper left corner of the active window.

Returns

A String in the format:  31948,17257

The x,y coordinates of the Mouse.

Examples

This example will print the mouse position in pixels from the upper left corner of the screen.

rem $system[screen,read,mouse]

$abortonerror="NO"

$tmp = $system["screen,read,mouse"]

Writecon "mouse position is = " , $tmp

end

Output

Mouse position is = 42112;47445

Description

The Writecon command writes a string to the console screen of the Target Agent.

Syntax

Writecon  "string"xe "WRITECON"xe "KSI BASIC Commands:WRITECON"xe "writing a string to the console"

Remarks

The Writecon command accepts and prints up to 512 characters per line.

The Coma (,) will allow combining variables in the Output line.

The Semi-Colin (;) will place a Tab character in the Output line

Example

For X = 1 to 2

Writecon X,"."; "This is an example of writing to the console at ",$TimeNow

Next

Output

1.      This is an example of writing to the console at 13:58:09

2.           This is an example of writing to the console at 13:58:09

Description  

Enumerates all top-level windows in the system.  Enumeration means that information is gathered about all the windows on the target machine.

Syntax

%System["WinCtrl, EnumWindows, options"]

Options

"Invisible"- specifies that invisible windows should be enumerated, but default invisible windows are not enumerated.

Returns

%: id number (referred to as EnumID) that identifies this enumeration.

Remarks

The "FreeEnum" command must be called when finished with this enumeration.  This will free the memory used by the "EnumWindows" command.

Example

%tmp = %system["WinCtrl, EnumWindows"]

Writecon "EnumID = " ,%tmp

Output

enumid = 9182904

Description

Frees the memory used by the enumeration returned by "EnumWindows" command.

Syntax

%System["WinCtrl, FreeEnum, emumid"]

Where

EnumID: id number that identifies the enumeration.

Example

%tmp = %System["WinCtrl, FreeEnum, ", %EnumID]

Description

Returns window enumeration parameters.

Syntax

%System["WinCtrl, EnumInfo, enumid, enuminfo"]

Where

EnumID: id number that identifies the enumeration

EnumInfo: specifies which parameter to return, can be:

"NumWindows"  %: returns the number of windows enumerated

"WindowID:num", followed by the zero based index of the window

$: returns the window text or "Not_Found" if there are no more windows.

%: returns WindowID number of the window or 0 if there are no windows.

Returns:

Depends on EnumInfo.

Examples

%EnumID = %system["WinCtrl, ENumWindows"]

%tmp = %system["WinCtrl, EnumInfo, ",%EnumID,",  NumWindows"]

Writecon "EnumID = " , %EnumID; "The number of windows = " , %tmp

for x=0 to %tmp-1

%WindowID = %system[ "WinCtrl, EnumInfo,", %EnumID, ",WindowID:" ,x]

$WindowID = $system["WinCtrl, EnumInfo,", %EnumID,", WindowID:" ,x]

Writecon "WindowID:", %WindowID ; $WindowID

next

%temp = %system["WinCtrl, FreeEnum,", %EnumID]

Output

EnumID = 8733208               The number of windows = 10

WindowID:6357604             AutoWiz - ksimjb e:\test27

WindowID:1114778             NoteTab Pro  -  E:\test27.mjb

WindowID:3473926             NoteTab Pro  -  E:\test27.mjb

WindowID:1704128             AutoWiz Users Guide.doc - Microsoft Word

WindowID:131138

WindowID:983576               E:\Knozall\MANUALS

WindowID:2228410             Inbox - Microsoft Outlook

WindowID:852954               AW Commands - (Plain Text) - Microsoft Word

WindowID:131610               New Messages of Interest

WindowID:65620                 Program Manager

Description

Returns some window parameters.

Syntax

$System["WinCtrl, WindowInfo, WindowID, WindowInfo"]

Where:

WindowID: id number that identifies the window.

WindowInfo: specifies which parameter to return, can be:

"IsValid"   $%: returns “Yes” or 1 if the window is valid and “No” or 0 if it is not.

"Text"   $: returns window text or "Not_Found" if the window is has no text.

"Invisible"   $%: returns “Yes” or 1 if the window is visible and “No” or 0 if not.

"IsMinimized"  $%: returns “Yes” or 1 if window IsMinimized and “No” or 0 if not.

"IsMaximized"  $%: returns “Yes” or 1 if maximized and “No” or 0 if not.

"ParentID"   %: returns the WindowID of the parent window or 0 if no parent.

"x"   %: returns the x coordinate of the upper left corner of the window.

"y"   %: returns the y coordinate of the upper left corner of the window.

"Width"   %$: returns the width of the window.

"Height"   %: returns the height of the window.

Example

This example gets information by enumerating windows, then uses the  $System["WinCtrl, WindowInfo, WindowID, WindowInfo"] command to get information about the windows.  All of the possible window information parameters are used.

%EnumID = %system["WinCtrl, ENumWindows"]

Writecon "EnumID = " ,%EnumID

%tmp = %system["WinCtrl, EnumInfo,", %EnumID,", NumWindows"]

Writecon "The number of windows = " ,%tmp

For x=0 to %tmp-1

%WindowID = %system["WinCtrl, EnumInfo,", %EnumID, ",WindowID:", x]

$WindowID = $system["WinCtrl, EnumInfo,", %EnumID, ",WindowID:", x]

Writecon "Window ID = " , %WindowID

Writecon " $WindowID = ", $WindowID

%IsValid = %system["WinCtrl, WindowInfo, ",%WindowID,", IsValid"]

$IsValid = $system["WinCtrl, WindowInfo, ",%WindowID,", IsValid"]

 

Writecon " Is valid? % = " ,%IsValid

Writecon " Is valid? $ = " ,$IsValid

 

%IsVisible = %system["WinCtrl, WindowInfo, ",%WindowID,", IsVisible"]

$IsVisible = $system["WinCtrl, WindowInfo, ",%WindowID,", IsVisible"]

 

Writecon " Is visible? % = " , %IsVisible

Writecon " Is visible? $ = " , $IsVisible

 

%IsMinimized = %system["WinCtrl, WindowInfo, ",%WindowID,", IsMinimized"]

$IsMinimized = $system["WinCtrl, WindowInfo, ",%WindowID,", IsMinimized"]

 

Writecon " Is minimized? % = " , %IsMinimized

Writecon " Is minimized? $ = " , $IsMinimized

 

%IsMaximized = %system["WinCtrl, WindowInfo, ",%WindowID,", IsMaximized"]

$IsMaximized = $system["WinCtrl, WindowInfo, ",%WindowID,", IsMaximized"]

 

Writecon " Is maximized? % = " , %IsMaximized

Writecon " Is maximized? $ = " , $IsMaximized

 

%ParentID = %system["WinCtrl, WindowInfo, ",%WindowID,", parentid"]

$ParentID = $system["WinCtrl, WindowInfo, ",%WindowID,", ParentID"]

 

Writecon " ParentID % = " , %ParentID

Writecon " ParentID $ = " , $ParentID

 

%xcoordinates = %system["WinCtrl, WindowInfo, ",%WindowID,", x"]

$xcoordinates = $system["WinCtrl, WindowInfo, ",%WindowID,", x"]

%ycoordinates = %system["WinCtrl, WindowInfo, ",%WindowID,", y"]

$ycoordinates = $system["WinCtrl, WindowInfo, ",%WindowID,", y"]

 

Writecon "x coordinates = ", %xcoordinates, $xcoordinates

Writecon "y coordinates = ", %ycoordinates, $ycoordinates

 

%width_dimension = %system["WinCtrl, WindowInfo, ",%WindowID,", width"]

$width_dimension = $system["WinCtrl, WindowInfo, ",%WindowID,", width"]

 

Writecon "width % = ", %width_dimension

Writecon "width $ = ", $width_dimension

 

%height_dimension = %system["WinCtrl, WindowInfo, ",%WindowID,", height"]

$height_dimension = $system["WinCtrl, WindowInfo, ",%WindowID,", height"]

 

Writecon "height % = ", %height_dimension

Writecon "height $ = ", $height_dimension

 

$text = $system["WinCtrl, WindowInfo, ",%WindowID,", text"]

Writecon "Window text is: " ,$text

Writecon "*******************************************"

next

%temp = %system["WinCtrl, FreeEnum,", %EnumID]

Output

 

Window ID = 65718

 $WindowID = Microsoft Office Shortcut Bar

 Is valid? % = 1

 Is valid? $ = Yes

 Is visible? % = 1

 Is visible? $ = Yes

 Is minimized? % = 0

 Is minimized? $ = No

 Is maximized? % = 0

 Is maximized? $ = No

 ParentID % = 65716

 ParentID $ = 65716

x coordinates = 721721

y coordinates = -14294967295

width % = 241

width $ = 241

height % = 19

height $ = 19

Window text is: Microsoft Office Shortcut Bar

.(rest of output clipped)

**************************************************************

Description   

Saves a snapshot of the specified window to a bitmap (.bmp) file.

Syntax

$System["WinCtrl, Snapshot, WindowID, path, options"]

Where:

WindowID: id number that identifies the window, specify 0 to take a snapshot of the entire screen.

path: specifies the path of the .bmp file.

Returns

$%: returns “Yes” or 1 if bitmap is written successfully and “No” or 0 if it was not.

Remarks

This command is only effective if the specified window is visible in the foreground.

Examples

rem $system[WinCtrl, Snapshot, WindowID, path, options]

$tmp = $system["WinCtrl, Snapshot,0, c:\snapshot.bmp"]

Writecon "successful? " ,$tmp

end

Output:

successful? Yes

Ending Job 'C:\TEMP\tmp1E7.tmp'... 

In the Windows Explorer the snapshot.bmp is stored.

snapshot.bmp                                  770KB    Bitmap Im...     7/19/2000 3:22 PM                      A

 

Description

Moves a window.

Syntax

%System[WinCtrl, MoveWindow, WindowID, x, y"]

Where:

WindowID: id number that identifies the window.

x: specifies the x coordinate of the upper left corner of the window.

y: specifies the y coordinate of the upper left corner of the window.

Returns

$%: returns “Yes” or 1 if the window moved successfully and “No” or 0 if not.

Example

%enumid = %system["WinCtrl,enumwindows"]

rem find the number of windows in the system

%tmp = %system["WinCtrl,enuminfo,",%enumid,",numwindows"]

rem run a for next loop to find the specified window

for x=0 to %tmp-1

%WindowID = %system["WinCtrl,enuminfo,",%enumid,",WindowID:",x]

$WindowID = $system["WinCtrl,enuminfo,",%enumid,",WindowID:",x]

if $WindowID = "AutoWiz Users Guide.doc - Microsoft Word" then GoTo 100

next

 

100

rem find the x,y coordinates of the specified window

%tmpx = %system["WinCtrl,WindowInfo,",%WindowID,",x"]

%tmpy = %system["WinCtrl,WindowInfo,",%WindowID,",y"]

Writecon "The x coordinate is:  " ,%tmpx; "The y coordinate is:  " ,%tmpy

Rem move the window to 200,200

$moved = %system["WinCtrl,movewindow,",%WindowID,",200,200"]

Writecon "Successful move?  = " ,$moved

Output

The x coordinate is:  29    The y coordinate is:  2

Successful move?  = Yes

 

Description

Changes the size of a window.

Syntax

%System["WinCtrl, SizeWindow, WindowID, width, height"]

Where:

WindowID: id number that identifies the window.

width: specifies the new width of the window.

height: specifies the new height of the window.

Returns

$%: returns “Yes” or 1 if the window was sized successfully and “No” or 0 if not.

Example

%enumid = %system["WinCtrl,enumwindows"]

%tmp = %system["WinCtrl,enuminfo,",%enumid,",numwindows"]

for x=0 to %tmp-1

%WindowID = %system["WinCtrl,enuminfo,",%enumid,",WindowID:",x]

$WindowID = $system["WinCtrl,enuminfo,",%enumid,",WindowID:",x]

if $WindowID = "AutoWiz Users Guide.doc - Microsoft Word" then GoTo 100

next

100

%tmpx = %system["WinCtrl,WindowInfo,",%WindowID,",width"]

%tmpy = %system["WinCtrl,WindowInfo,",%WindowID,",height"]

Writecon "The width is:  " ,%tmpx;  "The height is:  " ,%tmpy

$size = $system["WinCtrl,sizewindow,",%WindowID,",2000,500"]

Writecon "Successful resizing?  = " ,$size

Output

The width is:  935    The height is:  740

Successful resizing?  = Yes

Description

Sets the specified window's show state.

Syntax

%System["WinCtrl, ShowWindow, WindowID, ShowState"]

Where:

WindowID: id number that identifies the window.

ShowState: specifies the show state, can be:

 "hide" hides the window, "show" activates and displays the window.

"Minimize" minimizes the window, "Maximize" maximizes the window.

"Restore" activates and displays the specified window, if the window is minimized or maximized, restores the window to it's original size and position.

Returns

$%: returns “Yes” or 1 if the window's show state was changed successfully and “No” or 0 if it was not.

Examples

The same techniques used in the move and resize examples can be used to find, check the display status and then change the display status of windows.

%changed = %System["WinCtrl, ShowWindow, ", %WindowID, ", hide"]

%changed = %System["WinCtrl, ShowWindow, ", %WindowID, ", minimize"]

%changed = %System["WinCtrl, ShowWindow, ", %WindowID, ", maximize"]


 

 


Last updated 11/11/2009
©2009 Knozall Software, Inc.,  (800) 333 8698   (520) 426-3859
9386 N. Linnet Road, Casa Grande, Arizona 85294