Fix physical location of Undo (Ctrl-Z) and Redo (Ctrl-Y) shortcuts between German and Russian keyboard layouts in Windows

You may simply create your own keyboard layout using Microsoft Keyboard Layout Creator 1.4 from Official Microsoft Download Center.

Youtube provides a plenty of video tutorials how to use it (like this with Russian locale) - just search for its name. But basically, you clone one of existing keyboard layouts and modify it according to your needs.

AutoHotKey solution:

(note: replace 0x4090409 constant (US keyboard) with value which applies to your layout)

$^z::
    hWnd := WinExist("A")
    ThreadID := DllCall("GetWindowThreadProcessId", "UInt", hWnd, "UInt", 0)
    hKL := DllCall("GetKeyboardLayout", "UInt", ThreadID, "UInt")
    If (hKL = 0x4090409)
        Send ^z
    Else
        Send ^y
Return

$^y::
    hWnd := WinExist("A")
    ThreadID := DllCall("GetWindowThreadProcessId", "UInt", hWnd, "UInt", 0)
    hKL := DllCall("GetKeyboardLayout", "UInt", ThreadID, "UInt")
    If (hKL = 0x4090409)
        Send ^y
    Else
        Send ^z
Return

Hook ($) is needed to avoid recursion, i.e. Send ^z or Send ^y invoking just another AHK macro.

I tested that keyboard detection condition, it worked nicely.

Of course, you can place keyboard detection into function and therefore optimize the code etc. I was lazy to do that. :)