Thursday, March 26, 2015

windows 7 - How to remove rarely used languages from language switch hot keys?


I type in the following 3 languages:


Language A - 55% of the time


Language B - 40% of the time


Language C - 5% of the time


The usual solution would be to have all three languages installed and use Ctrl/Alt-Shift, however it is quite annoying to have to switch over Language C each time I swap back and forth between A and B.


Is there some sort of solution that would allow me to prevent Windows from switching over to language C when I press Ctrl/Alt-Shift? I could then add a separate hotkey for switching over to Language C.


I'm using Windows 7 SP1.


Thank you.


Answer



You can create Autoit script for "skip" Language "C" when switch keyboard language.


After install Autoit and Editor. Right click on desktop->New->Autoit Script. Right click on this created file->Edit. Now you should see ScITE window and after line "Add your code below here" add this code:


#include 
ClipPut(_WinAPI_GetKeyboardLayout(ControlGetHandle("[ACTIVE]","","")))

Press SHIFT+ALT(or which hotkeys registered for switch keyboard language) until your current language will be "C"(if keyboard language name not show up in taskbar press Win+R ->> CTFMON.EXE ->> Enter) then in the ScITE window press Tools->Go. Now in your clipboard Language "C" code. Paste(CTRL+V) and save it somewhere.


Remove previous code and paste this:



#include
#include
#include
#NoTrayIcon
$skiplang="0x04090409" ;skip this language when switch language
$list=_WinAPI_GetKeyboardLayoutList ( )
$fakeforwardlang=""
If IsArray($list) Then
if $list[0]<3 then Exit; you potato
For $i = 1 To $list[0]
if $list[$i]=$skiplang Then;find next lang
if $i=$list[0] then
$fakeforwardlang=$list[1]
ExitLoop
EndIf
$fakeforwardlang=$list[$i+1]
ExitLoop
EndIf
Next
Else
Exit
EndIf
$fakeforwardlang=StringMid($fakeforwardlang,1,6)
while 1
$handle=ControlGetHandle("[ACTIVE]","","")
if getcurkb($handle)=$skiplang then _WinAPI_SetKeyboardLayout($handle, $fakeforwardlang)
Sleep(100)
wend
Func getcurkb($handle)
Return _WinAPI_GetKeyboardLayout($handle)
EndFunc

For next step need replace saved language "C" code with 0x04090409 in this script(5 line).


Then in SciTE window press Tools->Build. Now you will get executable in same directory where was Autoit script. Run this executable(.exe).


Need use task manager for kill process if want stop script.


Works on Windows 7 with 3 keyboard language and disabled UAC.


Update:


I screw up. _WinAPI_SetKeyboardLayout Forward work only sometimes. Standard send very buggy when {down} key pressed. Current solution based on external function. But one issue with this function you need unpress shift and alt for switch to next keyboard language. Should recheck code later.


Update2:


Back to _WinAPI_SetKeyboardLayout but using fake forward. I can't find any issues now.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...