| Код | Private Const KL_NAMELENGTH As Long = 9 Private Const HKL_NEXT As Long = 1 Private Const HKL_PREV As Long = 0
Private Declare Function ActivateKeyboardLayout Lib "user32" ( _ ByVal HKL As Long, _ ByVal Flags As Long) As Long Private Declare Function GetKeyboardLayout Lib "user32" ( _ ByVal dwLayout As Long) As Long Private Declare Function GetKeyboardLayoutName Lib "user32" Alias "GetKeyboardLayoutNameA" ( _ ByVal pwszKLID As String) As Long
Private Sub Command1_Click()
Dim lngCurrent_HKL As Long Dim strCurrent_Buffer As String Dim lngSwitched_HKL As Long Dim strSwitched_Buffer As String
'узнать какая щас расскладка клавиатуры lngCurrent_HKL = GetKeyboardLayout(0) 'сделать буффер strCurrent_Buffer = String(KL_NAMELENGTH - 1, 0) strSwitched_Buffer = String(KL_NAMELENGTH - 1, 0) 'узнать название расскладки клавиатуры GetKeyboardLayoutName strCurrent_Buffer 'переключить на следующию расскладку клавиатуры ActivateKeyboardLayout HKL_NEXT, 0 'узнать переключёную расскладку клавиатуры lngSwitched_HKL = GetKeyboardLayout(0) 'узнать имя переключёной расскладки клавиатуры GetKeyboardLayoutName strSwitched_Buffer MsgBox "Рассклад клавиатуры поменялся" & vbCrLf & _ "из " & strCurrent_Buffer _ & " в " & strSwitched_Buffer 'вернуть начальную расскладку калвиатуры ActivateKeyboardLayout lngCurrent_HKL, 0
End Sub
|
|