|
|
@ -21,8 +21,14 @@ must not be misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source
|
|
|
|
3. This notice may not be removed or altered from any source
|
|
|
|
distribution.
|
|
|
|
distribution.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#define LINUX_BUILD
|
|
|
|
|
|
|
|
#include "DFCommonInternal.h"
|
|
|
|
#include "DFCommonInternal.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <X11/Xlib.h> //need for X11 functions
|
|
|
|
|
|
|
|
#include <X11/extensions/XTest.h> //need for Xtest
|
|
|
|
|
|
|
|
#include <X11/Xatom.h> //for the atom stuff
|
|
|
|
|
|
|
|
#define XK_MISCELLANY
|
|
|
|
|
|
|
|
#include <X11/keysymdef.h>
|
|
|
|
|
|
|
|
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace DFHack;
|
|
|
|
|
|
|
|
|
|
|
|
// ENUMARATE THROUGH WINDOWS AND DISPLAY THEIR TITLES
|
|
|
|
// ENUMARATE THROUGH WINDOWS AND DISPLAY THEIR TITLES
|
|
|
@ -232,389 +238,154 @@ void API::TypeSpecial (t_special command, int count, int delay)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case ENTER:
|
|
|
|
case ENTER:
|
|
|
|
mykeysym = XStringToKeysym ("Return");
|
|
|
|
mykeysym = XStringToKeysym ("Return");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case SPACE:
|
|
|
|
case SPACE:
|
|
|
|
mykeysym = XStringToKeysym ("space");
|
|
|
|
mykeysym = XStringToKeysym ("space");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case BACK_SPACE:
|
|
|
|
case BACK_SPACE:
|
|
|
|
mykeysym = XStringToKeysym ("BackSpace");
|
|
|
|
mykeysym = XStringToKeysym ("BackSpace");
|
|
|
|
xkeycode = XK_BackSpace;
|
|
|
|
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, XK_BackSpace);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case TAB:
|
|
|
|
case TAB:
|
|
|
|
mykeysym = XStringToKeysym ("Tab");
|
|
|
|
mykeysym = XStringToKeysym ("Tab");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case CAPS_LOCK:
|
|
|
|
case CAPS_LOCK:
|
|
|
|
mykeysym = XStringToKeysym ("Caps_Lock");
|
|
|
|
mykeysym = XStringToKeysym ("Caps_Lock");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case LEFT_SHIFT: // I am not positive that this will work to distinguish the left and right..
|
|
|
|
case LEFT_SHIFT:
|
|
|
|
mykeysym = XStringToKeysym ("Shift_L");
|
|
|
|
mykeysym = XStringToKeysym ("Shift_L");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case RIGHT_SHIFT:
|
|
|
|
case RIGHT_SHIFT:
|
|
|
|
mykeysym = XStringToKeysym ("Shift_R");
|
|
|
|
mykeysym = XStringToKeysym ("Shift_R");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case LEFT_CONTROL:
|
|
|
|
case LEFT_CONTROL:
|
|
|
|
mykeysym = XStringToKeysym ("Control_L");
|
|
|
|
mykeysym = XStringToKeysym ("Control_L");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
break;
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
case RIGHT_CONTROL:
|
|
|
|
case RIGHT_CONTROL:
|
|
|
|
mykeysym = XStringToKeysym ("Control_R");
|
|
|
|
mykeysym = XStringToKeysym ("Control_R");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case ALT:
|
|
|
|
case ALT:
|
|
|
|
mykeysym = XStringToKeysym ("Alt_L");
|
|
|
|
mykeysym = XStringToKeysym ("Alt_L");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case ESCAPE:
|
|
|
|
case ESCAPE:
|
|
|
|
mykeysym = XStringToKeysym ("Escape");
|
|
|
|
mykeysym = XStringToKeysym ("Escape");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case UP:
|
|
|
|
case UP:
|
|
|
|
mykeysym = XStringToKeysym ("Up");
|
|
|
|
mykeysym = XStringToKeysym ("Up");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DOWN:
|
|
|
|
case DOWN:
|
|
|
|
mykeysym = XStringToKeysym ("Down");
|
|
|
|
mykeysym = XStringToKeysym ("Down");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case LEFT:
|
|
|
|
case LEFT:
|
|
|
|
mykeysym = XStringToKeysym ("Left");
|
|
|
|
mykeysym = XStringToKeysym ("Left");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case RIGHT:
|
|
|
|
case RIGHT:
|
|
|
|
mykeysym = XStringToKeysym ("Right");
|
|
|
|
mykeysym = XStringToKeysym ("Right");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case F1:
|
|
|
|
case F1:
|
|
|
|
mykeysym = XStringToKeysym ("F1");
|
|
|
|
mykeysym = XStringToKeysym ("F1");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case F2:
|
|
|
|
case F2:
|
|
|
|
mykeysym = XStringToKeysym ("F2");
|
|
|
|
mykeysym = XStringToKeysym ("F2");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case F3:
|
|
|
|
case F3:
|
|
|
|
mykeysym = XStringToKeysym ("F3");
|
|
|
|
mykeysym = XStringToKeysym ("F3");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case F4:
|
|
|
|
case F4:
|
|
|
|
mykeysym = XStringToKeysym ("F4");
|
|
|
|
mykeysym = XStringToKeysym ("F4");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case F5:
|
|
|
|
case F5:
|
|
|
|
mykeysym = XStringToKeysym ("F5");
|
|
|
|
mykeysym = XStringToKeysym ("F5");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case F6:
|
|
|
|
case F6:
|
|
|
|
mykeysym = XStringToKeysym ("F6");
|
|
|
|
mykeysym = XStringToKeysym ("F6");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case F7:
|
|
|
|
case F7:
|
|
|
|
mykeysym = XStringToKeysym ("F7");
|
|
|
|
mykeysym = XStringToKeysym ("F7");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case F8:
|
|
|
|
case F8:
|
|
|
|
mykeysym = XStringToKeysym ("F8");
|
|
|
|
mykeysym = XStringToKeysym ("F8");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case F9:
|
|
|
|
case F9:
|
|
|
|
mykeysym = XStringToKeysym ("F9");
|
|
|
|
mykeysym = XStringToKeysym ("F9");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case F11:
|
|
|
|
case F11:
|
|
|
|
mykeysym = XStringToKeysym ("F11");
|
|
|
|
mykeysym = XStringToKeysym ("F11");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case F12:
|
|
|
|
case F12:
|
|
|
|
mykeysym = XStringToKeysym ("F12");
|
|
|
|
mykeysym = XStringToKeysym ("F12");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case PAGE_UP:
|
|
|
|
case PAGE_UP:
|
|
|
|
mykeysym = XStringToKeysym ("Page_Up");
|
|
|
|
mykeysym = XStringToKeysym ("Page_Up");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case PAGE_DOWN:
|
|
|
|
case PAGE_DOWN:
|
|
|
|
mykeysym = XStringToKeysym ("Page_Down");
|
|
|
|
mykeysym = XStringToKeysym ("Page_Down");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case INSERT:
|
|
|
|
case INSERT:
|
|
|
|
mykeysym = XStringToKeysym ("Insert");
|
|
|
|
mykeysym = XStringToKeysym ("Insert");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEY_DELETE:
|
|
|
|
case DFHack::DELETE: // collides with some windows stuff otherwise?
|
|
|
|
mykeysym = XStringToKeysym ("Delete");
|
|
|
|
mykeysym = XStringToKeysym ("Delete");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case HOME:
|
|
|
|
case HOME:
|
|
|
|
mykeysym = XStringToKeysym ("Home");
|
|
|
|
mykeysym = XStringToKeysym ("Home");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case END:
|
|
|
|
case END:
|
|
|
|
mykeysym = XStringToKeysym ("End");
|
|
|
|
mykeysym = XStringToKeysym ("End");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEYPAD_DIVIDE:
|
|
|
|
case KEYPAD_DIVIDE:
|
|
|
|
mykeysym = XStringToKeysym ("KP_Divide");
|
|
|
|
mykeysym = XStringToKeysym ("KP_Divide");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEYPAD_MULTIPLY:
|
|
|
|
case KEYPAD_MULTIPLY:
|
|
|
|
mykeysym = XStringToKeysym ("KP_Multiply");
|
|
|
|
mykeysym = XStringToKeysym ("KP_Multiply");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEYPAD_SUBTRACT:
|
|
|
|
case KEYPAD_SUBTRACT:
|
|
|
|
mykeysym = XStringToKeysym ("KP_Subtract");
|
|
|
|
mykeysym = XStringToKeysym ("KP_Subtract");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEYPAD_ADD:
|
|
|
|
case KEYPAD_ADD:
|
|
|
|
mykeysym = XStringToKeysym ("KP_Add");
|
|
|
|
mykeysym = XStringToKeysym ("KP_Add");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEYPAD_ENTER:
|
|
|
|
case KEYPAD_ENTER:
|
|
|
|
mykeysym = XStringToKeysym ("KP_Enter");
|
|
|
|
mykeysym = XStringToKeysym ("KP_Enter");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEYPAD_0:
|
|
|
|
case KEYPAD_0:
|
|
|
|
mykeysym = XStringToKeysym ("KP_0");
|
|
|
|
mykeysym = XStringToKeysym ("KP_0");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEYPAD_1:
|
|
|
|
case KEYPAD_1:
|
|
|
|
mykeysym = XStringToKeysym ("KP_1");
|
|
|
|
mykeysym = XStringToKeysym ("KP_1");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEYPAD_2:
|
|
|
|
case KEYPAD_2:
|
|
|
|
mykeysym = XStringToKeysym ("KP_2");
|
|
|
|
mykeysym = XStringToKeysym ("KP_2");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEYPAD_3:
|
|
|
|
case KEYPAD_3:
|
|
|
|
mykeysym = XStringToKeysym ("KP_3");
|
|
|
|
mykeysym = XStringToKeysym ("KP_3");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEYPAD_4:
|
|
|
|
case KEYPAD_4:
|
|
|
|
mykeysym = XStringToKeysym ("KP_4");
|
|
|
|
mykeysym = XStringToKeysym ("KP_4");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEYPAD_5:
|
|
|
|
case KEYPAD_5:
|
|
|
|
mykeysym = XStringToKeysym ("KP_5");
|
|
|
|
mykeysym = XStringToKeysym ("KP_5");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEYPAD_6:
|
|
|
|
case KEYPAD_6:
|
|
|
|
mykeysym = XStringToKeysym ("KP_6");
|
|
|
|
mykeysym = XStringToKeysym ("KP_6");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEYPAD_7:
|
|
|
|
case KEYPAD_7:
|
|
|
|
mykeysym = XStringToKeysym ("KP_7");
|
|
|
|
mykeysym = XStringToKeysym ("KP_7");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEYPAD_8:
|
|
|
|
case KEYPAD_8:
|
|
|
|
mykeysym = XStringToKeysym ("KP_8");
|
|
|
|
mykeysym = XStringToKeysym ("KP_8");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEYPAD_9:
|
|
|
|
case KEYPAD_9:
|
|
|
|
mykeysym = XStringToKeysym ("KP_9");
|
|
|
|
mykeysym = XStringToKeysym ("KP_9");
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
|
|
|
|
XSync (dpy, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KEYPAD_DECIMAL_POINT:
|
|
|
|
case KEYPAD_DECIMAL_POINT:
|
|
|
|
mykeysym = XStringToKeysym ("KP_Decimal");
|
|
|
|
mykeysym = XStringToKeysym ("KP_Decimal");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
xkeycode = XKeysymToKeycode (dpy, mykeysym);
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
|
|
|
|
XSync (dpy, true);
|
|
|
|
XSync (dpy, true);
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
|
|
|
|
XSync (dpy, true);
|
|
|
|
XSync (dpy, true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
usleep(20000);
|
|
|
|
usleep(20000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (currAttr.map_state == IsUnmapped)
|
|
|
|
if (currAttr.map_state == IsUnmapped)
|
|
|
|