如何做一个假鼠标滚轮移动在linux [英] How to do a fake mouse wheel move in linux

查看:488
本文介绍了如何做一个假鼠标滚轮移动在linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图模拟键盘和鼠标事件,我已经成功地假冒键盘键下,keyup。假鼠标按钮向下,向上和假鼠标移动,但我没有找到如何做假鼠标滚轮移动,有人可以解释给我一个简单的方法来做这个在c ++?

I'm trying to simulate keyboard and mouse events, i've successfully made fake keyboard keydown, keyup. Fake mouse button down, up and fake mouse move, but i don't found how to do fake mouse wheel move, can someone explain to me a simple way to do this in c++?

鼠标移动和鼠标按钮:

Display *dpy = XOpenDisplay(NULL);
XTestFakeMotionEvent(dpy, -1, 50, 50, 0);
XTestFakeButtonEvent(dpy, Button1, true, 0);
XTestFakeButtonEvent(dpy, Button1, false, 0);
XFlush(dpy);
XCloseDisplay(dpy);

键盘按键:

Display *dpy = XOpenDisplay(NULL);
unsigned int keycode = XKeysymToKeycode(dpy, XK_Super_L);
XTestFakeKeyEvent(dpy, keycode, true, 0);
XTestFakeKeyEvent(dpy, keycode, false, 0);
XFlush(dpy);
XCloseDisplay(dpy);


推荐答案

在Linux上不是一个鼠标滚轮步骤按?我现在不能测试这个,但我记得在我的系统上滚动鼠标滚轮只是生成按钮事件。您可以通过运行显示X个输入事件的程序 xev 在您的系统上进行测试。

Isn't a mousewheel step on Linux just another button press? I can't test this for you now, but I recall on my system that rolling the mousewheel simply generated button events. You can test this on your system by running the program xev which displays X input events.

这篇关于如何做一个假鼠标滚轮移动在linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆