AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

AX : Full application for accents - here is the source

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Peter Fox



Joined: 12 Sep 2008
Posts: 2
Location: Essex, England

PostPosted: Fri Sep 12, 2008 7:31 pm    Post subject: AX : Full application for accents - here is the source Reply with quote

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
Code:

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 ...
Code:

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
Code:

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.

Code:

; 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.
Code:

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.
Back to top
View user's profile Send private message Send e-mail
Guest






PostPosted: Fri Sep 12, 2008 8:01 pm    Post subject: Re: AX : Full application for accents - here is the source Reply with quote

Peter Fox wrote:
Code:

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.
Back to top
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Fri Sep 12, 2008 11:08 pm    Post subject: Reply with quote

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.).
Back to top
View user's profile Send private message
Guest






PostPosted: Sat Sep 13, 2008 4:52 am    Post subject: Reply with quote

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

http://www.autohotkey.com/forum/topic33313.html
Back to top
Peter Fox



Joined: 12 Sep 2008
Posts: 2
Location: Essex, England

PostPosted: Sat Nov 01, 2008 8:53 am    Post subject: Re: AX : Full application for accents - here is the source Reply with quote

Anonymous wrote:

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.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group