I was digging through my tutorials for something a bit more obscure than all the other stuff here.
I don't take credit for this tutorial but I don't know who wrote it originally, it was in a big zip of tutorials I got.
Basically, this allows you to simulate mouse clicks in Linux.
You might have to link against libXtst.so
TheXDisplay = XOpenDisplay(NULL); // Get current x display
XTestFakeButtonEvent(TheXDisplay, 1,true,0); // Left mouse down
XTestFakeButtonEvent(TheXDisplay, 1,false,0); // Left mouse up
XFlush(TheXDisplay); // Push all queued events out
XCloseDisplay(TheXDisplay); // Close display