5

I'm working on a college system (windows XP) and want to set the keyboard to Dvorak when I log on. I currently have a python script that changes the desktop image.

Can I use python to change the layout as well? Or are there other ways?

  • One answer in http://stackoverflow.com/questions/167031/programatically-change-keyboard-to-dvorak that doesn't programmatically change to the Dvorak layout but does remap all the keys -- that might be fine since registry settings will be cleared when you log out, assumably. – Mark Rushakoff Sep 14 '09 at 11:17
  • But how can you use vim with Dvorak? :/ – Corey D Sep 14 '09 at 12:42
  • I actually used vim with Dvorak for a while (back in aught-one). Bit of a mind blower. I got used to it, but I don't necessarily recommend it. – jcdyer Sep 14 '09 at 15:09
  • I didn't learn vim until well after converting to Dvorak, so vim with Dvorak works fine for me. – ℳ  . Sep 18 '09 at 01:38

3 Answers3

3

to Change keyboard layout

import win32api
win32api.LoadKeyboardLayout('00000409',1) # to switch to english
win32api.LoadKeyboardLayout('00000401',1) # to switch to arabic

and for Dvorak :

win32api.LoadKeyboardLayout("00010409",1)

or

win32api.LoadKeyboardLayout("00020409",1)
user2229472
  • 509
  • 3
  • 10
  • Do you have the keyboard layout code for Dvorak or a link to the documentation for `win32api`? – ASGM Apr 04 '13 at 11:33
  • 1
    use this to get your keyboard layout code: win32api.GetKeyboardLayout() – user2229472 Apr 06 '13 at 06:22
  • Thanks; but I don't want to find my own, I want to know whether `loadKeyboardLayout` has a Dvorak option, which is what OP is looking for. – ASGM Apr 06 '13 at 10:39
  • I think the keyboard layout code for Dvorak is ("00010409" or "00020409") – user2229472 Apr 07 '13 at 05:01
  • I don't know - I asked because that was what the OP was asking for. Thanks for adding it to the answer! – ASGM Apr 08 '13 at 08:17
  • This doesn't really change current layout for me. Instead, it just adds new one to current list. – Groosha Apr 03 '16 at 17:13
1

answer can be found at Programmatically change keyboard to Dvorak

Community
  • 1
  • 1
Tzury Bar Yochay
  • 8,798
  • 5
  • 49
  • 73
1

I would use AutoHotKey to change the layout. You could write a script remapping the keys and compile it as an executable file.

For example

q::'
+q::"
w::,
+w::<
e::.
+e::>
r::p

etc.