Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

适配rooted机器屏幕旋转问题 #19

Closed
Cheng77777 opened this issue Sep 25, 2020 · 8 comments · Fixed by #28
Closed

适配rooted机器屏幕旋转问题 #19

Cheng77777 opened this issue Sep 25, 2020 · 8 comments · Fixed by #28

Comments

@Cheng77777
Copy link

Cheng77777 commented Sep 25, 2020

机型: rog phone 2 (rooted)
问题: 在运行横屏程序的时候,不能正确对应屏幕旋转方向给出旋转后的坐标
解决: 临时解决办法是把x与y手动交换,并且屏幕左方朝下时需要用重新计算的新坐标 ( 1080 - y )

@Jinnrry
Copy link
Owner

Jinnrry commented Sep 26, 2020

复现步骤是怎么样的,你是横屏状态启动程序,然后竖屏运行?

目前所有点都是基于图像的,只要图像正确读取了,后续坐标就没问题。你可以用https://github.com/Jinnrry/RobotHelper/blob/master/Android/app/src/main/java/cn/xjiangwei/RobotHelper/Tools/ScreenCaptureUtil.java#L21 这个方法看一下图像是否正确获取了

@ChengZengRMIT
Copy link

ChengZengRMIT commented Sep 26, 2020

我运行的是阴阳师,从运行的时候就是横屏,获取图像之后是横屏的图像,然后识别图像给出的坐标也是按照横屏的坐标给的,我不确定是不是机型的问题,在执行点击command line的时候,我的机器始终是按照竖屏的屏幕坐标来触发的

@ChengZengRMIT
Copy link

然后在tap方法里面,我发现我的手机获取到的点击事件的顺序和你写的不太一样,所以我自己做了调整,应该是不同的机型的问题

@Jinnrry
Copy link
Owner

Jinnrry commented Sep 26, 2020

额。你是用的root方式提权吗?root方式底层是直接操作的硬件指令,这个确实没有处理屏幕方向问题。你可以试试xposed方式,这种方式应该是没问题的。

root方式因为是操作的底层硬件,很容易出现机型问题,但是这方面我没条件也没精力去适配

@Cheng77777
Copy link
Author

嗯,是的,我是用ROOT方式提取的,xposed框架对我手机上其他的app可能会有检测影响所以我没有尝试,不过没关系,各个机型可能会有不同的适配问题,手动解决也不复杂,有一定android开发基础就很容易定位问题解决

@Cheng77777
Copy link
Author

然后现在的问题是在于我还没找到简单的办法停止脚本,每一次我都是要在app设置里强制结束,如果框架能够后续更新出暂停或者停止脚本那就挺完善的了

@Jinnrry
Copy link
Owner

Jinnrry commented Sep 26, 2020

https://github.com/Jinnrry/RobotHelper/blob/master/Android/app/src/main/java/cn/xjiangwei/RobotHelper/Service/RunTime.java#L173

项目的运行原理是点击开始后新起一个线程,在新线程中运行自定义脚本,因此你可以在这里向线程发送中断指令,你程序里面响应中断指令退出就行了

@Cheng77777
Copy link
Author

嗯,我稍微做了一下修改,把Main改成实现Runnable,然后再RunTime class里实现了停止和重启脚本功能

@Jinnrry Jinnrry linked a pull request Nov 6, 2020 that will close this issue
@Jinnrry Jinnrry closed this as completed Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants