|
|
发表于 2026-3-22 19:54:31
|
显示全部楼层
实际对创口输出字符串的时候可以直接关闭输入法。不需要做这种转换。
#include <WinAPI.au3>
Opt("SendCapslockMode", 0)
Sleep(500)
Global $Win_MemberActive = WinGetHandle("[CLASS:Notepad]")
WinActivate($Win_MemberActive)
WinAPI_SetKeyboardLayout($Win_MemberActive) ;切换输入法到英文
ControlSend($Win_MemberActive, "", "", "AAbbccDD")
;输入法切换到英文
Func WinAPI_SetKeyboardLayout($hWnd, $iFlags = 0)
Local $hLocale, $iLanguage
If @OSVersion = "WIN_10" Then
$iLanguage = 0xd0000804
Else
$iLanguage = 0x00000804
EndIf
If Not _WinAPI_IsWindow($hWnd) Then Return SetError(@error + 10, @extended, 0)
Local $hLocale = 0
If $iLanguage Then
$hLocale = _WinAPI_LoadKeyboardLayout($iLanguage, $KLF_SUBSTITUTE_OK)
If Not $hLocale Then Return SetError(10, 0, 0)
EndIf
Local Const $WM_INPUTLANGCHANGEREQUEST = 0x0050
DllCall('user32.dll', 'none', 'SendMessage', 'hwnd', $hWnd, 'uint', $WM_INPUTLANGCHANGEREQUEST, 'uint', $iFlags, 'uint_ptr', $hLocale)
If @error Then Return SetError(@error, @extended, 0)
_WinAPI_ActivateKeyboardLayout($hLocale)
Return $hLocale
EndFunc ;==>WinAPI_SetKeyboardLayout |
评分
-
查看全部评分
|