[[ [testing], automation, ...]] [[Technologies: * [cwind] - find windows, inject keystrokes (free) * [wintclsend] - similar to cwind, includes mouse moves (license) * [ActiveX] * [Android] (when combined with [VNC] or '''rdesktop'''[http://www.rdesktop.org/]) * [AutoIt] [http://www.hiddensoft.com/AutoIt/] * [COM] * [DDE] * Eventcorder [http://www.volny.cz/eventcorder] * [Expect for Windows] * [Perl]'s Win32::GuiTest * [PowerPro] * [TWAPI] includes window management and input injection (mouse and keyboard) * [WSH] * Win32-GuiText-X * (other) commercial testing applications, * Girder [http://www.girder.nl] (including [Python] client [http://www.dur.ac.uk/christopher.saunter/soft.html]) * win32api's PostMessage provides for delivery of keystrokes, button presses, and such, to external processes; while this [http://mail.python.org/pipermail/python-win32/2002-December/000635.html] discussion, as well as this [http://www.brunningonline.net/simon/blog/archives/000664.html], are about Python coding, the same functionality is available to Tcl through ... (?) * ...]] ---- '''Forget Cwind, WinTclSend And The Like...''' Cwind, WinTclSend and Perl's Win32::GuiTest are programs that rely on three standard Windows API functions:- * '''Find Window''' - which given a window's title (the text string that goes in the Title Bar,) will return it's HWND (a unique identifier that Windows assigns to a window). * '''Set Foreground Window''' - which makes the HWND supplied it the ''foreground window'' - to which all subsequent key-strokes and mouse-clicks are sent, and; * '''Send''' - which sends the specified keystrokes to the current foreground window. The documentation for these programs says or implies that you can control applications like Notepad, Word, Excel, etc - from your Tcl script - just as a user could - by using the package functions to simulate user keyboard/mouse input. BOLLOCKS! This technique is hopelessly inadequate and unreliable - except in certain very restricted situations. There are three problems:- 1. '''The Disappearing Foreground Window'''. The foreground window is a global thing - shared by all processes and applications that are running. So although you can SetForegroundWindow to the application you want to send key-strokes and/or mouse-clicks too - Windows and/or any other application can do the same thing too. In particular, every time the user clicks on something, that something becomes the new foreground window. Quite obviously, if the user's trying to use their web browser (or whatever), at the same time as your script is trying to send keystrokes to (say) Excel (or whatever), it's going to be a complete disaster. And even if no user is using the computer while your script is running, that's still no guarantee your key-strokes will reach their intended destination. Other processes can pop up message boxes etc, and steal the foreground window away from the window you set it to, at any time. 1. '''