How to get raw input data from the win 32 API thats not dependant on a window?

Started by
15 comments, last by EmptyVoid 15 years, 6 months ago
So no one has anymore ideas?
This is your life, and it's ending one minute at a time. - Fight club
Advertisement
Documentation for RAWINPUTDEVICE: http://msdn.microsoft.com/en-us/library/ms645565(VS.85).aspx
Quote:
RIDEV_INPUTSINK
If set, this enables the caller to receive the input even when the caller is not in the foreground. Note that hwndTarget must be specified.


I don't mean to be rude, but this whole thread pretty much consists of questions that would've been answered if you'd glanced through the documentation. Ofcourse you can ask instead to get an educated answer, but you could at least look it over =) I suggest it mostly for your own benefit. Once you learn to use the available documentation and search tools, your development process will be quite significantly sped up.
I for one haven't even tried using this API, still I'm answering your questions.
Also you can benefit from explaining your problem in more detail in your question, together with the steps you've already taken attempting to solve your problem. Several times when I've been about to start a new topic, in the course of explaining the question well enough for everyone to understand exactly what I mean, I have found or realized the answer myself. While my more vague and not thought through questions rarely get me the answer I'm looking for.
Quote:Original post by Erik Rufelt
Documentation for RAWINPUTDEVICE: http://msdn.microsoft.com/en-us/library/ms645565(VS.85).aspx
Quote:
RIDEV_INPUTSINK
If set, this enables the caller to receive the input even when the caller is not in the foreground. Note that hwndTarget must be specified.


I don't mean to be rude, but this whole thread pretty much consists of questions that would've been answered if you'd glanced through the documentation. Ofcourse you can ask instead to get an educated answer, but you could at least look it over =) I suggest it mostly for your own benefit. Once you learn to use the available documentation and search tools, your development process will be quite significantly sped up.
I for one haven't even tried using this API, still I'm answering your questions.
Also you can benefit from explaining your problem in more detail in your question, together with the steps you've already taken attempting to solve your problem. Several times when I've been about to start a new topic, in the course of explaining the question well enough for everyone to understand exactly what I mean, I have found or realized the answer myself. While my more vague and not thought through questions rarely get me the answer I'm looking for.


I did read every line of that and every thing that has anything to do with raw input. Yes I may have missed something but I'm quit sure there is something completely different that I need to do and just to because I'll read every line again though I'm quit sure it won't help.

I may have not said so but I have tried each of your ideas and none of them have worked yet, plus many more I found on Google.

Code samples:

Init:

RAWINPUTDEVICE Rid[2];Rid[0].usUsagePage = 0x01; Rid[0].usUsage = 0x02; Rid[0].dwFlags = NULL;Rid[0].hwndTarget = 0;Rid[1].usUsagePage = 0x01; Rid[1].usUsage = 0x06; Rid[1].dwFlags = NULL;Rid[1].hwndTarget = 0;RegisterRawInputDevices(Rid, 2, sizeof(Rid[0]));


WndProc:

LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ){    switch( message )    {		case WM_INPUT: 		{			UINT dwSize;			GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));			LPBYTE lpb = new BYTE[dwSize];			GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER));			RAWINPUT* raw = (RAWINPUT*)lpb;			if (raw->header.dwType == RIM_TYPEKEYBOARD) 			{			}			else if (raw->header.dwType == RIM_TYPEMOUSE) 			{// If something happend with the mouse do lua On_MouseEvent and pass the values to it.				lua_getfield(g_Lua, LUA_GLOBALSINDEX, "On_MouseEvent");				lua_pushnumber(g_Lua,raw->data.mouse.lLastX);				lua_pushnumber(g_Lua,raw->data.mouse.lLastY);				lua_pushinteger(g_Lua,raw->data.mouse.ulButtons);				lua_call(g_Lua, 3, 0);			} 			delete[] lpb;             break;		}        default:            return DefWindowProc( hWnd, message, wParam, lParam );    }    return 0;}


The problem with this is that my program needs to receive inputs even if none of it's window are active.

EDIT: Why didn't you just say so?! Well anyways thanks and next time I'll read the msdn documents more then once just to make sure I didn't miss anything... (*Sigh* The darn Windows API defies logic...)

[Edited by - EmptyVoid on October 12, 2008 5:20:42 AM]
This is your life, and it's ending one minute at a time. - Fight club
TO create your key logger (which is effectively what you want) use a message only window using HWND_MESSAGE.
http://msdn.microsoft.com/en-us/library/ms632599(VS.85).aspx
Quote:Original post by CmpDev
TO create your key logger (which is effectively what you want) use a message only window using HWND_MESSAGE.
http://msdn.microsoft.com/en-us/library/ms632599(VS.85).aspx


Even better!!! Thank you!!!
This is your life, and it's ending one minute at a time. - Fight club
Quote:Original post by EmptyVoid
Quote:Original post by Erik Rufelt
Documentation for RAWINPUTDEVICE: http://msdn.microsoft.com/en-us/library/ms645565(VS.85).aspx
Quote:
RIDEV_INPUTSINK
If set, this enables the caller to receive the input even when the caller is not in the foreground. Note that hwndTarget must be specified.

...

...
EDIT: Why didn't you just say so?! Well anyways thanks and next time I'll read the msdn documents more then once just to make sure I didn't miss anything... (*Sigh* The darn Windows API defies logic...)


Haha, I did say so, you probably just missed it =) Read my quote again, it says exactly the flag, and that the hwndTarget must be specified.
Quote:Original post by Erik Rufelt
Quote:Original post by EmptyVoid
Quote:Original post by Erik Rufelt
Documentation for RAWINPUTDEVICE: http://msdn.microsoft.com/en-us/library/ms645565(VS.85).aspx
Quote:
RIDEV_INPUTSINK
If set, this enables the caller to receive the input even when the caller is not in the foreground. Note that hwndTarget must be specified.

...

...
EDIT: Why didn't you just say so?! Well anyways thanks and next time I'll read the msdn documents more then once just to make sure I didn't miss anything... (*Sigh* The darn Windows API defies logic...)


Haha, I did say so, you probably just missed it =) Read my quote again, it says exactly the flag, and that the hwndTarget must be specified.


Oh Haha!!!, I'm kinda half awake but the good news is with that and HWND_MESSAGE it works exactly how I want. Even though a bit more complex then I would have thought but still works perfect!
This is your life, and it's ending one minute at a time. - Fight club

This topic is closed to new replies.

Advertisement