Window Operations * STW.

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Window Operations > STW. - Search Top Window >

Window Operations * STW.

STW - Search-Top-Window

Previous Top Next


MiniRobotLanguage (MRL)

 

STW. Command

Search Top Window

 

 

Intention

 

This command localizes a specified Top-Window and sets the actual point into its center.

All following SCW-commands will be within this window.

STW. has a default window-treatmentto ensure that any further action in that window will be effective. This default treatment will do following:

- normalize minimized windows (like the "D"-Flag

- windows that are outside the desktop-work area will be moved to 0,0 (like "G"-Flag)

- The window will be moved in front of all other (non-TopMost)-windows.

- The window will receive the input focus. (like the "J"-Flag)

 

This default window-treatment can be completely deactivated using the "A"-Flag.

 

This makes sense, for example when working with Menu's or other windows which disappear when the default treatment is being applied.

 

Alternatively the default window treatment can be influenced using other flags, like "B" or "G".

 

If the window should be brought into work area, without other treatment, use the "B"-Flag. "G",  will just prevent the repositioning of the window and let the other treatment-steps happen.

 

All window search operations change the Timeout System Variables #tio# and #til#. Using these you can find out if a window was found or not, even if you have used the"X" Flag (X - run without Error).

 

Hint: Please note that the Flags have a priority from left to right (highest Priority). If you add other flags after the "A" there may be a treatment. Because the more right the flags, the higher their priority. If you place the "A" last inside the prototypes, all involved treatment will be disabled.

 

See two examples.

In this first case the "A" Flag has priority over the "C" Flag, because its right of it.

 

STW.tCA|explorer

MMV.

 

In this case the "C" Flag is right of the "A" Flag and therefore has priority over the "A" Flag.

 

STW.tAC|explorer

MMV.

 

Some Flags deactivate the default treatment or parts of it. See description below.

 

Hint: If you omit all parameters like this:

STW.

the command will automatically restore the parameters from the previous call. This makes it easy to always locate the same Top-Window.Note that this also applies to ITW. as both use the same parameters-store.

 

 

 

Syntax

 

 

STW.P1[|P2]...[|Px]

 

 

Parameter Explanation

 

P1 - Prototype

P2 .. PX - Parameters according to prototypes

 

 

A - (np) Switch off default window treatment completely

B - (np) disables following parts of "default treatment":

    NO Restore from Minimized, NO Set Input-Focus,

    NO Bring to Front

C - (np) If the window i maximized, it will be restored to

   normal size

D - (np) If the window is minimized,  will be restored to its

   previous size, before it was minimized,

E - (np) Put Localize window, then add window to

   Search Exclude List.    

F - (np) Move window to center of primary desktop

G - (np) disable default window-treatment-"repositioning if

    outside"

H - (np) a window that is outside the primary desktop working area

   will be repositioned. Default is that the window can be also

   on a second desktop.

I - (NUM/VAR) Remove window with the given window-handle from the

   search-exclude-list.

J - (np) Bring window to Front. Does not switch off default window

   treatment.

K - Immediately clear Exclude-List before specified search

M - (np) Set window to TOPMOST. Such windows will be on Top of all

   other Non-TOPMOST windows. DANGER - even Messageboxes may be

   hidden behind a TOPMOST window. Use this with caution!

N - (np) remove the TOPMOST Property from a window.

Q - use previous Prototypes (only prototypes)

V - (p/Label) Gosub Line/Label if the window was NOT found

W - (p/Label) Gosub Line/Label if the window was found

X - (np) run without error if window was not found. Timeout Flag

   #tio# and #til# will anyway be set and can be used.

 

a - (np) changes internal settings that "all" windows will be

   found. This includes invisible and disabled windows.

b - (np) "back" - moves window to the back, behind other windows.

c - (p) "class", window-class parameter

e - (np) enabled, the window must be enabled or it will ignored.

f - (np) disabled, the window must be disabled or it will ignored.

g - (p/Label) Goto Line/Label if the window was found

h - (p) localize the window directly using a given window handle.

   Note, if "h" is given, other search conditions will

   be ignored.

j - (p) WaitForInputIdle, you can specify the WII timeout

k - (np) WaitForInputIdle - no parameter, use the default

   WII timeout.

o - (Label/Variable) on not found goto (Label)

p - (p) process-ID, search only windows from process with this

   given PID

q - (p) ThreadID,, search only windows from process with this

   given TID

r - (p) No. of result to choose (Result-Number for Top-Windows)

t - (p) text, window-text (often the window caption)

u - (np) invisible, search only invisible windows

v - (np) visible, search only visible windows

w - (p) total waiting-time in Seconds, 0.5 (FP-numbers) is

   possible.

 

  Explanation:

    (np) -> only prototype, no additional parameter required

  (p) -> prototype requires additional parameter

    (NUM/VAR) - window handle/variable

  (p/Label) - Label-Parameter required, can also be a

              variable that contains the label

 

P2 - Px - Data according to the prototypes, separated by |

 

 

 

 

Example

 

'MR Script-file:  

'Version:

'Purpose: STW.-Features Demo

'Author: Theo Gottwald

'Creation date: 09.12.11

'===========================================================

'#EXE:?pfad\

'#SPI:ForceWrite

'

' Start an Application only, if that Application is not yet running.

'

' We use STW here to test if the Application is already running

' in that case we jump over the EXE-command and contine.

' We use the following flags:

' w ... 0 - Set waiting time to 0 seconds

' t ... "BCS - Testform" - this is the caption text of the window we search for

' g ... "found" - jump to Label ":found" if the window already exists

' X ... continue without errormessage if the window was not found in time

'

STW.wtgX|0|BCS - Testform|found

EXE.?exepfad\Sample Apps\BSC-Testform.exe

:found

 

' Now we can use the Application and press Buttons

STW.wt|0|BCS - Testform

SCW.nctb|1|Button|Next|0

' Compatible Button Click

MLC.

 

'-----------------------------------------------------------

ENR.

 

 

 

 

Remarks

 

To select/locate a Top- Window, you will most often use STW. or in few cases LAP.

 

 

 

Limitations:

 

-

 

 

See also:

 

    1.4. The Prototype Parameter System

    3.2 Standard-Search Pattern

    1.5. Features and Hints

    1.9. Locating Child-Windows

    1.7. Application and PID

    3.1 Systemvariables

    LAP. - Locate at Point