Results 1 to 4 of 4

Thread: [RESOLVED] Hotkey

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Location
    Denmark
    Posts
    132

    Resolved [RESOLVED] Hotkey

    The F3 hotkey works fine, but i cant get the F4 hotkey to work. What is the problem?

    Here is the code...

    vb Code:
    1. Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
    2.  
    3.     Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
    4.         Dim starthotkey As Boolean
    5.         Dim stophotkey As Boolean
    6.         starthotkey = GetAsyncKeyState(Keys.F3)
    7.         stophotkey = GetAsyncKeyState(Keys.F4)
    8.         If starthotkey = True Then
    9.             'start
    10.             Timer1.Enabled = True
    11.             If stophotkey = True Then
    12.                 'stop
    13.                 Timer1.Enabled = False
    14.             End If
    15.         End If
    16.     End Sub
    Last edited by Eldrup; Jun 20th, 2009 at 04:30 PM.
    Eldrup

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Hotkey

    have a look at the hotkeys link in my signature.
    it'll work with all of the F keys except F12 which is reserved

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Location
    Denmark
    Posts
    132

    Re: Hotkey

    I figured out my self

    Old code:

    vb Code:
    1. Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
    2.  
    3.     Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
    4.         Dim starthotkey As Boolean
    5.         Dim stophotkey As Boolean
    6.         starthotkey = GetAsyncKeyState(Keys.F3)
    7.         stophotkey = GetAsyncKeyState(Keys.F4)
    8.         If starthotkey = True Then
    9.             'start
    10.             Timer1.Enabled = True
    11.             If stophotkey = True Then
    12.                 'stop
    13.                 Timer1.Enabled = False
    14.             End If
    15.         End If
    16.     End Sub


    New code:
    vb Code:
    1. Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
    2.  
    3. Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
    4.         Dim starthotkey As Boolean
    5.         Dim stophotkey As Boolean
    6.         starthotkey = GetAsyncKeyState(Keys.F3)
    7.         stophotkey = GetAsyncKeyState(Keys.F4)
    8.         If starthotkey = True Then
    9.             'start
    10.             Timer1.Enabled = True
    11.              End if
    12.             If stophotkey = True Then
    13.                 'stop
    14.                 Timer1.Enabled = False
    15.             End If
    16.     End Sub
    Eldrup

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: [RESOLVED] Hotkey

    that'd work. you should change your API declaration:

    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Integer) As Integer

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