Hello Ahk forums again.
A long long time ago, I came to you on how to write a script that remaps the QWERTY keyboard layout to Dvorak except when the modifiers win, ctrl, or alt is held down. Which suspended the remap and used the default QWERTY. Also scroll lock light on = QWERTY off = Dvorak. The script is as follows:
Code:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#MaxHotkeysPerInterval 999
;----------------------------------------------------------------------------------------
Menu, Tray, Icon, main.cpl, 8
SetScrollLockState, off
~*ScrollLock::
Suspend, Permit
ScrollState := GetKeyState("ScrollLock", "T") ? "On" : "Off"
Suspend, %ScrollState%
Hotkey, *Ctrl, toggle
Hotkey, *Ctrl up, toggle
Hotkey, *Alt, toggle
Hotkey, *Alt up, toggle
Hotkey, *LWin, toggle
Hotkey, *LWin up, toggle
Hotkey, *Rwin, toggle
Hotkey, *Rwin up, toggle
return
;----- Release keys from remap when modifier is down-----
~*Ctrl::
SetKeyDelay -1
Send {Blind}{Ctrl DownTemp}
Suspend On
return
~*Ctrl up::
Suspend Off
SetKeyDelay -1
Send {Blind}{Ctrl Up}
return
~*Alt::
SetKeyDelay -1
Send {Blind}{Alt DownTemp}
Suspend On
return
~*Alt up::
Suspend Off
SetKeyDelay -1
Send {Blind}{Alt Up}
return
*LWin::
SetKeyDelay -1
Send {Blind}{LWin DownTemp}
Suspend On
return
*LWin up::
Suspend Off
SetKeyDelay -1
Send {Blind}{LWin Up}
return
*RWin::
SetKeyDelay -1
Send {Blind}{RWin DownTemp}
Suspend on
Return
*RWin Up::
Suspend off
SetKeyDelay -1
Send {Blind}{RWin Up}
Return
;----------- REMAP TO DVORAK ------------
-::[
=::]
q::'
w::,
e::.
r::p
t::y
y::f
u::g
i::c
o::r
p::l
[::/
]::=
;\::\ ;no change
;a::a ;no change
s::o
d::e
f::u
g::i
h::d
j::h
k::t
l::n
SC027::s
SC028::-
z::SC027
x::q
c::j
v::k
b::x
n::b
m::m
,::w
.::v
/::z
The above script the keyboard is kept at QWERTY and then using the script is switched to Dvorak. I need help making a script that does essentially the opposite. Instead of the OS using QWERTY as a default and using ahk to remap, the OS will use Dvorak as default, and ahk will suspend the remap until win, ctrl, or alt is held down. And when such keys are held down, it'll remap the Dvorak to QWERTY.
The reason why I'm wanting to remake the script is because my typing speed is getting faster and ahk is not very reliable at remapping at higher speeds. Often it would fail a remap, so I'm hoping this way, letting the OS handle the speeds unless I need to cut copy or paste would be more reliable.
Here is the hardest part and I've done it.. the correlation between which key remaps to which:
Code:
[::-
]::=
'::q
,::w
.::e
p::r
y::t
f::y
g::u
c::i
r::o
l::p
/::[
=::]
;\::\ ;no change
;a::a ;no change
o::s
e::d
u::f
i::g
d::h
h::j
t::k
n::l
s::SC027
-::SC028
SC027::z
q::x
j::c
k::v
x::b
b::n
;m::m ;no change
w::,
v::.
z::/
Also, as with the original script, scroll lock light Off = dvorak (remap always off unless modifiers are held down), Scroll lock light on = QWERTY (remap always on regardless if modifiers held down or not)
Problems I had trying to do this:
--The scroll lock light is opposite, off = qwerty on = dvorak
--Pushing and releasing modifier breaks the sync between light on/off correlates to which layout.
My failed script attempt:
Code:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#MaxHotkeysPerInterval 999
;----------------------------------------------------------------------------------------
Menu, Tray, Icon, main.cpl, 8
SetScrollLockState, off
~*ScrollLock::
Suspend, Permit
ScrollState := GetKeyState("ScrollLock", "T") ? "On" : "Off"
Suspend, %ScrollState%
Hotkey, *Ctrl, toggle
Hotkey, *Ctrl up, toggle
Hotkey, *Alt, toggle
Hotkey, *Alt up, toggle
Hotkey, *LWin, toggle
Hotkey, *LWin up, toggle
Hotkey, *Rwin, toggle
Hotkey, *Rwin up, toggle
return
;----- Release keys from remap when modifier is down-----
~*Ctrl::
SetKeyDelay -1
Send {Blind}{Ctrl DownTemp}
Suspend Off
return
~*Ctrl up::
Suspend On
SetKeyDelay -1
Send {Blind}{Ctrl Up}
return
~*Alt::
SetKeyDelay -1
Send {Blind}{Alt DownTemp}
Suspend Off
return
~*Alt up::
Suspend On
SetKeyDelay -1
Send {Blind}{Alt Up}
return
*LWin::
SetKeyDelay -1
Send {Blind}{LWin DownTemp}
Suspend Off
return
*LWin up::
Suspend On
SetKeyDelay -1
Send {Blind}{LWin Up}
return
*RWin::
SetKeyDelay -1
Send {Blind}{RWin DownTemp}
Suspend Off
Return
*RWin Up::
Suspend On
SetKeyDelay -1
Send {Blind}{RWin Up}
Return
;----------- REMAP FROM QWERTY TO DVORAK------------
[::-
]::=
'::q
,::w
.::e
p::r
y::t
f::y
g::u
c::i
r::o
l::p
/::[
=::]
;\::\ ;no change
;a::a ;no change
o::s
e::d
u::f
i::g
d::h
h::j
t::k
n::l
s::SC027
-::SC028
SC027::z
q::x
j::c
k::v
x::b
b::n
;m::m ;no change
w::,
v::.
z::/
Hopefully with the help of you guys, things will go well.
Thank you all,
-albert