linux按键代码,Linux上的按键模拟问题(Ubuntu18)

阅读: 评论:0

linux按键代码,Linux上的按键模拟问题(Ubuntu18)

linux按键代码,Linux上的按键模拟问题(Ubuntu18)

我开始只在XTests中使用XLib,但是没有成功,所以我尝试了XSendEvent而不是XTests,但是所有的症状都没有改变,所以最后一次尝试是使用XDO,结果更好,但是仍然冻结了操作系统。

这是我试图用来模拟按键的当前片段:

//Constructor

CheatCore::CheatCore() {

xdo_t x = xdo_new(NULL);

Window *list;

xdo_search_t search;

unsigned int nwindows;

memset(&search, 0, sizeof(xdo_search_t));

search.max_depth = -1;

search.searchmask = SEARCH_CLASS | SEARCH_ONLYVISIBLE;

search.winclass = "Chrome";

int id = xdo_search_windows(x, &search, &list, &nwindows);

qDebug() << nwindows;

if(!nwindows){

qDebug() << "Chrome not found";

return;

}

w = list[0];

//I have to call activate twice to really bring it forward, I suspect that its

//because I use a transparent "overlay" that show stats for the cheat and it is set as Aways on top

//(i used Qt to set it to not get any Events)

xdo_activate_window(x,w);

xdo_activate_window(x,w);

}

//there is a function that executes every second to check if a pixel color has changed,

//if so, then the SendKey is called to Reload weapon magazine pressing the "space" key

void CheatCore::SendKey(){

xdo_activate_window(x,w);

xdo_activate_window(x,w);

xdo_send_keysequence_window(x, w, "space", 500);

}

我使用一个透明的覆盖来显示bot状态,只显示一些数字,这是一个使用Qt创建的小部件,即

AlwaysOnTop

而paint事件绘制了所需的信息,它是另一个对象,在

CheatCore

,但这是用于绘制透明窗口并忽略事件的窗口标志。

setWindowFlags(Qt::WindowTransparentForInput | Qt::FramelessWindowHint |

Qt::WindowStaysOnTopHint);

setAttribute(Qt::WA_NoSystemBackground);

setAttribute(Qt::WA_TranslucentBackground);

setAttribute(Qt::WA_TransparentForMouseEvents);

另外,我试图找到一种Qt方式来模拟鼠标/键盘输入,但我没有找到任何解决方案来发送事件到其他窗口,如果有可能实现这一点将是伟大的!

我正在尝试自动化的游戏叫做“风暴屋”

如果感兴趣,请点击在线回购链接:

link

你能帮我做这个吗?谢谢您!

使用VGA和Nvidia驱动程序的Ubuntu 18.10(如果它可能影响xserver)

本文发布于:2024-02-03 04:48:13,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170690689348750.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:按键   代码   linux   Linux
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23