前言
获取屏幕坐标的方式:
- LUA 函数
touchDown(idx, x, y)
获取坐标
x,y 整数型 屏幕坐标屏幕坐标,横坐标为 x,纵坐标为 y,单位为像素。
例如,iPhone 4 与 iPhone 4S 的屏幕分辨率 为 640 * 960,则其最大横坐标为 640,最大纵坐标为 960。
lua脚本常常作为触动精灵的代码,而进行辅助完成功能。
- 使用iOS API获取在屏幕上的点击坐标
- 先截图,然后用photoshop打开,用PS 去描点获取。
I 使用catchTouchPoint 函数实现点坐标的获取
获取用户点击的坐标
--test
--获取用户点击的坐标
-- x,y = catchTouchPoint();
-- sysLog("tcatchTouchPoint"..x..","..y);
--end test
- 结果日志
* PID 2751
Oct 15 10:45:27 iPhone iCal135c[2751] <Warning>: tcatchTouchPoint367,732
Oct 15 10:45:57 iPhone iCal135c[2751] <Warning>: tcatchTouchPoint269,1112
Oct 15 10:48:26 iPhone iCal135c[2751] <Warning>: tcatchTouchPoint365,769
Oct 15 10:48:35 iPhone iCal135c[2751] <Warning>: tcatchTouchPoint459,565
Oct 15 10:53:29 iPhone iCal135c[2751] <Warning>: tcatchTouchPoint405,722
exit
II 使用iOS API获取在屏幕上的点击坐标
https://download.csdn.net/download/u011018979/14046495
2.1 创建UIApplication
子类,实现sendEvent:
获取在屏幕上的点击坐标
//获取在屏幕上的点击坐标
- (void)sendEvent:(UIEvent *)event{
if (event.type==UIEventTypeTouches) {
UITouch *touch = [event.allTouches anyObject];
if (touch.phase == UITouchPhaseBegan) {
self.isMoved = NO;
}
// if (touch.phase == UITouchPhaseMoved) {//滑动
// self.isMoved = YES;
// }
if (touch.phase == UITouchPhaseEnded) {
if (!self.isMoved && event.allTouches.count == 1) {//非多点触控,非滑动
UITouch *touch = [event.allTouches anyObject];
//在屏幕上的点击坐标
CGPoint locationPointWindow = [touch preciseLocationInView:touch.window];//touch.view
NSLog(@"TouchLocationWindow:(%.1f,%.1f)",locationPointWindow.x,locationPointWindow.y);
}
self.isMoved = NO;
}
}
[super sendEvent:event];
}
2.2 在main方法添加principalClassName
int main(int argc, char * argv[]) {
NSString * appDelegateClassName;
NSString * principalClassName;// The name of the UIApplication class or subclass. If you specify nil, UIApplication is assumed.
@autoreleasepool {
// Setup code that might create autoreleased objects goes here.
appDelegateClassName = NSStringFromClass([AppDelegate class]);
principalClassName = NSStringFromClass([KNApplication4sendEvent class]);
}
return UIApplicationMain(argc, argv, principalClassName, appDelegateClassName);
}
see also
gzh:iOS逆向