Commands & Syntax > Commands > Macro Flow Control >

IF WINDOW - < if_win >() ... [Free]

www.perfectkeyboard.com

 

IF WINDOW
<if_win>("Window","Condition",Match)
Available in: Free edition

The command evaluates a window specific condition and if it is evaluated as "true" then following macro steps (steps between "if" and "else/endif") are executed.

 

#

Parameter name

Parameter description

1

Window

Window identification to check against the condition.

2

Condition

Condition can be one from the following:
"OPEN" - the statement is true if window with the WinTitle is opened (exist).
"CLOSE" - the statement is true if window with the WinTitle is not opened (no more exist).
"ACT" - the statement is true if window with the WinTitle is active (top most, receives keyboard events).
"NOACT" - the statement is true if window with the WinTitle is not active (not receives keyboard events).

3

Match

If 1, window identification must exactly match the window.
If 0, window identification can just partially match the window.

 

Example (Macro Steps):

 

1

<#> <#> This macro shows how to use "if_win" command

2

Macro execution: ONLY COMMANDS

3

IF WINDOW "notepad" Is Open (Match=Partial)

4

IF WINDOW "Notepad" Is Active (Match=Partial)

5

Message SHOW "" : "Notepad is opened and active." (other parameters: x = 100, y = 100, Window title = Message, Buttons = OK, Timeout (seconds) = , Always on top = ).

6

ELSE activate

7

Message SHOW "" : "Notepad is opened but not active." (other parameters: x = 100, y = 100, Window title = Message, Buttons = OK, Timeout (seconds) = , Always on top = ).

8

ENDIF

9

ELSE activate

10

Message SHOW "" : "Notepad is not opened." (other parameters: x = 100, y = 100, Window title = Message, Buttons = OK, Timeout (seconds) = , Always on top = ).

11

ENDIF

Example (Plain Text):

 

<#> This macro shows how to use "if_win" command

<#>

<cmds>

<if_win>("notepad","OPEN",0)

   <if_win>("Notepad","ACT",0)

      <msg>(100,100,"Notepad is opened and active.","Message",1)

   <else>

      <msg>(100,100,"Notepad is opened but not active.","Message",1)

   <endif>

<else>

   <msg>(100,100,"Notepad is not opened.","Message",1)

<endif>