找回密码
 加入
搜索
查看: 6949|回复: 10

[AU3基础] 切换五笔输入法,只有notepad成功word等等失败

  [复制链接]
发表于 2011-5-14 15:07:57 | 显示全部楼层 |阅读模式
悬赏10金钱未解决
朋友们给的代码是下面这样的。记事本可以成功切换极点五笔输入法,打出中文

我就把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

发表于 2011-5-14 22:29:56 | 显示全部楼层
;Opt("WinTitleMatchMode", 4)
Run("C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE")
Sleep(2000)
$hWnd = WinGetHandle("[CLASS:OpusApp]")

;~ 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("E0210804", $hWnd);qq五笔
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
 楼主| 发表于 2011-5-16 12:43:57 | 显示全部楼层
谢谢,请问Word为什么匹配OpusApp
如果不IE或其他程序呢?
不懂CLASS
 楼主| 发表于 2011-5-17 06:52:41 | 显示全部楼层
明白了。问题解决。
 楼主| 发表于 2011-5-17 06:53:57 | 显示全部楼层
;Opt("WinTitleMatchMode", 4)
Run("C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE")
Sleep(2000)
$hWnd = WinGetHandle("[CLASS:OpusApp]");窗口类

;~ 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
 楼主| 发表于 2011-5-17 06:55:53 | 显示全部楼层
怎么标记已解决?
发表于 2011-5-18 19:24:08 | 显示全部楼层
回复 6# lqs_lfzz


    直接编辑主贴,在标题最后加~~
 楼主| 发表于 2011-6-1 06:52:11 | 显示全部楼层
回复 7# annybaby


您的主题售价扣除积分交易税后为 0,请返回修改。

我改不了了,死活不行,不知道这是什么规则
 楼主| 发表于 2011-6-1 06:52:31 | 显示全部楼层
积分那么少,晕倒
发表于 2011-6-1 16:44:24 | 显示全部楼层
很不错 顶一下。
发表于 2011-6-2 08:24:25 | 显示全部楼层
代码不错值得收藏谢谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-11 03:41 , Processed in 0.077627 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表