Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Mac Style Dvorak QWERTY Command Layout Switcher for Windows


  • Please log in to reply
36 replies to this topic
arkenflame
  • Members
  • 5 posts
  • Last active: May 29 2008 11:26 PM
  • Joined: 12 Jan 2008
On Macs, there is a way to have the keyboard layout Dvorak when you type, but when you use a hotkey (by holding alt, ctrl, etc) it switches back to QWERTY so you don't have to remap all the shortcuts or have them in inconvenient places.

This script does just that. You can also toggle back to QWERTY by pressing the right windows key. I find this helpful for playing games etc.

Here is the script:

SendMode Input
#NoEnv
Menu, Tray, Icon, main.cpl, 8

;----------- 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


;----------- RELEASE KEYS FROM REMAP WHEN MODIFIER 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

;----------- TOGGLE DVORAK-QWERTY WITH RIGHT WINDOWS KEY

*RWin::
Suspend, Permit
Suspend, toggle
Hotkey, *Ctrl, toggle
Hotkey, *Ctrl up, toggle
Hotkey, *Alt, toggle
Hotkey, *Alt up, toggle
Hotkey, *LWin, toggle
Hotkey, *LWin up, toggle
return

I also keep a (compiled) version of this on my flash drive that has a small gui allowing others to "fix" their keyboards by closing the window, in case I want to type on their computers and forget to switch it back myself.

Here is that version:

SendMode Input
#NoEnv

;----------- CREATE INFORMATION WINDOW
Menu, Tray, Icon, main.cpl, 8
Gui, Add, GroupBox, x2 y2 w326 h130 , Information
Gui, Add, Text, x10 y20 w300, Your keyboard layout has been temporarily changed. Close this window to restore your prior layout.
Gui, Add, Text, x10 y60 w300, If your keys aren't working right, or you are confused, press toggle or close this window.
Gui, Add, Text, x10 y100 w300, Current Layout: Dvorak
Gui, Add, Button, x20 y138 w90 h30  , Toggle 
Gui, Add, Button, x120 y138 w90 h30 , Minimize
Gui, Add, Button, x220 y138 w90 h30 , Close
Gui, Show, x552 y209 h175 w330, Dvorak Keyboard Layout Changer
Return

ButtonToggle:
Toggle()
Return

ButtonMinimize:
Gui, Show, Minimize
Return

GuiClose:
ButtonClose:
ExitApp

;----------- 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 ; no change
,::w
.::v
/::z


;----------- RELEASE KEYS FROM REMAP WHEN MODIFIER 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

;----------- TOGGLE DVORAK-QWERTY WITH RIGHT WINDOWS KEY

*RWin::
Suspend, Permit
Toggle()
return

Toggle() {
Suspend, toggle
Hotkey, *Ctrl, toggle
Hotkey, *Ctrl up, toggle
Hotkey, *Alt, toggle
Hotkey, *Alt up, toggle
Hotkey, *LWin, toggle
Hotkey, *LWin up, toggle
if (A_IsSuspended = 1) {
GuiControl, Text, Static3, Current Layout: QWERTY (normal)
} else {
GuiControl, Text, Static3, Current Layout: Dvorak
}
return
}

I hope someone finds this as useful as I do. Enjoy!

Jero3n
  • Members
  • 147 posts
  • Last active: Mar 31 2010 05:07 PM
  • Joined: 19 Jan 2007
Can ahk run on a mac?
Didn't knew that.

arkenflame
  • Members
  • 5 posts
  • Last active: May 29 2008 11:26 PM
  • Joined: 12 Jan 2008
No no no. This is just a script that allows you to do something on Windows you can normally only do on a Mac.

trik
  • Members
  • 1317 posts
  • Last active: Jun 11 2010 11:48 PM
  • Joined: 15 Jul 2007
Alls it does is remap the keys. It does nothing to altar the windows processes.

keybored
  • Members
  • 351 posts
  • Last active: Apr 26 2013 09:08 AM
  • Joined: 18 Jun 2006
arkenflame, Thank You so much! I couldn't figure out how to do this. I will be practicing Dvorak again.

hatsat
  • Guests
  • Last active:
  • Joined: --
i've never played with the scripts before could you please post a link or explain in brief how to use the above script ... i saved it in notepad but don't know what to do next?

Anyways, thanks a million arkenflame !! i've been searching for an easy way to switch between qwerty and dvorak ... there is a constant fight between me (dvorak) and my qwerty loving siblings over the keyboard layout... i have to do atleast 2-3 times/day... control panel ...regional and language options ..languages ...details .. add ...dvorak ...and back again. thanks again

Btw is there a way to change the keyboard layout from qwerty to dvorak and vice versa with a simple command from cmd.exe in windows ...like qw=qwerty and dv=dvorak

arkenflame
  • Members
  • 5 posts
  • Last active: May 29 2008 11:26 PM
  • Joined: 12 Jan 2008
hatsat, it's pretty easy.

Install AutoHotKey, right click on your dektop (or wherever) and select New > AutoHotKey Script, and name it what you want. Open it with notepad and paste in the code above. Then save it and double click on the file on your desktop. You can also right click on it and choose "Compile Script" if you want to run the (newly created) file without installing AutoHotKey elsewhere.

And just as a side note, my antivirus software (avast!) registers ahk-compiled programs as trojans, so you may need to add the program to an exception list.

KayDat
  • Members
  • 2 posts
  • Last active: Feb 22 2008 12:45 PM
  • Joined: 19 Feb 2008
What an excelent idea. I was just starting to do the same thing, but it looks like you beat me to it ;)

Patulo
  • Guests
  • Last active:
  • Joined: --
Such a useful piece of code! I was using a Dvorak configuration before (with Windows Control Panel Regional Settings), but I had to memorize the new hotkeys and it wasn't easily customizable. Then I found this script and was pretty happy with it except for one problem: I can't use it with Jim Biancolo's AutoCorrect.ahk ( http://www.autohotke...AutoCorrect.ahk ). That script won't work properly when I use it simultaneously with this code. Anybody have a solution?

Claes
  • Guests
  • Last active:
  • Joined: --
I run in to a strange problem...

I tried the script and when I press "f" and get "g" when I expect "u". The circle reference is f::u u::g. What can I do to fix this?

Jag02
  • Members
  • 44 posts
  • Last active: Feb 15 2010 08:46 AM
  • Joined: 16 Apr 2008
Can this script be shortened?

infogulch
  • Moderators
  • 717 posts
  • Last active: Jul 31 2014 08:27 PM
  • Joined: 27 Mar 2008
You don't have to Add the keyboard layout every time, just switch it. In fact, I have a couple hotkeys to switch it between English and dvorak. Just go to "Text services and input languages" (See *), "[Button]Key Settings..." and set up some hotkeys to switch between the two layouts. (All within windows, btw) I have Windows use !+1 for regular layout, and !+2 for the dvorak, so if you have issues with other people using it, hit the hotkey to change it to dvorak, and when you're done, hit the hotkey to change it back.


*That's under "Control Panel>Reigonal and Language options>[Tab]Languages>[Button]Details". If you didn't have the new layout installed already, continue: "[Button]Add...>[CheckBox]Keyboard Layout". Then select the layout you want.

:D

TheChaosMachine
  • Guests
  • Last active:
  • Joined: --
Hello,
This macro is awesome. It works exactly how I want it to, and is completely transparent.

There is 1 minor issue: I alt+tab very quickly. When I do so, the window that comes up which shows the icons of all running programs stays up. I found that if I hold ALT for about 1 second before hitting Tab, this problem does not happen.

I looked into the SetKeyDelay function, but at the -1 value it's set for already it is supposed to have 0 delay. Obviously there is a delay, and I can't figure out how to fix this. Does anyone know how to solve that issue?

Thanks!

TheChaosMachine
  • Guests
  • Last active:
  • Joined: --
So I found a workaround. I mapped the following in the script, and it resolved the alt delay:

LAlt & `::AltTab
LAlt & ~::ShiftAltTab

Not sure why this worked, but if anyone else is running into the same problem, I would assume mapping Alt Tab to some other keypress would work the same way in case ` and ~ are used by other things.

arkenflame
  • Members
  • 5 posts
  • Last active: May 29 2008 11:26 PM
  • Joined: 12 Jan 2008
I recently got a Logitech MX Revolution (very nice) and found that SetPoint (the logitech software) interfered with this ahk script. To work around this, I downloaded uberOptions from here http://www.mstar.net/users/rlowens/ and set my mouse buttons to keys F13-F<whatever> in SetPoint and then caught them in autohotkey to do what I wanted them to (like show desktop, aka Win+D).

If anyone else was having problems with this, I hope this helps. I still don't have any suggestions on fixing One-Touch Search though.

Thanks to this thread http://www.autohotke.../topic7695.html for the idea.