Sends a message consisting of key strokes and mouse clicks to the active window or dialog. This way external programs can be 'remote controlled' by the engine.
message - STRING* or char*, text containing the key characters to be sent.
Within the string, the following tokens have a special meaning:
[Ctrl-] - the following character is sent together with the [Ctrl]-key.
the following character is sent together with the [Alt]-key.
[Shift-] - the following character is sent together with the [Shift]-key.
[Win-] - the following character is sent together with the [Window]-key.
[Click x,y] - mouse click on the spot given by the x,y coordinates relative to the window's upper left corner.
[...] - special function keys, such as [Enter], [Tab], [F1] etc. (see key mapping) are given in square brackets.
], [ - the right and left square bracket can be given in square brackets.
- The keys are sent to the active window's message loop. This will work for all normal Windows applications, but not for special programs that don't use a message loop.
- The function returns as soon as the key strokes are sent, but the reaction of the controlled program can take more time. If the key stroke opens a dialog window, use sys_active to wait until the dialog is active before sending further keys.
- sys_message should not be used to send messages to the engine window itself.
// Opens Notepad, writes something, saves it, and closes Notepad.
exec("c:\\windows\\system32\\notepad.exe",NULL); // start Notepad
while(!sys_active("Editor")) wait(1); // wait until Notepad is open
sys_message("Lite-C is really cool!"); // write something
sys_message("[Ctrl-]s"); // open Save dialog (Ctrl-S)
while(!sys_active(NULL)) wait(1); // wait until the dialog window is open
sys_message("cool.txt[Enter][Alt-][F4]"); // save as "cool.txt", and exit (Alt-F4)