A problem with getasynckeystate

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts Page 1 of 1
Contributors
User avatar
anthonygz
Member
Member
Posts: 48
Joined: Sun Feb 13, 2011 7:25 pm

A problem with getasynckeystate
anthonygz
Hello fellow Codenstuff members, i made this topic today to possibly get some help from you.


Here is the error i keep getting:

GetAsyncKeyState' has unbalanced the stack.


Here is the error ed code:

If (GetAsyncKeyState(113)) Then






sorry for wasting your time but i just don't get what i'm doing wrong, it used to work before.


Edit:
sorry here's the full error

PInvokeStackImbalance was detected
Message: A call to PInvoke function 'MouseRecord!MouseRecord.Form1::GetAsyncKeyState' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

Edit:
What i'm thinking is that 2010 doesn't support it and i need 2008.



OS: Vista
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Should be:
Code: Select all
GetAsyncKeyState((113))
Or you can just use the key name:
Code: Select all
GetAsyncKeyState(Keys.F2)
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: A problem with getasynckeystate
MrAksel
Its nothing to do with version of VB or your OS. Neither will Cody's code help. You should declare it like this:
Code: Select all
    <DllImport("user32.dll")> _
     Public Shared Function GetAsyncKeyState(ByVal vKey As System.Windows.Forms.Keys) As Short
     End Function
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
3 posts Page 1 of 1
Return to “Coding Help & Support”