#Include <WinAPI.au3>
Global $aHookRegister[2], $aCombinList[1][5]
; Virtual-Key Codes - http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
; b t w
Global $aBtw[3] = [ 0x42, 0x54, 0x57 ]
; e t c
Global $aEtc[3] = [ 0x45, 0x54, 0x43 ]
If CombinationRegister() Then
$hForm = GUICreate('', 400, 300)
GUISetState( @SW_HIDE )
#cs
"0407" Немецкий (стандартный)
"0409" Английский (США)
"040C" Французский (стандартный)
"040D" Финский
"0410" Итальянский
"0415" Польский
"0419" Русский
"0422" Украинский
"0423" Белорусский
"0425" Эстонский
"0426" Латвийский
"0427" Литовский
#ce
AddCombinationEvent( $aBtw, '__OnBtw', "0409" )
AddCombinationEvent( $aEtc, '__OnEtc', "0409" )
While 1
Switch GUIGetMsg()
Case -3
CombinationUnregister()
Exit
EndSwitch
Wend
EndIf
Func __OnBtw()
Send( "{BS}{BS}{BS}by the way" )
EndFunc
Func __OnEtc()
Send( "{BS}{BS}{BS}et cetera" )
EndFunc
; ---
Func CombinationRegister()
$aHookRegister[0] = DllCallbackRegister('__hock_Proc', 'long', 'int;wparam;lparam')
$aHookRegister[1] = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($aHookRegister[0]), _WinAPI_GetModuleHandle(''))
If $aHookRegister[1] Then
AdlibRegister('__compare_keys', 1)
Return 1
EndIf
Return 0
EndFunc
Func CombinationUnregister()
If $aHookRegister[1] Then
_WinAPI_UnhookWindowsHookEx($aHookRegister[1])
EndIf
If $aHookRegister[0] Then
DllCallbackFree($aHookRegister[0])
EndIf
AdlibUnRegister('__compare_keys')
EndFunc
Func AddCombinationEvent($aKeyList, $sProc, $sKeyboardLayout)
If IsArray($aKeyList) And UBound($aKeyList) And Not Ubound($aKeyList, 2) Then
$aCombinList[0][0] += 1
ReDim $aCombinList[$aCombinList[0][0] + 1][UBound($aCombinList, 2)]
$aCombinList[$aCombinList[0][0]][0] = $aKeyList
$aCombinList[$aCombinList[0][0]][1] = $sProc
$aCombinList[$aCombinList[0][0]][2] = 0
For $i = 0 To UBound($aKeyList) -1
$aCombinList[$aCombinList[0][0]][3] += $aKeyList[$i]
Next
$aCombinList[$aCombinList[0][0]][4] = $sKeyboardLayout
Return 1
EndIf
Return 0
EndFunc
Func __hock_Proc($nCode, $wParam, $lParam)
Local $ttKeyHook, $aTemp
$tKeyHook = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)
If ($wParam = 256) Then
For $i = 1 To $aCombinList[0][0]
If DllStructGetData($tKeyHook, 'vkCode') == 0x10 And DllStructGetData($tKeyHook, 'vkCode') == 0x14 Then
ContinueLoop
EndIf
If __compare($aCombinList[$i][0], DllStructGetData($tKeyHook, 'vkCode')) Then
$aCombinList[$i][2] += DllStructGetData($tKeyHook, 'vkCode')
Else
$aCombinList[$i][2] = 0
EndIf
Next
EndIf
Return _WinAPI_CallNextHookEx(0, $nCode, $wParam, $lParam)
EndFunc
Func __compare_keys()
For $i = 1 To $aCombinList[0][0]
If $aCombinList[$i][2] == $aCombinList[$i][3] Then
If __GetKeyboardLayout( WinGetHandle( "[ACTIVE]" ) ) == $aCombinList[$i][4] Then _
Call($aCombinList[$i][1])
$aCombinList[$i][2] = 0
EndIf
Next
EndFunc
Func __compare($aKeys, $vkCode)
For $i = 0 To UBound($aKeys) -1
If ($aKeys[$i] = $vkCode) Then
Return 1
EndIf
Next
Return 0
EndFunc
Func __GetKeyboardLayout($hWnd)
Local $aRet = DllCall("user32.dll", "long", "GetWindowThreadProcessId", "hwnd", $hWnd, "ptr", 0)
$aRet = DllCall("user32.dll", "long", "GetKeyboardLayout", "long", $aRet[0])
Return Hex($aRet[0], 4)
EndFunc