Use cwind package for GUI automation test

Discuss about TCL

Use cwind package for GUI automation test

Postby scriptdev » Sat Aug 07, 2010 1:11 pm

Overview
Cwind is a control interface of Tcl, it can simulate expansion pack, keyboard, mouse operation, capture interface, control interface such information, similar to the window, like QARUN software, through Tcl cwind library can use scripting easily realizing QARUN function, so it can be used in various GUI test.

Command usage
The available commands are :
Code: Select all
In version 1.4

to simulate a left click on the mouse
::cwind::lclick

to simulate a right click on the mouse
::cwind::rclick

to simulate a middle click on the mouse
::cwind::mclick

to set the mouse position
::cwind::setpos 
where the starting position (0 0) is the upper left corner

to get the mouse position
::cwind::getpos

to get the cursor postion based on the position of the foreground window
::cwind::getwpos

to set the cursor postion based on the position of the foreground window
::cwind::setwpos 

In version 1.3

to send a message to the foreground window.
::cwind::sendmessage  ?? ??
Message name is the windows's message to be sent.
Wparam and lparam are additional value.

to post a message to the foreground window.
::cwind::postmessage  ?? ??
Message name is the windows's message to be posted.
Wparam and lparam are additional value.

In version 1.2

I've expanded the specification of some commands for MDI.

to put in active a window.
::cwind::show ?-exact?
Search into the list of active window's name and set in foreground this window.
Window's name is treated as a glob-style pattern.
Window's name is specified in list form,
The first element is a parent window name and the optional second element is a MDI child window name.

to get the status of a window (Maximized, Minimized or Normal).
::cwind::state ?-exact?
Window's name is treated as a glob-style pattern.
Window's name is specified in list form,
The first element is a parent window name and the optional second element is a MDI child window name.

to have a list of all opened windows.
::cwind::wlist ?-exact? ??
If Window's name is omitted, Will show you a Tcl list with all the window's name.
If Window's name is specified, Will show you a Tcl list with all the MDI child window's name.
Window's name is treated as a glob-style pattern.

In version 1.1

Due to confilcts with the Tcl command "list",
I've renamed the command ::cwind::list to ::cwind::wlist.
::cwind::wlist

to get the status of a window (Maximized, Minimized or Normal).
::cwind::state ?-exact?
Window's name is treated as a glob-style pattern.

to restore the foreground window at the original size.
::cwind::restore

to minimize the foreground window.
::cwind::minimize

to maximize the foreground window.
::cwind::maximize

to minimize all the windows.
::cwind::minimizeAll

to wait a specific window on the foreground.
::cwind::waitwind  ??
Max wait is in seconds and the default value is 5.
Window's name is treated as a glob-style pattern.

In version 1.0

to send a text to the foreground window.
::cwind::send  ...
Send the arguments, separated by spaces.
If you want send the spaces, enclose your text into { and }.

to put in active a window.
::cwind::show ?-exact?
Search into the list of active window's name and set in foreground this window.
Window's name is treated as a glob-style pattern.

to get the active window name.
::cwind::gettext
Get the test of the foreground window.

to get the content of the clipboard.
::cwind::getcb

to put strings into the clipboard.
::cwind::putcb

to have a list of all opened windows.
::cwind::list
Will show you a Tcl list with all the window's name.

to set the sleep time.
::cwind::sleeptime ??
Time is to ask to the system to wait before each character sent.
A sort of delay in milliseconds.


Special keys
You have the possibility to send some special characters. For example ctrl+c, ctrl+o, PF4, ... To distinguish a normal string from a special character, you must enclose it between pipes(the character |). For example, if you want to send ctrl+c, you must send the following string : "|CTRL+| c |CTRL-|". This say that you want type the character "CTRL", hold that key, type "c", and release "CTRL".

Special key list
Code: Select all
"ALT+"   press ALT
"ALT-"   release ALT
"ALTL+"   press left ALT key
"ALTL-"   release left ALT key
"ALTR+"   press right ALT key
"ALTR-"   release right ALT key

"CTRL+"   press CTRL
"CTRL-"   release CTRL
"CTRLL+"   press left CTRL key
"CTRLL-"   release left CTRL key
"CTRLR+"   press right CTRL key
"CTRLR-"   release right CTRL key

"SHIFT+"   press SHIFT
"SHIFT-"   release SHIFT
"SHIFTL+"   press left SHIFT key
"SHIFTL-"   release left SHIFT key
"SHIFTR+"   press right SHIFT key
"SHIFTR-"   release right SHIFT key

"TAB"   press the tabulation key
"RET"   press the return key
"ESC"   press the escape key

"BACK"   press the backward key
"DEL"   press the delete key
"INS"   press the insert key
"HELP"   press the help key

"LEFT"   send the cursor to the left
"RIGHT"   send the cursor to the right
"UP"   send the cursor to up
"DOWN"   send the cursor to down
"PGUP"   press the page up key
"PGDN"   press the page down key
"HOME"   press the home key
"END"   press the end key

"F1"   press the function key F1
"F2"   press the function key F2
"F3"   press the function key F3
"F4"   press the function key F4
"F5"   press the function key F5
"F6"   press the function key F6
"F7"   press the function key F7
"F8"   press the function key F8
"F9"   press the function key F9
"F10"   press the function key F10
"F11"   press the function key F11
"F12"   press the function key F12

"NUM0"   press the 0 on the key pad
"NUM1"   press the 1 on the key pad
"NUM2"   press the 2 on the key pad
"NUM3"   press the 3 on the key pad
"NUM4"   press the 4 on the key pad
"NUM5"   press the 5 on the key pad
"NUM6"   press the 6 on the key pad
"NUM7"   press the 7 on the key pad
"NUM8"   press the 8 on the key pad
"NUM9"   press the 9 on the key pad

"NUM*"   press the * on the key pad
"NUM+"   press the + on the key pad
"NUM-"   press the - on the key pad
"NUM,"   press the , on the key pad
"NUM/"   press the / on the key pad

"SNAP"   press the print key
"APPS"   press the application key
"KANJI"   press the kanji key
"CONV"   press the convert key
"NCONV"   press the nonconvert key


Sample script
package require cwind
Code: Select all
exec $env(COMSPEC) /c start wordpad.exe &
::cwind::waitwind {*WordPad} 10
::cwind::send {Hello World!} |RET|
after 1000
::cwind::send |CTRL+| a |CTRL-|
after 1000
::cwind::send |CTRL+| c |CTRL-|
after 1000
set clip [::cwind::getcb]
after 1000
::cwind::send |END| |CTRL+| v |CTRL-|
after 1000
::cwind::send |ALT+| h |ALT-| a
after 1000
::cwind::send |ALT+| |SNAP| |ALT-|

exec $env(COMSPEC) /c start mspaint.exe &
::cwind::waitwind {*Paint} 10
::cwind::send |ALT+| e |ALT-| p

exit
scriptdev
Site Admin
 
Posts: 5
Joined: Fri Aug 06, 2010 2:37 pm

Return to TCL

Who is online

Users browsing this forum: No registered users and 1 guest

cron