• Popular Now

• 14
• 12
• 9
• 10
• 13

Archived

This topic is now archived and is closed to further replies.

Pocket PC GetAsyncKeyState C#.Net

This topic is 5342 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi.. I''ve been learning C#.net for use on a Pocket PC 2002...(uses .net compact framework) On This Site he talks about using GetAsyncKeyState for detecting arrowkeys... Its declared as:
[DllImport("coredll.dll")]
private static extern int GetAsyncKeyState(int vkey);

But Im not able to get it to detect if any of the hardware arrowkeys are down, I believe that Left is 37, Up is 38, Right is 39, and Down is 40...because thats what his enum had.
//in a loop
if (GetAsyncKeyState(38) != 0)
{
//This is not reached when i press up...why!?
}

This is what Im apparently supposed to do, but it doesnt work...argh Can anyone help with this? Thanks, Lord Hen

Share on other sites
Could it be that Im using the VS.NET 2003 Pocket PC Emulator?

I wont be getting my pocket pc for a few days(shipping...argh)...so I cant exactly test it on a real device.

If anyone would try this out on both the emulator and the actual device, it would be greatly appreciated =)

psuedocode of what im doing:
//loopif (GetAsyncKeyState(left) == Pressed)    //notify of keypress: msgbox, label, etcApplication.DoEvents();//end loop

Thanks,
Lord Hen

Edit: OK, I got my pocket pc and getasynckeystate DOESNT work on the emulator, but it works like a charm on the actual device. Im sorry, I should have waited until I actually got it.

[edited by - Lord Hen on August 6, 2003 12:20:15 AM]