   get input while the window is not active
  Hello everyone,I'm trying to make some kind of a "shortcuts program" for my computer, like, when i press something, the program reacts to it, for example, i want to make the "i" button execute the internet explorer, it's simple to use GetAsyncKeyState, but i probably dont want the window to be on the top to do it, as it wont be much "neat".so i was wondering, is there a way to do it?also, how to make the program run at windows startup?Thanks in advance   
  You'll need to subclass the window to gain access to its message loop. See here.   ;Quote:Original post by Hassanbasilalso, how to make the program run at windows startup?Google can be so wonderful sometimes.If you don't want to mess with the registry, you can add the program to the Startup folder in Start Menu (not sure if this works in Vista and 7, though).;  that looks too complicated, i heard that it can be done with something, i tihnk it was called "hook", not sure, thanks for the links tho, i think i have to read about those subclasses anyway   ;  Yes, you can use SetWindowsHookEx, with WH_KEYBOARD.   ;Quote:Original post by Evil SteveYes, you can use SetWindowsHookEx, with WH_KEYBOARD.hMod [in]    HINSTANCE    Handle to the DLL containing the hook procedure pointed to by the lpfn parameter. The hMod parameter must be set to NULL if the dwThreadId parameter specifies a thread created by the current process and if the hook procedure is within the code associated with the current process. is it possible without a DLL?   ;  currently i have the following:int APIENTRY Main (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow ){mainInstance = hInstance;InitCommonControls ( );if ( !Init ( ) ){MessageBoxA ( NULL, "failed to initialize the application", "PC Manager", MB_OK | MB_ICONERROR );return FALSE;}keyboardHook = SetWindowsHookExA ( WH_KEYBOARD, keyboardHookProc, hInstance, 0 );MSG msg;while ( GetMessage ( &msg, NULL, 0, 0 ) ){TranslateMessage ( &msg );DispatchMessage ( &msg );}Shell_NotifyIconA ( NIM_DELETE, &dt );    UnhookWindowsHookEx ( keyboardHook );return (int) msg.wParam;}LRESULT CALLBACK keyboardHookProc ( int nCode, WPARAM wParam, LPARAM lParam ){//this place is never reached ( breakpoint not triggered )}shouldnt the break point trigger when i press anything? what am i doing wrong?   ;Quote:Original post by Hassanbasilis it possible without a DLL?For a global keyboard hook, no - the DLL gets loaded into other processes, which is how the hook works. So it needs to be in a DLL.Quote:Original post by Hassanbasilcurrently i have the following:*** Source Snippet Removed ***shouldnt the break point trigger when i press anything? what am i doing wrong?Only if your application's message queue has a keyboard message in it (which it won't because you don't have a window), as per the Documentation.   ;  in the snippets above:MSG msg;while ( GetMessage ( &msg, NULL, 0, 0 ) ){TranslateMessage ( &msg );DispatchMessage ( &msg );};Quote:Original post by Hassanbasilin the snippets above:*** Source Snippet Removed ***I thinkyou replied just before I edited my post [smile]Because you don't have a window in your app, you won't get any keyboard messages, so your keyboard hook won't be called.   