Archive

Archive for June, 2009

SendMessage function in RoutineBot

June 17th, 2009

The SendMessage function sends the specified message to a window or windows. It calls the window procedure for the specified window and does not return until the window procedure has processed the message.
Syntax

SendMessage( Handles:String, Message:String, WParam:Integer [optional], LParam:Integer [optional], Count:Integer [optional] )

Parameters

Handles:String

String that contains handles whose window procedure will receive the message. You can obtain these handles via function FindWindows.

Message:String

Specifies the message to be sent. If message is a number then this function is equivalent to WinAPI function SendMessage. Otherwise, can be one of predefined string constant

“Activate” – function activates windows with handles represented in parameter handles
“Close” – function closes windows with handles represented in parameter handles
“Maximize” – function maximizes windows with handles represented in parameter handles
“Minimize” – function minimizes windows with handles represented in parameter handles
“Normalize” – function normalizes windows with handles represented in parameter handles

WParam:Integer [optional]

Specifies additional message-specific information.

LParam:Integer [optional]

Specifies additional message-specific information.

Count:Integer [optional]

Specifies how many handles from parameter handle will be used in function. If this parameter is -1 then all handles will be used, otherwise function uses only first count handles form parameter handles.

Example

This Example will run Notepad.exe, type “abc”, save file and close Notepad.

SetWarningsOn('ON');
FilePath := 'c:\temp.txt';
FExist := FileExists(FilePath);
Execute('c:\windows\notepad.exe',FilePath);
//Running notepad
handles := FindWindows('','notepad');
//searching it handles
if ListSize(handles) > 0 then // if more than 1 window found
begin
h := ListItem(Handles,0);
SendMessage(h,'Activate'); //activating window
if not (FExist = 1) then
begin //if not exist file 'c:\temp.txt'
//we must enter button on keyboard
EnterKeys('{ENTER}');
handles := FindWindows('','notepad');
h := ListItem(Handles,0);
SendMessage(h,'Activate');
//searching and activating new notepad windows
end;
//maximizes window
SendMessage(h,'Maximize');
//typing text "abc"
EnterKeys('abc');
//typing Ctrl+S
EnterKeys('^s');
Wait(1000);
//Closing window. 16 is predefined constant
//for message WM_CLOSE
SendMessage(h,16);
end;

Download example SendMessage.

  • Share/Bookmark

Developer Articles

KillProcess function in RoutineBot

June 17th, 2009

Syntax

KillProcess( Path:String )

Parameters

Path:String

Full path to executable file, that need to be terminated.

Return value
If application is running and is successfully terminated, the function returns 1, otherwise function returns 0.

Example
Execute('C:\WINDOWS\notepad.exe');
Wait(1000);
KillProcess('C:\WINDOWS\notepad.exe');

This example will run notepad, wait 1 second and close notepad.
Download example KillProcess.

  • Share/Bookmark

Developer Articles

ShellExecute function in RoutineBot

June 17th, 2009

Syntax
ShellExecute( Path:String, Params:String [optional], WaitBeforeClose:Integer [optional] )

Parameters

Path:String

string that specifies the file to execute. File can be executable file or some document.

Params:String [optional]

string that specifies parameters to be passed to the application.

WaitBeforeClose:Integer [optional]

if this parameter is 1, then interpreter wait, before application is running or file is opened. Otherwise, if this parameter is 0, function does not wait, before application(file) is running. If this parameter is 0 this function is equal to function Execute.

Return value

If file exists function return 1, otherwise function return 0.

Remarks

If WaitBeforeClose = 1 then function waits, before application will be closed.

Example
ShellExecute('C:\WINDOWS\notepad.exe','',1);
This example runs notepad.exe and waits until notepad is running.
Download example Shellexecute.

Reference
Execute function

  • Share/Bookmark

Developer Articles