Results 1 to 6 of 6

Thread: Hidden Commands using Keycodes(Hotkeys)

  1. #1

    Thread Starter
    Addicted Member Reapism's Avatar
    Join Date
    Sep 2012
    Posts
    170

    Hidden Commands using Keycodes(Hotkeys)

    I have been fiddling with the keys and stuff and I stumbled upon adding a "Secret" key that opens up a form.

    I have been trying to add this key to Form1.load() so it is secret but upon doing so I receive a error

    Code:
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim Reap As System.EventArgs
            Reap.keycode = Keys.F1 then
            Form1.Show()
    
    'I understand you can use e.keycode but I like to be fancy :P
    How do I make it work, Should i have a default focus and then add the keycode method or using the form1.load() Please be explanatory

    All replies are invaluable.

    I am new to the VBForums, be nice I am only 16
    Last edited by Reapism; Oct 4th, 2012 at 03:46 PM. Reason: I messed up the title :(

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Hidden Commands using Keycodes(Hotkeys)

    Er ... um ... well ... nope, haven't a clue what you're trying to do. Are we talking about an application that's running with a hidden form or do you want to start a new application on a hotkey or .... ?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Addicted Member Reapism's Avatar
    Join Date
    Sep 2012
    Posts
    170

    Re: Hidden Commands using Keycodes(Hotkeys)

    I am essentially trying to have form1 have a hidden feature of when pressing F1 it will open up a form. I am not entirely sure on how these all work but I am trying to explain the best I can on my current struggle.

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Hidden Commands using Keycodes(Hotkeys)

    Well, much as you like to be fancy, there's no substitute for just plain old logic. You meed to detect a key press then you use a key event ...

    vb.net Code:
    1. Private Sub Form1_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown, TextBox1.KeyDown 'etc.
    2. ' the important thing to do here is to add all controls which have a keydown event in the handles section
    3. ' otherwise it will only be detected when no control has focus
    4.  
    5.         If e.KeyCode = Keys.F12 Then Form2.Show() ' I wouldn't use F1, it has far too many associations already!
    6.  
    7.     End Sub
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  5. #5

    Thread Starter
    Addicted Member Reapism's Avatar
    Join Date
    Sep 2012
    Posts
    170

    Re: Hidden Commands using Keycodes(Hotkeys)

    Thanks so much I actually did this before I read this and I acknowledge your feedback, but yes I am running into a problem where button1 has focus on form1 load so I added under Form1.load Me.Focus() But that did not work so I just made the key event on the button as well :_

  6. #6
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: Hidden Commands using Keycodes(Hotkeys)

    Code:
     Dim Reap As System.EventArgs
            Reap.keycode = Keys.F1 then
    Are you actually using late binding there ? Stop that blasphemous practice ASAP
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width