If the threading tutorial is too much for you to soak in, here's an example:
- Code: Select all
BOOL bFreeze;
void On_HK_0( DWORD dw1, DWORD dw2 )
{
bFreeze = !bFreeze;
if (bFreeze == true)
{
HANDLE hNewThread = CreateThread("NewThread", 0);
if (!hNewThread) { bFreeze = false; return; }
CloseHandle(hNewThread);
}
}
VOID NewThread(DWORD dwParam)
{
while (bFreeze == true)
{
// put your code here to write the value.
Sleep(1);
}
}
In this snippet, When you press the hotkey it will toggle freezing. If bFreeze is FALSE then it will set it to TRUE, create the new thread, and execute the code in NewThread until bFreeze is FALSE again (which will happen if you press the hotkey again). Very simple, once you get the hang of it. The Sleep function is there so the constant looping doesn't lag or freeze MHS (or the game).