gpt4 book ai didi

ios - 如何在 iOS 上使用 GSEvent 模拟触摸移动事件?

转载 作者:行者123 更新时间:2023-11-29 13:11:47 31 4
gpt4 key购买 nike

通过在 stackoverflow 中搜索,我了解了如何在 iOS 上模拟 touchDown 事件,但经过多次尝试,我没有了解如何使用 GSEvent 制作 touchMoved 事件,有人知道吗?

模拟一个 touchDown 事件:

static void sendclickevent() {

CGPoint location = CGPointMake(200, 288);

// structure of touch GSEvent
struct GSTouchEvent {
GSEventRecord record;
GSHandInfo handInfo;
} * event = (struct GSTouchEvent*) &touchEvent;
bzero(touchEvent, sizeof(touchEvent));

// set up GSEvent
event->record.type = kGSEventHand;
event->record.windowLocation = location;
event->record.timestamp = GSCurrentEventTimestamp();
event->record.infoSize = sizeof(GSHandInfo) + sizeof(GSPathInfo);
event->handInfo.type = kGSHandInfoTypeTouchDown;
if (is_50_or_higher){
event->handInfo.x52 = 1;
} else {
event->handInfo.pathInfosCount = 1;
}
bzero(&event->handInfo.pathInfos[0], sizeof(GSPathInfo));
event->handInfo.pathInfos[0].pathIndex = 1;
event->handInfo.pathInfos[0].pathIdentity = 2;
event->handInfo.pathInfos[0].pathProximity = 1 ? 0x03 : 0x00;;
event->handInfo.pathInfos[0].pathLocation = location;

mach_port_t port = (mach_port_t)getFrontMostAppPort();
GSSendEvent((GSEventRecord *)event, port);
}

最佳答案

  event->handInfo.type = kGSHandInfoTypeTouchDown;

你触地得分,你触地得分对吗?

单击是这样的:

   touchdownAtPoint(x,y);
wait(0.1);//wait for 0.1 sec
touchUpAtPoint(x,y);

当你想做一个触摸感动的时候,应该是这样的:

    touchdownAtPoint(x,y);
touchdownAtPoint(x+1,y);//scroll to right?
touchdownAtPoint(x+2,y);
.................
touchdownAtPoint(x+n,y);
touchUpAtPoint(x+n,y);

当然你应该为它写你自己的循环。无论如何,我不知道这是否是最正确的方法,但我让它起作用了。

关于ios - 如何在 iOS 上使用 GSEvent 模拟触摸移动事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17122194/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com