我使用的是 OS X 和 Windows 10 系统。一个很好的解决方案是,我使用OS X 上的Alt按钮Command,并习惯按Alt+Space来更改语言。
现在我想在 Windows 上实现类似的东西,但是它对这些热键有严格的规定。
如何在 Windows 10 上将默认按钮更改为Ctrl+Space 或Alt+ ?Space
答案1
看起来你天生就没那么幸运。查看注册表,Windows 似乎只依赖修饰键(Ctrl、Alt、Shift),似乎不支持其他键。不过,你看过这个第三方工具了吗:
您可以在这里找到更多详细信息:在 Windows 7 中切换输入语言的热键
答案2
作为 AutoIt 的替代品,自动热键。
首先,您可以执行一行代码(将其保存为 *.ahk 到您的启动文件夹,以最快的方式通过 Win+R, Shell:Startup
, Enter 打开):
^Space::#Space
基本上,当您按下 Ctrl+Space 时,它会发送 Win+Space。Alt+Space 类似:
!Space::#Space
如果您在脚本开头添加以下内容,则仅占用约 100-200kb 的 RAM。否则,大约 3 MB。
#NoEnv
#NoTrayIcon
;save a bit on memory if Windows 5 or newer - MilesAhead
DllCall("psapi.dll\EmptyWorkingSet", "Int", -1, "Int")
或者,有脚本可以发送“切换布局”消息,而不是依赖于发送 Win+Space。它也应该在后台运行。在当前版本中,当点击右 Control 时它会切换布局,但它很容易在以 开头的两行中修改$~RControl
。
所有荣誉归功于 wOxxOm。
;http://www.autohotkey.com/board/topic/24666-keyboard-layout-switcher/
;save a bit on memory if Windows 5 or newer - MilesAhead
DllCall("psapi.dll\EmptyWorkingSet", "Int", -1, "Int")
$~RControl::LangSwitch(1)
$~RControl up::LangSwitch(2)
LangSwitch( iKeyDownUp=0 )
{
static tickLast
IfEqual,iKeyDownUp,1
{ tickLast=%A_TickCount%
return
}
IfEqual,iKeyDownUp,2
If( A_TickCount-tickLast>200 )
return
HKL:=DllCall("GetKeyboardLayout", "uint",GetThreadOfWindow(), "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 )
{ HKL:=NumGet( HKLlist, mod(A_Index,HKLnum)*4 )
break
}
}
ControlGetFocus,ctl,A
SendMessage,0x50,0,HKL,%ctl%,A ;WM_INPUTLANGCHANGEREQUEST
;show traytip
LOCALE_SENGLANGUAGE=0x1001
LOCALE_SENGCOUNTRY=0x1002
VarSetCapacity( sKbd, 260, 0 )
VarSetCapacity( sCountry, 260, 0 )
DllCall("GetLocaleInfo","uint",HKL>>16,"uint",LOCALE_SENGLANGUAGE, "str",sKbd, "uint",260)
DllCall("GetLocaleInfo","uint",HKL & 0xFFFF,"uint",LOCALE_SENGCOUNTRY, "str",sCountry, "uint",260)
traytip,%sKbd%,%sCountry%
SetTimer,REMOVE_TOOLTIP,500 ;0.5 second
return
REMOVE_TOOLTIP:
SetTimer,REMOVE_TOOLTIP,off
traytip
return
}
;returns first thread for the <processID>
;sets optional <List> to pipe | separated thread list for the <processID>
GetProcessThreadOrList( processID, byRef list="" )
{
;THREADENTRY32 {
THREADENTRY32_dwSize=0 ; DWORD
THREADENTRY32_cntUsage = 4 ;DWORD
THREADENTRY32_th32ThreadID = 8 ;DWORD
THREADENTRY32_th32OwnerProcessID = 12 ;DWORD
THREADENTRY32_tpBasePri = 16 ;LONG
THREADENTRY32_tpDeltaPri = 20 ;LONG
THREADENTRY32_dwFlags = 24 ;DWORD
THREADENTRY32_SIZEOF = 28
TH32CS_SNAPTHREAD=4
hProcessSnap := DllCall("CreateToolhelp32Snapshot","uint",TH32CS_SNAPTHREAD, "uint",0)
ifEqual,hProcessSnap,-1, return
VarSetCapacity( thE, THREADENTRY32_SIZEOF, 0 )
NumPut( THREADENTRY32_SIZEOF, thE )
ret=-1
if( DllCall("Thread32First","uint",hProcessSnap, "uint",&thE ))
loop
{
if( NumGet( thE ) >= THREADENTRY32_th32OwnerProcessID + 4)
if( NumGet( thE, THREADENTRY32_th32OwnerProcessID ) = processID )
{ th := NumGet( thE, THREADENTRY32_th32ThreadID )
IfEqual,ret,-1
ret:=th
list .= th "|"
}
NumPut( THREADENTRY32_SIZEOF, thE )
if( DllCall("Thread32Next","uint",hProcessSnap, "uint",&thE )=0)
break
}
DllCall("CloseHandle","uint",hProcessSnap)
StringTrimRight,list,list,1
return ret
}
; Returns thread owning specified window handle
; default = Active window
GetThreadOfWindow( hWnd=0 )
{
IfEqual,hWnd,0
hWnd:=WinExist("A")
DllCall("GetWindowThreadProcessId", "uint",hWnd, "uintp",id)
GetProcessThreadOrList( id, threads )
IfEqual,threads,
return 0
CB:=RegisterCallback("GetThreadOfWindowCallBack","Fast")
lRet=0
lParam:=hWnd
loop,parse,threads,|
{ NumPut( hWnd, lParam )
DllCall("EnumThreadWindows", "uint",A_LoopField, "uint",CB, "uint",&lParam)
if( NumGet( lParam )=true )
{ lRet:=A_LoopField
break
}
}
DllCall("GlobalFree", "uint", CB)
return lRet
}
GetThreadOfWindowCallBack( hWnd, lParam )
{
IfNotEqual,hWnd,% NumGet( 0+lParam )
return true
NumPut( true, 0+lParam )
return 0
}
答案3
使用 PowerToys,它可以将特定快捷键重新映射到另一个快捷键。我用它将 win+space 重新映射到 alt-space,效果很好!而且它是免费的。
你可以在 GitHub 上下载 https://github.com/microsoft/PowerToys/releases/tag/v0.25.0