Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: [Request / Listing] [VB6]Keyboard Checking?  (Read 2636 times)

0 Members and 1 Guest are viewing this topic.
[Request / Listing] [VB6]Keyboard Checking?
« on: April 22, 2006, 11:59:51 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 562
For example in Game Maker it is:
Code: [Select]
if keyboard_check(vk_left) then {obj1.x=x-1}in vb it would be:
Code: [Select]
if ???=vbkeyleft
image1.left=mage1.left-1
end if
What would ??? be? Please and thank you!
« Last Edit: February 24, 2012, 12:20:40 pm by Niek »
Logged

Dayjo

shut the fuck up donny.
Re: [VB6]Keyboard Checking?
« Reply #1 on: April 23, 2006, 02:06:04 am »
  • hungry..
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3602
VB6 (not sure if it works on other versions)

First of all you need to declare the GetAsyncKeyState library:
Code: [Select]
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As KeyCodeConstants) As Long

Then you can declare your KeyDown function
Code: [Select]
Private Function KeyDown(ByVal vKey As KeyCodeConstants) As Boolean
KeyDown = GetAsyncKeyState(vKey) And &H8000
End Function


Then use the function like this:
Code: [Select]
If KeyDown(vbKeyF12) Then
End
End If
Logged
  • My Blog
Re: [VB6]Keyboard Checking?
« Reply #2 on: April 23, 2006, 04:17:38 am »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 4588
How do you check that as in a Step Event in GM? (While the window is active perhaps it checks for keydown?)
« Last Edit: April 23, 2006, 04:24:28 am by AoDC »
Logged
the a o d c

mit

Re: [VB6]Keyboard Checking?
« Reply #3 on: April 23, 2006, 07:43:15 am »
  • QBASIC programmer since age 4. Take that, world.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 1079
You wouldn't have it in a step event, VB6 is event driven and so you would have a private sub onkeydown or something. I can't remember, I haven't used it in ages.
Logged
Programmer / Spriter / Level designer / Game Director / Web Designer / Music Sequencer for
Random Highscore table:

Play the Kousou Arcade today!
  • Kousou Games
Re: [VB6]Keyboard Checking?
« Reply #4 on: April 23, 2006, 08:33:55 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 2245
you would likely have to use a timer
Logged

Dayjo

shut the fuck up donny.
Re: [VB6]Keyboard Checking?
« Reply #5 on: April 23, 2006, 01:30:05 pm »
  • hungry..
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3602
Yeah you could add a timer and set the interval to something small. 1000 = 1 second, so 250 might be fast enough. You also might want to make a function to determine if the button has been clicked rather than if the button is just being held (which is what that KeyDown function checks).

You could just check like this:

Code: [Select]
Private Sub Timer1_Timer()
'Check to see if the key is down, and the key wasnt down before
If KeyDown(vbKeyF12) And eftwelve = False Then
        eftwelve = True
        'Do whatever you want to happen when the key is pressed
End If

If Not KeyDown(vbKeyF12) Then
      eftwelve = False
End If
End Sub
« Last Edit: April 23, 2006, 01:44:57 pm by Dayjo Aspen »
Logged
  • My Blog
Re: [VB6]Keyboard Checking?
« Reply #6 on: April 23, 2006, 04:38:34 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 562
I want to use it as a movement thing. But then I found out that to make an ActiveX Control I can't use Private Declare Functions. Any help?

EDIT: Never mind. Thanks alot Dayjo! I envy you!  ;D

[CLOSED]
« Last Edit: April 23, 2006, 04:42:31 pm by Pensoftware »
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.045 seconds with 48 queries.

anything