i'm an absolute beginner at c# and i need to make a form that recognises if w a s d is pressd. a portion of the code is this
[DllImport("user32.dll")]
internal static extern ushort GetAsyncKeyState(int vKey);
static void Main(string[] args)
{ ushort down = 32768;
ushort up=32768;
while (true)
{ if ((GetAsyncKeyState(0x26)&up)==up)
MessageBox.Show("up pressed");
else
//something
if ((GetAsyncKeyState(0x28)&down)==down)
//something
else
//something
i managed to make it work (after days) butin console only. can you help me put it in a windows form?
the internet wasn't very helpful, there are a lot of getasynckey examples in vb (even on youtube) and the few that i found in c# were very complicated or gave errors when i tried to put them in quicksharp or c# - i should have modified something to work, but i don't know.
so, please, help me put it in a windows form; just a empty form and when w or up key (whatever suits you) is pressed, a dialog appears, or something.