通过在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);
}