CWind

Update of "manpage"
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

Artifact ID: 71704426e412806fa7be3a3ce2c8a766fa6ab0092586c75fd38a8c36c0f35f69
Page Name:manpage
Date: 2017-09-04 22:54:23
Original User: imdave
Parent: 896a17e40cbad6d35cc15d32d837205d062751e822d1e0428d0e63e91e514c20
Content

NAME

cwind - keyboard and mouse simulation

SYNOPSIS

package require cwind ?1.5.1?
::cwind::command ?args …?

DESCRIPTION

SPECIAL CHARACTERS

WINDOW MANAGER COMMANDS

REQUIREMENTS

INSTALLATION

LICENSE


NAME


cwind - keyboard and mouse simulation


SYNOPSIS


package require cwind ?1.5.1?

::cwind::command ?args …?


DESCRIPTION


The CWind package allows one to simulate keyboard and mouse interactions on windows. Keystrokes, mouse clicks and window manager commands can be sent to arbitrary windows.

::cwind::wlist ?-exact? ?window-title?

If window-title (a glob pattern) is omitted, return a list of all existing window titles.
If window-title is specified, return a list of all the MDI child window names. It appears (2017) that there are very few applications using MDI and the technology is falling out of favor although PhotoFiltre and Paint.NET make use of it.

::cwind::show ?-exact? window-title

Search for a window with the given title (a glob pattern) and make it the active window.
The window-title must be a proper Tcl list of one or two elements. The first element is a parent window title and the optional second element is a MDI child window name. It appears (2017) that there are very few applications using MDI and the technology is falling out of favor although PhotoFiltre and Paint.NET make use of it.

::cwind::waitwind window-title ?seconds?

Wait seconds (default 5) for a window with the given title (a glob pattern) to become the active window.

::cwind::gettext

Return the active window's title.

::cwind::top ?-exact? window-title

Places the window with the given title (a glob pattern) at the top of the Z order. Refer to the microsoft documentation of the SetWindowPos() function for a full description.

::cwind::bottom ?-exact? window-title

Places the window with the given title (a glob pattern) at the bottom of the Z order. Refer to the microsoft documentation of the SetWindowPos() function for a full description.

::cwind::topmost ?-exact? window-title

Places the window with the given title (a glob pattern) above all non-topmost windows. The window maintains its topmost position even when it is deactivated. Refer to the microsoft documentation of the SetWindowPos() function for a full description.

::cwind::notopmost ?-exact? window-title

Places the window with the given title (a glob pattern) above all non-topmost windows (that is, behind all topmost windows). Refer to the microsoft documentation of the SetWindowPos() function for a full description.

::cwind::getrect

Return a four-element list containing the coordinates of the client rectangle for the active window. This is effectively the size of the client window since the first two coordinates are always 0 0.

::cwind::getwrect

Return a four-element list containing the screen coordinates of the active window

::cwind::getpos

Return a list containing the current mouse coordinates on the screen.

::cwind::setpos coordinates

Set the mouse position relative to the origin {0 0} at the upper left corner on the screen to coordinates (a list of two elements).

::cwind::getwpos

Return a list containing the current mouse coordinates on the screen relative to the active window.

::cwind::setwpos coordinates

Set the mouse position in the active window relative to the origin {0 0} at the upper left corner to coordinates (a list of two elements).

::cwind::minimize

Minimize the active window.

::cwind::maximize

Maximize the active window.

::cwind::restore

Restore the active window to its original size.

::cwind::minimizeAll

Minimize all the windows.

::cwind::state ?-exact? window-title

Return the status of the window with the given title (a glob pattern): Maximized, Minimized or Normal.
The window-title must be a proper Tcl list of one or two elements. The first element is a parent window title and the optional second element is a MDI (Multiple-Document Interface) child window name. It appears (2017) that there are very few applications using MDI and the technology is falling out of favor although PhotoFiltre and Paint.NET make use of it.

::cwind::lclick

Send a left mouse click to the active window.

::cwind::rclick

Send a right mouse click to the active window.

::cwind::mclick

Send a middle mouse click to the active window.

::cwind::dragl coordinates

Drag the mouse with the left-button to screen coordinates (a list of two elements).

::cwind::dragm coordinates

Drag the mouse with the middle-button to screen coordinates (a list of two elements).

::cwind::dragr coordinates

Drag the mouse with the right-button to screen coordinates (a list of two elements).

::cwind::wdragl coordinates

Drag the mouse with the left-button to coordinates (a list of two elements) within the active window.

::cwind::wdragm coordinates

Drag the mouse with the middle-button to coordinates (a list of two elements) within the active window.

::cwind::wdragr coordinates

Drag the mouse with the right-button to coordinates (a list of two elements) within the active window.

::cwind::send text

Send each text argument to the active window.

::cwind::sendmessage command ?wparam? ?lparam?

Send a windows manager command (either the integer value or name – see WINDOW MANAGER COMMANDS) to the active window via SendMessage. Wparam and lparam are additional integer values required by the command.

::cwind::postmessage command ?wparam? ?lparam?

Send a windows manager command (either the integer value or name – see WINDOW MANAGER COMMANDS) to the active window via PostMessage. Wparam and lparam are additional integer values required by the command.

::cwind::getcb

Return the text content of the clipboard.

::cwind::putcb text

Put text into the clipboard.

::cwind::sleeptime ?milliseconds?

Return or set the sleep time which is the number of milliseconds to delay before sending each character. The default is zero.

::cwind::version

Return a string that identifies the Cwind version, the architecture for which it was built (32- or 64-bit), the date and time compiled and the GNU C compiler version.


SPECIAL CHARACTERS


Special characters may be included with sent text. For example ctrl+c, ctrl+o, PF4, ...

To distinguish a normal string from a special character, enclose it between pipes (the character '|').

For example, to send ctrl+c, use the following: |CTRL+| c |CTRL-|. This specifies that you want to hold the CTRL key, type 'c', and then release CTRL.

Since this may not be common knowledge, note that sending |SNAP| (Print Screen) will copy the entire screen into the clipboard while |ALT+| |SNAP| |ALT-| (Alt-Print Screen) restricts the copy to the active window.


SPECIAL CHARACTERS


ALT+press ALTPGUPthe Page Up key
ALT-release ALTPGDNthe Page Down key
ALTL+press left ALT keyHOMEthe Home key
ALTL-release left ALT keyENDthe End key
ALTR+press right ALT keySNAPthe Print Screen key
ALTR-release right ALT key 
 F1 - F12Function keys 1-12
CTRL+press CTRL 
CTRL-release CTRLNUM0 - NUM9Digits 0-9 on the numeric key pad
CTRLL+press left CTRL key 
CTRLL-release left CTRL keyNUM*'*' on the numeric keypad
CTRLR+press right CTRL keyNUM/'/' on the numeric keypad
CTRLR-release right CTRL keyNUM+'+' on the numeric keypad
 NUM-'-' on the numeric keypad
SHIFT+press SHIFTNUM.'.' on the numeric keypad
SHIFT-release SHIFTNUM#synonym for NUM.
SHIFTL+press left SHIFT keyNUM,apparently the keypad Enter key
SHIFTL-release left SHIFT key 
SHIFTR+press right SHIFT keySELthe menu select key (to the right of the space bar)
SHIFTR-release right SHIFT keyLWINthe windows key (to the left of the space bar)
 RWINthe windows key (to the right of the space bar)
TABthe Tab key 
RETthe Return keyKANJIthe kanji key (Japanese keyboard)
ESCthe Escape keyKANAJapanese keyboard only
SPACEthe Space keyHANGULJapanese keyboard only
 JUNJAJapanese keyboard only
BACKthe Backspace keyFINALJapanese keyboard only
DELthe Delete keyHANJAJapanese keyboard only
INSthe Insert keyCONVthe IME convert key
HELPthe help keyNCONVthe IME nonconvert key
 ACCEPTthe IME accept key
LEFTarrow leftCLRUnknown key
RIGHTarrow rightPRINTUnknown key
UParrow upEXECUnknown key
DOWNarrow downAPPSUnknown key
 MODEUnknown key


WINDOW MANAGER COMMANDS


For a comprehensive list, see the winuser.h header file and the microsoft documentation.

WM_NULLWM_NCPAINTWM_XBUTTONDBLCLK
WM_CREATEWM_NCACTIVATEWM_MOUSELAST
WM_DESTROYWM_GETDLGCODEWM_PARENTNOTIFY
WM_MOVEWM_SYNCPAINTWM_ENTERMENULOOP
WM_SIZEWM_NCMOUSEMOVEWM_EXITMENULOOP
WM_ACTIVATEWM_NCLBUTTONDOWNWM_NEXTMENU
WM_SETFOCUSWM_NCLBUTTONUPWM_SIZING
WM_KILLFOCUSWM_NCLBUTTONDBLCLKWM_CAPTURECHANGED
WM_ENABLEWM_NCRBUTTONDOWNWM_MOVING
WM_SETREDRAWWM_NCRBUTTONUPWM_POWERBROADCAST
WM_SETTEXTWM_NCRBUTTONDBLCLKWM_DEVICECHANGE
WM_GETTEXTWM_NCMBUTTONDOWNWM_MDICREATE
WM_GETTEXTLENGTHWM_NCMBUTTONUPWM_MDIDESTROY
WM_PAINTWM_NCMBUTTONDBLCLKWM_MDIACTIVATE
WM_CLOSEWM_NCXBUTTONDOWNWM_MDIRESTORE
WM_QUERYENDSESSIONWM_NCXBUTTONUPWM_MDINEXT
WM_QUERYOPENWM_NCXBUTTONDBLCLKWM_MDIMAXIMIZE
WM_ENDSESSIONWM_INPUT_DEVICE_CHANGEWM_MDITILE
WM_QUITWM_INPUTWM_MDICASCADE
WM_ERASEBKGNDWM_KEYFIRSTWM_MDIICONARRANGE
WM_SYSCOLORCHANGEWM_KEYDOWNWM_MDIGETACTIVE
WM_SHOWWINDOWWM_KEYUPWM_MDISETMENU
WM_WININICHANGEWM_CHARWM_ENTERSIZEMOVE
WM_SETTINGCHANGEWM_DEADCHARWM_EXITSIZEMOVE
WM_DEVMODECHANGEWM_SYSKEYDOWNWM_DROPFILES
WM_ACTIVATEAPPWM_SYSKEYUPWM_MDIREFRESHMENU
WM_FONTCHANGEWM_SYSCHARWM_IME_SETCONTEXT
WM_TIMECHANGEWM_SYSDEADCHARWM_IME_NOTIFY
WM_CANCELMODEWM_UNICHARWM_IME_CONTROL
WM_SETCURSORWM_KEYLASTWM_IME_COMPOSITIONFULL
WM_MOUSEACTIVATEWM_IME_STARTCOMPOSITIONWM_IME_SELECT
WM_CHILDACTIVATEWM_IME_ENDCOMPOSITIONWM_IME_CHAR
WM_QUEUESYNCWM_IME_COMPOSITIONWM_IME_REQUEST
WM_GETMINMAXINFOWM_IME_KEYLASTWM_IME_KEYDOWN
WM_PAINTICONWM_INITDIALOGWM_IME_KEYUP
WM_ICONERASEBKGNDWM_COMMANDWM_MOUSEHOVER
WM_NEXTDLGCTLWM_SYSCOMMANDWM_MOUSELEAVE
WM_SPOOLERSTATUSWM_TIMERWM_NCMOUSEHOVER
WM_DRAWITEMWM_HSCROLLWM_NCMOUSELEAVE
WM_MEASUREITEMWM_VSCROLLWM_WTSSESSION_CHANGE
WM_DELETEITEMWM_INITMENUWM_TABLET_FIRST
WM_VKEYTOITEMWM_INITMENUPOPUPWM_TABLET_LAST
WM_CHARTOITEMWM_MENUSELECTWM_CUT
WM_SETFONTWM_MENUCHARWM_COPY
WM_GETFONTWM_ENTERIDLEWM_PASTE
WM_SETHOTKEYWM_MENURBUTTONUPWM_CLEAR
WM_GETHOTKEYWM_MENUDRAGWM_UNDO
WM_QUERYDRAGICONWM_MENUGETOBJECTWM_RENDERFORMAT
WM_COMPAREITEMWM_UNINITMENUPOPUPWM_RENDERALLFORMATS
WM_GETOBJECTWM_MENUCOMMANDWM_DESTROYCLIPBOARD
WM_COMPACTINGWM_CHANGEUISTATEWM_DRAWCLIPBOARD
WM_COMMNOTIFYWM_UPDATEUISTATEWM_PAINTCLIPBOARD
WM_WINDOWPOSCHANGINGWM_QUERYUISTATEWM_VSCROLLCLIPBOARD
WM_WINDOWPOSCHANGEDWM_CTLCOLORMSGBOXWM_SIZECLIPBOARD
WM_POWERWM_CTLCOLOREDITWM_ASKCBFORMATNAME
WM_COPYDATAWM_CTLCOLORLISTBOXWM_CHANGECBCHAIN
WM_CANCELJOURNALWM_CTLCOLORBTNWM_HSCROLLCLIPBOARD
WM_NOTIFYWM_CTLCOLORDLGWM_QUERYNEWPALETTE
WM_INPUTLANGCHANGEREQUESTWM_CTLCOLORSCROLLBARWM_PALETTEISCHANGING
WM_INPUTLANGCHANGEWM_CTLCOLORSTATICWM_PALETTECHANGED
WM_TCARDWM_MOUSEFIRSTWM_HOTKEY
WM_HELPWM_MOUSEMOVEWM_PRINT
WM_USERCHANGEDWM_LBUTTONDOWNWM_PRINTCLIENT
WM_NOTIFYFORMATWM_LBUTTONUPWM_APPCOMMAND
WM_CONTEXTMENUWM_LBUTTONDBLCLKWM_THEMECHANGED
WM_STYLECHANGINGWM_RBUTTONDOWNWM_CLIPBOARDUPDATE
WM_STYLECHANGEDWM_RBUTTONUPWM_HANDHELDFIRST
WM_DISPLAYCHANGEWM_RBUTTONDBLCLKWM_HANDHELDLAST
WM_GETICONWM_MBUTTONDOWNWM_AFXFIRST
WM_SETICONWM_MBUTTONUPWM_AFXLAST
WM_NCCREATEWM_MBUTTONDBLCLKWM_PENWINFIRST
WM_NCDESTROYWM_MOUSEWHEELWM_PENWINLAST
WM_NCCALCSIZEWM_XBUTTONDOWNWM_APP
WM_NCHITTESTWM_XBUTTONUPWM_USER


REQUIREMENTS


CWind requires Tcl 8.1 or higher.

The CWind package is available for Windows 95/98/Me/NT4.0/2000/+
For windows versions prior to vista, you can download the 32-bit version 1.4 from the project home page or the archived ZIP from this site. You might also be able to compile the original source with the appropriate microsoft sdk.

For windows versions vista and beyond, either download the appropriate pre-built binary from this repository or compile it from source. The included src/GNUmakefile was tested with MSYS2's 32- and 64-bit gcc.

Note that I am only able to test the compiled version on a virtual windows XP system and a windows 7 64-bit system. Furthermore, the test is reduced to running the script sample/english/sample.tcl.


INSTALLATION


Edit src/GNUmakefile and update the locations for your Tcl installation and the location (if possible) to the latest winuser.h header file.
Run make install to create the directory ../CWind1.5.1
Copy that directory to your TCL library.


LICENSE


CWind is free software copyrighted by Satoshi Imai. You can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation.
Use this package at your own risk and expense.


s-imai@japan.interq.or.jp
Author's Project home page
Tcl wiki page which discusses the cwind extension