当前位置: 首页>>代码示例>>C++>>正文


C++ XTestFakeButtonEvent函数代码示例

本文整理汇总了C++中XTestFakeButtonEvent函数的典型用法代码示例。如果您正苦于以下问题:C++ XTestFakeButtonEvent函数的具体用法?C++ XTestFakeButtonEvent怎么用?C++ XTestFakeButtonEvent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了XTestFakeButtonEvent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assert

/**
 * 在某坐标模拟鼠标消息
 *
 * @x,@y 为鼠标坐标
 * @type 为鼠标按键类型
 * 	MLEFT 为左键,MMIDDLE 为中键,MRIGHT 为右键
 */
void VirKey::ClickAt(int x, int y, VirKeyMType type)
{
	assert(handle_);

	XEvent event;

	// 保存鼠标当前位置等信息
	XQueryPointer(  handle_, 
			RootWindow(handle_, DefaultScreen(handle_)), 
			&event.xbutton.root,
			&event.xbutton.window,
      			&event.xbutton.x_root,
			&event.xbutton.y_root,
      			&event.xbutton.x,
			&event.xbutton.y,
      			&event.xbutton.state);

	// 移动鼠标,-1 表示当前屏幕
	XTestFakeMotionEvent(handle_, -1, x, y, CurrentTime);

	// 模拟按下和松开鼠标
	XTestFakeButtonEvent(handle_, type, 1, CurrentTime);
	XTestFakeButtonEvent(handle_, type, 0, CurrentTime);

	// 移动鼠标到原先位置
	XTestFakeMotionEvent(handle_, -1, event.xbutton.x, event.xbutton.y, CurrentTime);
}
开发者ID:hurley25,项目名称:Experiment,代码行数:34,代码来源:VirKey.cpp

示例2: sendevent

//actually creates an XWindows event  :)
void sendevent(const FakeEvent &e) {
    Display* display = QX11Info::display();

    switch (e.type) {
    case FakeEvent::MouseMove:
        if (e.move.x == 0 && e.move.y == 0) return;
        XTestFakeRelativeMotionEvent(display, e.move.x, e.move.y, 0);
        break;

    case FakeEvent::KeyUp:
        if (e.keycode == 0) return;
        XTestFakeKeyEvent(display, e.keycode, false, 0);
        break;

    case FakeEvent::KeyDown:
        if (e.keycode == 0) return;
        XTestFakeKeyEvent(display, e.keycode, true, 0);
        break;

    case FakeEvent::MouseUp:
        if (e.keycode == 0) return;
        XTestFakeButtonEvent(display, e.keycode, false, 0);
        break;

    case FakeEvent::MouseDown:
        if (e.keycode == 0) return;
        XTestFakeButtonEvent(display, e.keycode, true, 0);
        break;
    }
    XFlush(display);
}
开发者ID:LibreGames,项目名称:qjoypad,代码行数:32,代码来源:event.cpp

示例3: main

int main(int argc, char **argv)
{
        Display *d;
        struct timespec interval;
        interval.tv_sec = 0;
        interval.tv_nsec = 100000000;

        if(!(d = XOpenDisplay(NULL))) {
                fprintf(stderr, "\"%s\" can't open.\n", XDisplayName(NULL));
                exit(EXIT_FAILURE);
        }

        int ignore;
        if(!(XQueryExtension(d, "XTEST", &ignore, &ignore, &ignore))) {
                fprintf(stderr, "\"XTEST\" extension disabled.\n");
                exit(EXIT_FAILURE);
        }

        while(1){
                XTestFakeButtonEvent(d, RMB, True, 0);
                XTestFakeButtonEvent(d, RMB, False, 0);
                nanosleep(&interval, NULL);
                XSync(d, False);
        }
        XCloseDisplay(d);
        exit(EXIT_SUCCESS);
}
开发者ID:BtPht,项目名称:autoClick,代码行数:27,代码来源:steamIA.c

示例4: cancel

void CommandInterpreter::zoom(TACommand command)
{
	int threshold = 20;
	
	if (lastEvent != TACommandTypeZoom)
		cancel(lastEvent, command.type);
    
	switch (command.touch)
	{
		case TACommandTouchStart:
			lastEvent = TACommandTypeZoom;
			XTestFakeButtonEvent(display, 3, True, CurrentTime);
            XTestFakeMotionEvent(display, 0, xOrigin, yOrigin, CurrentTime);
		break;
		case TACommandTouchMove:
		{
			if (command.zoomValue > 1.0)
				XTestFakeRelativeMotionEvent(display, 0, threshold, CurrentTime);
			if (command.zoomValue < 1.0)
				XTestFakeRelativeMotionEvent(display, 0, (-1 * threshold), CurrentTime);
		}
		break;
		case TACommandTouchEnd:
		{
			XTestFakeButtonEvent(display, 3, False, CurrentTime);
            XTestFakeMotionEvent(display, 0, xOrigin, yOrigin, CurrentTime);
			lastEvent = NULL;
		}
		break;
		default:
		break;
	}
}
开发者ID:uhd,项目名称:modelremote,代码行数:33,代码来源:CommandInterpreter.cpp

示例5: mouseClick

void mouseClick(int button)
{
XTestFakeButtonEvent(dpy, button, True, CurrentTime);
XTestFakeButtonEvent(dpy, button, False, CurrentTime);
XFlush(dpy);

}
开发者ID:MaTriXy,项目名称:p2w12-android-mouse,代码行数:7,代码来源:btmouse-server.c

示例6: click

/* Simulate a click at (@x, @y). */
static void click(unsigned x, unsigned y)
{
	XTestFakeMotionEvent(Dpy, DefaultScreen(Dpy), x, y, 0);
	XTestFakeButtonEvent(Dpy, Button1, True, 0);
	XTestFakeButtonEvent(Dpy, Button1, False, 250);
	XFlush(Dpy);
} /* click */
开发者ID:community-ssu,项目名称:hildon-home,代码行数:8,代码来源:waitidle.c

示例7: XTestFakeButtonEvent

void MouseClick::mouseClick() {
    for (int i = 0; i < this->times; i++) {
        XTestFakeButtonEvent(QX11Info::display(), this->button, true, 0);
        XTestFakeButtonEvent(QX11Info::display(), this->button, false, 0);
    }
    XFlush(QX11Info::display());
}
开发者ID:d3m3vilurr,项目名称:touchegg,代码行数:7,代码来源:MouseClick.cpp

示例8: Java_sun_awt_X11_XRobotPeer_mouseWheelImpl

JNIEXPORT void JNICALL
Java_sun_awt_X11_XRobotPeer_mouseWheelImpl (JNIEnv *env,
                           jclass cls,
                           jint wheelAmt) {
/* Mouse wheel is implemented as a button press of button 4 and 5, so it */
/* probably could have been hacked into robot_mouseButtonEvent, but it's */
/* cleaner to give it its own command type, in case the implementation   */
/* needs to be changed later.  -bchristi, 6/20/01                        */

    int32_t repeat = abs(wheelAmt);
    int32_t button = wheelAmt < 0 ? 4 : 5;  /* wheel up:   button 4 */
                                                 /* wheel down: button 5 */
    int32_t loopIdx;

    AWT_LOCK();

    DTRACE_PRINTLN1("RobotPeer: mouseWheelImpl(%i)", wheelAmt);

    for (loopIdx = 0; loopIdx < repeat; loopIdx++) { /* do nothing for   */
                                                     /* wheelAmt == 0    */
        XTestFakeButtonEvent(awt_display, button, True, CurrentTime);
        XTestFakeButtonEvent(awt_display, button, False, CurrentTime);
    }
    XSync(awt_display, False);

    AWT_UNLOCK();
}
开发者ID:ChenYao,项目名称:jdk7u-jdk,代码行数:27,代码来源:awt_Robot.c

示例9: sml_clickat

/*
 * 在某坐标模拟鼠标消息
 *
 * @x,@y 为鼠标坐标
 * @type 为鼠标按键类型
 * 	MLEFT 为左键,MMIDDLE 为中键,MRIGHT 为右键
 */
void sml_clickat(sml_handle handle, int x, int y, mktype_t type)
{
	assert(handle);

	XEvent event;

	// 保存鼠标当前位置等信息
	XQueryPointer(  handle, 
			RootWindow(handle, DefaultScreen(handle)), 
			&event.xbutton.root,
			&event.xbutton.window,
      			&event.xbutton.x_root,
			&event.xbutton.y_root,
      			&event.xbutton.x,
			&event.xbutton.y,
      			&event.xbutton.state);

	// 移动鼠标,-1 表示当前屏幕
	XTestFakeMotionEvent(handle, -1, x, y, CurrentTime);

	// 模拟按下和松开鼠标
	XTestFakeButtonEvent(handle, type, 1, CurrentTime);
	XTestFakeButtonEvent(handle, type, 0, CurrentTime);

	// 移动鼠标到原先位置
	XTestFakeMotionEvent(handle, -1, event.xbutton.x, event.xbutton.y, CurrentTime);
}
开发者ID:hurley25,项目名称:Experiment,代码行数:34,代码来源:sml_input.c

示例10: XTestFakeButtonEvent

/* void MouseClick (in long button); */
NS_IMETHODIMP MainComponent::MouseClick(PRInt32 button)
{
    XTestFakeButtonEvent(display, button, True, CurrentTime);
    XTestFakeButtonEvent(display, button, False, CurrentTime);
    XSync(display,0);
    return NS_OK;
}
开发者ID:nishant8887,项目名称:xpcom,代码行数:8,代码来源:MainComponent.cpp

示例11: click

		void click(int button) {
		        Display *display = XOpenDisplay(NULL);
			XTestFakeButtonEvent (display, button, True,  CurrentTime);
			usleep(1);
                        XTestFakeButtonEvent (display, button, False, CurrentTime);
                        XFlush(display);
		        XCloseDisplay(display);
                }
开发者ID:kashimAstro,项目名称:MouseController,代码行数:8,代码来源:main.cpp

示例12: x11_shadow_input_mouse_event

void x11_shadow_input_mouse_event(x11ShadowSubsystem* subsystem, UINT16 flags, UINT16 x, UINT16 y)
{
#ifdef WITH_XTEST
	int button = 0;
	BOOL down = FALSE;
	rdpShadowServer* server;
	rdpShadowSurface* surface;

	server = subsystem->server;
	surface = server->surface;

	x += surface->x;
	y += surface->y;

	if (server->shareSubRect)
	{
		x += server->subRect.left;
		y += server->subRect.top;
	}

	XTestGrabControl(subsystem->display, True);

	if (flags & PTR_FLAGS_WHEEL)
	{
		BOOL negative = FALSE;

		if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
			negative = TRUE;

		button = (negative) ? 5 : 4;

		XTestFakeButtonEvent(subsystem->display, button, True, CurrentTime);
		XTestFakeButtonEvent(subsystem->display, button, False, CurrentTime);
	}
	else
	{
		if (flags & PTR_FLAGS_MOVE)
			XTestFakeMotionEvent(subsystem->display, 0, x, y, CurrentTime);

		if (flags & PTR_FLAGS_BUTTON1)
			button = 1;
		else if (flags & PTR_FLAGS_BUTTON2)
			button = 3;
		else if (flags & PTR_FLAGS_BUTTON3)
			button = 2;

		if (flags & PTR_FLAGS_DOWN)
			down = TRUE;

		if (button)
			XTestFakeButtonEvent(subsystem->display, button, down, CurrentTime);
	}

	XTestGrabControl(subsystem->display, False);

	XFlush(subsystem->display);
#endif
}
开发者ID:AMV007,项目名称:FreeRDP,代码行数:58,代码来源:x11_shadow.c

示例13: main

int main(int argc, const char *argv[])
{
    struct cpn_opt opts[] = {
        CPN_OPTS_OPT_STRING('f', "--from-display", NULL, NULL, false),
        CPN_OPTS_OPT_STRING('t', "--to-display", NULL, NULL, false),
        CPN_OPTS_OPT_END
    };
    struct payload payload;
    struct cpn_thread t;
    Display *dpy;
    int i, retval = 0;

    if (cpn_opts_parse_cmd(opts, argc, argv) <  0)
        return -1;

    payload.dpy1 = opts[0].value.string;
    payload.dpy2 = opts[1].value.string;

    cpn_spawn(&t, process_events, &payload);

    if ((dpy = XOpenDisplay(payload.dpy1)) == NULL) {
        retval = -1;
        goto out;
    }

    if (!XTestFakeRelativeMotionEvent(dpy, 2000, 0, CurrentTime)) {
        retval = -1;
        goto out;
    }

    XFlush(dpy);
    usleep(10000);

    for (i = 0; i < REPEATS * 2; i++) {
        if (!XTestFakeButtonEvent(dpy, 1, True, CurrentTime)) {
            puts("Unable to generate fake button event");
            retval = -1;
            goto out;
        }
        XFlush(dpy);
        usleep(20);

        if (!XTestFakeButtonEvent(dpy, 1, False, CurrentTime)) {
            puts("Unable to generate fake button event");
            retval = -1;
            goto out;
        }
        XFlush(dpy);
        usleep(20);

        usleep(1000);
    }

out:
    cpn_join(&t, NULL);

    return retval;
}
开发者ID:capone-project,项目名称:capone-core,代码行数:58,代码来源:cpn-bench-input.c

示例14: main

int main() {
  Display *xdpy;
  Window root;
  char *display_name = NULL;
  int ver;
  
  if ( (display_name = getenv("DISPLAY")) == (void *)NULL) {
    fprintf(stderr, "Error: DISPLAY environment variable not set\n");
    exit(1);
  }

  printf("Display: %s\n", display_name);

  if ( (xdpy = XOpenDisplay(display_name)) == NULL) {
    fprintf(stderr, "Error: Can't open display: %s", display_name);
    exit(1);
  }

  if (XTestQueryExtension(xdpy, &ver, &ver, &ver, &ver) != True) {
    printf("No xtest :(\n");
    return 1;
  }

  {
    int control, alt, key_l, key_two, del;
    control = XKeysymToKeycode(xdpy, XStringToKeysym("Control_L"));
    alt = XKeysymToKeycode(xdpy, XStringToKeysym("Alt_L"));
    key_l = XKeysymToKeycode(xdpy, XStringToKeysym("L"));
    key_two = XKeysymToKeycode(xdpy, XStringToKeysym("2"));
    del = XKeysymToKeycode(xdpy, XStringToKeysym("BackSpace"));

    printf("%d %d %d %d\n", control, alt, key_l, key_two);

    return;
    XTestFakeKeyEvent(xdpy, alt, True, CurrentTime);
    XTestFakeKeyEvent(xdpy, key_two, True, CurrentTime);
    XTestFakeKeyEvent(xdpy, key_two, False, CurrentTime);
    XTestFakeKeyEvent(xdpy, alt, False, CurrentTime);

    XTestFakeKeyEvent(xdpy, control, True, 100);
    XTestFakeKeyEvent(xdpy, key_l, True, CurrentTime);
    XTestFakeKeyEvent(xdpy, key_l, False, CurrentTime);
    XTestFakeKeyEvent(xdpy, control, False, CurrentTime);

    XTestFakeMotionEvent(xdpy, 0, 50, 55, CurrentTime);
    //XTestFakeButtonEvent(xdpy, 1, True, CurrentTime);
    //XTestFakeButtonEvent(xdpy, 1, False, CurrentTime);
    XTestFakeKeyEvent(xdpy, del, True, 50);
    XTestFakeKeyEvent(xdpy, del, False, CurrentTime);
    XTestFakeButtonEvent(xdpy, 2, True, CurrentTime);
    XTestFakeButtonEvent(xdpy, 2, False, CurrentTime);
    XFlush(xdpy);
  }

  return 0;
}
开发者ID:jordansissel,项目名称:semicomplete-googlecode-archive,代码行数:56,代码来源:xtest.c

示例15: while

/*
 * Event: Mouse Wheel
 * Input: int distance, default 5
 */
void Event::mouseRoll(int distance)
{
    //mouse roll, negative will roll reverse direction
    int timer = distance;
    while(timer > 0){
        XTestFakeButtonEvent (display, 5, True,  CurrentTime);
        timer --;
    }
    XTestFakeButtonEvent (display, 5, False,  CurrentTime);
}
开发者ID:peitaosu,项目名称:PalmA-crossplatform,代码行数:14,代码来源:event.cpp


注:本文中的XTestFakeButtonEvent函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。