Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than user32, prefix the name with the module name and a period.
GetAsyncKeyState (user32)
.
C# Signature:
[DllImport("user32.dll")]
static extern short GetAsyncKeyState(System.Windows.Forms.Keys vKey);
VB.NET Signature:
<DllImport("user32.dll")> _
Shared Function GetAsyncKeyState(ByVal vKey As System.Windows.Forms.Keys) As Short
End Function
VB Signature:
Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Integer) As Short
Or for hotkeys and such. This works even if the window isn't focused.
This works not for keyboard only, for mouse also (VK_RBUTTON, VK_LBUTTON).
C# Sample Code:
// this is import of libraries
[DllImport("User32.dll")]
private static extern short GetAsyncKeyState(System.Windows.Forms.Keys vKey); // Keys enumeration
[DllImport("User32.dll")]
private static extern short GetAsyncKeyState(System.Int32 vKey);
Public Class Form1
<DllImport("user32.dll")> _
Shared Function GetAsyncKeyState(ByVal vKey As System.Windows.Forms.Keys) As Short
End Function
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If GetAsyncKeyState(Keys.Return) <> 0 Then
TextBox1.Text = "Enter pressed now"
Else
TextBox1.Text = "Enter not pressed now"
End If
End Sub
End Class
An open source managed .NET wrapper written in C# is available on Codeplex at http://inputsimulator.codeplex.com/. It has all of these definitions complete with documented code comments and can be used to determine key states as well. Thanks to all the contributors at pinvoke.
Click to read this page
1/9/2023 2:53:16 AM - -31.215.156.67
TODO - a short description
5/29/2011 8:39:56 AM - -87.206.232.220
http://mwinapi.sourceforge.net/
3/31/2008 6:53:29 AM - -217.54.254.83
TODO - a short description
11/18/2012 5:41:15 AM - -151.33.171.142
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).