|
Console Commands |
|||||||||||||||||||||||||||||||||||
|
Console Controls %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]
DescriptionThis 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. SyntaxCLRCONxe "CLRCON"xe "KSI BASIC Commands:CLRCON"xe "clearing the console screen" RemarksThis command duplicates the action of CLS (clear screen) in DOS. ExampleRem 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. DescriptionThis 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. SyntaxKeycon "Screen Name::string"xe "KEYCON"xe "KSI BASIC Commands:KEYCON"xe "sending keystrokes to the console screen" RemarksIf 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
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 '::'. ExampleExample 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 AlsoMouseCon Load Sload DescriptionSends commands to the mouse for the entire screen or to a specific window. (to move or click the mouse). SyntaxMOUSECON “Window Name::<commands> ” Commands
[R] Indicates a relative position [x] Indicates the horizontal axis [y] Indicates the vertical axis RemarksOn 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 ExampleThis 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 AlsoKeycon $System[“System,Read,Mouse”] DescriptionReads Agent screen information Syntax$System[Screen, List, Number] $System[Screen, List, Name] OptionsTo 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. RemarksWhen Number is minus one (-1) the current screen is displayed. ExamplesFor x = 0 TO 10 Writecon "screen name ",x," ",$system["screen, list,", x] Next Reports current Mouse position. DescriptionReads the mouse position on the screen or relative to the active screen. Syntax$System[Screen, Read, Mouse, <Screen Name>] OptionsWhen 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. ReturnsA String in the format: 31948,17257 The x,y coordinates of the Mouse. ExamplesThis 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 OutputMouse position is = 42112;47445 DescriptionThe Writecon command writes a string to the console screen of the Target Agent. SyntaxWritecon "string"xe "WRITECON"xe "KSI BASIC Commands:WRITECON"xe "writing a string to the console" RemarksThe 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 ExampleFor X = 1 to 2 Writecon X,"."; "This is an example of writing to the console at ",$TimeNow Next Output1. 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 DescriptionEnumerates 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. RemarksThe "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 Outputenumid = 9182904 DescriptionFrees 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] DescriptionReturns window enumeration parameters. Syntax%System["WinCtrl, EnumInfo, enumid, enuminfo"] WhereEnumID: 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] OutputEnumID = 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 DescriptionReturns 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. ExampleThis 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) ************************************************************** DescriptionSaves 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. RemarksThis command is only effective if the specified window is visible in the foreground. Examplesrem $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
DescriptionMoves 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 OutputThe x coordinate is: 29 The y coordinate is: 2 Successful move? = Yes
DescriptionChanges 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 OutputThe width is: 935 The height is: 740 Successful resizing? = Yes DescriptionSets 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. ExamplesThe 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"]
|
|||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||