Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

VB6 Hot Keys

I would like to make the F1-F12 keys Hot Keys for when a user is running one of my programs. All I want is for a certain form to pop up when one of these keys are clicked. Is there a way to do this without having to register the hot keys?

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Making Diagonal Keys Work With The Arrows Keys...
I want to figure out how to make up-left happen. Such as moving diagonal in a game or so what.

So far I have:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyUp
sngYFactor = -1
sngXFactor = 0
Case vbKeyDown
sngYFactor = 1
sngXFactor = 0
Case vbKeyLeft
sngYFactor = -1
sngXFactor = 0
Case vbKeyRight
sngXFactor = 1
sngYFactor = 0
End Select
End Sub

Also note that I'm making a game with controlling lines. I just want it to happen so when you press like the up arrow and left arrow, then you would move diagonally.


Disable All Keys On Keyboard Except Numeric Keys
hello everybody

i am developing a small quiz application wehre in i want that except the numeric keys all keys should be disabled once the application starts and enabled once the application ends.can i do this using some api.plz help


Using Keyboar Keys/shortcut Keys
Hi to all,

I know that using the KeyPreview property of a form is a useful thing when you try to implement shortcut key or re-act to keyboard keys. But I'd really like to implement something that can react to the keys when a user presses a keyboard without using the KeyPreview property, KeyDown, KeyPress and KeyUp events.

Do I need to use the GetAsyncKeyProperty API value (correct me if that is not the right function spelling/name)? Should it be implemented inside a Timer's Timer event?

Like for example if trying to create a typing software and I would be happy if anyone could give me ideas on the keyboard area.

Thanks and god bless all!

Fn Keys, Special Keys On Keyboards
Does anyone know how to approach this kind of programs? I need to write a program to override Fn keys (laptops) and keyboard specific keys. For example pressing wireless key on the keyoard launches a certain program, i'd like to override it and launch something else. Fn+F5 dims the LCD panel...same here, would like to over ride it. Anyone has any idea where to even start? Any articles/sample code for this? Thank you.

Deleting Keys And Their Sub-keys From Registry

I have been trauling over all the posts on the subject and have not found anything that would work. I have this code below that should delete all sub-keys but it does not. Anyone know of code that does it or know why this code does not work?? Thanks.

Public Function DeleteKey(ByVal hKey As Long, ByVal strKey As String)
'e.g.: Call DeleteKey(HKEY_CURRENT_USER, "SoftwareVBW")
Dim r As Long
'Dim RegOp

r = RegDeleteKey(hKey, strKey)
If (r <> 0) Then
' Maybe there are subkeys... let's roll (IE4+, Win98/2K)
With New RegOp
.Root = hKey
.key = strKey
End With
End If

End Function

Reg Keys
How can i remove a reg key using visual basic 6.
I mean all the subkeys and then the reg key. In One blow. If there are 1000 subkeys under one key i dont want to know all there names. I wanna delete the subkeys in either one line and then the empty key. Or delete the full key and the subkeys will be removed with it.
Can i get an example easiest that way thanks.

Ive read the create license tutorial.. Not quite sure of it..I wanna distrubute the program as a exe because I know no other way to do a setup file. So I was wondering how Can i fix it so if they were to share the exe that when the put in the key for it. It would delete it from something I dunno any other easier way?

Hot Keys
I am using the forms keypress event to trigger something. How do i code it so that i don't have to press shift + the letter? I just want to press "P" ....not 'shift" + "P".

Ok is it possible for me to make a chat program an Ip 2 Ip one which when u type somthing the other person see's what u are putting when ur puttin it so if i where to write "Hello" it would come up on the others person coputer as i was typing it.. If that makes any sense2 any1 So i others words if i where 2 write hello i wouldn't have to send it they would see it b4 hand as i was writing it.. Reply soon Thanks...

Hot Keys
I have made a application in visual basic and now I want to create hot key for my application by using VB.I mean the exe of my application should run when I press hot key like ctrl+A etc.
Please give me any idea and any code which can help me .
I shall be thankful to you.

Help With Keys
Hi all. I know this is a stupid question but I'm new to VB. I created a calculator program and I'd like to know how to make the numeric keypad keys launch the individual buttons. How do I make a key on the keyboard execute the same code that is executed by a mouse click as shown here?

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Is there something I can add to that line so that the form detects a key pressed and executes the same code? Thanks.

Hot Keys
How can I make hot keys to command buttons etc. ?

Hi folks
How can I program keys such as E, F and G? How can I know when they have been pressed so that I can program what is gonna happen when they are pressed?
Thank you so much,

If i have the ascii numbers for the keys i want to disable(96-105) THen what is the code to disable them and where do i write the code. I do not want anything to have to initialize it. I just want the keys diasable right away when the form opens up and keep them disabled while the program is running. THanks a lot.

How Do I Use Two Keys At Once?
I am programming a video game in visual basic ( i know bad choice) i've just spent near on a month figuring out how to stop the flickering thing and less than a day later, i run into another problem, is it possible for me to use two keys at once? Example Up arrow + Right Arrow?
If it is kindly post here or send me an e-mail, (
Thanks so much!

Reg Keys
I am trying to save some registry values on an NT machine but an error keeps occuring. Are they any things I need to be aware of when save registry values on NT - other than NT permissions. The same code works for saving the settings on Windows 98 and 95.

I am using the RegSetValueEx / RegOpenKeyEx and RegCreateKeyEx API calls to open and save the keys. I am saving the keys in an HKEY_CURRENT_USERsoftwaresystemk folder. All values are strings.

Can anyone provide any answers. If you need to see code I will be more than willing to post them.

F Keys
how do i tell which f key is pressed???

this thread needs to be moved, sorry.

F1 To F12 Keys
Hi guys,

How will VB6 know that the user presses F1,F2..F12 keys?

I could not find the Ascii values of these keys.

I need to work with them in Form_KeyPress event.

thank you guys.

About Hot Keys
I have an Timerecorder.exe file already or a runable program.somewhere in my pc.Nobody knows it's even there unless they hit that hotkey(F12), and that's when the file or .exe starts running or activitaing.Or just popup's when F12 is pressed.

but i dont know how to use a hot key or how to implement it...

any help pls?

Use Keys

i would like to know how i can use the keys CTRL+A+D
to open a new window


ok i want when every i press right click or f12 no matter which window i have opened it opens up a another form on my Project

Right now i'm using

If keycode = vbkeyright then
me.right = me.right + 100
If keycode = vbkeyup then = - 100

how do i make it so i can press them both at the same time so i can have both effects at the same time?

i know lots of oposts liek this, but after a weak attempt i couldnt find what i needed

basically i got

Private Sub pList_KeyDown(KeyAscii As Integer, Shift As Integer)
Select Case KeyAscii
Case vbKeyDelete: show_del
End Select
End Sub

works fine,

but i want a case for when someone pressed CTRL + Page up
i know ctrl is ^ etc but canna werk out how to hook it in u know??

any help would be great.


Hot Keys Help
I registered a hot key for my application.
When the main form is invisible, I want to make it visible when that hot key is pressed.
But I'm not able to generate any event when that key is pressed. Can som'ne tell me how to know when the hot key is pressed...!

Really in need of help...


Hot Keys Do Not Appear
When I create a menu and try to assign a hot key to one of the items (ex. &File would appear with an underscore under the F), it appears in the IDE but when I run the app it is not there. I seem to remember something like this when I was using Win98 and found it to be a Windows setting. Im now using Win2k and Win XP and can not figure out how to make them appear.

Using Hot Keys
I am creating a program which allows hotkeys to be used. If the user pressed a combonation of keys, how would I make my program execute code, not just on focus but also when the program is minimized into the task bar? (NOTE: I have already got code on how to minimize the program to the task bar)

I am trying to send some keys from my application to some other application say MS Word using Sendkeys function. But its not consistent sometimes it does works fine, and sometimes it does not. Some keys are always working some are hardly working. Is it something to do with my program, if yes, then what is the reason. Or is it something else. I wrote a global keyhook program to simulate this. Is it getting messed up with some thing else. The other program is not MS word but some outsourced application. Is there something wrong with sendkeys function?

Please Advise.

How would I get VB to make 2 key strokes, in this case ctrl + a at once, showing general code would help, if not necesserally these two.

I want to make a timer that sends them, I can do that bit myself, not sure how I get it to press them though.

Would it just send the key stroke to the maximised program?

If so, that's what I want.

Hot KEys
I have a problem that occurs rarely, and I can't find a sure-fire way to recreate it, but it has to do with Registering Hot Keys.
The client that got this recently has Windows 98 and on open of the software he gets an error -2147220453 Failed to Register Hot Key.
Another programmer wrote this, but no longer works for the company and there is no documentation on Hot Keys or this error if it was a known cause.

Any help would be GREAT!!


what would i put in sendkeys for the start menu, and maximize/minimize

Using CD Keys

How could I add a cd key to my application?

How do the software companies do it? Is it a one key fits all? Do they compile a special file containing the cd key for each cd they sell?

I have also seen an application which uses a key which is created specifically for your pc. If you try to use it on another pc, it doesn't work. So how do they do these things? How can I simulate this?


how can i make input into a text box be limited... Only allow say... 10 characters and they all must be numbers with out dashes... can i do this.... and if all this is possible than can i make each character a variable...?
Thank You :-)))

Hot Keys
Hi all,
I have a application with many forms.
I need to use a hot key to show one of this forms.
But the hot key press should be detected in anyone of these forms.
I want to use Ctrl+Shift+d to show a form.
Anybody can give me a example ??

Just wanted to find out what u guys do to generate unique keys (for membersid,booksid,....)

I dont want to use auto number or the system time.

Then how do I make sure that the number which I generate shd be UNIQUE.

Were Are My Keys?
Ya where are my keys?

Reg Keys
Hey all again

Could someone help me i am making a program that will remember a user name and pass number.I want this to get saved to the registry in their own seperate key.Problem is i only know how to retreive the info and not save it.

So could someone please give me some examples of code?

Thanx alot you people have helped me out alot,Hopefully one day i will be just like you guys.

how when i user pressses a button i can make it do something then press 2 keys

like alt and enter ?

Hot Keys
Ok how do i make these, what i'm trying to do is set it so when i run the program the "esc" key and the "Enter" Will do there functions. The enter key will calculate and trhe esc will clear the calculation.

Hot Keys?
How would I make it so that when someone presses a certain button, it performs a certain function. I need it so I know when the button is pushed, and let go. Thanks!

what's the defference between Key_press and Key_down ?

Get Both Down Keys
If i am holding down both the Down arrow key and the z key, but they control different things, how can I tell if both are down?


How do I go about detecting if more than one key is pressed than once ? I'm making a game here and I just realised this... hehe. =)


Does anyone know how to make the computer press a key without you toughing the keyboard when you click on a button?
Exp: you click a button and the computer presses the print screen key

CD Keys?
Hi, i was wondering if anybody could show me how to make some security on a VB program, maybe show me how to make a good CD Key or encryption method for the data. Ive tried doing this in the past, except when i encrypt a file using BINARY it takes forever.

I've also been traying to make a good CD key but i cant find a good way of encrypting it. Usually with CD Keys though, theres always a crack out there so i was wondering if anybody had any suggestions of how to make a CD key that will only work on a perticular computer upon registration.

I tried making a server to look up your CD key but that is to time consuming and ive droped the project.

If anybody has any suggestions about a way of securing your product in any way like a CD key or Encryption please share your thoughts!
Thanks in advance!

I was wondering if there was a way to diable the enter button while a rich text box was in focus.

Hot Keys
Hi!  I am new to this, please forgive if it does not make sense.  I have a vb6 form with hotkeys on labels to bring me to the textbox when hit, ie.) on the caption I have "&Invoice #:" but when you hit Alt+I it does not work - nothing happens.  So I tried to do the following on the form - keydown():
  CODEIf vbAltMask Then    
    Select Case KeyCode
        Case vbKeyI
            KeyCode = 0
    End Select
   End If
End If

I have, what may be a silly question...
You all know about this routine
Private Sub Form_KeyPress(KeyAscii As Integer)
With it you can read the keys typed into the window.
So if I use:
Dim String1 as string
Private Sub Form_KeyPress(KeyAscii As Integer)
string1 = string1 + chr(keyascii)
if string1 like "*test*" then
Msgbox "typed in!"
string1 = ""
end if
end sub
it will message "typed in!" when the user types "test" .
its all fine till here, but what if the user doesn't type it into my window?
if my window does not have focus, it will not read any keys sent to the form.
any one knows how to solve this problem?
Also, is there a way to read keys from a module?

Edited by - Maltadav on 9/13/2007 7:59:07 AM

Hot Keys!
Ok, so I have been working on a program that takes screenshots for months now and I want to add a hotkey feature. The program runs in the taskbar so no forms are in focus. I want the user to be able to specify their hotkey and when this hot key is pressed it should execute the code I have written to take the screenshot. Any help would be greatly appreciated. I have been stumped on this for months, its the only thing holding my program back from being released to the world! Thanks in advance!

Edited by - piles on 2/28/2006 2:33:47 PM

Hot Keys
How do i make, in essence, hot keys for buttons or pics or whatever. Like if i want to see if 'x' was pressed, make a sub for it, and then check to see if CTRL was pushed too....then have it do something.....

its prolly easy, just never did it before nor was it in any of my books....

Copyright 2005-08, All rights reserved