c - How to grab mouse on Windows -



c - How to grab mouse on Windows -

i'm writing cross-platform application on status takes command of user input period of time.

on gnu/linux i've used gtk+, allows me retrieve mouse , keyboard events such motion or presses. that's need application responds them. has little graphical interfce created gtk+.

i've been trying grab mouse input on windows without success gtk work graphically, not grab user input. i've tried using blockintput() not works expected because:

i need administrator priviledges run application i can't read mouse nor keyboard input

is there way grab mouse , keyboard input on windows , still beingness able read inputs without administrative rights?

i found solution fits requirements. 1 of marc's links guided me utilize of hooks on windows had tried no success, ended implementing them both keyboard , mouse grabbing.

my windows code uses windows libraries , when need block input create thread calls function:

dword dwthread; createthread(null, 0, (lpthread_start_routine)mousehooker, null, 0, &dwthread);

then install hook:

dword winapi mousehooker(lpvoid lpparameter) { hinstance hexe = getmodulehandle(null); //the thread's parameter first command line argument path our executable. if (!hexe) //if fails seek load ourselves library. hexe = loadlibrary((lpcstr) lpparameter); if (!hexe) homecoming 1; //install hook low level mouse hook thats calls mouseevent hmousehook = setwindowshookex (wh_mouse_ll, (hookproc)mouseevent, hexe, 0); ... unhookwindowshookex(hmousehook); homecoming 0;

}

and on each mouse event code gets called:

if (ncode == hc_action && ...) { //hc_action means may process event, may add together specific mouse events //we block mouse input here , our thing } //return callnexthookex(hkeyhook, ncode, wparam, lparam); homecoming 1;

so not go on hook chain input never gets processed , workstation gets blocked.

the code runs on windows 7 expected. kept using gtk+ on windows can still generate gui , retrieve mouse inputs gdk. on gnu/linux code works using gtk+ libraries had no issues when grabbing input.

c windows gtk cross-platform mouse

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -