Button Names Refresh From Table

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
MusoCity
Posts: 95
Joined: 24 Mar 2018, 20:45

Button Names Refresh From Table

17 May 2018, 23:34

I need to change the button/function name from a table as I change the radio selection, one radio has the Key C,C#,Db,D... and the other the Scale Major, Minor, Harmonic_Major, Harmonic_Minor, ....
It needs to refresh/redraw the names when the key/scale is changed.
So if the Key is on C# and Scale on Minor it will read the C#Minor table.

Code: Select all

CMajor = {"C", "Dm", "Em", "F", "G", "Am", "Bdim", "CMaj7", "Dm7", "Em7", "FMaj7", "G7", "Am7", "Bm7b5"}
C#Major = {"C#", "Ebm", "Fm", "F#", "G#", "A#m", "Cdim", "C#Maj7", "D#m7", "Fm7", "F#Maj7", "G#7", "A#m7", "Cm7b5"}

Code: Select all

Gui, Add, Button, x22 y100 w90 h20 , %Chord1%
Gui, Add, Button, x122 y100 w90 h20 , %Chord2%
Gui, Add, Button, x222 y100 w90 h20 , %Chord3%
Gui, Add, Button, x322 y100 w90 h20 , %Chord4%
Gui, Add, Button, x422 y100 w90 h20 , %Chord5%
Gui, Add, Button, x522 y100 w90 h20 , %Chord6%
Gui, Add, Button, x622 y100 w90 h20 , %Chord7%
Gui, Add, Button, x22 y130 w90 h20 , %Chord8%
Gui, Add, Button, x122 y130 w90 h20 , %Chord9%
Gui, Add, Button, x222 y130 w90 h20 , %Chord10%
Gui, Add, Button, x322 y130 w90 h20 , %Chord11%
Gui, Add, Button, x422 y130 w90 h20 , %Chord12%
Gui, Add, Button, x522 y130 w90 h20 , %Chord13%
Gui, Add, Button, x622 y130 w90 h20 , %Chord14%
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Button Names Refresh From Table

18 May 2018, 03:13

This could be one approach

Code: Select all

#SingleInstance,Force

List1:= ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

Gui,1:+AlwaysOnTop
Gui,1:Color,Black

Loop 26
	{
		if(Mod(A_Index,14)!=0&&A_Index!=1)
			Gui,1:Add,Button,x+10 w30 r1,%A_Index%
		else
			Gui,1:Add,Button,x10 w30 r1,%A_Index%
		
	}
Gui,1:Add,Button,x10 w100 r1 gSwap,swap
Gui,1:Show,
return

GuiClose:
GuiEscape:
*^ESC::
	ExitApp

Swap:
	if(Swap:=!Swap)
		Loop 26
			GuiControl,1:,Button%A_Index%,% List1[A_Index]
	else 
		Loop 26
			GuiControl,1:,Button%A_Index%,% A_Index
	return

MusoCity
Posts: 95
Joined: 24 Mar 2018, 20:45

Re: Button Names Refresh From Table

18 May 2018, 21:49

Not sure how I would use that with the 2 Radios or DropDownList as one has 17 choices and the other 13 choices.
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Button Names Refresh From Table

18 May 2018, 22:10

I'm not trying to add your text to the buttons. This just shows how to change one set of button names to another set.
The whole thing about the number of buttons I have and how I added them only had to do with setup for the swap to take place in the "swap" label.

It needs to refresh/redraw the names when the key/scale is changed.
Here it is with radios

Code: Select all

#SingleInstance,Force

List1:= ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

Gui,1:+AlwaysOnTop
Gui,1:Color,Black

Loop, 26
	{
		if(Mod(A_Index,14)!=0&&A_Index!=1)
			Gui,1:Add,Button,x+10 w60 r1,%A_Index%
		else
			Gui,1:Add,Button,x10 w60 r1,%A_Index%
		
	}
Gui,1:Add,Radio,cWhite x10 w100 r1 Group Checked vRad1 gSwap ,Radio 1
Gui,1:Add,Radio,cWhite x+10 w100 r1 gSwap ,Radio 2
;~ Gui,1:Add,Button,x10 w100 r1 gSwap,swap
Gui,1:Show,
Gui,1:Submit,Nohide
return

GuiClose:
GuiEscape:
*^ESC::
	ExitApp

Swap:
	Gui,1:Submit,Nohide
	if(Rad1=2)
		Loop 26
			GuiControl,1:,Button%A_Index%,% List1[A_Index]
	else 
		Loop 26
			GuiControl,1:,Button%A_Index%,% A_Index
	return
MusoCity
Posts: 95
Joined: 24 Mar 2018, 20:45

Re: Button Names Refresh From Table

19 May 2018, 17:58

Thanks I think I see now, I was just coming from Lua where I made the GUI:

Image
Lua-Key-Scale.gif
Lua-Key-Scale.gif (50.83 KiB) Viewed 1009 times

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 227 guests