NAME

Win32::Setupsup - implements some functions to automate setups which have no silent mode

SYNOPSIS

use Win32::Setupsup;

DESCRIPTION

This module supports you in automate setup routines. You can get window list, window properties and you can send key stroke to windows like VB's SendKey.

CONSTANTS

FUNCTIONS

SendKeys($window, $keystr, $activate, [$timeout]) EnumWindows(\@windows) EnumChildWindows($window, \\@childs) WaitForWindow($title, \$window, $timeout, [$refresh]) WaitForAnyWindow($title, \$window, $timeout, [$refresh]) WaitForAnyWindowAsynch($title, \$thread, \@actions, $timeout, [$refresh]) WaitForWindowClose($window, $timeout, [$refresh]) GetWindowText($window, \$windowtext) SetWindowText($window, $windowtext) GetDlgItem($window, $id, \$item) SetFocus($window) GetWindowProperties($window, @proptoget, \%windowprop) SetWindowProperties($window, \%windowprop) AccountToSid($server, $account, \$sid) SidToAccount($server, $sid, \$account) GetVersionInfo($filename, \%fileinfo) GetProcessList(\@proc, \@thread) KillProcess($proc, [$exitval, [$systemproc]]) Sleep([$time])

NOTE:

All of the functions return false if they fail. You can call Win32::Setupsup::GetLastError() to get more error information.

Note: the module defines some own error codes. You cannot call "net helpmsg" for a description and these errors are currently not exported.

SendKeys($window, $keystr, $activate, [$timeout])

Sends some key strokes to a window. $window must be a valid window handle or null. If $window is not valid the results are undefined. $keystr contains the keys to send. Some special keys are defined (see below). They must be enclosed in backslashes (you have to write two backslashes in perl). If you send alt, ctrl or shift down keys (f.e. \\alt+\\) don't forget the up key (\\alt-\\). If $activate is not null, $window will be activated everytime before a key will be sent. $timeout is the (optional) time between two key strokes. It's useful for debugging.

special keys: ALT+ alt down ALT- alt up CTRL+ ctrl down CTRL- ctrl up SHIFT+ shift down SHIFT- shift up TAB tabulator RET return ESC escape BACK backspace DEL delete INS insert HELP help LEFT arrow left RIGHT arrow right UP arrow up DN arrow down PGUP page up PGDN page down BEG pos1 END end F1 function 1 ... F12 function 12 NUM0 0 on the num block ... NUM9 9 on the num block NUM* multiply key on the num block NUM+ add key on the num block NUM- minus key on the num block NUM/ divide key on the num block

EnumWindows(\@windows)

Enumerates all desktop windows on the screen and returns the handles in the @windows array. @windows must be an array reference.

EnumChildWindows($window, \\@childs)

Enumerates all child windows that belong to $window and returns the handles in the @childs array. $window must be a valid window handle @childs must be an array reference.

WaitForWindow($title, \$window, $timeout, [$refresh])

Waits for a window title and returns the app. window handle. Search is case insensitive. Returns if a window was found or $timeout elapsed (whatever happens earlier). $refresh is optional but you should specify a value (f.e. 100ms). Otherwise the function loops and consumes about 70 - 90% cpu time. If $timeout elapses GetLastError() returns ERROR_TIMEOUT_ELAPSED.

WaitForAnyWindow($title, \$window, $timeout, [$refresh])

Waits for a window title and returns the app. window handle. Search is case insensitive. $title could be a regular expression. Returns if a window was found or $timeout elapsed (whatever happens earlier). $refresh is optional but you should specify a value (f.e. 100ms). Otherwise the function loops and consumes about 70 - 90% cpu time. If $timeout elapses GetLastError() returns ERROR_TIMEOUT_ELAPSED.

WaitForAnyWindowAsynch($title, \$thread, \@actions, $timeout, [$refresh])

Creates a thread which waits for a window title. Function returns immediatly. If a app. window is catched, all actions defined in @actions will be applied. The thread handle is returned in $thread. $title could be a regular expression. Search is case insensitive. No actions are carried out if $timeout elapesed before a window was found. $refresh is optional but you should specify a value (f.e. 100ms). Otherwise the function loops and consumes about 70 - 90% cpu time.

The following actions are defined:

keys : sends key strokes to the window close : closes the window (sends a WM_CLOSE message) wait : simply waits kill : kills the process the window belongs to

WaitForWindowClose($window, $timeout, [$refresh])

Waits until a window will be closed. $window must be a valid window handle. Returns if $window is closed or $timeout elapsed (whatever happens earlier). $refresh is optional but you should specify a value (f.e. 100ms). Otherwise the function loops and consumes about 70 - 90% cpu time. If $timeout elapses GetLastError() returns ERROR_TIMEOUT_ELAPSED.

GetWindowText($window, \$windowtext)

Returns the caption of a window. $window must be a valid window handle and $windowtext a salar reference. There is no check if $window is valid. The function fail if there is not enougth memory. GetLastError() returns NOT_ENOUGTH_MEMORY_ERROR.

SetWindowText($window, $windowtext)

Sets the caption of a window. $window must be a valid window handle and $windowtext a salar value. You can use also SetWindowProp.

GetDlgItem($window, $id, \$item)

Gets the window handle of a dialog item. $window is the parent window and $id the id. $item contains the window handle if the function succeeds.

SetFocus($window)

Sets the focus to $window. It does not activate the window (the foreground application will not be changed if $windows belongs to another application).

GetWindowProperties($window, @proptoget, \%windowprop)

Gets the properties of a window. Specify all properties you wish in @proptoget. See the supported properties below. %windowprop will contain the properties on success. If you specify an unknown property GetLastError() returns UNKNOWN_PROPERTY_ERROR.

valid properties are: checked : is window checked (checkboxes only) class : window class name classatom : class atom that $window belongs (see RegisterClass in win32 api) classbrush : handle to class background brush that $window belongs classcursor : handle to class cursor that $window belongs classicon : handle to class icon that $window belongs classiconsmall : handle to class small icon that $window belongs classmenu : handle to class menu that $window belongs classmodule : handle to class module that $window belongs classproc : pointer to class procedure that $window belongs classstyle : class style that $window belongs client : $window's client rectangle desktop : handle to desktop window dlgproc : pointer to $window's dialog procedure (if $window belongs to a dialog) enabled : is $window enabled or not extstyle : $window's extended style focused : is $window focused or not foreground : is $window the foreground window or not iconic : is $window iconic or not id : $window's id instance : application instance that $window belongs lastactivepopup : handle to the last active popup window owned by $window menu : handle to $window's menu next : handle to $window's next window in z order parent : handle to $window's parent window prev : handle to $window's previous window in z order pid : process id that $window belongs rect : $window's rectangle on the desktop style : $window's style text : $window's caption tid : thread id that $window belongs top : handle to $window's top window in z order unicode : is $window unicoded or not valid : is $window a valid window or not visible : is $window visible or not wndproc : pointer to $window's procedure zoomed : is $window zoomed or not

SetWindowProperties($window, \%windowprop)

Sets the properties of a window. Specify all properties you want to set in %windowprop. Some properties from GetWindowProperties cannot be set. These are:

class classatom classproc client desktop focused lastactivepopup pid tid unicode valid

If you specify some of them, they are ignored.

AccountToSid($server, $account, \$sid)

Converts an account name to a sid in a textual form (S-1-5-21- ...). The command will be executed on server $server. If $server is empty the local machine is used. If you need an account from a specific domain or server, you should specify domain\account or server\account. Otherwise the account will be resolved from trusted domains too. The first try will be made on $server. If it could not be resolved the next try is the domain $server belongs. After that all trusted domains will be tried. If you need a well known account (like system or everyone) don't specify a server or domain name. Otherwise the function will fail.

SidToAccount($server, $sid, \$account)

Converts a sid in a textual form to an account name. The command will be executed on server $server. If $server is empty the local machine is used.

GetVersionInfo($filename, \%fileinfo)

Gets the file information record stored in a file with version information. The following information will be retrieved:

FileVersionMS FileVersionLS ProductVersionMS ProductVersionLS FileFlagsMask FileFlags FileOS FileType FileSubtype FileDateMS FileDateLS Language Comments CompanyName FileDescription FileVersion InternalName LegalCopyright LegalTrademarks OriginalFilename PrivateBuild ProductName ProductVersion SpecialBuild

See also GetFileVersionInfo in Win32-SDK.

GetProcessList($server, \@proc, \@thread)

Gets all process and thread id's running on $server. $server must be a valid machine name or '' if you need data from the local machine. @proc contains the process id's and process names and @thread the thread id's and app. process index the tread belongs to. @proc and @thread are arrays. Each array element is a hash reference. To access the hash values see the example GetProcessList below.

KillProcess($proc, [$exitval, [$systemproc]])

Kills a process with pid $proc. The process ends with $exitval or 0 if omitted. If $systemproc is not null you can kill system processes too. But you need the app. rigths to do that (debug process must be enabled).

Sleep([$time])

Slepps $time milliseconds. If $time is omitted, your process sleeps forever.

CaptureMouse([$refresh])

Captures mouse pointer in the upper left corner. Mouse will be captured until UnCaptureMouse is called. Optionally, you can specify a refresh value. This means, every $refresh milliseconds the mouse pointer is moved to the upper left corner. Default is 100 ms.

UnCaptureMouse([$refresh])

Uncaptures a captured mouse pointer.

GetProcessList($server, \@proc, \@thread)

die if(!Win32::Setupsup::GetProcessList('', \@proc, \@threads));

foreach $item (@proc) { print "name: ${$item}{'name'}; pid: ${$item}{'pid'}\n";}

foreach $item (@threads) { print "tid: ${$item}{'tid'}; pidx: ${$item}{'process'}; process: ${$proc[${$item}{'process'}]}{'name'}\n"; }

1 POD Error

The following errors were encountered while parsing the POD:

Around line 693:

You forgot a '=back' before '=head1'