Getox Posted June 1, 2005 Posted June 1, 2005 how would i do this: if ctrl+1 is pressed how would i make it output text? like if i had notepad open and i pressed ctrl+1 it would output hello how would i do this? Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
thenerd Posted June 1, 2005 Posted June 1, 2005 You want this to work as a universal hotkey? If so, I think GetASynchKeyState api would work for you. Otherwise, if you just want it to work in your program, you use the form's keydown event and keyup events. You set booleans for control and 1 and if both booleans are true, control 1 is being pressed: dim control as boolean dim one as boolean private sub form1_keydown() if e.keycode = keys.control then control = true elseif e.keycode = keys.1 then one = true end if if control and one then messagebox.show("CONTROL + 1") end if end sub private sub form1_keyup() if e.keycode = keys.control then control = false elseif e.keycode = keys.1 then one = false end if end sub Quote
Getox Posted June 1, 2005 Author Posted June 1, 2005 To be honest, im making a trainer for a game :) so how would i make it say for example "forcefood" when in game? Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
*Experts* DiverDan Posted June 1, 2005 *Experts* Posted June 1, 2005 I think using e.Modifiers would be a bit simplier that the Boolean. Public Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown If e.KeyCode = Keys.D1 And e.Modifiers = Keys.Control Then TextBox1.Text = "forcefood" End If End Sub Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
Getox Posted June 1, 2005 Author Posted June 1, 2005 i want to print it to any textbox in any program, not just mine Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
thenerd Posted June 1, 2005 Posted June 1, 2005 To type it: sendkeys.send("forcefood") To get key detection, you'd want GetASynchKeyState, look it up, I'm not sure how to use it. Quote
Getox Posted June 2, 2005 Author Posted June 2, 2005 I think using e.Modifiers would be a bit simplier that the Boolean. Public Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown If e.KeyCode = Keys.D1 And e.Modifiers = Keys.Control Then TextBox1.Text = "forcefood" End If End Sub Would i need "GetASynchKeyState" for it to work or? Basicly i want to open a game press ctrl+1 and it will activate the cheat ;) Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
thenerd Posted June 2, 2005 Posted June 2, 2005 As I've said. GetASynchKeyState should get you the State of the Keys at any given time, not sure how to use it. Look it up on google. Quote
Getox Posted June 3, 2005 Author Posted June 3, 2005 As I've said. GetASynchKeyState should get you the State of the Keys at any given time' date=' not sure how to use it. Look it up on google.[/quote'] i did, and it gave me some crap about cars, google sucks ;) Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Getox Posted June 3, 2005 Author Posted June 3, 2005 can anyone help? Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Leaders snarfblam Posted June 3, 2005 Leaders Posted June 3, 2005 Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Int32) As Short It is pretty simple to use. Try experimenting. I figured out how to use it by throwing it into VB6 and whipping up a quick test app. GetAsyncKeyState returned a negative value for the following keycodes when control and F1 are being held down: 17 (control), 162 (left control), 163 (right control), and 112 (F1). i did, and it gave me some crap about cars, google sucks Here is a crazy idea: search MSDN. From http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/getasynckeystate.asp Parameters vKey [in] Specifies one of 256 possible virtual-key codes. For more information, see Virtual-Key Codes. Windows NT/2000/XP: You can use left- and right-distinguishing constants to specify certain keys. See the Remarks section for further information. Return Value If the function succeeds, the return value specifies whether the key was pressed since the last call to GetAsyncKeyState, and whether the key is currently up or down. If the most significant bit is set, the key is down, and if the least significant bit is set, the key was pressed after the previous call to GetAsyncKeyState[/Quote] Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.