HomeCalendarGalleryFAQSearchMemberlistUsergroupsRegisterLog in

Share | 

 [TUT] Global Hotkeys!

Go down 

Posts : 42
Points : 28086
Reputation : 3
Join date : 2010-06-26
Location : Netherlands

PostSubject: [TUT] Global Hotkeys!   13/7/2010, 18:41

Hey guys well im gonna show you how to create Global Hotkeys!
You can use Global Hotkeys for ingame features!
Well first you need to start a new project!

Follow my steps:

First declare this:

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Now what our program does is check frequently whether the keys we want are being pressed.

So for this we need a timer.

Add a timer, and add this code to the Form1_Load event.

Timer1.enabled = true
Timer1.interval = 1

This is just turning on the Timer and setting its interval to 1.

Now, it depends on how many keys you want to press in order for your function to initiate.

Say, you want Them to press Shift.

You'll need to declare a boolean for shift like so:

Dim Shiftkey as Boolean
When that is done we need to set the value of the booleans. This is the part where the keys that need to be pressed are specified.

Add this code under the one previous.
Shiftkey = GetAsyncKeyState(Keys.ShiftKey)

Now we use an If statement to check if the keys are down.

If Shiftkey = True Then
'Put the code of what you want to happen when Shift is pressed here.
End If

I hope you learned from this tutorial, and remember not to copy and paste!
Type it up so you LEARN.

Back to top Go down
View user profile http://cdssys.boardlog.com
[TUT] Global Hotkeys!
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
CDSsys :: Programming :: .NET (C#, VB8)-
Jump to: