AutoHotkey Community

It is currently May 26th, 2012, 4:18 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 36 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: January 12th, 2008, 9:24 pm 
Offline

Joined: January 12th, 2008, 3:47 am
Posts: 5
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:

Code:
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:

Code:
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2008, 9:30 pm 
Offline

Joined: January 19th, 2007, 9:09 pm
Posts: 147
Can ahk run on a mac?
Didn't knew that.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 13th, 2008, 11:20 pm 
Offline

Joined: January 12th, 2008, 3:47 am
Posts: 5
No no no. This is just a script that allows you to do something on Windows you can normally only do on a Mac.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 13th, 2008, 11:24 pm 
Offline

Joined: July 15th, 2007, 1:43 am
Posts: 1320
Alls it does is remap the keys. It does nothing to altar the windows processes.

_________________
Religion is false. >_>


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Thank You!!
PostPosted: January 17th, 2008, 11:39 pm 
Offline

Joined: June 18th, 2006, 8:47 am
Posts: 346
Location: Phoenix, AZ
arkenflame, Thank You so much! I couldn't figure out how to do this. I will be practicing Dvorak again.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: January 25th, 2008, 7:29 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2008, 4:40 am 
Offline

Joined: January 12th, 2008, 3:47 am
Posts: 5
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2008, 12:09 pm 
Offline

Joined: February 19th, 2008, 12:06 pm
Posts: 2
Location: Melbourne, Victoria, Australia
What an excelent idea. I was just starting to do the same thing, but it looks like you beat me to it ;)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 19th, 2008, 5:30 am 
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.autohotkey.com/download/AutoCorrect.ahk ). That script won't work properly when I use it simultaneously with this code. Anybody have a solution?


Report this post
Top
  
Reply with quote  
PostPosted: May 8th, 2008, 12:10 pm 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 11th, 2008, 8:53 pm 
Offline

Joined: April 16th, 2008, 7:55 am
Posts: 43
Can this script be shortened?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 12th, 2008, 8:32 pm 
Offline

Joined: March 27th, 2008, 2:14 pm
Posts: 700
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

_________________
Scripts - License


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Alt+Tab window stays up
PostPosted: May 20th, 2008, 8:04 pm 
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!


Report this post
Top
  
Reply with quote  
 Post subject: Worked around
PostPosted: May 20th, 2008, 9:41 pm 
So I found a workaround. I mapped the following in the script, and it resolved the alt delay:

[code]
LAlt & `::AltTab
LAlt & ~::ShiftAltTab
[/code]

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.


Report this post
Top
  
Reply with quote  
PostPosted: May 30th, 2008, 12:12 am 
Offline

Joined: January 12th, 2008, 3:47 am
Posts: 5
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.autohotkey.com/forum/topic7695.html for the idea.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 36 posts ]  Go to page 1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 12 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group