使用 GraphicsServices.h/GSEvent 以及使用 Xcode 编译 CLI iPhone 工具
我将其发送给 KennyTM(在 GitHub 上有所有私有框架标头),但我想我也会在这里问,以防万一有人有一些好主意或任何方法来帮助我。
我正在尝试编写一个命令行实用程序,发送 GSEvents 来操作键盘、触摸/拖动屏幕上的元素以及操作硬件按钮(音量、主页、睡眠等)。
我抓住了 MouseSupport 代码并尝试查看它,但我找不到发送 GSEvents 的最简单方法。我希望这里有人能帮助我。
首先,声明 GSEvent 并发送它的最简单方法是什么?我查看了 iPhone 开发 wiki,但文档非常模糊。我知道我必须将这些事件发送到一个紫色事件端口(?),但我不明白该怎么做。有人可以提供一些示例,例如触摸坐标、键入某个键或按下硬件按钮吗?
另外,如果我希望这个实用程序能够像 Springboard 一样操作所有应用程序,我是否必须编写或执行任何特殊操作?我不知道这是否是一个特殊情况,因为我希望它在操作系统级别。理想情况下,我会通过 SSH 连接到手机,启动程序,然后它将发送 GSEvent,这些事件将由打开的任何应用程序处理。
至于编译这段代码,在Xcode下有什么办法吗?我不知道应该使用哪种项目模板(如果有的话),这让我很失望。我不需要“构建并运行”支持,我非常乐意将程序发送到电话上。据我了解,在手机上编译代码也是可行的。我的手机上有 SDK 中的所有标头以及 iphone-gcc,但是在编译一些测试程序时,我仍然会收到有关找不到 mach 标头和 CoreFoundation 的错误。有没有更简单的方法来做到这一点?
最后,是否还有其他指南或文献可供我参考以了解更多相关信息?我很高兴能够进入开放式 iPhone 开发(我有使用官方 SDK 的经验,但我想更深入)。
感谢人们提供的所有帮助!
I sent this to KennyTM (has all the private framework headers on GitHub) but I figured I'd ask here too just in case someone has some good ideas or any way to help me out.
I'm trying to write a command line utility that sends GSEvents to operate the keyboard, touch/drag elements onscreen, and operate hardware buttons (volume, home, sleep, etc.)
I grabbed the MouseSupport code and tried to look through it, but I couldn't find the easiest way to send GSEvents. I'm hoping someone here can help me.
First, what's the simplest way to declare a GSEvent and send it? I looked at the iPhone development wiki, but the documentation was very vague. I understand that there's a purple event port (?) that I have to send these events to, but I don't understand how to do that. Could someone offer examples for, say, touching at a coordinate, typing a certain key, or pressing a hardware button?
Also, do I have to write or do anything special if I want this utility to operate all applications as well as Springboard? I don't know if this is a special case because I want it at the OS level. Ideally, I would SSH into the phone, start the program, and it would send GSEvents that would be handled by whatever application was open.
As far as compiling this code, is there any way to do so under Xcode? I don't know what sort of project template I should use (if any) and this is throwing me off. I don't need "build and go" support, I'm more than happy to scp the program over to the phone. I understand that compiling the code is also feasible on the phone. I have all of the headers from the SDK on my phone along with iphone-gcc, but when compiling some test programs I still get errors about not finding mach headers and CoreFoundation. Is there an easier way to do this?
Lastly, are there other guides or pieces of literature that anyone can point me towards for learning more about this? I'm excited to get into open iPhone development (I have experience with the official SDK, but I want to go deeper).
Thanks for any and all help people can offer!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于 GSEvent 的类型。有些事件具有可以一步创建和发送的便捷函数,例如
GSEventLockDevice()
。但HID事件(触摸、按键等)不具备这些简单的功能。原因可能是因为GSEventLockDevice()
等将从应用程序发送到 SpringBoard,但 HID 事件从 SpringBoard 发送到应用程序。因此,只有SpringBoard团队需要知道如何构造一个复杂的GSEvent。无论如何,要创建 HID 事件(例如加速度计事件),您不需要创建 GSEvent。只需使用
GSSendEvent()
:但是“应用程序的端口”是什么?不幸的是没有函数可以实现这一点。从 3.1 开始,mach 端口的名称与其捆绑包 ID 相同,因此您可以使用:
据我所知,没有。
对于另外两个问题,您可能应该将它们分成单独的问题。
It depends on the type of the GSEvent. Some events have convenient functions that can be created and sent in one step, e.g.
GSEventLockDevice()
. But HID events (touches, key presses, etc.) do not have these simple functions. The reason is likely becauseGSEventLockDevice()
etc are to be sent from the app to SpringBoard, but HID events are sent from SpringBoard to an app. Therefore, only the SpringBoard team needs to know how to construct a complicated GSEvent.Anyway, to create a HID event (e.g. accelerometer event) you don't need to create a GSEvent. Just use
GSSendEvent()
:But what is "the port of app"? Unfortunately there's no function to get that. As of 3.1, the name of the mach port is same as its bundle ID, so you could use:
As far as I know, no.
For the other two, probably you should split them into individual questions.