winctrl

manipulate windows 

Command


SYNOPSIS

winctrl

winctrl hwnd|title close

winctrl hmenu dumpmenu

winctrl hmenu [-v] getsubmenu

winctrl hwnd|title setposition x y

winctrl hwnd|title setheight num

winctrl hwnd|title getchildren

winctrl hwnd|title setwidth num

winctrl hwnd|title settitle title_name

winctrl hwnd|title ischildi parenthwnd|parenttitle

winctrl hwnd|title setfocus

winctrl hwnd|title minimize

winctrl hwnd|title maximize

winctrl hwnd|title restore

winctrl hwnd|title hide

winctrl hwnd|title getstate

winctrl hwnd|title gettitle

winctrl hwnd|title getparent

winctrl hwnd|title gethwnd

winctrl hwnd|title gettop

winctrl hwnd|title getleft

winctrl hwnd|title getbottom

winctrl hwnd|title getright

winctrl hwnd|title getwidth

winctrl hwnd|title getheight


DESCRIPTION

The winctrl utility lets you set and retrieve information about windows open on your system.

With no arguments, winctrl displays a list of all valid windows, as follows:

HANDLE      PARENT             PID TITLE
0x00240886  0x00000000        3136 SysFader
0x001d0718  0x00000000        3136 SysFader
0x00620774  0x00000000        3136 SysFader

The window handles are displayed in hexadecimal format. The second column is the parent (or owner), the third column is the process ID (in decimal, as with the ps utility), and the fourth column is the title. If the second column entry is 0x00000000, the window is a top-level unowned window.

Virtually all winctrl commands require you to specify a window using either its handle or title. These can be obtained by issuing a winctrl command with no arguments, as described earlier.

When searching for a window title to match a title (or parettitle) argument, winctrl uses this procedure:

  1. All window titles are searched for a match for title.

  2. If one (or more) exact matches for the title are found, winctrl uses the first window that is an exact match.

  3. If no exact matches are found, winctrl searches for partial matches. A partial match occurs when the title argument is a substring of a window title. For example, if you have five windows:

    BOO
    boo
    boohooyou
    boohoome
    

    The title argument boo matches only boo, but boohoo matches one of boohooyou and boohoome.

If a window is created while winctrl is searching the list of windows, that new window may not yet be accessible to winctrl. For example:

notepad & ; winctrl

may or may not list the window for notepad.

To avoid this problem in scripts, use the sleep utility to pause the script long enough for the window to be created.

Note:

Attempting to use winctrl to resize or maximize a window which does not have standard Windows support for that operation can produce indeterminate results.

Commands

winctrl hwnd|title setposition x y 

sets the position of the top left corner of the specified window at horizontal position x and vertical position y where 0,0 is the upper left hand corner of the screen.

winctrl hwnd|title setheight num 

sets the height of the specified window to num.

winctrl hwnd|title width num 

sets the width of the specified specified window to num.

winctrl hwnd|title settitle title_name 

sets the title of the specified window to title_name

winctrl hwnd|title ischild parenthwnd|parenttitle 

outputs yes if parenthwnd|parenttitle is the parent (or owner) of hwnd|title; otherwise, it outputs no.

winctrl hwnd|title setfocus 

moves the specified window to the foreground and gives it the focus. If the specified window is minimized or not visible, it is restored.

winctrl hwnd|title minimize 

minimizes the specified window.

winctrl hwnd|title maximize 

maximizes the specified window.

winctrl hwnd|title restore 

restores the specified window to its normal size and position on the screen.

winctrl hwnd|title hide 

hides the specified window.

winctrl hwnd|title close 

closes the specified window.

winctrl hwnd|title getstate 

outputs the current state of the specified window. The status is one of the following:

SW_HIDE
SW_MAXIMIZE
SW_MINIMIZE
SW_RESTORE
SW_SHOW
SW_SHOWMAXIMIZED
SW_SHOWMINIMIZED
SW_SHOWMINNOACTIVE
SW_SHOWNA
SW_SHOWNOACTIVATE
SW_SHOWNORMAL
winctrl hwnd|title gettitle 

outputs the title of the specified window.

winctrl hwnd|title getparent 

outputs the handle of parent (or owner) of the specified window.

winctrl hwnd|title getchildren 

outputs the handles of any windows for which the specified window is the parent (or owner).

winctrl hwnd|title gethwnd 

outputs the handle of the specified window.

winctrl hwnd|title gettop 

outputs the "top" coordinate of the specified window.

winctrl hwnd|title getleft 

outputs the "left" coordinate of the specified window.

winctrl hwnd|title getbottom 

outputs the "bottom" coordinate of the specified window.

winctrl hwnd|title getright 

outputs the "right" coordinate of the specified window.

winctrl hwnd|title getwidth 

outputs the width of the specified window.

winctrl hwnd|title getheight 

outputs the height of the specified window.


DIAGNOSTICS

Possible exit status values are:

0 

Successful completion.

>0 

An error occurred.


PORTABILITY

Windows 8.1. Windows Server 2012 R2. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022.


AVAILABILITY

PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Commands:
sendevent


PTC MKS Toolkit 10.4 Documentation Build 39.