本帖最后由 nmgwddj 于 2012-3-31 18:37 编辑
输入法顺序修改工具,输入法排序,删除无用输入法
http://blog.nmgwddj.com/?p=52
这些方法都是在论坛看到的。自己搜索不可能找不到解决办法!
#NoTrayIcon
#region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=C:\WINDOWS\system32\internat.exe|-1
#AutoIt3Wrapper_outfile=IME.exe
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Comment=输入法排序工具
#AutoIt3Wrapper_Res_Description=输入法排序工具
#AutoIt3Wrapper_Res_Fileversion=1.0.0.1
#AutoIt3Wrapper_Res_LegalCopyright=nmgwddj
#AutoIt3Wrapper_Res_Field=By|nmgwddj
#endregion ;**** 参数创建于 ACNWrapper_GUI ****
#include <Misc.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
_Singleton("test")
#region ### START Koda GUI section ### Form=
$Folder = IniRead('Path.ini', '路径', 'Path', 0);程序运行前先读取一下是否有配置文件存在。
If $CmdLine[0] > 0 Then;设置程序加参数运行
If $CmdLine[1] = '/Setup' Then
If FileExists(@ScriptDir & "\Data.ini") Then
Else
MsgBox(4096, "提示:", "没找到配置文件,请运行程序选择补丁文件目录.")
Exit
EndIf
Main()
Exit
Else
MsgBox(0, '', '没有这个参数')
Exit
EndIf
EndIf
Opt("TrayMenuMode", 1)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
$Form1 = GUICreate("IME输入法排序工具", 289, 214)
$ListView1 = GUICtrlCreateListView("输入法名称|标志", 8, 8, 273, 145)
_GUICtrlListView_SetColumn($ListView1, 0, "输入法名称", 165, -1)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 88)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
$hImageList = _GUIImageList_Create(0, 20, 6)
_GUICtrlListView_SetImageList($ListView1, $hImageList, 1)
$Button1 = GUICtrlCreateButton("向 上", 8, 160, 51, 25)
$Button2 = GUICtrlCreateButton("向 下", 64, 160, 51, 25)
$Button3 = GUICtrlCreateButton("删 除", 120, 160, 51, 25)
$Button4 = GUICtrlCreateButton("确 定", 176, 160, 51, 25)
$Button5 = GUICtrlCreateButton("退 出", 232, 160, 51, 25)
$nmgwddj = _GUICtrlStatusBar_Create($Form1)
_GUICtrlStatusBar_SetSimple($nmgwddj)
_GUICtrlStatusBar_SetText($nmgwddj, "By nmgwddj")
GUISetState(@SW_SHOW)
start()
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $Button5
Exit
Case $Button1
up()
Case $Button2
down()
Case $Button3
Delete()
Case $Button4
Enter()
EndSwitch
WEnd
Func up()
$ViewId = _GUICtrlListView_GetSelectedIndices($ListView1)
$Gcr = GUICtrlRead(GUICtrlRead($ListView1))
$StringS = StringSplit($Gcr, '|')
If @error Then Return
$ReadText_1 = _GUICtrlListView_GetItemText($ListView1, $ViewId - 1, 0)
$ReadText_2 = _GUICtrlListView_GetItemText($ListView1, $ViewId - 1, 1)
_GUICtrlListView_SetItemText($ListView1, $ViewId - 1, $StringS[1])
_GUICtrlListView_SetItemText($ListView1, $ViewId - 1, $StringS[2], 1)
_GUICtrlListView_SetItemText($ListView1, $ViewId, $ReadText_1)
_GUICtrlListView_SetItemText($ListView1, $ViewId, $ReadText_2, 1)
_GUICtrlListView_SetItemSelected($ListView1, $ViewId - 1, True)
If _GUICtrlListView_GetSelectedIndices($ListView1) = 0 Then
GUICtrlSetState($Button1, $GUI_DISABLE)
Else
GUICtrlSetState($Button2, $GUI_ENABLE)
EndIf
EndFunc ;==>up
Func down()
$ViewId = _GUICtrlListView_GetSelectedIndices($ListView1)
$Gcr = GUICtrlRead(GUICtrlRead($ListView1))
$StringS = StringSplit($Gcr, '|')
If @error Then Return
$ReadText_1 = _GUICtrlListView_GetItemText($ListView1, $ViewId + 1, 0)
$ReadText_2 = _GUICtrlListView_GetItemText($ListView1, $ViewId + 1, 1)
_GUICtrlListView_SetItemText($ListView1, $ViewId + 1, $StringS[1])
_GUICtrlListView_SetItemText($ListView1, $ViewId + 1, $StringS[2], 1)
_GUICtrlListView_SetItemText($ListView1, $ViewId, $ReadText_1)
_GUICtrlListView_SetItemText($ListView1, $ViewId, $ReadText_2, 1)
_GUICtrlListView_SetItemSelected($ListView1, $ViewId + 1, True)
If _GUICtrlListView_GetSelectedIndices($ListView1) + 1 = _GUICtrlListView_GetItemCount($ListView1) Then
GUICtrlSetState($Button2, $GUI_DISABLE)
Else
GUICtrlSetState($Button1, $GUI_ENABLE)
EndIf
EndFunc ;==>down
Func Delete()
$ViewId = _GUICtrlListView_GetSelectedIndices($ListView1)
_GUICtrlListView_DeleteItem($ListView1, $ViewId)
EndFunc ;==>Delete
Func Enter()
FileDelete(@ScriptDir & '\Data.ini')
$All = _GUICtrlListView_GetItemCount($ListView1)
For $i = 1 To $All
IniWrite(@ScriptDir & '\Data.ini', 'Main', $i, _GUICtrlListView_GetItemText($ListView1, $i - 1, 1))
Next
If MsgBox(32 + 4, '温馨提示', '保存配置文件成功' & @CRLF & @CRLF & '是否按现有配置文件更新输入法?') = 6 Then
Main()
Else
MsgBox(32, '提示', '配置文件保存陈功' & @CRLF & @CRLF & '将配置文件放置于程序目录,就可以使用/setup参数静默修改了。')
EndIf
EndFunc ;==>Enter
Func start()
_GUICtrlListView_DeleteAllItems($ListView1)
$i = 0
While 1
$i += 1
$Rev = RegEnumVal('HKEY_CURRENT_USER\Keyboard Layout\Preload', $i)
$ReadRev = RegRead('HKEY_CURRENT_USER\Keyboard Layout\Preload', $Rev)
If @error Then ExitLoop
$ReadKey = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts' & '\' & $ReadRev, 'Layout Text')
If $ReadRev <> '00000804' Then GUICtrlCreateListViewItem($ReadKey & '|' & $ReadRev, $ListView1)
;MsgBox(0, '', $ReadRev)
WEnd
EndFunc ;==>start
Func Main()
$i = 0
While 1
$i += 1
$ReadReg = RegRead('HKEY_CURRENT_USER\Keyboard Layout\Preload', $i)
If @error Then ExitLoop
$inputMethod = DllCall("user32.dll", "long", "LoadKeyboardLayout", "str", $ReadReg, "int", 0x1)
DllCall("user32.dll", "int", "UnloadKeyboardLayout", "long", $inputMethod[0])
WEnd
$i = 0
While 1
$i += 1
If RegDelete('HKEY_CURRENT_USER\Keyboard Layout\Preload', $i) <> 1 Then ExitLoop
WEnd
$IniRead = IniReadSection(@ScriptDir & '\Data.ini', 'Main')
RegWrite('HKEY_CURRENT_USER\Keyboard Layout\Preload', '1', 'REG_SZ', '00000804')
For $i = 1 To $IniRead[0][0]
RegWrite('HKEY_CURRENT_USER\Keyboard Layout\Preload', $i + 1, 'REG_SZ', $IniRead[$i][1])
Next
$i = 0
While 1
$i += 1
$ReadReg = RegRead('HKEY_CURRENT_USER\Keyboard Layout\Preload', $i)
If @error Then ExitLoop
DllCall("user32.dll", "long", "LoadKeyboardLayout", "str", $ReadReg, "int", 0x1)
WEnd
start()
EndFunc ;==>Main
Func WM_NOTIFY($hWndGUI, $MsgID, $WParam, $LParam)
Local $tagNMHDR, $Event, $hWndFrom, $IDFrom
Local $tagNMHDR = DllStructCreate("int;int;int", $LParam)
If @error Then Return $GUI_RUNDEFMSG
$IDFrom = DllStructGetData($tagNMHDR, 2)
$Event = DllStructGetData($tagNMHDR, 3)
$tagNMHDR = 0
Switch $IDFrom;选择产生事件的控件
Case $ListView1
Switch $Event; 选择产生的事件
Case $NM_CLICK ; 左击
Mouse()
Case $NM_DBLCLK ; 双击
Case $NM_RCLICK ; 右击
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func Mouse()
If _GUICtrlListView_GetSelectedIndices($ListView1) = 0 And _
_GUICtrlListView_GetSelectedIndices($ListView1) + 1 <> _
_GUICtrlListView_GetItemCount($ListView1) Then
GUICtrlSetState($Button1, $GUI_DISABLE)
GUICtrlSetState($Button2, $GUI_ENABLE)
Return
Else
If _GUICtrlListView_GetSelectedIndices($ListView1) + 1 = _
_GUICtrlListView_GetItemCount($ListView1) And _
_GUICtrlListView_GetSelectedIndices($ListView1) <> 0 Then
GUICtrlSetState($Button2, $GUI_DISABLE)
GUICtrlSetState($Button1, $GUI_ENABLE)
Return
EndIf
GUICtrlSetState($Button1, $GUI_ENABLE)
GUICtrlSetState($Button2, $GUI_ENABLE)
EndIf
EndFunc ;==>Mouse
|