views:

547

answers:

2

I like to know if its possible to use win32 keyboard hook function (SetWindowsHookEx , SetWindowsHookEx ) in a Qt application.

If possible pls provide a sample code on using SetWindowsHookEx , SetWindowsHookEx functions in Qt.

//Update as of 18 Feb 2010 //

I havent figured out how to do that in QT yet.

But as a workaround I have created a win32 dll using vc++ express edition and placed my hook commands inside the dll functions. And I call that dll functions from Qt using QLibrary class

/* hearder file code*/ QLibrary *myLib; typedef HHOOK (*MyPrototype)(HINSTANCE);

/* source file code */ myLib = new QLibrary( "ekhook.dll" ); MyPrototype myFunction; myFunction = (MyPrototype) myLib->resolve( "Init" );

init() is the function in ekhook.dll thats being called

+1  A: 

I believe it is possible, yes. Use QWidget::winId.

Benoît
It would be great help if you can let me know a sample code showing how to use Qwidget::winId with SetWindowsHookEx. I am not sure how to us these together.
Mugunth
+2  A: 

You don't need to do anything with Qt. Just follow the windows examples:

http://msdn.microsoft.com/en-us/library/ms644960(VS.85).aspx

Mike