"Well, considering you're not using it at all, I would have to doubt you know what you're doing."
Of course i don't; that is why i posted the question.
Anyways, I have it working like so:
Code:
#include <windows.h>
#include <iostream>
using namespace std;
int main ()
{
RegisterHotKey(NULL, 666, MOD_CONTROL, 'Q');
for(;;)
{
MSG Msg;
if(PeekMessage(&Msg, NULL, WM_HOTKEY, WM_HOTKEY, PM_REMOVE) && (LOWORD(Msg.lParam)==(MOD_CONTROL)) && (HIWORD(Msg.lParam)== 'Q'))
{
cout << "Key has been pressed" << endl;
return 0;
}
}
return 0;
}
I took this from a Windows programming example and changed it slightly to work in a console application.
I was wondering if there is a way to simplify the if statement here:
Code:
MSG Msg;
if(PeekMessage(&Msg, NULL, WM_HOTKEY, WM_HOTKEY, PM_REMOVE) && (LOWORD(Msg.lParam)==(MOD_CONTROL)) && (HIWORD(Msg.lParam)== 'Q'))
{
cout << "Key has been pressed" << endl;
return 0;
}
Edit:
Another question:
So, once ctrl + q is pressed, i want to read and store a string the user types, while still not in the console window (minimized). Then, when the user hits a certain key combination again (maybe ctrl + w), the string will stop being read in.
Basically, like cin >> text, except when i'm not in the console window.
Same for outputting the text when a certain key combination is pressed.
Thanks.