Ctrl+Alt shortcut activates AltGr?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
boardtc
Posts: 48
Joined: 12 Feb 2016, 10:13
Contact:

Ctrl+Alt shortcut activates AltGr?

Post by boardtc » 22 Jul 2021, 09:46

Apologies if this is a FAQ, it feels like one,but I could not find an answer.

In my .ahk I have a shortcut setup for Ctrl+ALt+a:

^!a::SEND my text

However, when I press AltGr+a to get á it activates the same shortcut.

Why is this? How can I stop it happening?
User avatar
mikeyww
Posts: 27140
Joined: 09 Sep 2014, 18:38

Re: Ctrl+Alt shortcut activates AltGr?

Post by mikeyww » 22 Jul 2021, 09:59

Code: Select all

<^>!a::Send á
^!a::Send my text
You can't use the left Ctrl and right Alt for your "my text", because that's what AltGr is, but you could change what sends your other text, and you can change what AltGr does.
Last edited by mikeyww on 22 Jul 2021, 10:04, edited 1 time in total.
User avatar
boardtc
Posts: 48
Joined: 12 Feb 2016, 10:13
Contact:

Re: Ctrl+Alt shortcut activates AltGr?

Post by boardtc » 22 Jul 2021, 10:02

Really. I had no idea. Every day is a school day.
User avatar
boardtc
Posts: 48
Joined: 12 Feb 2016, 10:13
Contact:

Re: Ctrl+Alt shortcut activates AltGr?

Post by boardtc » 22 Jul 2021, 10:04

My main shortcuts are F10 based but I had run out, it would not allow me to do Ctrl+F10+a for some reason so I tried that
User avatar
mikeyww
Posts: 27140
Joined: 09 Sep 2014, 18:38

Re: Ctrl+Alt shortcut activates AltGr?

Post by mikeyww » 22 Jul 2021, 10:15

Here you can type the A shortly after releasing Ctrl+F10.

Code: Select all

str := {a: "my text", b: "your text"}
$^F10::
Input, key, L1T.6
SendInput % str.HasKey(key) ? "{Text}" str[key] : "^{F10}"
Return
User avatar
boardtc
Posts: 48
Joined: 12 Feb 2016, 10:13
Contact:

Re: Ctrl+Alt shortcut activates AltGr?

Post by boardtc » 22 Jul 2021, 10:32

interesting. How do I use that? It looks like a method. I tried including the body and also the the function name is it (CODE: SELECT ALL - TOGGLE LINE NUMBERS)
User avatar
mikeyww
Posts: 27140
Joined: 09 Sep 2014, 18:38

Re: Ctrl+Alt shortcut activates AltGr?

Post by mikeyww » 22 Jul 2021, 10:49

Paste the text into a new file called "test.ahk". Omit the "CODE" line; that is just part of the online forum itself. Run the script. See the green "H" icon in the Windows system tray. Open & activate Notepad. Press Ctrl+F10 followed by A within 0.6 seconds.

Alternative script:

Code: Select all

:CT:fa::my text
You run this script. In notepad, type F A Space. Use lower-case letters here.
User avatar
boardtc
Posts: 48
Joined: 12 Feb 2016, 10:13
Contact:

Re: Ctrl+Alt shortcut activates AltGr?

Post by boardtc » 22 Jul 2021, 11:13

The alternative script is interesting and works for me. Sticking with my long used F10 shortcuts, the first thing I tried was copying the five lines into my single script file, minus the "header". The return threw me which is why I posted about a function. Including the 4 lines or the 5 lines with the return in my script do not work for me....in notepad it does highlight File for some reason
User avatar
mikeyww
Posts: 27140
Joined: 09 Sep 2014, 18:38

Re: Ctrl+Alt shortcut activates AltGr?

Post by mikeyww » 22 Jul 2021, 12:01

The Ctrl+F10 is sent-- highlighting "File"-- if you do not press A within 0.6 seconds. In any case, if you have a bunch of different text strings to send, then using hotstrings is simple and convenient. It also prevents you from having to memorize various hotkeys, as long as you know the hotstring triggers, which are often easier to remember.
User avatar
boardtc
Posts: 48
Joined: 12 Feb 2016, 10:13
Contact:

Re: Ctrl+Alt shortcut activates AltGr?

Post by boardtc » 22 Jul 2021, 12:13

I'm not following you re the text snippets being easier. I have used F10+e for email address for 10+ years, similarly for a bunch of others, easy to remember. I want to add a control as I need to double up on one letter. the a is not recognised after the ctrl+f10 for me, unfortunately.
User avatar
mikeyww
Posts: 27140
Joined: 09 Sep 2014, 18:38

Re: Ctrl+Alt shortcut activates AltGr?

Post by mikeyww » 22 Jul 2021, 12:18

So you tested my script with no other code in it, and no other scripts running at the same time? You can increase the timeout (T.6) to something like T1 or T2.
User avatar
boardtc
Posts: 48
Joined: 12 Feb 2016, 10:13
Contact:

Re: Ctrl+Alt shortcut activates AltGr?

Post by boardtc » 22 Jul 2021, 14:20

No, I have my own ahk file, I want to include your script in it, surely that's possible? I don't know how to have 2 .ahk files, do I need to have?
User avatar
mikeyww
Posts: 27140
Joined: 09 Sep 2014, 18:38

Re: Ctrl+Alt shortcut activates AltGr?

Post by mikeyww » 22 Jul 2021, 14:22

One script is fine. Since I cannot see what you are doing with the other script, I cannot advise you much, but you will need the str array definition at the top of the script.
User avatar
boardtc
Posts: 48
Joined: 12 Feb 2016, 10:13
Contact:

Re: Ctrl+Alt shortcut activates AltGr?

Post by boardtc » 22 Jul 2021, 14:53

I have your script posted verbatim in lines 48-52 of my script...unsure why I would need to move str to line #1?
braunbaer
Posts: 478
Joined: 22 Feb 2016, 10:49

Re: Ctrl+Alt shortcut activates AltGr?

Post by braunbaer » 22 Jul 2021, 15:17

Because the variable str must be initialized for the hotkey to work correctly.
But you could also move the line below the line $^F10::, then the initialization of str is executed everytime the hotkey is triggered, if you don't wnat to move the line to the top of the script.
User avatar
mikeyww
Posts: 27140
Joined: 09 Sep 2014, 18:38

Re: Ctrl+Alt shortcut activates AltGr?

Post by mikeyww » 22 Jul 2021, 15:35

Explained: Auto-execute
User avatar
boardtc
Posts: 48
Joined: 12 Feb 2016, 10:13
Contact:

Re: Ctrl+Alt shortcut activates AltGr?

Post by boardtc » 22 Jul 2021, 17:12

Moving str definition below means it all works now :-) Thanks!
Does the return match the $ ?
User avatar
mikeyww
Posts: 27140
Joined: 09 Sep 2014, 18:38

Re: Ctrl+Alt shortcut activates AltGr?

Post by mikeyww » 22 Jul 2021, 17:28

Return ends the hotkey routine.

Explained: Return
User avatar
boardtc
Posts: 48
Joined: 12 Feb 2016, 10:13
Contact:

Re: Ctrl+Alt shortcut activates AltGr?

Post by boardtc » 23 Jul 2021, 05:02

I get it, thanks so much :-) Totally sorted now.
Post Reply

Return to “Ask for Help (v1)”