GetAsyncKeyState And Numpad?
Do you need something made? then ask 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.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
How do i use sendkeys on the numpad? i've tried "{NUMPAD1}" But it doesnt work! Is there a way to sendkeys numpad? Oh and is GetAsyncKeyState Stable? Because i've been trying to run it but it keeps messing up. Any code to sendkeys numpad? Thanks a ton
And how do i make hotkeys like ctrl+q?
And how do i make hotkeys like ctrl+q?
The hotkeys IN your program? Of sendkeys to create the hotkey?
Practice makes perfect!
VIP since: 6-10-2011
VIP since: 6-10-2011
Sendkeys the numpad numbers and hotkeys like alt+q and stuff..
The alt+q is that also a sendkey or a hotkey in YOUR program to activate the sendkeys?
Practice makes perfect!
VIP since: 6-10-2011
VIP since: 6-10-2011
The numpad question has been asked before: viewtopic.php?f=32&t=6275&start=0
GetAsyncKeyState is very reliable if you use it correctly.
RegisterHotKey is a good way to assign hotkeys across different programs; alternatively you could use GetAsyncKeyState for this purpose but it would mean extra work.
GetAsyncKeyState is very reliable if you use it correctly.
RegisterHotKey is a good way to assign hotkeys across different programs; alternatively you could use GetAsyncKeyState for this purpose but it would mean extra work.
Heyy.. thanka for the replies... and about the getasynckeystate, i want to create a hotkey called 'alt+q' so when the userpresses alt+q, it will show a message, getasyncketstate(key
s.alt+keys.q) doesnt work...
s.alt+keys.q) doesnt work...
If you want to do that with GetAsyncKeyState you could use this code as an example:
Code: Select all
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
<DllImport("user32.dll")> Shared Function GetAsyncKeyState(ByVal vKey As Integer) As Short
End Function
Dim isDown As Boolean = False 'stops the message appearing until the keys are released/pressed again
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
Dim leftAltDown As Short = GetAsyncKeyState(Keys.LMenu)
Dim qDown As Short = GetAsyncKeyState(Keys.Q)
If leftAltDown = -32768 And qDown = -32768 And Not isDown Then
isDown = True
MsgBox("Left Alt and Q are down")
ElseIf leftAltDown = 0 And qDown = 0 And isDown Then
isDown = False
End If
End Sub
Wow.. thanks for that! now.. for this code
Btw i dont really understand the
Code: Select all
how can i tweak this so it works for other numpads too? How do i modify so like when i press f5, it will push numpad 2 and when i press f4 it will push numpad 3...? Is it possible for you to type out the code so that when i pressed f5 it will push numpad 2, f4 it will push numpad 3 and possibly roughly explain it? Thanks a lot mandai!Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_KEYUP As Long = &H2
Private Const KEYEVENTF_EXTENDEDKEY As Long = &H1
Const VK_MENU = &H12 'ALT
Const VK_NUMPAD0 = &H60
Private Sub PressKey
keybd_event VK_NUMPAD0, 0, KEYEVENTF_KEYUP, 0 ' release 0
keybd_event VK_NUMPAD0, 0, 0, 0 ' press 3
End Sub
Btw i dont really understand the
Code: Select all
What is -32768?If leftAltDown = -32768 And qDown = -32768 And Not isDown Then
-32768 is the min value for the Int16, aka Short, data type. GetAsyncKeyState returns -32768 if the key is pressed.
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!
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!
Copyright Information
Copyright © Codenstuff.com 2020 - 2023