gpt4 book ai didi

iphone - iOS 上的系统级点击模拟

转载 作者:可可西里 更新时间:2023-11-01 06:16:39 25 4
gpt4 key购买 nike

我想通过 MobileSubstrate 插件在 iOS 上实现系统范围的点击模拟。这个想法是能够在 iOS 5.1.1 中在系统范围内模拟触摸(第一次是单点触摸,然后是多点触摸)。

我已成功实现 this article为了模拟特定 View 上的触摸,我现在希望能够在系统范围内模拟它们。

我知道我应该使用私有(private) MobileServices 框架来这样做,我已经 documented myself在 GSEvent 上(我还查看了 Veency 和 MouseSupport 源代码)。

我尝试连接一个 View 来拦截 UIEvent 并查看底层结构:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

GSEventRef eventRef = (GSEventRef)[event performSelector:@selector( _gsEvent)];
GSEventRecord record = *_GSEventGetGSEventRecord(eventRef);
< breakpoint here to look at record >
}

结果与上面详述的旧 (iOS 3) 结构极为相似。

然后我尝试自己触发这些事件(在独立应用程序上,现在不是 MS 调整):

+(void)simulateTouchDown:(CGPoint)point{

point.x = roundf(point.x);
point.y = roundf(point.y);

GSEventRecord record;
memset(&record, 0, sizeof(record));

record.type = kGSEventHand;
record.windowLocation = point;
record.timestamp = GSCurrentEventTimestamp();

GSSendSystemEvent(&record);

}

现在,这根本不起作用(也不会崩溃)。

大多数代码(MouseSupport、Veency)看起来像这样

// Create & populate a GSEvent
struct {
struct GSEventRecord record;
struct {
struct GSEventRecordInfo info;
struct GSPathInfo path;
} data;
} event;

memset(&event, 0, sizeof(event));

event.record.type = kGSEventHand;
event.record.windowLocation = point;
event.record.timestamp = GSCurrentEventTimestamp();
event.record.infoSize = sizeof(event.data);

event.data.info.handInfo.type = kGSHandInfoTypeTouchDown;
event.data.info.handInfo._0x44 = 0x1;
event.data.info.handInfo._0x48 = 0x1;

event.data.info.pathPositions = 1;

event.data.path.pathIndex = 0x01;
event.data.path.pathIdentity = 0x02;
event.data.path.pathProximity = 0x00;
event.data.path.pathLocation = event.record.windowLocation;


GSSendSystemEvent(&event.record);

仅:

  • GSEventRecordInfo 未知(而且我找不到它的定义位置)
  • 我不认为为了打破记录而举办整个事件有什么意义

请在 iOS 5 上经历过此问题的人指导我。

最佳答案

GSEventRecordInfo 可能是从 iOS 3.2 开始引入的(这是您链接到的图形服务 header 的来源)。 class-dump iOS 5.1.1 设备上实际存在的框架,看看它是否在那里定义?

关于iphone - iOS 上的系统级点击模拟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11493846/

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