run a program in background

so I want to make a program that plays a random sound when a certain key is hit but I am not sure how to run it in the background so it doesn't have to be in the application itself just as long as its running and I guess hide it as well


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <windows.h>

using namespace std;

int main(){
    string mystring;

    cin>>mystring;
    if (GetKeyState(VK_SHIFT)){
       //play a sound
    }
    system("pause");
    return 0;
}


is just a simple way to think of it but still need to do all of what I stated above
Need to make a process I believe
Nope just need to use this nifty code chunk ;)

1
2
3
4
HWND window;
AllocConsole();
window = FindWindowA("ConsoleWindowClass", NULL);
ShowWindow(window,0);
sweet if thats all that is needed ill have this written in no time! I thought I was going to have to thread to make it work
Yup that's all you should need ;) Happy coding!
Last edited on
Topic archived. No new replies allowed.