在 Mac OS X 上将 CGEvent 与 Qt 结合使用
我需要在我的 Qt 应用程序上模拟按键(我使用的是 mac Os X 10.6)。
我写了这段代码:
#include <ApplicationServices/ApplicationServices.h>
...
CGEventRef mkey = CGEventCreateKeyboardEvent(NULL, (CGKeyCode)46, true);
CGEventPost(kCGAnnotatedSessionEventTap, mkey);
CFRelease(mkey);
...
但是有一个错误:
Undefined symbols:
"_CGEventCreateKeyboardEvent", referenced from:
SimuleEvent::PressControl(QString) in simuleevent.o
"_CGEventPost", referenced from:
SimuleEvent::PressControl(QString) in simuleevent.o
"_CFRelease", referenced from:
SimuleEvent::PressControl(QString) in simuleevent.o
我想我必须链接一个库,但我不知道哪个?
谢谢你
尼科
I need to simulate keyPress on my Qt application (I'm on mac Os X 10.6).
I wrote this code:
#include <ApplicationServices/ApplicationServices.h>
...
CGEventRef mkey = CGEventCreateKeyboardEvent(NULL, (CGKeyCode)46, true);
CGEventPost(kCGAnnotatedSessionEventTap, mkey);
CFRelease(mkey);
...
But there is an error:
Undefined symbols:
"_CGEventCreateKeyboardEvent", referenced from:
SimuleEvent::PressControl(QString) in simuleevent.o
"_CGEventPost", referenced from:
SimuleEvent::PressControl(QString) in simuleevent.o
"_CFRelease", referenced from:
SimuleEvent::PressControl(QString) in simuleevent.o
I think I have to link a library but I don't know which ?
Thank you
Nico
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将此行添加到您的 .pro 文件中:
Add this line to your .pro file:
您需要链接应用程序服务框架。例如,
(
-framework
是链接器标志)You need to link the Application Services framework. For instance,
(
-framework
is a linker flag)