Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_SETHOTKEY = &H32
Const HOTKEYF_SHIFT = &H1
Const HOTKEYF_CONTROL = &H2
Const HOTKEYF_ALT = &H4
Const HOTKEYF_EXT = &H8
Private Type tInteger
aint As Integer
End Type
Private Type t2Byte
lByte As Byte
hByte As Byte
End Type
Private ii As tInteger
Private bb As t2Byte
Private Sub Command1_Click()
Dim wParam As Long, I As Long
'设定ctl-shift-T 为该window的hotkey
bb.hByte = HOTKEYF_CONTROL Or HOTKEYF_SHIFT
bb.lByte = vbKeyT
LSet ii = bb
wParam = CLng(ii.aint)
I = SendMessage(Me.hwnd, WM_SETHOTKEY, wParam, 0)
If I = 1 Then
Debug.Print "Ctl-Shift-T 为hotkey"
Else
If I = 2 Then
Debug.Print "有其他Window也用Ctl-Shift-T当Hotkey"
Else
Debug.Print "指定失败"
End If
End If
End Sub
|