Usage with VS 2012 and .NET 4

May 7, 2013 at 3:47 PM
Edited May 7, 2013 at 3:47 PM
First of all: The Input Simulator is a great project.

After migrating from VS 2008 and .NET 3.5 to VS 2012 and .NET 4 (both on Windows 7, 64 bit) I recognized, that method IsKeyDownAsync didn't work anymore. Whatever the state of a key in question will be (down or up): IsKeyDownAsync is returning false.

The reason for this behavior is, that GetAsyncKeyState always returns 0 and sets error code 87 (ERROR_INVALID_PARAMETER). After changing the import signature from
static extern Int16 GetAsyncKeyState(UInt16 virtualKeyCode);
static extern Int16 GetAsyncKeyState(Int32 virtualKeyCode);
everything seems to be fixed.
Aug 2, 2013 at 12:06 AM
Thanks for that, I'll look into a fix for both x86 and x64 versions.

Mar 27, 2014 at 3:49 AM
Thank you very much!!!!!!
Apr 8, 2014 at 10:56 PM

Thank you very much!!
Apr 10, 2014 at 12:51 PM
One more information, same problem apply to:
    [DllImport("user32.dll", SetLastError = true)]
    static extern Int16 GetKeyState(Int32 virtualKeyCode);