通过在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);
}
答案 0 :(得分:1)
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);
当然你应该为它编写自己的循环。无论如何,我不知道它是否是最正确的方式,但我让它工作。