I'm switching between Swedish and Colemak, with additional keyboard shortcuts for disable and reload (if I've edited the script).
In addition, I have a layer for programming keys and another transpose layer for arrow keys. If you don't need those layers the autohotkey code is even easier.
Here's my script. You'd probably need to know how to code to make use of it.
#SingleInstance force
#HotKeyInterval 2000
#MaxHotkeysPerInterval 200
#NoEnv
SendMode input
SetTitleMatchMode RegEx
altgrcount := 0
transposed := 0
transposed_occured := 0
suspended := 0
english := 1
menu_swedish = &Swedish (Alt+F6)
menu_suspend = &Suspend (Alt+F7)
menu_reload = &Reload (Alt+F8)
Menu Tray, Add, %menu_swedish%, k_Swedish
Menu Tray, Add, %menu_suspend%, k_MenuSuspend
Menu Tray, Add, %menu_reload%, k_MenuReload
Menu Tray, Add, &Exit, k_MenuExit
Menu Tray, Icon, on.ico
;Menu Tray, NoStandard
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Map(normal, shifted, altgr, transpose, is_letter)
{
global altgrcount
global transposed
global transposed_occured
if altgrcount
sendinput {blind}%altgr%
else if transposed
{
transposed_occured := 1
sendinput {blind}%transpose%
}
else if getkeystate("Shift")
if is_letter
sendinput {blind}%shifted%
else
sendinput %shifted%
else if (caps_sensitive and getkeystate("Capslock", "T"))
sendinput {blind}%shifted%
else
sendinput {blind}%normal%
}
MapLetter(normal, altgr, transpose)
{
Map(normal, normal, altgr, transpose, true)
}
MapChar(normal, shifted, altgr, transpose)
{
Map(normal, shifted, altgr, transpose, false)
}
MapLang(engnorm, engshift, swenorm, sweshift, altgr, transpose, is_letter)
{
global english
if english
Map(engnorm, engshift, altgr, transpose, is_letter)
else
Map(swenorm, sweshift, altgr, transpose, true)
}
IncAltGr()
{
global altgrcount
altgrcount := altgrcount + 1
}
DecAltGr()
{
global altgrcount
altgrcount := altgrcount - 1
}
SetTransposed(val)
{
global transposed
transposed := val
}
$*q::MapLetter("q", "", "") ; Q
$*w::MapLetter("w", "$", "") ; W
$*e::MapLetter("f", "{{}", "") ; E
$*r::MapLetter("p", "{}}", "") ; R
$*t::MapLetter("g", "\", "") ; T
$*a::MapLetter("a", "@", "") ; A
$*s::MapLetter("r", "*", "") ; S
$*d::MapLetter("s", ":", "") ; D
$*f::MapLetter("t", "/", "") ; F
$*g::MapLetter("d", """", "") ; G
$*x::MapLetter("x", "~", "") ; X
$*c::MapLetter("c", "|", "") ; C
$*v::MapLetter("v", "&", "") ; V
$*b::MapLetter("b", "{#}", "") ; B
$*y::MapLetter("j", "1", "") ; Y
$*u::MapLetter("l", "{+}", "") ; U
$*i::MapLetter("u", "[", "{up}") ; I
$*o::MapLetter("y", "]", "") ; O
$*p::MapLang("z", "z", "ö", "Ö", "", "", true) ; P
$*sc01a::MapLang("[", "{{}", "å", "Å", "", "", false) ; [
$*h::MapLetter("h", "0", "{backspace}") ; H
$*j::MapLetter("n", "=", "{left}") ; J
$*k::MapLetter("e", "(", "{down}") ; K
$*l::MapLetter("i", ")", "{right}") ; L
$*sc027::MapLetter("o", ";", "{return}") ; ;
$*sc028::MapLang("'", """", "ä", "Ä", "{!}", "", false) ; '
$*n::MapLetter("k", "_", "") ; N
$*m::MapLetter("m", "-", "{appskey}") ; M
$*sc033::MapChar(",", "?", "<", "") ; ,
$*sc034::MapChar(".", "{!}", ">", "") ; .
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Map the altgr and an extra shift
; Z key
$sc02c::
IncAltGr()
KeyWait sc02c
DecAltGr()
return
; / key
$sc035::
IncAltGr()
KeyWait sc035
DecAltGr()
return
; \ key
$sc02b::
sendinput {RShift down}
KeyWait sc02b
sendinput {RShift up}
return
; Caps lock key
$*sc03a::
transposed := 1
KeyWait sc03a
transposed := 0
if (not transposed_occured)
ToggleCaps()
transposed_occured := 0
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ToggleCaps()
{
GetKeyState, state, CapsLock, T ; D if CapsLock is ON or U otherwise.
if state = D
SetCapsLockState, off
else
SetCapsLockState, on
}
CapsOff()
{
GetKeyState, state, CapsLock, T ; D if CapsLock is ON or U otherwise.
if state = D
SetCapsLockState, off
}
; Apps, escape -> caps off + escape
$Esc::
AppsKey::
CapsOff()
sendinput {Esc}
return
; App switching (set to work with alt tab replacement)
End::
RAlt::
sendinput #{F12}
return
+End::
sendinput #{F11}
return
; Miscellaneous
Shift & backspace::sendinput ^{backspace}
; App launch
PgUp::sendinput #{space}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Window functions
; Win kill
PgDn::
$#n::
$#w::WinClose, A
; Switch to desktop
$#h::
sendinput {blind}d
return
; Win maximise
$#m::
winget, max, MinMax, A
if max = 1
WinRestore, A
else
WinMaximize, A
return
;$#k::
;run ..\FreeCommander\FreeCommander.exe,,,pid
;WinWait, ahk_pid %pid%
;WinActivate
;return
; End of auto-execute section
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Menu functions
!F6::
k_Swedish:
english := 1 - english
Menu Tray, ToggleCheck, %menu_swedish%
return
!F7::
k_MenuSuspend:
Suspend
if suspended
Menu Tray, Icon, on.ico
else
Menu Tray, Icon, off.ico, 1, 1
suspended := 1 - suspended
Menu Tray, ToggleCheck, %menu_suspend%
return
!F8::
k_MenuReload:
Reload
return
k_MenuExit:
ExitApp
return