朋友们给的代码是下面这样的。记事本可以成功切换极点五笔输入法,打出中文
我就把notepad改成Word
打出字来成英文的了
不知道怎么回事
Opt("WinTitleMatchMode", 4)
Run("C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE")
Sleep(500)
$hWnd = WinGetHandle("classname=Word")Opt("WinTitleMatchMode", 4)
Run("notepad.exe")
Sleep(500)
$hWnd = WinGetHandle("classname=Notepad")
;~ HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts
$KeyStr=_GetKeyboardLayout($hWnd)
$KeyName=RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts" & $KeyStr, "Layout Text")
MsgBox (0, $KeyStr, $KeyName);显示当前输入法
LoadKeyboardLayout("E0060804", $hWnd);极点五笔
Sleep(500)
Send("kljg")
Func _GetKeyboardLayout($hWnd)
Local $ret = DllCall("user32.dll", "long", "GetWindowThreadProcessId", "hwnd", $hWnd, "ptr", 0)
$ret = DllCall("user32.dll", "long", "GetKeyboardLayout", "long", $ret[0])
Return Hex($ret[0], 8)
EndFunc
Func LoadKeyboardLayout($sLayoutID, $hWnd)
Local $WM_INPUTLANGCHANGEREQUEST = 0x50
Local $ret = DllCall("user32.dll", "long", "LoadKeyboardLayout", "str", $sLayoutID, "int", 1 + 0)
DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hWnd, "int", $WM_INPUTLANGCHANGEREQUEST, "int", 1, "int", $ret[0])
EndFunc ;==>LoadKeyboardLayout
|