Page 1 of 1

Modifying Skrommel's Accents script

Posted: 11 Nov 2019, 09:46
by Zatheos
Hi, I'm looking to modify the script linked here: http www.dcmembers.com /skrommel/download/accents/
Accents.ahk
Skrommel's Accents Script
(5.06 KiB) Downloaded 20 times
Currently it triggers if you press the trigger key three times or more, but I want it to trigger instead when you press alt+ the hotkey. e.g. alt + a gives access to the åäâàá characters. I want to keep the repetitions scrolling through the options and the config file (accents.ini) etc. I just want to change the trigger, but I don't understand the source code well enough.
Here the main body of the code:

Code: Select all

#Persistent
#SingleInstance,Force
#NoEnv
SendMode,Input
SetKeyDelay,-1
SetBatchLines,-1

applicationname=Accents
Gosub,INIREAD
; Gosub,TRAYMENU
Loop,Parse,hotkeys,`,
  Hotkey,%A_LoopField%,ACCENT,On
Return


ACCENT:
hotkey:=A_ThisHotkey
Loop,Parse,hotkeys,`,
  Hotkey,%A_LoopField%,ACCENT,Off

StringRight,key,hotkey,1
StringLower,key,key

GetKeyState,caps,CapsLock,T

IfInString,hotkey,+
If caps=D
  caps=U
Else
  caps=D

string=
counter=1
Loop,
{
  ascii:=Asc(key)
  char:=%ascii%%counter%
  string=%string%%char%
  If %ascii%%A_Index%=
    Break
  counter+=1
}
counter=1

If caps=D
  StringUpper,string,string

Loop
{
  If A_Index=3
  {  
    counter=1
    char:=%ascii%%counter%
    If caps=D
      StringUpper,char,char
    Else
      StringLower,char,char
    Send,{BackSpace 2}%char%
  }
  Else
  If A_Index>3
  {
    char:=%ascii%%counter%
    If caps=D
      StringUpper,char,char
    Else
      StringLower,char,char
    Send,{BackSpace %length%}%char%
  }
  Else
  {
    If caps=D
      StringUpper,key,key
    Else
      StringLower,key,key
    Send,%key%
  }

  IfInString,hotkey,+
    Send,{Shift Down}
  Else
    Send,{Shift Up}

  Input,input,T1 L1,{BackSpace}{Left}{Right}{Up}{Down}{Shift},%char%
  If ErrorLevel=Timeout
  {
    ToolTip,
    Break
  }
  IfInString,ErrorLevel,EndKey:
  {
    StringTrimLeft,endkey,ErrorLevel,7
    endkey={%endkey%}
    Send,%endkey%
    ToolTip,
    Break
  }
  If (input<>key)
  {
;    If caps=D
;      StringUpper,input,input
;    Else
;      StringLower,input,input
    Send,%input%
    ToolTip,
    Break
  }

  StringLen,length,char

  StringLeft,char,string,% length
  StringTrimLeft,string,string,% length
  string=%string%%char%
  ToolTip,%string%,% A_CaretX,% A_CaretY-20 ;%counter%`n%key%`n%char%`n%caps%
  counter+=1
  If %ascii%%counter%=
    counter=1
}
Loop,Parse,hotkeys,`,
  Hotkey,%A_LoopField%,ACCENT,On
Return

INIREAD:
IfNotExist,%applicationname%.ini
{
  ini=
(
[Settings]
delay=1

[1]
key=a
1=å
2=ä
3=â
4=à
5=á
6=a

[2]
key=e
1=æ
2=ë
3=ê
4=è
5=é
6=e

[3]
key=i
1=ï
2=î
3=ì
4=í
5=i

[4]
key=o
1=ø
2=ö
3=ô
4=ò
5=ó
6=o

[5]
key=u
1=ü
2=û
3=ù
4=ú
5=u

[6]
key=y
1=ÿ
2=ý
3=y

)
  FileAppend,%ini%,%applicationname%.ini
  ini=
}
hotkeys=
IniRead,delay,%applicationname%.ini,Settings,delay
Loop
{
  section:=A_Index
  IniRead,key,%applicationname%.ini,%section%,key
  If key=ERROR
    Break
  hotkeys=%hotkeys%%key%,+%key%,
  Loop
  {
    ascii:=Asc(key)
    IniRead,%ascii%%A_Index%,%applicationname%.ini,%section%,%A_Index%
    If %ascii%%A_Index%=ERROR
    {
      %ascii%%A_Index%=
      Break
    }
  }
}
StringTrimRight,hotkeys,hotkeys,1
Return


WM_MOUSEMOVE(wParam,lParam)
{
  Global hCurs
  MouseGetPos,,,,ctrl
  If ctrl in Static9,Static13,Static17
    DllCall("SetCursor","UInt",hCurs)
  Return
}
Return

I think I understand some of it but not enough to know where to make the change to the hotkey. Any tips would be hugely appreciated.