Search code examples
autohotkey

Umlaut script does work on my device but not on a friends


I'm running into a problem with an AutoHotkey script I made for myself to type German texts on my english keyboard. As it works great for me, I wanted to share it with a friend, but strangely when I try to run it on a friends PC it does result in strange outputs:

Ä -> Ä  
ä -> ä  
Ö -> Ö  
ö -> ö  
Ü -> Ãœ  
ü -> ü  
ß -> ß

The ~ does not work at all and the ° is the only working hotkey.

Here is the script:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.\
!+A::
Send, Ä
return
!a::
Send, ä
return
!+O::
Send, Ö
return
!o::
Send, ö
return
!+U::
Send, Ü
return
!u::
Send, ü
return
!s::
Send, ß
return
!e::
Send, €
return
!m::
Send, µ
return
!d::
Send, °
return
!]::
Send, {Alt down}{Numpad1}{Numpad2}{Numpad6}{Alt up}
return
^!#right::
Run C:\Users\cmcdi\Documents\Shortcuts\display64.exe /rotate:90
return

If you need any more information, I'll be happy to provide them.


Solution

  • It's likely an encoding issue as people in the comments have noted, however you may also experience some unexpected behavior with Send when normally sending characters that don't exists in the current keyboard layout.
    A good way to get around this, and to not have to worry about any encoding issues, is to specify these special characters with the Unicode character notation.

    Also, since you have one-liner hotkeys, you can omit Returns and do it like this:

    !+A::SendInput, {U+00C4}
    !a::SendInput, {U+00E4}
    !+O::SendInput, {U+00D6}
    !o::SendInput, {U+00F6}
    

    To get the Unicodes for characters, you can use e.g. this website.
    I'm also using SendInput instead of Send, since it's just good practice to do so. Even though it makes no difference here whatsoever (as described in my above link about the Unicode character notation).

    And also, your script seems include the autogenerated ahk code at the top, which specifies SendMode, Input, which means all instances of Send are automatically converted to SendInput.
    All of the autogenerated code at the top can be removed if you want a nice lightweight script. None of the stuff in there is doing anything for you.