Could be that this is possible.
But you have to ask the experts for X11 on how to do it.
This group deals with Standard C++ only. Standard C++ doesn't have
a screen or a mouse or X11 or something like that.
I will say it would bee better to ask this in comp.os.linux.x but
I do happen to know.
I am writing a class to do just this it is already capable of all
the things you want to do. I have two even. One uses the XTrap
extention the other uses XTest. I can email you the source code if
you want it. The code can also record input to a macro language.
To use the XTrap class you must have the line 'Load "xtrap"' in
the module section of your XF86Config-4 file and have the extention
compiled and installed. It comes with XFree86 and is compiled if
it is not disabled.
here is example code for using the class:
#include "send_event2.hh"
int main() {
X11_Send_Events hi;
hi.set_window("Mozilla Firebird"); // Sets the Curent window to the a window matching
// string. Returns zero on fail.
hi.set_default_window_position(0, 24); // exactly what it says...
X, Y.
hi.window_to_front(); // Brings the window to the front and to the default
sleep(1); // position.
hi.button_toggle(3); // Toggles the mouse button of choise 1-5.
sleep(1);
hi.button_toggle(3);
sleep(1);
hi.button_click(1); // Clicks the mouse button of choise 1-5.
sleep(1);
hi.move_mouse(100, 200); // Move mouse x and y pixels.
sleep(1);
hi.move_mouse_absolute_window(200, 35); // Move mouse to asolute position from corner of
sleep(1); // selected window. Uses top left corner.
hi.move_mouse_absolute_screen(400, 300); // Move mouse to absolute postion from top left
sleep(1); // corner of screen.
hi.center_mouse_pointer_in_window(); // Centers the mouse pointer in the current window.
sleep(1);
hi.record_input_to_ostream (std::fstream*);// You must send the program a signal to get it
// to exit from this loop.
return 0;
}