一丶起因
闲着没事,想通过os系统控制iPhone做一些机械操作;写了这么个脚本
丶二 使用
image.png1.点击 [开始记录]
会开始记录你一系列鼠标点击的位置,包括点击的时长;
2.设置重复次数,不设置默认1次;
3.点击开始,就会回放你刚才一些列操作;
4.点击停止记录,将清空所有记录;
核心代码:
ZBMouseTapModel *model = [dataArray firstObject];
NSLog(@"-->准备点击%@",model);
CGPoint mousePoint = model.point;
CGEventRef click1_down = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseDown, mousePoint, kCGMouseButtonLeft);
CGEventPost(kCGHIDEventTap, click1_down);
CFRelease(click1_down);
__weak typeof(self) weakSelf = self;
CGFloat interval = [@(model.time) floatValue]/10.0f;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(interval * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
CGEventRef click1_up = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseUp, mousePoint, kCGMouseButtonLeft);
CGEventPost(kCGHIDEventTap, click1_up);
CFRelease(click1_up);
[weakSelf completeOnceEventWithDataArray:dataArray];
});
三丶地址
https://github.com/k373379320/ZBMouseAutoClick
四丶其他
有更好的想法可以提出来~
考虑加上去
网友评论