Help with loop defining Gui Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Noo0B
Posts: 151
Joined: 26 Jan 2018, 19:54

Help with loop defining Gui

17 Feb 2018, 14:08

I want to make a script with a gui that autoupdates itself.
Anyone ever tried that?
I thought about reading the vairables from the ini file.
then a gui with a variable with the number of lines in the program and how many to add.
Then another gui with that amount of checkboxes, with these variables from the .ini on a checked checkbox line and new checkbox lines with these new variable values.
For example the checkbox would add the line or delete it regardless of how many you chose to be able to edit on the gui, and the variables would write part of that line to what is inside the gui edit box.
Maybe use the clipboard but I think the clipboard wont be able to write a different line for each checkbox variables, maybe a variable for each part of the literal code then the edit box literal variables with their indexes themselves.
I think first it would need to know where the file is, open it, which line to start writing, how to save, etc.
Then save the variables, the file itself and restart.
Can someone point me to the right direction or write me a code that would do that?
I´d much appreciate that because I´m a noob.
Thanks a lot.
Last edited by Noo0B on 17 Feb 2018, 17:29, edited 2 times in total.
Noo0B
Posts: 151
Joined: 26 Jan 2018, 19:54

Re: Script Auto edit

17 Feb 2018, 14:27

Maybe I should stick with a predetermined amount of entries on the gui and the script?
Noo0B
Posts: 151
Joined: 26 Jan 2018, 19:54

Re: Script Auto edit

17 Feb 2018, 17:24

I did this:
Spoiler
But when I tried to do this:

Code: Select all

N:= 2
GuiN:= 1
GuiY= -25+30*%GuiN%
GuiNY= 30 * %GuiN%
	Loop
		{
			Gui, Add, Checkbox, X0 Y-22+30*%GuiN% vIconToggle%GuiN%
			Gui, Add, Edit, X30 Y%GuiY% H21 W130 vName%GuiN%, % Name%GuiN%
			Gui, Add, Edit, X170 Y%GuiY% H21 W21 vCollumn%GuiN%, % Column%GuiN%
			Gui, Add, Edit, X200 Y%GuiY% H21 W21 vLine%GuiN%, % Line%GuiN%
			GuiN+= 1
				If (A_Index = N)
					Break
			}
Gui, Show, w1500 h1000 X200 Y10+30*%GuiN%, Include Toggle`, Name`, Column`, Line
I failed. how can I do it like that?
Thanks.
User avatar
boiler
Posts: 16927
Joined: 21 Dec 2014, 02:44

Re: Help with loop defining Gui  Topic is solved

17 Feb 2018, 17:54

Your GuiY equation/assignment has to be inside the loop or it doesn't update each time through the loop. Also, you need to use expression syntax for the Gui, Add options. Here it is with those fixes (and N = 10) as well as some other clean-up, such as using loop the way it is mean instead of an if statement and a break. Also, you could just use A_Index directly since GuiN is just the same as GuiN, but I left that in there.

Code: Select all

N := 10
GuiN := 1
Loop, %N%
{
	GuiY := -25 + 30 * GuiN
	Gui, Add, Checkbox, % "X0 Y" -22 + 30 * GuiN " vIconToggle" GuiN
	Gui, Add, Edit, % "X30 Y" GuiY " H21 W130 vName" GuiN, % Name%GuiN%
	Gui, Add, Edit, % "X170 Y" GuiY " H21 W21 vCollumn" GuiN, % Column%GuiN%
	Gui, Add, Edit, % "X200 Y" GuiY " H21 W21 vLine" GuiN, % Line%GuiN%
	GuiN += 1
}
Gui, Show, % "w1500 h1000 X200 Y" 10 + 30 * GuiN, Include Toggle`, Name`, Column`, Line
Last edited by boiler on 17 Feb 2018, 18:01, edited 1 time in total.
User avatar
boiler
Posts: 16927
Joined: 21 Dec 2014, 02:44

Re: Help with loop defining Gui

17 Feb 2018, 17:58

By the way, the % Name%GuiN%, % Column%GuiN%, and % Line%GuiN% implies that you have three pseudo-arrays here that aren't shown in your code. I don't know what you were trying to accomplish with that, so I didn't change it. If you remove the the % at the start of each, perhaps that's what you were looking to do.
Noo0B
Posts: 151
Joined: 26 Jan 2018, 19:54

Re: Help with loop defining Gui

17 Feb 2018, 19:21

I just thought of that a second ago! It makes sence since I ouldn´t find anything that worked to export those values outside the loop. It makes sense since AHK is single threaded.

Code: Select all

 Gui, Add, Edit, % "X200 Y" GuiY " H21 W21 vLine" GuiN, % Line%GuiN%
should be like this:

Code: Select all

 Gui, Add, Edit, X200 Y65 H21 W21 vLine3, %Line3%
.
Thanks and Best Regards!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: CrowexBR, doodles333, vysmaty and 247 guests