Guidance
指路人
g.yi.org
software / rapidq / Examples / Devices / keyboard / hotkeys / hotkeys.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
' Global hotkeys

     $TYPECHECK ON

     CONST WM_HOTKEY = &H312

     CONST MOD_CTRL = &H2
     CONST MOD_SHFT = &H4
     CONST MOD_ALT = &H1


     DECLARE FUNCTION RegisterHotKey LIB "USER32" ALIAS "RegisterHotKey" _
      (hWnd AS LONG, ID AS LONG, fsModifiers AS LONG, _
      vk AS LONG) AS LONG
     DECLARE FUNCTION UnRegisterHotKey LIB "USER32" ALIAS "UnregisterHotKey" _
      (hWnd AS LONG, ID AS LONG) AS LONG
     DECLARE SUB SetForegroundWindow LIB "USER32" ALIAS "SetForegroundWindow" _
      (HWnd AS LONG)

     DECLARE SUB FormWndProc (hWnd&, uMsg&, wParam&, lParam&)


     CREATE Form AS QFORM
      Center
      CAPTION = "Global hotkeys"
      WndProc = FormWndProc
     END CREATE

'-- CTRL+A
     IF RegisterHotKey(Form.Handle, 0, MOD_CTRL, ASC("A")) = 0 THEN
      SHOWMESSAGE("Sorry, hot key CTRL+A already taken!")
     END IF

'-- CTRL+SHIFT+B
     IF RegisterHotKey(Form.Handle, 1, MOD_CTRL OR MOD_SHFT, ASC("B")) = 0 THEN
      SHOWMESSAGE("Sorry, hot key CTRL+SHIFT+B already taken!")
     END IF

     Form.SHOWMODAL

     UnRegisterHotKey(Form.Handle, 0)
     UnRegisterHotKey(Form.Handle, 1)

     SUB FormWndProc (hWnd&, uMsg&, wParam&, lParam&)
      IF uMsg& = WM_HOTKEY THEN
       SetForeGroundWindow(hWnd&)
       SHOWMESSAGE("Hotkey "+STR$(wParam&)+" hit!")
      END IF
     END SUB
掌柜推荐
 
 
¥1,390.00 ·
 
 
¥287.00 ·
 
 
¥410.00 ·
 
 
¥1,380.00 ·
 
 
¥1,080.00 ·
 
 
¥271.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2000-06-25 01:22:14