I wan to emulate linux keyboard input

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
NewtSoup
Posts: 3
Joined: 18 Apr 2021, 20:08

I wan to emulate linux keyboard input

18 Apr 2021, 20:51

Hi there,

I'm primarily a linux user and new to AHK scripting.

Being bilingual I frequently use accented characters á, é, í, ó, ú, for example which are easy enough in Windows simply by using <AltGr>+<key> but I need other accents too such as the cedilla, accent grave and ^

In linux I am used to using

<AltGr>+; followed by the letter to produce á etc
<AltGr>+' followed by letter to produce â and
<AltGr>+# followed by letter to produce à

I'd like to ( if possible ) use AHK to emulate at least these three and ideally other symbols too so that my Windows Keyboard layout largely mirrors the Linux one. I tried the windows keyboard layout creator but found it entirely unhelpful as it's not ( tired dyslexic brain can't remember the word for when something is natural to use ) and I don't want to have to define an entire layout from the ground up anyway. Just partly override my current one.

I found a script here that claims to do what I need but uses different triggers. I want to use my triggers ; ' and # respectively for consistency with Linux ( English International )

https://www.autohotkey.com/boards/viewtopic.php?f=6&t=82484&hilit=accents
I can't make this script work the way I want it to though

Can anyone school me in what's going on?

Thanks

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

Re: I wan to emulate linux keyboard input

19 Apr 2021, 04:54

It's hard to say what's going on without seeing your script, but the following may work.

Code: Select all

<^>!;::á
<^>!'::â
<^>!LWin::à
Explained: AltGr
NewtSoup
Posts: 3
Joined: 18 Apr 2021, 20:08

Re: I wan to emulate linux keyboard input

19 Apr 2021, 05:36

mikeyww wrote:
19 Apr 2021, 04:54
It's hard to say what's going on without seeing your script, but the following may work.

Code: Select all

<^>!;::á
<^>!'::â
<^>!LWin::à
Explained: AltGr
That's not exactly what I'm looking for. The script I'm trying to modify is linked in the first post. What I want to do is:

press AltGr and ; together and THEN press any of the vowels aeiou and have them come out on the screen as áéíóú respectively

I have tried to modify the linked script but all it does is print the accented characters without requiring the trigger. My modified script is this:

Code: Select all

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


global Trigger:=0

<^>!;::Trigger :=1

if (Trigger = 1 )
{
	:C*?:a::
		SendInput {U+00E1} ; á
		Trigger := 0
		return
	
	:C*?:A::	
		SendInput {U+00C1} ; Á
		Trigger := 0
		return
	
	:C*?:e::
		SendInput {U+00E9} ; é
		Trigger := 0
		return

	:C*?:E::
		SendInput {U+00C9} ; É
		Trigger := 0
		return

	:C*?:i::
		SendInput {U+00ED} ; í
		Trigger := 0
		return

	:C*?:I::
		SendInput {U+00CD} ; Í
		Trigger := 0
		return
	
	:C*?:o::
		SendInput {U+00F3} ; ó
		Trigger := 0
		return
	
	:C*?:O::
		SendInput {U+00D3} ; Ó
		Trigger := 0
		return
	
	:C*?:u::
		SendInput {U+00FA} ; ú
		Trigger := 0
		return
	
	:C*?:U::
		SendInput {U+00DA} ; Ú
		Trigger := 0
		return
	
	:C*?:c::
		SendInput {U+00E7} ; ç
		Trigger := 0
		return
	
	:C*?:C::
		SendInput {U+00C7} ; Ç
		Trigger := 0
		return
	
	:C*?:n::
		SendInput {U+00F1} ; ñ
		Trigger := 0
		return
	
	:C*?:N::
		SendInput {U+00D1} ; Ñ
		Trigger := 0
		return
	
	:*?:!::
		SendInput {U+00A1} ; ¡
		Trigger := 0
		return
	
	:*?:?::
		SendInput {U+00BF} ; ¿
		Trigger := 0
		return

	Trigger := 0 ;; should but doesn't reset it for any other character
}
I don't fully understand the code so yet so I have little to no chance of modifying it to my needs.
User avatar
mikeyww
Posts: 26951
Joined: 09 Sep 2014, 18:38

Re: I wan to emulate linux keyboard input

19 Apr 2021, 06:13

Code: Select all

<^>!;::accent(1)
<^>!'::accent(2)

accent(set) {
 Static acc := [{a: "á", e: "é", i: "í", o: "ó", u: "ú"}, {a: "b", e: "c"}]
 SoundBeep, 1500
 Input, key, L1T1
 If (ErrorLevel = "Timeout" && key = "")
  SoundBeep, 1000
 Else Send % acc[set].HasKey(key) ? acc[set][key] : key
}
NewtSoup
Posts: 3
Joined: 18 Apr 2021, 20:08

Re: I wan to emulate linux keyboard input

19 Apr 2021, 06:22

Ooh shiny! Thank you

I think I understand the second one better

Code: Select all

acc1 := {a: "á", e: "é", i: "í", o: "ó", u: "ú"}
<^>!;::
SoundBeep, 1500
Input, key, L1
Send % acc1[key]
Return
I will have a go adding extra triggers for other characters and see what I can come up with.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: metallizer and 129 guests