The image you posted (of CE) says the data type in the game is just 1 byte. (?)
But mem.Write(0x******,117); is probably (do you know?) writing an INT (ie. 4 bytes)
Check if the library explicitly has a .WriteByte() function, or if it's using generics, try
Code:
mem.Write(0x********,(BYTE)117); //BYTE is defined in Windows.h?...I forget
mem.Write(0x********,(char)117); //
mem.Write<BYTE>(0x********,117); //?
mem.Write<char>(0x********,117); //?
by default the value '117', even though it would fit into a byte, is treated as int32.
edit: what Tony* said is true -- you're going to end up writing to it hundreds of times in a single key press, which shouldn't cause a problem (?), but might, depending on your memory library I guess - either way, it's not 'good'.
Code:
bool wasKeyDown = false;
while (1)
{
if (GetAsyncKeyState(VK_F1)) // see msdn for return value :|
{ // key is currently down
wasKeyDown = true;
}
else
{//key isn't currently down, but was it down a moment ago?!
if (wasKeyDown)
{
//do the thing
wasKeyDown = false; // have to reset it..
}
}
}
^^this will cause the function to be called only after the key has been pressed and also *released*, which works for your needs, and avoids the call the Sleep. -->As opposed to doing something constantly while the key is pressed down.