Hi guys,
I'm using windows 8.1 and I write in two languages often so I have to switch the input language (layout) using the default windows combination Ctrl + Shift.
I already broke one pair of ctrl and shift, and I have a new keyboard now so I want to keep it.
So can you help me with a script which is going to change the languages by only pressing CTRL, but still keep it's functionality for other ctrl combinations like copy and paste.
Thanks!
Change input language with CTRL only
-
- Posts: 4331
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Change input language with CTRL only
Hi, dhtj,
Try this:
Try this:
Code: Select all
~Ctrl Up::
if (A_PriorKey = "RControl" || A_PriorKey = "LControl") {
ControlGetFocus, FocusedControl, A
PostMessage, WM_INPUTLANGCHANGEREQUEST := 0x50, INPUTLANGCHANGE_FORWARD := 2,, % FocusedControl, A
}
Return
Last edited by teadrinker on 22 Sep 2017, 19:58, edited 1 time in total.
Re: Change input language with CTRL only
Thank you for the fast response.
It works but it's has a bit of a lag.
When I press ctrl, the language indicator at the taskbar starts flashing and after 1-2 seconds the change is done.
And if I press any other key during these 1-2 seconds, the change is interrupted.
And if i press it more than 3 times it happens this:
It works but it's has a bit of a lag.
When I press ctrl, the language indicator at the taskbar starts flashing and after 1-2 seconds the change is done.
And if I press any other key during these 1-2 seconds, the change is interrupted.
And if i press it more than 3 times it happens this:
-
- Posts: 4331
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Change input language with CTRL only
Uh-uh... This should not happen, tested on two computers with Windows 7 and 10. Something is wrong with your keyboard, maybe? Hotkey "Ctrl Up" should not work until it is released.
Re: Change input language with CTRL only
I just took the keyboard out of the box, so i think its not the problem.
Also all CTRL combinations are working fine.
This is the log after ONE pressing and releasing the ctrl.
I'm not holding the button, just quick press and release.
Also all CTRL combinations are working fine.
This is the log after ONE pressing and releasing the ctrl.
I'm not holding the button, just quick press and release.
Code: Select all
Script lines most recently executed (oldest first). Press [F5] to refresh. The seconds elapsed between a line and the one after it is in parentheses to the right (if not 0). The bottommost line's elapsed time is the number of seconds since it executed.
---- C:\Program Files\AutoHotkey\hotkeys.ahk
003: SendMode,Input
004: SetWorkingDir,%A_ScriptDir%
006: Return (15.17)
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return (0.02)
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return (0.01)
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return (0.02)
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return (0.02)
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return (0.01)
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
011: ControlGetFocus,FocusedControl
012: PostMessage,WM_INPUTLANGCHANGEREQUEST := 0x50,INPUTLANGCHANGE_FORWARD := 2,,FocusedControl,A
013: }
014: Return
010: if (A_PriorKey = "RControl" || A_PriorKey = "LControl")
014: Return (1.61)
Press [F5] to refresh.
-
- Posts: 4331
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Change input language with CTRL only
Do you run my code separately, or adding it to your script with other hotkeys?
Try one more version:
Do any keyboard applications work in the same time?
Try one more version:
Code: Select all
~LCtrl Up::
~RCtrl Up::
if (A_PriorKey = "RControl" || A_PriorKey = "LControl") {
ControlGetFocus, FocusedControl, A
PostMessage, WM_INPUTLANGCHANGEREQUEST := 0x50, INPUTLANGCHANGE_FORWARD := 2,, % FocusedControl, A
}
Return
Last edited by teadrinker on 22 Sep 2017, 20:03, edited 2 times in total.
-
- Posts: 4331
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Change input language with CTRL only
No other keyboard applications and scripts are runing.
I'm running your code only.
The second version works just like the first one.
Can we try different logic like:
"when ctrl is released :: act like ctrl+shift"
or
"when ctrl is released :: act like win+space"
I don't know how to write it properly though
I'm running your code only.
The second version works just like the first one.
Can we try different logic like:
"when ctrl is released :: act like ctrl+shift"
or
"when ctrl is released :: act like win+space"
I don't know how to write it properly though
-
- Posts: 4331
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Change input language with CTRL only
Code: Select all
$~Ctrl Up:: SendInput, {Ctrl Down}{Shift}{Ctrl Up}
Re: Change input language with CTRL only
Thanks!
This is working now:
This is working now:
Code: Select all
~Ctrl Up::
if (A_PriorKey = "RControl" || A_PriorKey = "LControl") {
Send, {Ctrl down}{Shift down}{Shift up}{Ctrl up}{Ctrl up}
}
Return
-
- Posts: 4331
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Change input language with CTRL only
For AHK v2, the working code is:
Note the "Ctrl" hotkey is used without "Up" modifier as it is by activated on release by design
Code: Select all
Ctrl:: Send "{Ctrl down}{Shift down}{Shift up}{Ctrl up}"