AltGr up and down status

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Sov3rain
Posts: 3
Joined: 01 May 2020, 07:04

AltGr up and down status

01 May 2020, 07:14

Hi there,

I'm a owner of a 60% keyboard, and such missing the arrow keys. I'm French and I use an AZERTY layout, with an AltGr key in place of the RAlt one. I would like to remap the bottom right keys a such :

RShift : Up
RCtrl : Right
RAlt (AltGr) : Left
RWin : Down

Here is the script:

Code: Select all

#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.

#InstallKeybdHook
#UseHook On

LControl & RAlt::Send {LEFT} ; AltGr
RWin::Send {DOWN}
RControl::Send {RIGHT}
RShift Up::Send {UP}
I managed to do so and everything is working. Now here is the problem: as I need to access some things with the AltGr key (accents, special characters), I can't just remap the key like this. What I need to do is this I imagine:

RAlt Up : Left
RAlt Down (hold) : AltGR

I found a block of code that do pretty much that for RShift, but i've been unable to do the same thing for AltGr:

Code: Select all

RShift Up::
    If (A_PriorKey = "RShift") ;  If RShift was pressed alone
   	 Send, {Up} ; up arrow
return
>+Del:: Send {Shift Down}{Del}{Shift Up} ; >+ means RShift
I tried this:

Code: Select all

AltGr Up::
	If (B_PriorKey = "AltGr")
	 Send, {Left}
return
<^>!Del:: Send {AltGr Down}{Del}{AltGr Up}
but I get this error:
Error at line 25

Line text: AltGr Up::
Error: Invalid Hotkey

The script was not reloaded, the old version will remain in effect

Can someone help me with that? Thanks!
GEV
Posts: 844
Joined: 25 Feb 2014, 00:50

Re: AltGr up and down status

01 May 2020, 10:06

Try

Code: Select all

; AltGR down
LControl & RAlt:: AltGR := true

; AltGR up
LControl & RAlt Up::
	AltGR := false
	; If (A_PriorHotkey = "LControl & RAlt") ;  or:
	If (A_PriorKey = "RAlt")  ;  AltGR was pressed alone
		Send, {Left}
return

; AltGR + key
#If (AltGR)

	; AltGR+Del
	Del::a
	
	; AltGR+a
	a::b
	
	; ...

#If
Rohwedder
Posts: 3269
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: AltGr up and down status

01 May 2020, 10:10

Or:

Code: Select all

RWin::DOWN
RControl::RIGHT
RShift::UP
LControl & ~RAlt::Return
LControl & RAlt Up::
IF A_PriorKey = Ralt
	Send, {Left}
Return
User avatar
Sov3rain
Posts: 3
Joined: 01 May 2020, 07:04

Re: AltGr up and down status

01 May 2020, 13:14

Rohwedder wrote: Or:

Code: Select all

RWin::DOWN
RControl::RIGHT
RShift::UP
LControl & ~RAlt::Return
LControl & RAlt Up::
IF A_PriorKey = Ralt
	Send, {Left}
Return
That works well, thank you! I even change the Shift behaviour to do the same thing!
I might ask too much here, but the shortcut "Ctrl+Shift+Arrow left or right" to select word by word is not working anymore. Is there a way to make it work with this?

Thanks again guys!
Rohwedder
Posts: 3269
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: AltGr up and down status

01 May 2020, 14:05

At least the "right version" works here.
But the "left version" with AltGr? I see no possibility!

Code: Select all

RWin::DOWN
RControl::Send, {RIGHT}
+RControl::
<^RControl::
<^+RControl::
Send, {Blind}{RIGHT}
Return
RShift::UP
LControl & ~RAlt::Return
LControl & RAlt Up::
IF A_PriorKey = Ralt
	Send, {Left}
Return
User avatar
Sov3rain
Posts: 3
Joined: 01 May 2020, 07:04

Re: AltGr up and down status

02 May 2020, 06:52

Rohwedder wrote: At least the "right version" works here.
But the "left version" with AltGr? I see no possibility!
I guess it's the limitations of this kind of layouts. Nevertheless, thank you very much for your help!

Return to “Ask For Help”

Who is online

Users browsing this forum: Epialis, frankr, Google [Bot], imNotTupid, ReCordLe, Sabestian Caine, Smile_ and 40 guests