Problem: My friends CTRL key sends the "insert" button for whatever reason on her laptop
Solution: Write a program that will send the ctrl message to everything whenever insert is pressed
(At least that's the hope, the main thing is for WC3 when she is creating ctrl groups, aka: you select a few units and press ctrl + 1, but for her it does insert + 1 which does nothing, and we can't remap the in-game ctrl key to something else, so we're trying to remap the insert to ctrl for anything (for general use) )
Anyways, so I wrote some code and it works...sorta. When my program sends the VK_CONTROL command it like closes programs and stuff? o.O
Any idea what I'm ........ing up on?
Code:
int runthread = 0;
unsigned __stdcall FixThread( void* pArguments )
{
while ( runthread == 0)
{
if ( GetAsyncKeyState(VK_INSERT) )
SendMessage(HWND_BROADCAST, VK_CONTROL, NULL, NULL);
}
_endthreadex( 0 );
return 0;
}
...
// at some point start the thread
_beginthreadex( NULL, 0, &FixThread, NULL, 0, NULL );
Oh, and is there any way I can keep it constantly checking for insert, but without running at 100% cpu? I'm guessing a timer, but I don't know for sure. (I'm waiting to address that problem until it actually works, but I figured now I might as well ask it here as well just in case anyone knows )
Sorry in advanced if it's something stupid.