begin program with keystroke

Hey,
so I have made a program that I want to begin by simply hitting a specified key.
I guess I could do this by using cin, but this is my first attempt at a macro/bot (whichever it's called) so i don't want the window to be open :)

1
2
3
4
5
6
int main(int argc, char *argv[]){
    HWND hWnd = GetConsoleWindow();
    ShowWindow(hWnd, SW_HIDE);
    Sleep(2000);
    beginning();
}

beginning is simply a void that I defined earlier. As of now I have the Sleep so that i can switch windows, but if i can automate it by simply pressing a key, then i can get rid of that as well :) I tried messing around with GetAsyncKeyState but pretty much failed with that.
Help is greatly appreciated!
You have to have a system hook to see key presses when your program does not have input focus. System hooks (of this kind) require you to write a DLL.
Topic archived. No new replies allowed.