Results 1 to 5 of 5

Thread: [VB6] HotKeyW - Unicode Hot Key UserControl

  1. #1

    Thread Starter
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Thumbs up [VB6] HotKeyW - Unicode Hot Key UserControl

    A simple and lightweight Hot Key UserControl that "enables the user to enter a combination of keystrokes to be used as a hot key". This is a drop-in ready UserControl module that wraps the Hot Key control from Windows' Common Controls Library.


    Name:  Screenshot.png
Views: 2200
Size:  18.3 KB
    Attached Files Attached Files
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  2. #2
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Re: [VB6] HotKeyW - Unicode Hot Key UserControl

    Hi Bonnie,
    Does this pre register (permanently register) the Hot Key, to fire up an EXE in any future session of Windows
    or
    Does it alert our running application, that the user clicked the hot key ?

    Rob
    PS I admire your work.

  3. #3

    Thread Starter
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: [VB6] HotKeyW - Unicode Hot Key UserControl

    Both the RegisterHotKey function and the WM_SETHOTKEY message require that the application should already be running in order for them to work.

    If you want the ability to launch your app via a system-wide hotkey, you could create a shortcut file to your app on either the Desktop or the Start menu and in the shortcut file's Properties dialog box, type in your desired hotkey in the Shortcut key field. Windows Explorer will then register the hotkey for you every time you log on to Windows and launch your app whenever you press the hotkey.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  4. #4
    Addicted Member
    Join Date
    May 2016
    Location
    China
    Posts
    197

    Re: [VB6] HotKeyW - Unicode Hot Key UserControl

    How can I make hotkeys only apply to this program, not global?
    QQ: 289778005

  5. #5
    Hyperactive Member
    Join Date
    Aug 2017
    Posts
    380

    Re: [VB6] HotKeyW - Unicode Hot Key UserControl

    Quote Originally Posted by ChenLin View Post
    How can I make hotkeys only apply to this program, not global?
    You would have to use TranslateAccelerator instead of RegisterHotKey or WM_SETHOTKEY. See About Keyboard Accelerators and Using Keyboard Accelerators for more info. Note that, by default, the VB6 runtime creates a message loop for us. In order to use TranslateAccelerator, you will either need to override the VB6-supplied message loop or insert a call to TranslateAccelerator via a GetMsgProc hook.

    If you find that to be too much work, you could "cheat" by simply polling for the hotkey using a timer and then checking for the key combinations via multiple calls to GetKeyState. You won't be able to consume/discard the hotkey though.

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