Help Need To Number Controls horizontally, How ...

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Roonyroo
Posts: 36
Joined: 29 Jan 2014, 20:29

Help Need To Number Controls horizontally, How ...

30 Jan 2014, 14:11

I'm having a hard time generating controls vertically, as the script generates the rows horizontally

How do I modify the script to generate the controls vertically, its driving me nuts ...

Code: Select all

setBatchLines -1
xl:=0
lp:=0

yx := -5


;SetTimer,UPDATEDSCRIPT,1000

;outer loop number of row of boxes using xl++ in x axis , inner loop repeats number of rows of boxes 32 times in y axis
; important to null movex so starts 0
loop, 5 ;outer loop
{ ;1
xl ++
movex:=xl*100-100
;lp:=xl+lp
yx:=0
Loop, 16 ;inner loop

{

lp ++
	yx += 35

	Gui, Add, Edit, x%movex% y%yx% w90 h30 -Multi vKutu%lp%a,%lp%xx 

}

} ;1







User avatar
fischgeek
Posts: 435
Joined: 29 Jan 2014, 21:39

Re: Help Need To Number Controls horizontally, How ...

30 Jan 2014, 14:38

What exactly are you trying to accomplish outside of using the "Section -- ys, ym, xs, xm" positioning tools? I'm confused. Here's what I see.
Spoiler
What are you expecting/wanting?
garry
Posts: 3795
Joined: 22 Dec 2013, 12:50

Re: Help Need To Number Controls horizontally, How ...

30 Jan 2014, 15:04

not sure, was trying this

Code: Select all

setBatchLines -1
lp=0
y:=10
gui,2:add,text,section x0   y%y% w0 h0,    ;-- set position for y
loop,5
{
loop,15
  {
  lp++
  Gui, 2:Add, Edit, x+7 y%y% w90 h30 -Multi vKutu%lp%a,%lp%xx
  }
gui,2:add,text,section x0   y0  w0 h0,    ;-- set position for x
y +=35
}
Gui,2:show,x10 y10 ,TEST
return

2guiclose:
exitapp
Roonyroo
Posts: 36
Joined: 29 Jan 2014, 20:29

Re: Help Need To Number Controls horizontally, How ...

30 Jan 2014, 17:22

@garry

Thanks I wasnt sure how to set the x & y seperately

@fisch

I have no idea what you're referring to lol ... ive never used section for a gui before
User avatar
fischgeek
Posts: 435
Joined: 29 Jan 2014, 21:39

Re: Help Need To Number Controls horizontally, How ...

30 Jan 2014, 17:30

@garry
Help Docs wrote:
Spoiler
So, a better example would be:

Code: Select all

Gui, Add, Text,, Enter your name
Gui, Add, Text, Section, First Name
Gui, Add, Text,, Last Name
Gui, Add, Edit, ys
Gui, Add, Edit
Gui, Show
return
Roonyroo
Posts: 36
Joined: 29 Jan 2014, 20:29

Re: Help Need To Number Controls horizontally, How ...

30 Jan 2014, 18:38

@fisch

thnx for the explanation, i'll have to practise using those coords never heard of them before ...

I now have a slightly different problem lol

How would I number each line of boxes horizontally, but display it as a normal text, at the start of each line

ie. 1 box box box
2 box box box
3 box box box

erm i'm using garry's script

Code: Select all


setBatchLines -1
lp=0
y:=10
gui,2:add,text,section x0   y%y% w0 h0,    ;-- set position for y
loop,5
{
loop,15
  {
  lp++
  Gui, 2:Add, Edit, x+7 y%y% w90 h30 -Multi vKutu%lp%a,%lp%xx
  }
gui,2:add,text,section x0   y0  w0 h0,    ;-- set position for x
y +=35
}
Gui,2:show,x10 y10 ,TEST
return

2guiclose:
exitapp
 




User avatar
fischgeek
Posts: 435
Joined: 29 Jan 2014, 21:39

Re: Help Need To Number Controls horizontally, How ...

31 Jan 2014, 09:42

Here's a way that I quickly threw together. I'm sure there's a bunch of different ways to do this. You'll have to make some tweaks to get your text and stuff in the way you want it, but this just shows how to setup the grid pattern.

Code: Select all

Gui, Add, Text,, 1.
Loop, 14
	Gui, Add, Text,, % A_Index+1
Loop, 60
{
	if a_index in 1,16,31,46
		Gui, Add, Edit, Section ys
	else
		Gui, Add, Edit
}
Gui, Show
return

GuiClose:
ExitApp
Roonyroo
Posts: 36
Joined: 29 Jan 2014, 20:29

Re: Help Need To Number Controls horizontally, How ...

31 Jan 2014, 11:42

@fischer

Thats great thanks

How would I generate the rows vertically instead of horizontally, as I need the boxes labelled vertically

I've never used sections before, as I normally just use a loop to generate gui's, not sure what the syntax is

So basically

box1 box2 box3

instead of

box1
box2
box3
User avatar
fischgeek
Posts: 435
Joined: 29 Jan 2014, 21:39

Re: Help Need To Number Controls horizontally, How ...

31 Jan 2014, 12:02

Read up on sections in the help file under Gui > positioning and sizing of controls.

Section is basically a way to denote that controls that have a coordinate followed by an "s" will coincide with the most previous Section.

Code: Select all

Gui, Add, Text, Section ; Start a section here
Gui, Add, Edit, ys ; put this control in the next y column of the section
Gui, Add, Edit, xs ; put this control on the next line of the section
Gui, Add, Edit, Section xm ; start a completely new section beginning on the next line
Gui, Add, Edit, ys ; put this control in the next y column of the most previous section
Try to visualize what the above code with produce.

Were you right?
Spoiler
See if you can't play with the order of operation with the loop and output what you're looking for. I'll try to get an example out here soon.
garry
Posts: 3795
Joined: 22 Dec 2013, 12:50

Re: Help Need To Number Controls horizontally, How ...

31 Jan 2014, 14:57

thank you fischgeek for explanation and good easy examples
Roonyroo
Posts: 36
Joined: 29 Jan 2014, 20:29

Re: Help Need To Number Controls horizontally, How ...

31 Jan 2014, 21:34

Wouldnt a nested loop be easier?

ie
loop 3 ;y axis
{
y ++
loop 10 ;x axis draws y axis after finishes drawing x axis
{
x ++

}
}
User avatar
fischgeek
Posts: 435
Joined: 29 Jan 2014, 21:39

Re: Help Need To Number Controls horizontally, How ...

01 Feb 2014, 09:58

Honestly, whatever works for you. There's no right or wrong way. I personally would probably do it this way:

Code: Select all

Gui, Add, Text, Section, 1. ; static column (A)
Loop, 14
	Gui, Add, Text,, % A_Index+1 "." ; since there are no coords in these controls they will stack in column (A)
Loop, 74
{
	if (a_index == 1)
		Gui, Add, Edit, Section ys ; putting the first edit control in a new column (B)
	if a_index in 5,10,15,20,25,30,35,40,45,50,55,60,65,70,75
		Gui, Add, Edit, Section xs ; xs says make this control in the same column as the previous "Section" but on a new line (row)
	else
		Gui, Add, Edit, ys ; ys says make this control a new column in the same row as the previous "Section"
}
Gui, Show
return
garry
Posts: 3795
Joined: 22 Dec 2013, 12:50

Re: Help Need To Number Controls horizontally, How ...

01 Feb 2014, 11:53

thank you fischgeek, small mod's , added variable to your example

Code: Select all

;-------- http://ahkscript.org/boards/viewtopic.php?f=5&t=1792 ---
Gui, Add, Text, Section, 1.                            ;- static column (A)
Loop, 14
    Gui, Add, Text, , % A_Index+1 "."                  ;- since there are no coords in these controls they will stack in column (A)

Loop, 75
{
    if (a_index == 1)
        {
        Gui, Add, Edit , vA%a_index% Section ys        ;- putting the first edit control in a new column (B)
        continue
        }
    if a_index in 6,11,16,21,26,31,36,41,46,51,56,61,66,71
        Gui, Add, Edit , vA%a_index% Section xs        ;- xs says make this control in the same column as the previous "Section" but on a new line (row)
    else
        Gui, Add, Edit , vA%a_index% ys                ;- ys says make this control a new column in the same row as the previous "Section"
}
Gui, Show
GuiControl,1:,a1 ,A1
GuiControl,1:,a5 ,A5
GuiControl,1:,a10,A10
GuiControl,1:,a11,A11
GuiControl,1:,a21,A21
GuiControl,1:,a31,A31
GuiControl,1:,a41,A41
GuiControl,1:,a51,A51
GuiControl,1:,a61,A61
GuiControl,1:,a71,A71
GuiControl,1:,a75,A75
return
GuiClose:
exitapp

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], peter_ahk and 336 guests