在測試客戶端的過程中有時需要切換輸入法 ,網上給的不是很嚴謹會報錯,究竟如何寫呢?
這樣寫(不要跨行):
$hWnd = WinGetHandle("[ACTIVE]");$hWnd 爲目標窗口句柄,這裏設置的是當前活動窗口 $ret = DllCall("user32.dll", "long", "LoadKeyboardLayout", "str", "08040804", "int", 1 + 0) DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hWnd, "int", 0x50, "int", 1, "int", $ret[0]) Send("you text")