Ctrl + Z & Ctrl + Y in German and Russian layouts become a mess after a reboot

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
scharyu
Posts: 9
Joined: 20 Oct 2021, 07:14

Ctrl + Z & Ctrl + Y in German and Russian layouts become a mess after a reboot

Post by scharyu » 20 Oct 2021, 07:28

I often use two layouts: Russian and German. When I use Russian layout, the Undo shortcut is Ctrl + Z (relatively to English layout), and Redo is Ctrl + Y. But German layout switches Z and Y, so it´s QWERTZ, not QWERTY. Hence in German layout shortcuts Undo and Redo are the same, but since Z and Y switched their places, using these shortcuts is very uncomfortable.

Relatively to English layout:
* in Russian Undo is Ctrl + Z, Redo is Ctrl + Y;
* in German Undo is Ctrl + Y, Redo is Ctrl + Z.

I hope you understood my problem.

But there is a solution. A guy with absolutely the same problem found it here.

His script looks like this:

Code: Select all

; Undo Ctrl-Z
^sc02C::
    Send, ^{sc015}
Return

; Redo Ctrl-Y
^sc015::
    Send, ^{sc02C}
Return
And actually it works: relatively to English Undo is Ctrl + Z and Redo is Ctrl + Y both in Russian and German, that is regardless to the chosen layout.

But there is another problem. I put this script in Autostart so the script automatically launches when I boot my PC. But after a reboot or shutdown it becomes a mess. Now relatively to English the Undo shortcut both in Russian and German is Ctrl + Y and Redo is Ctrl + Z. But after a manual restart of the script from the tray it starts working as it should: relatively to English Undo is Ctrl + Z and Redo is Ctrl + Y both in Russian in German.

First of all I thought that this is because of the layout. So technically I use Russian and English languages, but English keyboard set to German layout since my laptop has German layout (RU - RU and EN - DE). I changed it to real German keyboard (RU - RU and DE - DE), but it didn´t help.

Also I tried to create a script which I put in Autostart and which should reload this script after 5 secs. So technically I tried to automatically reload a script after 5 secs after a startup.

Code: Select all

sleep 5000
Reload, ctrlz.ahk
ExitApp
I´m not sure that I did it correct. So, the script indeed restarts ctrlz.ahk, but... it restarts it every 5 secs, so it starts an infinite loop of reloads. I put ExitApp because as I understood it terminates the script, but it doesn´t. Again, I´m pretty sure that I did it wrong, but that´s how I understood it.

My question is, why the script starts working in another direction after a reboot, but after a manual restart it stars working in right direction? What are the possible solutions?

P.S. Sorry, I´m very new to AHK. I surfed the Internet a lot, but still can´t understand what´s wrong and even why my workaround with reload script works not as I expect.

User avatar
mikeyww
Posts: 26856
Joined: 09 Sep 2014, 18:38

Re: Ctrl + Z & Ctrl + Y in German and Russian layouts become a mess after a reboot

Post by mikeyww » 20 Oct 2021, 07:51

Click the word "Reload" in your posted script. As noted there, this command takes no parameters.

Reload:
Replaces the currently running instance of the script with a new one.
In other words, Reload does not load a different script; it reloads the same script.

You could try running a new script that waits 30 seconds and then uses Run to run your main script.

garry
Posts: 3758
Joined: 22 Dec 2013, 12:50

Re: Ctrl + Z & Ctrl + Y in German and Russian layouts become a mess after a reboot

Post by garry » 20 Oct 2021, 10:21

in autostart-folder , script should begin with :

Code: Select all

SetWorkingDir , %A_ScriptDir%   ;- Ensures a consistent starting directory.

scharyu
Posts: 9
Joined: 20 Oct 2021, 07:14

Re: Ctrl + Z & Ctrl + Y in German and Russian layouts become a mess after a reboot

Post by scharyu » 21 Oct 2021, 10:20

mikeyww wrote:
20 Oct 2021, 07:51
Click the word "Reload" in your posted script. As noted there, this command takes no parameters.

Reload:
Replaces the currently running instance of the script with a new one.
In other words, Reload does not load a different script; it reloads the same script.

You could try running a new script that waits 30 seconds and then uses Run to run your main script.
Well, can I put Reload in ctrlzde.ahk (script which unify Undo and Redo for both layouts), but make it activate only once? Like, the script launches from Windows Autostart, then waits, let´s say, 5 secs and then reloads itself. And that´s it. Without infinite loop of reloads.

scharyu
Posts: 9
Joined: 20 Oct 2021, 07:14

Re: Ctrl + Z & Ctrl + Y in German and Russian layouts become a mess after a reboot

Post by scharyu » 21 Oct 2021, 10:23

garry wrote:
20 Oct 2021, 10:21
in autostart-folder , script should begin with :

Code: Select all

SetWorkingDir , %A_ScriptDir%   ;- Ensures a consistent starting directory.
I´m sorry but I did´t quite understand what you mean. Why should I put it in the script if it´s located not in the Autostart folder? In Autostart folder locates a shortcut which leads to the script.

User avatar
mikeyww
Posts: 26856
Joined: 09 Sep 2014, 18:38

Re: Ctrl + Z & Ctrl + Y in German and Russian layouts become a mess after a reboot

Post by mikeyww » 21 Oct 2021, 10:29

Code: Select all

If !Instr(DllCall("GetCommandLine", "str"), "/restart") {
 SoundBeep, 1500
 Sleep, 5000
 Run, %A_AhkPath% /restart "%A_ScriptFullPath%"
 ExitApp
}
MsgBox, 64, Success, Ready!
Does this help? Why not just suspend the script for five seconds instead, or something to that effect?

Code: Select all

Suspend, On
Sleep, 5000
Suspend, Off
Gosub, F3
F3::MsgBox, Ready!

Post Reply

Return to “Ask for Help (v1)”