problem with Fractions at my computer Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
asad41163
Posts: 268
Joined: 29 Jul 2014, 14:31

problem with Fractions at my computer

07 Dec 2019, 16:12

I know this is a special problem, and I shouldn't introduce it here, I apologize for asking for help with that
this code from here: http://www.computoredge.com/AutoHotkey/Downloads/HotstringMenu.ahk

Code: Select all

/*
Hotstring Menu Function HotstringMenu(TextList) and Subroutine HotstringMenuAction:
=============================================
Found at:
http://www.computoredge.com/AutoHotkey/Free_AutoHotkey_Scripts_and_Apps_for_Learning_and_Generating_Ideas.html#HotstringMenu

Originally, discussed the in the book, "Beginning AutoHotkey Hotstrings: 
A Practical Guide for Creative AutoCorrection, Text Expansion and Text Replacement", found at:
https://www.computoredgebooks.com/Beginning-AutoHotkey-Hotstrings-All-File-Formats_c40.htm?sourceCode=AHKScript

The following function and subroutine creates a menu of replacement option when
activating the a Hotstring. Call the function in the form:
:x:flux::TextMenu("Flux | &0,Flux #&1,Flux #&2")
The vertical bar delimiter | allows the addition of descriptive tags and single-key
shortcuts (e.g. &0 for the zero key) which will not appear in the replacement text.

November 22, 2019, Now includes the three-parameter variadic function 
HotstringMenuV(MenuType,Handle,MenuArray*) for using simple and associative
arrays.
*/

; Examples of arrays set up in the auto-execute section:

Fractions := ["⅒","⅑","⅛","⅐","⅙","⅕","¼","⅓","⅜","⅖","½","⅗","⅝","⅔","¾","⅘","⅚","⅞"]
FractionsA := {⅒: "one-tenth",⅑: "one-ninth",⅛: "one-eight",⅐: "one-seventh",⅙: "one-sixth Brk",⅕: "one-fifth",¼: "one-fourth",⅓: "one-third Brk",⅜: "three-eights",⅖: "two-fifths",½: "one-half",⅗: "three-fifths",⅝: "five-eights",⅔: "two-thirds",¾: "three-fourths",⅘: "four-fifths",⅚: "five-sixths",⅞: "seven-eights"}
ArrowsA := {⇐: "Left arrow &1"
          ,⇔: "Double arrow &5",⇒: "Right arrow &3"
          ,⇑: "Up arrow &2",⇓: "Down arrow &4"}

Return

; Original HotstringMenu() function:

HotstringMenu(TextList)
{
  MenuItems := StrSplit(TextList, "`,")
  Loop % MenuItems.MaxIndex()
  {
    Menu, MyMenu, add, % MenuItems[A_Index], HotstringMenuAction
  }
  Menu, MyMenu, Show
  Menu, MyMenu, DeleteAll
}

; Original called menu Label subroutine

HotstringMenuAction:
  InsertText := StrSplit(A_ThisMenuItem, "|")
  TextOut := StrReplace(RTrim(InsertText[1]), "&")
  SendInput {raw}%TextOut%%A_EndChar%
Return

; Variadic function HotstringMenuV(MenuType,Handle,MenuArray*)

HotstringMenuV(MenuType,Handle,MenuArray*)
{
  For Each, Item in MenuArray
    If (MenuType = "A")         ; Add alphabetic single-key menu shortcuts
      Menu, MyMenu, Add, % "&" Chr(Each+96) " " Item, % Handle
    Else If (MenuType = "N")   ; Add numeric single-key menu shortcuts
      Menu, MyMenu, Add, % "&" Each "  " Item, % Handle
    Else If (MenuType = "T")    ; For use with associative arrays
      If (InStr(Item,"Brk"))      ; Add column breaks to long menus
        Menu, MyMenu, Add, % Each " | " StrReplace(Item,"Brk"), % Handle, +BarBreak
      Else
        Menu, MyMenu, Add, % Each " | " Item, % Handle
    Else    ; Default menu item. Use "" in calling function
      Menu, MyMenu, add, % Item , % Handle
  Menu, MyMenu, Show
  Menu, MyMenu, DeleteAll
}

; Additional menu Label subroutine for variadic function:

MenuShortcut:
  TextOut := SubStr(A_ThisMenuItem, 4)
  SendInput {raw}%TextOut%%A_EndChar%
Return

; HotstringMenu() Sample Menus
; Delete or comment out /* … */ to remove.

:x*?:$``::HotstringMenu("¢,£,¥,€")
:x*?:f``::HotstringMenu("⅒,⅑,⅛,⅐,⅙,⅕,¼,⅓,⅜,⅖,½,⅗,⅝,⅔,¾,⅘,⅚,⅞")
:x*?:s``::HotstringMenu("© | Copyright,® | Registered TradeMark,™|Trademark,° | Degree,• | Bullet,· | Dot,… | ellipsis,¶  | Paragraph")
:x*?:m``::HotstringMenu("±,×,÷,≈,≅,∑,ƒ,¹,²,³")
:x*?:b``::HotstringMenu("🦄 | Unicorn &1,🐀 | Rat &2
          ,🐁 | Mouse &3,🐂 | Ox &4,🐃 | Water Buffalo &5
          ,🐄 | Cow &6,❓ | Red &7,❔ | White &8")
:x:flux::HotstringMenu("Flux|&0,Flux #&1,Flux #&2")

; HotstringMenuV() Sample Menus
; Delete or comment out /* … */ to remove.

:x:brb::HotstringMenuV("C","HotstringMenuAction","FractionA")
:x*:frt::HotstringMenuV("A","MenuShortcut",Fractions*)
:x*:frct::HotstringMenuV("T","HotstringMenuAction",FractionsA*)
:x:bn::HotstringMenuV("N","MenuShortcut","Ox","Water Buffalo","Cow")
:x:ba::HotstringMenuV("A","MenuShortcut","Ox","Water Buffalo","Cow")
:x*?:b2``::HotstringMenuV("" ,"HotstringMenuAction","🦄 | Unicorn &1","🐀 | Rat &2"
                                       ,"🐁 | Mouse &3","🐂 | Ox &4","🐃 | Water Buffalo &5"
                                       ,"🐄 | Cow &6","❓ | Red &7","❔ | White &8")
:x*?:c``::HotstringMenuV("T","HotstringMenuAction",ArrowsA*)
:x*?:a``::HotstringMenuV("T","HotstringMenuAction",{⇐: "Left arrow &1",⇔: "Double arrow &5",⇒: "Right arrow &3",⇑: "Up arrow &2",⇓: "Down arrow &4"}*)
:x*?:c``::HotstringMenuV("","HotstringMenuAction",["⇐ | Left arrow &1","⇔ | Double arrow &2","⇒ | Right arrow &3","⇑ | Up arrow &4","⇓ |Down arrow &5"]*)
The code appears on the website page has no problem, I mean, the normal Fractions and arrows appear to be completely correct.
When I opened the code on the editor on my computer, the usual Fractions and arrows appeared as question marks.
Note the difference in the two pic
The Site.PNG
Pic from the Site
The Site.PNG (66.23 KiB) Viewed 1576 times
My System.PNG
Pic from My System
My System.PNG (64.06 KiB) Viewed 1576 times
When running the code, it gives this message: \ Hotstring Menus.ahk (106): ==> Missing "key:" in object literal.
My question is: What should I do for the code to appear correctly?
Any help would be much appreciated.
TAC109
Posts: 1129
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: problem with Fractions at my computer  Topic is solved

07 Dec 2019, 16:52

Save the script (.ahk file) as UTF8 with BOM.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
asad41163
Posts: 268
Joined: 29 Jul 2014, 14:31

Re: problem with Fractions at my computer

07 Dec 2019, 17:59

Mr. TAC109 :bravo:
All thanks and appreciation.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], effel, FortniteSpanishGuy, mikeyww and 104 guests