Help with Text Menu script Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
leo007
Posts: 50
Joined: 26 Oct 2019, 04:56

Help with Text Menu script

26 Nov 2019, 09:20

Hi Everyone,

I have script that I found on the web that close to my need. and I'm trying to modify this code so when I select 1,2,3 from menu other relative value like "a,b,c" will be printed instead?
so I need help with script to apply this logic.

Code: Select all

    TextMenu(TextOptions)
    {
      StringSplit, MenuItems, TextOptions , -`,
      Loop %MenuItems0%
      {
        Item := MenuItems%A_Index%
        Menu, MyMenu, add, %Item%, MenuAction
      }
      Menu, MyMenu, Show
      Menu, MyMenu, DeleteAll
    }

    MenuAction:
      SendInput %A_ThisMenuItem%{raw}%A_EndChar%
    Return

    ::cur::
      TextMenu("1,2,3")
    Return
  }
Thanks in advance for your help :)
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: Help with Text Menu script  Topic is solved

26 Nov 2019, 10:34

Code: Select all

TextMenu(TextOptions)
{
	arrVal := []
	fn := Func("MenuAction").Bind( arrVal )
	
	Loop, Parse, TextOptions, CSV
	{
		arr := StrSplit(A_LoopField, "=", " ")
		arrVal.push(arr[2])
		Menu, MyMenu, Add, % arr[1], % fn
	}
	
	Menu, MyMenu, Show
	Menu, MyMenu, DeleteAll
}

MenuAction(arrVal)
{
	SendInput % "{Text}" . arrVal[A_ThisMenuItemPos]
}

:X:cur::TextMenu("hello = world, 2=b, 3=c")
leo007
Posts: 50
Joined: 26 Oct 2019, 04:56

Re: Help with Text Menu script

26 Nov 2019, 12:24

tmplinshi Thanks for your Reply
you script works great
one small thing

if I want:

Code: Select all

2=b

to be equal instead:

Code: Select all

2="ab",cd
is the an easy way to make it?
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: Help with Text Menu script

26 Nov 2019, 23:33

Code: Select all

::cur::
	v = 1=a,"2=""ab"",cd",3=c
	TextMenu(v)
return
If you are confusing about the quotes, you can use Excel to create a CSV file, then open it in notepad.
leo007
Posts: 50
Joined: 26 Oct 2019, 04:56

Re: Help with Text Menu script

27 Nov 2019, 22:43

its exactly what I needed
tmplinshi Thank you very much

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Spawnova and 59 guests