输入法控制相关示例合集

以下是输入法控制相关的代码:

切换中英文【搜狗正常】.ahk

 
 
; 第三方输入法有的是切换英文有的是禁用【搜狗一切正常】


SetMsCtrStatus() ; 切换成英文
Sleep 2000
SetMsCtrStatus(1) ; 切换成中文


; Send ^, ; 搜狗切换到默认状态【中文】 Ctrl+,


SetMsCtrStatus(State:=False) {
DllCall("SendMessage", "Ptr", DllCall("imm32\ImmGetDefaultIMEWnd", "Ptr", WinExist("A")), "UInt", 0x0283, "UPtr", 0x006, "Ptr", State)
}

输入法切换时_鼠标样式跟着换.ahk

 
 
; 更改系统光标 的类库
; https://github.com/iseahound/SetSystemCursor
; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=75867&hilit=SetSystemCursor


; https://docs.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-setsystemcursor?redirectedfrom=MSDN


白标:="C:\Windows\Cursors\aero_arrow_xl.cur" ; 白标
黑标:="C:\Windows\Cursors\arrow_rl.cur" ; 黑标
Result:=DllCall("GetKeyboardLayout","int",0,"UInt")
SetFormat, integer, hex
ToolTip % Result += 0
SetFormat, integer, D
if (Result="0x4090409") { ; 英文输入法时
; 设置鼠标指针为白标
CursorHandle := DllCall( "LoadCursorFromFile", "Str", 白标)
DllCall("SetSystemCursor", "Uint", CursorHandle, "Int", 32512)
} else { ; 非英文输入法时
; 设置鼠标指针为黑标
CursorHandle := DllCall( "LoadCursorFromFile", "Str", 黑标)
DllCall("SetSystemCursor", "Uint", CursorHandle, "Int", 32512)
}


; 还原光标样式
DllCall("SystemParametersInfo", "Uint", SPI_SETCURSORS := 0x57, "Uint", 0, "Ptr", 0, "Uint", 0)
 

 

切换输入法和英文键盘.ahk

 
 
#SingleInstance Force


F1::
SetDefaultKeyboard(0x0409) ;; 切換為英文輸入
return


F2::
SetDefaultKeyboard(0x0404) ;; 切換為中文輸入
return


F3::
V++
M := mod(V,2) ;; 模數
if M=1
SetDefaultKeyboard(0x0404) ;; 切換為中文輸入
else
SetDefaultKeyboard(0x0409) ;; 切換為英文輸入
return


SetDefaultKeyboard(LocaleID) {
Global SPI_SETDEFAULTINPUTLANG := 0x005A
SPIF_SENDWININICHANGE := 2
Lan := DllCall("LoadKeyboardLayout", "Str", Format("{:08x}", LocaleID), "Int", 0)
VarSetCapacity(Lan%LocaleID%, 4, 0)
NumPut(LocaleID, Lan%LocaleID%)
;Lan := 0xE0090404
DllCall("SystemParametersInfo", "UInt", SPI_SETDEFAULTINPUTLANG, "UInt", 0, "UPtr", &Lan%LocaleID%, "UInt", SPIF_SENDWININICHANGE)
WinGet, windows, List
Loop %windows% {
PostMessage 0x50, 0, %Lan%, , % "ahk_id " windows%A_Index%
}
}
 

 

搜狗输入法 按住Shift输入大写+全局记录输入状态自动切换

 
 
; 搜狗输入法可以直接ctrl+逗号切换成中文后,再按Shift切换到英文


Loop 26
Hotkey, % "+"Chr(Asc("a")+A_Index-1), 按住Shift可输入大写
DllCall("RegisterShellHookWindow", "Ptr", A_ScriptHwnd)
, OnMessage(DllCall("RegisterWindowMessage", "Str", "ShellHook"), "ShellEvent")
Global 切换记录输入法状态=1
Return


~Shift::切换记录输入法状态 := !IME_GET()


按住Shift可输入大写:
if (LShift重置!=1)
Shift记录输入法状态 := IME_GET()
大小写转换 := RegExReplace(A_ThisHotkey, "(.*)(.+?)", "$U2"), LShift重置=1
Send {text}%大小写转换%
Return


~LShift Up::
if (LShift重置=1) {
if (Shift记录输入法状态=1)
Send ^,
else {
Send ^,
Send {Shift}
}
LShift重置=0
} Return


ShellEvent(wParam, lParam) {
Sleep 150
if (切换记录输入法状态!=IME_GET())
Send {RShift}
}


IME_GET(WinTitle="") {
ifEqual WinTitle,,SetEnv,WinTitle,A
WinGet,hWnd,ID,%WinTitle%
DefaultIMEWnd := DllCall("imm32\ImmGetDefaultIMEWnd", Uint,hWnd, Uint)
, DetectSave := A_DetectHiddenWindows
DetectHiddenWindows On
SendMessage 0x283, 0x005,0,,ahk_id %DefaultIMEWnd%
DetectHiddenWindows,%DetectSave%
Return ErrorLevel
}
 

 

切换输入法【不好用】

 
 
SetBatchLines, -1
Process, Priority,, High
SendMode Input
SetWorkingDir %A_ScriptDir%


; 搜狗输入法可用Ctrl+,来强制切换到中文


;强制英文:
DllCall("SendMessage", UInt, WinActive("A"), UInt, 80, UInt, 1, UInt, DllCall("LoadKeyboardLayout", Str,, UInt, 1))


;强制中文:
DllCall("SendMessage", UInt, WinActive("A"), UInt, 80, UInt, 1, UInt, DllCall("LoadKeyboardLayout", Str,, UInt, 1))
Send, #{Space}


;==================================================================


SwitchToEngIME(){
; 下方代码可只保留一个
SwitchIME(0x04090409) ; 英语(美国) 美式键盘
}
SwitchToChsIME(){
;~ SwitchIME(0x08040804) ; 中文(中国) 简体中文-美式键盘
PostMessage, 0x50, 0, 0x8040804, , A
If !IME_Return_0E1C()
SendInput, #{Space}
}


GET_IMESt(WinTitle=""){ ;返回0为英文键盘,1为中文状态
ifEqual WinTitle,, SetEnv,WinTitle,A
WinGet,hWnd,ID,%WinTitle%
DefaultIMEWnd := DllCall("imm32\ImmGetDefaultIMEWnd", Uint,hWnd, Uint)
;Message : WM_IME_CONTROL wParam:IMC_GETOPENSTATUS
DetectSave := A_DetectHiddenWindows
DetectHiddenWindows,ON
SendMessage 0x283, 0x005,0,,ahk_id %DefaultIMEWnd%
DetectHiddenWindows,%DetectSave%
Return ErrorLevel
}




SwitchIME(dwLayout){
HKL:=DllCall("LoadKeyboardLayout", Str, dwLayout, UInt, 1)
ControlGetFocus, ctl, A
SendMessage, 0x50, 0, HKL, %ctl%, A
}


IME_Return_0E1C(WinTitle="A"){ ;借鉴了某日本人脚本中的获取输入法状态的内容,减少了不必要的切换,切换更流畅了
;~ ifEqual WinTitle,, SetEnv,WinTitle,A
WinGet, hWnd, ID, %WinTitle%
DefaultIMEWnd:=DllCall("imm32\ImmGetDefaultIMEWnd", Uint, hWnd, Uint)
;Message : WM_IME_CONTROL wParam:IMC_GETOPENSTATUS
DetectSave:=A_DetectHiddenWindows
DetectHiddenWindows, ON
SendMessage 0x283, 0x005, 0, ,ahk_id %DefaultIMEWnd%
DetectHiddenWindows, %DetectSave%
Return ErrorLevel
}


;==================================================================


;W10下在英文和中文之间切换
F6:: ;第1次按F6切换到中文状态(W10选中文输入法),第2次按切换到英文状态,同时取消大小状态
if (FGW:=!FGW) ;If var ; 如果变量的内容为空或 0 时, 它被视为 false. 否则它被视为 true.
{
SetCapsLockState,off
; switchime(0)
switchime(1)
ToolTip,已切换到中文状态!
SetTimer, RemoveToolTip, 2000
return
}
else
{
;F7::
SetCapsLockState,off
switchime(0) ;切换到系统英文输入法
ToolTip,已切换到En英文状态!
SetTimer, RemoveToolTip, 2000
return
}
CapsLock:: ;注意大写打开后,再按是关不了的,要用上面的F6,才能取消
SetCapsLockState,on
ToolTip,已打开A大写!
SetTimer, RemoveToolTip, 2000
return


switchime(ime := "A")
{
if (ime = 1){
DllCall("SendMessage", UInt, WinActive("A"), UInt, 80, UInt, 1, UInt, DllCall("LoadKeyboardLayout", Str,"00000804", UInt, 1)) ;E0210804是QQ五笔代码;E0200804是搜狗拼音代码,00000804是美式键盘
;输入法代码可以在注册表HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Keyboard Layouts查到
}else if (ime = 0)
{
DllCall("SendMessage", UInt, WinActive("A"), UInt, 80, UInt, 1, UInt, DllCall("LoadKeyboardLayout", Str,, UInt, 1))
}else if (ime = "A")
{
;ime_status:=DllCall("GetKeyboardLayout","int",0,UInt)
Send, #{Space}

 

搜狗输入法光标处状态提示(大小写,中英文)

 
 
;功能:中、英、大小写输入状态提示
;环境:win10+搜狗输入法,输入法状态切换用默认的shift键。
;作者:傲慢与偏见zxc, 837449776@qq.com
;时间:20210407


; 按下 Shift 键切换输入法
; EN-英文, CN-中文, A-Caps On
CN := chr(20013)
EN := chr(33521)


~CapsLock::
If GetKeyState("CapsLock","T")
ToolTip, Caps_On
Else
ToolTip, Caps_Off
return


~Shift::
ToolTip
If (IME_GET()=1)
{
If GetKeyState("CapsLock","T")
ToolTip, A
Else
ToolTip, % EN
}
else
{
If GetKeyState("CapsLock","T")
ToolTip, A
Else
ToolTip, % CN
}
return


; 鼠标左键按下,且为工形图标,判定为文本输入模式
; 显示 Tooltips
~LButton::
If (A_Cursor = "IBeam")
{
Edit_Mode := 1
}
Else if(A_Cursor = "Arrow")
{
Edit_Mode := 0
}
MouseGetPos, , , WhichWindow, WhichControl
WinGetPos,winx,winy,,,%WhichWindow%
ControlGetPos, x, y, w, h, %WhichControl%, ahk_id %WhichWindow%


if ( 0 = not_Edit_InFocus())
{
If (IME_GET()=1)
{
If GetKeyState("CapsLock","T")
ToolTip, A
Else
ToolTip, % CN
}
else
{
If GetKeyState("CapsLock","T")
ToolTip, A
Else
ToolTip, % EN
}
}
return


; 按下Ctrl键查询当前状态
~Ctrl::
if ( 0 = not_Edit_InFocus())
{
If (IME_GET()=1)
{
If GetKeyState("CapsLock","T")
ToolTip, A
Else
ToolTip, % CN
}
else
{
If GetKeyState("CapsLock","T")
ToolTip, A
Else
ToolTip, % EN
}
}
return


; 默认显示时间1s
~Shift up::
~Lbutton up::
~CapsLock up::
~Ctrl up::
Sleep,1000
ToolTip
return


not_Edit_InFocus(){
Global Edit_Mode
ControlGetFocus theFocus, A
return !(inStr(theFocus , "Edit") or (theFocus = "Scintilla1")
or (theFocus ="DirectUIHWND1") or (Edit_Mode = 1))
}


IME_GET(WinTitle="")
;-----------------------------------------------------------
; “获得 Input Method Editors 的状态”
;-----------------------------------------------------------
{
ifEqual WinTitle,,SetEnv,WinTitle,A
WinGet,hWnd,ID,%WinTitle%
DefaultIMEWnd := DllCall("imm32\ImmGetDefaultIMEWnd", Uint,hWnd, Uint)


DetectSave := A_DetectHiddenWindows
DetectHiddenWindows,ON
SendMessage 0x283, 0x005,0,,ahk_id %DefaultIMEWnd%
DetectHiddenWindows,%DetectSave%
Return ErrorLevel
}

 

根据程序自动切换输入法

 

;操作系统: Winxp
;作者: 小猛<skc2015@163.com&gt;
;脚本说明: 根据程序设置输入法
;脚本版本: 2014年7月30日12:25:20 AHKCN群修正版
#Persistent
#SingleInstance force
Menu, Tray, Click, 1
Menu, Tray, Tip, By,小死猛
Menu, Tray, Add, By,小死猛, Menu_Show
Menu, Tray, Add, 反馈更新, Menu_Tray_Feedback
Menu, Tray, Add, 使用说明, Menu_Tray_illustrate
Menu, Tray, Add, 版本信息, Menu_Tray_Version
Menu, Tray, Add, 清空配置, Menu_Tray_Empty
Menu, Tray, Add, 重启脚本, Menu_Tray_Reload
Menu, Tray, Add, 退出脚本, Menu_Tray_Exit
Menu, Tray, Default, By,小死猛
Menu, tray, NoStandard
Gui, Add, Hotkey, Limit1 vChosenHotkey gMySubroutine w60
Gui, Add, Text, +y10 ,设置程序为配置输入法
Gui, Add, ListView, AltSubmit Checked -HScroll r14 x10 w208 vMyListView gMyListView ,进程名|输入状态|编号|路径|


IniRead, ChosenHotkey, %A_WorkingDir%\其他配置.ini, 热键, key
if ChosenHotkey is alpha
{
}
else
{
Hotkey, %ChosenHotkey%, MyLabel
GuiControl,, ChosenHotkey,%ChosenHotkey%
}


ImageListID1 := IL_Create(10)
ImageListID2 := IL_Create(10, 10, true) ; 大图标列表和小图标列表.


; 关联图像列表到 ListView, 然而它就可以显示图标了:
LV_SetImageList(ImageListID1)
LV_SetImageList(ImageListID2)


Gui, Add, Button, gMshiqh vMshiqh,开启自动模式
Gui, Add, Button, x+10 gTxck,更新程序到列表
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow ; +ToolWindow 避免显示任务栏按钮和
WinSet, TransColor, EEAA99 230, %WindowColor%
Gui,Show, ,输入法配置
GuiControl, -Redraw, MyListView
;;;;;;;;;;;;;创建ListView内容;;;;;;;;;;;;;
Txck:
sfi_size := A_PtrSize + 8 + (A_IsUnicode ? 680 : 340)
VarSetCapacity(sfi, sfi_size)
LV_Delete()
WinGet, WinList, list,,, Program Manager
WinAll:= Object()
WinAll.Conut:=WinList
loop,%WinList% {
id:=WinList%A_Index%
WinGet, win_ex, ProcessName, ahk_id %id%,
StringReplace, win_exe, win_ex,.exe , ,
WinGet, win_cklj, ProcessPath , ahk_id %id%,
if (win_exe = win_cf)
{
continue
}
win_cf = %win_exe%
loop ;排除配置中进程被添加
{
IniRead, win_dq, %A_WorkingDir%\设定.ini, 用户配置, %A_Index%
if win_dq = ERROR
{
break
}
if (win_dq = win_exe) ;在列表中出现 告诉下面删除新创建的行
{
sbs = shac
}
}
if not DllCall("Shell32\SHGetFileInfo" . (A_IsUnicode ? "W":"A"), "str", win_cklj
, "uint", 0, "ptr", &sfi, "uint", sfi_size, "uint", 0x101) ; 0x101 为 SHGFI_ICON+SHGFI_SMALLICON
IconNumber = 9999999 ; 把它设置到范围外来显示空图标.
else ; 成功加载图标.
{
; 从结构中提取 hIcon 成员:
hIcon := NumGet(sfi, 0)
; 直接添加 HICON 到小图标和大图标列表.
; 下面加上 1 来把返回的索引从基于零转换到基于一:
IconNumber := DllCall("ImageList_ReplaceIcon", "ptr", ImageListID1, "int", -1, "ptr", hIcon) + 1
DllCall("ImageList_ReplaceIcon", "ptr", ImageListID2, "int", -1, "ptr", hIcon)
; 现在已经把它复制到图像列表, 所以应销毁原来的:
DllCall("DestroyIcon", "ptr", hIcon)
; 缓存图标来节省内存并提升加载性能:
IconArray%ExtID% := IconNumber
}
LV_Add("Icon" . IconNumber ,win_exe,,,win_cklj)
if sbs = shac
{
RowNumber := LV_GetCount()
LV_Delete(RowNumber)
}
sbs =
}
;;;;;;;;;;;;;添加配置文件设置;;;;;;;;;;;;;
loop
{
IniRead, win_exe, %A_WorkingDir%\设定.ini, 用户配置, %A_Index%
if win_exe = ERROR
{
break
}
IniRead, win_exe, %A_WorkingDir%\设定.ini, %win_exe%, 进程
IniRead, win_zt, %A_WorkingDir%\设定.ini, %win_exe%, 状态
IniRead, win_bh, %A_WorkingDir%\设定.ini, %win_exe%, 编号
IniRead, win_cklj, %A_WorkingDir%\设定.ini, %win_exe%, 路径
if not DllCall("Shell32\SHGetFileInfo" . (A_IsUnicode ? "W":"A"), "str", win_cklj
, "uint", 0, "ptr", &sfi, "uint", sfi_size, "uint", 0x101) ; 0x101 为 SHGFI_ICON+SHGFI_SMALLICON
IconNumber = 9999999 ; 把它设置到范围外来显示空图标.
else ; 成功加载图标.
{
; 从结构中提取 hIcon 成员:
hIcon := NumGet(sfi, 0)
; 直接添加 HICON 到小图标和大图标列表.
; 下面加上 1 来把返回的索引从基于零转换到基于一:
IconNumber := DllCall("ImageList_ReplaceIcon", "ptr", ImageListID1, "int", -1, "ptr", hIcon) + 1
DllCall("ImageList_ReplaceIcon", "ptr", ImageListID2, "int", -1, "ptr", hIcon)
; 现在已经把它复制到图像列表, 所以应销毁原来的:
DllCall("DestroyIcon", "ptr", hIcon)
; 缓存图标来节省内存并提升加载性能:
IconArray%ExtID% := IconNumber
}
LV_Add("Icon" . IconNumber ,win_exe,win_zt,win_bh,win_cklj)
RowNumber := LV_GetCount()
LV_Modify(RowNumber,"Check")
}
GuiControl, +Redraw, MyListView
LV_ModifyCol(1,90)
LV_ModifyCol(2,"SortDesc")
LV_ModifyCol(2,108)
LV_ModifyCol(3,0)
LV_ModifyCol(4,0)
;;;;;;;;;;;;;创建右键输入法内容;;;;;;;;;;;;;
HKLnum:=DllCall("GetKeyboardLayoutList","uint",0,"uint",0)
VarSetCapacity( HKLlist, HKLnum*4, 0 )
DllCall("GetKeyboardLayoutList","uint",HKLnum,"uint",&HKLlist)
loop,%HKLnum%
{
SetFormat, integer, hex
HKL:=NumGet( HKLlist,(A_Index-1)*4 )
StringTrimLeft,Layout,HKL,2
Layout:= Layout=8040804 ? "00000804" : Layout
Layout:= Layout=4090409 ? "00000409" : Layout
RegRead,IMEName,HKEY_LOCAL_MACHINE,SYSTEM\CurrentControlSet\Control\Keyboard Layouts\%Layout%,Layout Text
SetFormat, integer, D
IniWrite, %Layout%, %A_WorkingDir%\其他配置.ini, %A_Index%, 编号
Menu, MyContextMenu, Add, %IMEName%,SubMenu
}
return


MySubroutine:
Sleep,1000
if ChosenHotkey is alpha
{
return
}
else
{
IniWrite, %ChosenHotkey%, %A_WorkingDir%\其他配置.ini, 热键, key
Hotkey, %ChosenHotkey%, MyLabel
}
return


;;;;;;;;;;;;;快捷键切换输入法;;;;;;;;;;;;;
MyLabel:
WinGet, win_ex, ProcessName, A
StringReplace, win_exe, win_ex,.exe , ,
loop % LV_GetCount()
{
RowNumber := LV_GetNext(RowNumber,"Checked")
LV_GetText(win_cl, RowNumber, 1)
if (win_cl = win_exe)
{
LV_GetText(Layout, RowNumber, 3)
SwitchIME(Layout)
return
}
}
return


Mshiqh:
GuiControl,, mshiqh,已启动检测
loop
{
loop % LV_GetCount() ;循环次数为复选框被选中的数量 检查窗口是否有相对的输入法设置
{
RowNumber := LV_GetNext(RowNumber,"Checked") ;RowNumber为选中复选框的行数
LV_GetText(win_exe, RowNumber, 1) ;获取选中复选框项目的第一列
WinGet, win_ex, ProcessName,A ;获取当前窗口的进程名
StringReplace, win_pc, win_ex,.exe , , ;对进程名排除.exe
if (win_exe = win_pc)
{
LV_GetText(win_exe, RowNumber, 1) ;获取进程名相对的输入法编号并设置输入法
LV_GetText(Layout, RowNumber, 3) ;获取进程名相对的输入法编号并设置输入法
SwitchIME(Layout)
WinWaitNotActive,ahk_exe %win_ex% ;等待这个窗口不活动
}
}
Sleep,100
}
return


MyListView:
if A_GuiEvent = Normal
{
FileDelete,%A_WorkingDir%\设定.ini
loop % LV_GetCount()
{
RowNumber := LV_GetNext(RowNumber,"Checked")
if not RowNumber ; 上面返回零, 所以选择的行已经都找到了.
break
LV_GetText(win_exe, RowNumber, 1)
LV_GetText(win_zt, RowNumber, 2)
LV_GetText(win_bh, RowNumber, 3)
LV_GetText(win_lj, RowNumber, 4)
IniWrite, %win_exe%, %A_WorkingDir%\设定.ini, 用户配置, %A_Index%
IniWrite, %win_exe%, %A_WorkingDir%\设定.ini, %win_exe%, 进程
IniWrite, %win_bh%, %A_WorkingDir%\设定.ini, %win_exe%, 编号
IniWrite, %win_zt%, %A_WorkingDir%\设定.ini, %win_exe%, 状态
IniWrite, %win_lj%, %A_WorkingDir%\设定.ini, %win_exe%, 路径
}
}
return


GuiContextMenu: ;只在MyListView中显示菜单
ggwz := A_EventInfo
if A_GuiControl <> MyListView
return
Menu, MyContextMenu, Show, %A_GuiX%, %A_GuiY%
return


Submenu: ;输入法配置菜单
IniRead, win_yys, %A_WorkingDir%\其他配置.ini,%A_ThisMenuItemPos%, 编号 ;写入输入法顺序
LV_Modify(ggwz, , ,A_ThisMenuItem ,win_yys)
LV_ModifyCol(1,90)
LV_ModifyCol(2,"SortDesc")
LV_ModifyCol(2,108)
LV_ModifyCol(3,0)
LV_ModifyCol(4,0)
return


Menu_Show:
IfWinExist, 输入法配置
{
Gui, Cancel
return
}
Gui,Show, ,
return


Menu_Tray_Reload:
Reload
return


Menu_Tray_Exit:
ExitApp
return


Menu_Tray_Feedback:
TrayTip,百度空间,https://hi.baidu.com/yan8023 , 10, 1
return


Menu_Tray_illustrate:
TrayTip, 说明, 首先鼠标在行上右键选择输入法`n在选择行前复选框启用次窗口配置, 10, 1
return


Menu_Tray_Version:
TrayTip,版本信息,内部修正版, 10,1
return


Menu_Tray_Empty:
FileDelete, %A_WorkingDir%\设定.ini
FileDelete, %A_WorkingDir%\其他配置.ini
GuiControl,, ChosenHotkey,
TrayTip, 已删除, 配置文件:设定与其他配置, 10, 1
gosub, Txck
return


GuiClose: ; 用户关闭了窗口
ExitApp


SeekIME(PN)
{
HKL:=DllCall("GetKeyboardLayout", "uint",GetThRead(), "uint")
HKLnum:=DllCall("GetKeyboardLayoutList","uint",0,"uint",0)
VarSetCapacity( HKLlist, HKLnum*4, 0 )
DllCall("GetKeyboardLayoutList","uint",HKLnum,"uint",&HKLlist)
loop,%HKLnum%
{
if( NumGet( HKLlist, (A_Index-1)*4 ) = HKL )
{
Index:= A_Index+PN
Index:= Index=0 ? HKLnum : Index
Index:= Index=HKLnum+1 ? 1 : Index
;~ ToolTip %Index%
HKL:=NumGet( HKLlist,(Index-1)*4 )
break
}
}
ControlGetFocus,ctl,A
SendMessage,0x50,0,HKL,%ctl%,A
}


SwitchIME(dwLayout)
{
HKL:=DllCall("LoadKeyboardLayout", Str, dwLayout, UInt, 1)
ControlGetFocus,ctl,A
SendMessage,0x50,0,HKL,%ctl%,A
}


GetThread()
{
ResultID:=0
hWnd:=WinExist("A")
VarSetCapacity( thE, 28, 0 )
NumPut( 28, thE )
WinGet,ProcessID,pid,ahk_id %hWnd%
hProcessSnap := DllCall("CreateToolhelp32Snapshot","uint",4, "uint",ProcessID)
if (DllCall("ThRead32First","uint",hProcessSnap, "uint",&thE )=0)
{
return 0
}


loop
{
if (NumGet(thE,12) = ProcessID)
{
DllCall("CloseHandle","uint",hProcessSnap)
ResultID:=NumGet(thE,8)
return ResultID
}
NumPut( 28, thE )
if( DllCall("ThRead32Next","uint",hProcessSnap, "uint",&thE )=0)
{
DllCall("CloseHandle","uint",hProcessSnap)
return 0
}
}
}
 
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA捐赠
共{{data.count}}人
人已捐赠
其他应用案例

给 Maye Lite 添加鼠标右键双击激活主窗口的功能 2025-04-22

2025-4-22 9:57:55

其他教程

通过文件对象复制二进制文件(读写) Autohotkey

2020-2-19 10:29:35

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
有新私信 私信列表
搜索