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

标签 ios objective-c jailbreak

通过在 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/

相关文章:

ios - NSPredicate 在多对多关系上计数 > 0

ios - UITableViewCell ImageView 变得像素化

ios - `uicache`命令在越狱iPhone上有什么作用?

ios - iOS 应用程序中的 fork() 可能会被 Apple 的审查程序拒绝吗?

objective-c - 排序 JSON 对象

objective-c - iOS 进程信息 (pid, uid, cpu, mem, ...)

iphone - 我可以在不注册开发人员计划的情况下实现推送通知吗?

ios - 当项目名称有空格时无法从桥头获取正确的文件路径

ios - 使 UIViewPropertyAnimator 永不完成

ios - - (CGRect) textRectForBounds :(CGRect)bounds not being called