Results 1 to 7 of 7

Thread: how to activate Hot Keys with vb.net code?

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Location
    Bulgaria
    Posts
    12

    how to activate Hot Keys with vb.net code?

    Hi All,

    vb.net , WinForm

    I would like to fire ALT+P hot keys with the timer or a button..

    any helps?

    best regards
    Krasimir

  2. #2
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    Yes, assign the hotkey to the menuitem for printing.

    eg. you have a main menu that contains a file menu with a submenu named print, assign the hotkey Alt P to the print submenu.

    Revised: AltP is not an assignable shortcut, I don't know why but I'll see what I can find.
    Last edited by CyberHawke; Jul 9th, 2004 at 05:31 AM.
    Whadayamean it doesn't work....
    It works fine on my machine!

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Location
    Bulgaria
    Posts
    12
    Thank you CyberHawke,

    seems to be a dificult task with the timer event.

    the timer will be activated on period of time and Alt+P should be activated somehow from Timer1_Tick Event..


    best regards
    Karsimir

  4. #4
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    you should just call your print routine directly from the Timer_Tick event.
    Whadayamean it doesn't work....
    It works fine on my machine!

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Location
    Bulgaria
    Posts
    12
    the problem is that i do not need Alt+P for printing routine,

    i would like to use also Alt+L for other wake up session

    somehow should find code to activate keyboard with vb.net

    best regards
    Krasimir

  6. #6
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    this?
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Me.Text = "The quick brown monkey jumps over the lazy dog."
    3.     End Sub
    4.  
    5.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    6.         KeyPreview = True
    7.     End Sub
    8.  
    9.     Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    10.         If e.Alt And e.KeyCode = Keys.P Then
    11.             Button1.PerfumeClick()       'Button1.PerformClick()
    12.         End If
    13.     End Sub
    please inform me if i'm on the wrong thread. i'll delete this. thanx.

  7. #7
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    Dear Kasimir, I'm not sure if this could be a useful suggestion (My english is really weak). If you need to fire a routine in your Tick event, you can set a flag in your button click event and you can run the appropriate routine testing flag in timer Tick event procedure. I've not understood why you can't use Alt+L as a direct shortcut, anyway if you want to use particular combinations (Ctrl+Shift+SpaceBar for example) to perform your shortcut, you can use the Brown Monkey's way, or you can directly set the Flag in place of Button1.PerformClick. Another suggestion....e.handled=true could be a useful idea.
    Good job.
    Live long and prosper (Mr. Spock)

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