2011-04-28 3 views
0

J'ai besoin de simuler keypress sur mon application Qt (je suis sur mac Os X 10.6).Utiliser CGEvent avec Qt sur Mac Os X

J'ai écrit ce code:

#include <ApplicationServices/ApplicationServices.h> 
... 
CGEventRef mkey = CGEventCreateKeyboardEvent(NULL, (CGKeyCode)46, true); 
CGEventPost(kCGAnnotatedSessionEventTap, mkey); 
CFRelease(mkey); 
... 

Mais il y a une erreur:

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 

Je pense que je dois lier une bibliothèque, mais je ne sais pas qui?

Merci

Nico

Répondre

2

Ajouter cette ligne à votre fichier .pro:

LIBS += -framework ApplicationServices 
0

Vous devez lier le cadre des services d'application. Par exemple,

clang -framework ApplicationServices yoursourcefile.c 

(-framework est un indicateur de linker)