PDA

For continued disscussion on this topic : Keydown event in vb 6



Baggio
07-02-2001, 05:45 PM
hey i want to use the keydown event in vb to open a secrect form

something like ctrl + alt + U and to open a new form,
if anyone has any ideas?

ciao

gzazJim
07-02-2001, 07:45 PM
Hey baggio,

I believe you'd use something like the following (this opens Notepad, loads a file whose name is passed as a parameter, and then sets focus to notepad):



Private Sub FireUpNotepad(strFunc As Strung)

Dim lngTaskID As Long
Dim strCmdLine As String

strCmdLine = "C:\windows\notepad.exe " & strFunc
lngTaskID = Shell(strCmdLine, vbNormalNoFocus)
' set your timing delay...
DelayLoop 100000

AppActivate lngTaskID, False
DoEvents
' timing delay
DelayLoop 100000

SendKeys "%Fx", False

End Sub


The SendKeys function only works in WIndows. You could sent the ctrl + alt + u as (^%{u}) (ctrl = ^, alt = %, literal u = {u}).

Regards and I hope this is of some help!

Jim

Baggio
07-03-2001, 12:34 PM
sorry maybe i didn't make myself clear,

im making a single program with two form, i'll call it frmone and frmtwo.

wat i want to be able to do is open frmtwo only by using a combination of keystrokes for example pressing

ctrl+alt+U at the same time.

frmtwo is supposed to be a secret form that can only be accessed by these keystrokes

thanks,

ciao

:cool:

gzazJim
07-03-2001, 03:52 PM
Hey baggio,

You can still use the SendKeys format to do that (I think!)...

SendKeys "^%(u)", False
frmtwo.Show

If this doesn't work as expected, let me know, and I'll look into it a bit further - it's been a while since I've worked with pure VB...!

Regards,

Jim

Baggio
07-03-2001, 06:01 PM
i am still unable to make the form show by a combination of key presses

what i am attemting to do is to have an "Easter Egg" to pop up when three keys are pressed at the same time. The "Easter Egg" is to be contained in a Form (call it frmtwo)

thankyou

ciao:cool:

Baggio
07-04-2001, 11:32 AM
hello children baggio returns again still hell bent on solving this problem,

i have managed to to show the second form if and only IF the first form has no other objects on it and if only one key is used to trigger the event

ciao

Chopper
07-04-2001, 03:40 PM
Raj I talked to ray today and he says it is an interupt, what you need to do is create an interup function which will read it and then do what you want it to do.

Baggio
07-04-2001, 03:58 PM
ok truss ill try that

gabits2000
03-07-2006, 01:54 AM
this must be what u're lookin' for:

Place this code in FrmOne...

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If Shift = 6 Then
If KeyCode = vbKeyU Then
frmTwo.Show
End If
End If
End Sub
Note:
Make sure that the "KeyPreview" property of FrmOne is set to true...

P.S. e-mail me if it works...
E-mail address removed, we prefer not to encourage
junk and/or spam spiders. :)

Baggio
08-18-2007, 11:00 PM
Whoa, you sure dusted this one off from the archives.. LoL I already did my A-levels and got my degree since then!