Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

AX : Full application for accents - here is the source


  • Please log in to reply
4 replies to this topic
Peter Fox
  • Members
  • 5 posts
  • Last active: Mar 09 2011 07:34 PM
  • Joined: 12 Sep 2008
This application uses a single key to do all/any accents and symbols in an easy to configure way for 11 European languages (selectable). The source code is posted here in case more experienced ahk-ers have suggestions for improvement.

The whole thing, compiled, with instructions, read-me, and detailed configuration is at http://vulpeculox.net/ax

Method
Hotkey causes the character before the cursor to be cut into the clipboard
DoTheDirtyDeed:
ClipboardSave := clipboard      ; save for later
clipboard := ""
; Cut out the last character, ie the one before the caret.
Send, +{Left}^c     
ClipWait, 0.1
if ErrorLevel
{ 
  Char := "INVALID"  
} else {
  Char := clipboard  
}
clipboard := ClipboardSave      ; restore the original
... followed by looking up the character in a cyclic string of characters such as for example for Spanish ...
aáa AÁA eée EÉE ií¡i IÍI oóo OÓO uúüu UÚÜU ?¿? nñn NÑN
then returning the next character
CharPosn := InStr(TransformArray,Char,true)
if CharPosn > 0
{ 
  CharPosn++
  C_NewChar  := SubStr(TransformArray,CharPosn,1)
  Send %C_NewChar%
} else {
  Send {Right}#
}
return

Setup code
This comes before the active code The complete code in the correct order full of more comments is contained in the download package referred to above.

; Only one instance required
#SingleInstance force
#NoEnv


; -----------------------------------------
; Read configuration file
; -----------------------------------------
Loop, read, AX.cfg
{
  NextLine = %A_LoopReadLine%
  LineLength := StrLen(NextLine)  
  if LineLength > 0
  {  
    SemiColonPos := InStr(NextLine,";")
    if SemiColonPos <> 1 
    {
      StringSplit, KV,NextLine,"="
      ; we now have K in KV1 and V in KV2
      Name = %KV1%
      %Name% = %KV2%
      Value := %Name%
      ;MsgBox, (%Name%) : %Value%
    }
  }
}


; -----------------------------------------
; If command line parameters are given then
; use them to select the transformation sets
; -----------------------------------------
if 0 > 0 ; do we have any parameters?
{
  SETS = 
  Loop, %0%
  {
    Param := %A_Index%
    SETS = %SETS%,%Param%
  }
}

; -----------------------------------------
; Combine the selected sets into a single array
; -----------------------------------------
TransformArray :=  ""
Loop, parse, SETS, `,
{
  Param := A_LoopField
  Cycle := %Param%
  DisplayList = %DisplayList%•  %Param% : %Cycle% `r
  TransformArray = %TransformArray% %Cycle%
}
StringReplace, TransformArray, TransformArray, %A_SPACE%, , All




; -----------------------------------------
; Tell the user we are loaded
; -----------------------------------------
StringReplace, msg, HOWTO, *KEY*, %KEY%, All
msg = %msg%<BR><BR>%INFO%<BR>%DisplayList%<BR><BR>%MOREINFO% %WebSite%<BR><BR>Program %Version%
StringReplace, msg, msg, <BR>, `r, All
MsgBox , 0, AX Character cycling,  %msg%, %SPLASHDELAY%


; -----------------------------------------
; Set up the appropriate hot key
; -----------------------------------------
HotKey, %KEY%, DoTheDirtyDeed, On


exit

Now all the above seems to work (it was a bit of a struggle at times getting % signs in the right places) but more experienced coders may have suggestions for improvements, in which case I'd be pleased to hear about them.


Configuration
Here is an edited version (all the comments, many languages and some parameters stripped out to save space) of the configuration file. The object was to allow configuration without any need to hack the source. It took me ages to get this bit right having tried some dead-ends and some poke-n-hope.
KEY=F8
French=aàâäa AÀÂÄA cçc CÇC eéêèëe EÉÊÈËE iîïi IÎÏI oôo OÔO uûùüu UÛÙÜU
German=BßB aäa AÄA eée EÉE oöo OÖO uüu UÜU
Swedish=aåäa AÅÄA oöo OÖO
Math=2²2 3³3 o°o /÷/ +±+ *×* uµu
Symbol=£€£ $¢$ c©c .•…. <«< >»>
SETS=French,Math,Symbol
SPLASHDELAY=20


Packaging
The compiler is marvellously easy to use, then it was just a matter of sticking the necessary files into a self extracting zip (I used "SFX compiler") and writing a web page.

  • Guests
  • Last active:
  • Joined: --

aáa AÁA eée EÉE ií¡i IÍI oóo OÓO uúüu UÚÜU ?¿? nñn NÑN


I see the last character of every group is the same as the first. Why is that? It seems wasteful.

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
Here is another implementation of the idea. I have been using it for 4 years (with full Unicode support now, auto detection of the capabilities of the current window, editable list of apllications with special treatment, etc.).

  • Guests
  • Last active:
  • Joined: --
Another script which fixes your already typed text (more than one character) if you're a quick typer and forgot to change layouts:

<!-- m -->http://www.autohotke...topic33313.html<!-- m -->

Peter Fox
  • Members
  • 5 posts
  • Last active: Mar 09 2011 07:34 PM
  • Joined: 12 Sep 2008

I see the last character of every group is the same as the first. Why is that? It seems wasteful.


This is needed so that you can cycle back to the start of each group next time when editing. Just suppose you have an accent where all you really wanted was a plain letter.