Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Loop checkboxes



  • Please log in to reply
8 replies to this topic
Dorian
  • Members
  • 85 posts
  • Last active: Apr 16 2016 07:57 AM
  • Joined: 16 Oct 2014

How can I loop this?

 

Gui, Add, Checkbox, x350 y100 checked%Var1% vVar1 
Gui, Add, Checkbox, x350 y120 checked%Var2vVar2
Gui, Add, Checkbox, x350 y140 checked%Var3vVar3
Gui, Add, Checkbox, x350 y160 checked%Var4vVar4
Gui, Add, Checkbox, x350 y180 checked%Var5vVar5
 
For the checked%....% part everything i try is wrong.
Thank you!


arizonabuckeye
  • Members
  • 49 posts
  • Last active: Jun 03 2015 09:19 PM
  • Joined: 13 Mar 2014
✓  Best Answer

What do you mean loop? What are you trying to accomplish? What error are you getting?

 

the %....% part shouldn't be needed because 'Checked' is already passing that value to the variable.



Dorian
  • Members
  • 85 posts
  • Last active: Apr 16 2016 07:57 AM
  • Joined: 16 Oct 2014

I thought checked was needed, hehe. Thanks!



kon
  • Members
  • 1652 posts
  • Last active:
  • Joined: 04 Mar 2013

How can I loop this?

Loop, 5 {   ; set some random values for the vars
    Random, n, 0, 1
    Var%A_Index% := n
}
   
Loop, 5
    Gui, Add, Checkbox, % "x10 y+10 checked" Var%A_Index% " vVar" A_Index, Checkbox %A_Index%

Gui, Add, Button, gButton1, Submit
Gui, Show
return

Button1:
Gui, Submit, NoHide
Output := ""
Loop, 5
    Output .= Var%A_Index% "`r`n"
MsgBox, %Output%
return

GuiClose:
ExitApp


Dorian
  • Members
  • 85 posts
  • Last active: Apr 16 2016 07:57 AM
  • Joined: 16 Oct 2014

Yes, this works :)

One more question, how can I change the starting pos y

(I am terrible understanding when to use %.. " dots and combinations of everything... and I read the files many times :/ )



Dorian
  • Members
  • 85 posts
  • Last active: Apr 16 2016 07:57 AM
  • Joined: 16 Oct 2014

The y position must be something like y%PosY%, because sometimes I am looping several columns of checkboxes.

Example:

 

Loop 5
{
PosY := 100 + (A_Index-1) * 20
Gui, Add, Checkbox, % "x150 y+5 checked" NameABC%A_Index% " vNameABC" A_Index, % SomeText%A_Index%
Gui, Add, Checkbox, % "x200 y+5 checked" NameXYZ%A_Index% " vNameXYZ" A_Index
Gui, Add, Checkbox, % "x250 y+5 checked" NameFFF%A_Index% " vNameFFF" A_Index
Gui, Add, Checkbox, % "x300 y+5 checked" NameDDD%A_Index% " vNameDDD" A_Index
}
 
It should look ending like a square of checkboxes


arizonabuckeye
  • Members
  • 49 posts
  • Last active: Jun 03 2015 09:19 PM
  • Joined: 13 Mar 2014

Look at the documentation on Gui's http://www.autohotke...ommands/Gui.htm I think you are missing some commas and have quotes misplaced. I "think" it should be like

 

Gui, Add, Checkbox,X150 Y+5, Checked NameABC%A_Index%, vNameAbc%A_Index%, SomeText%A_Index%

 

In this case the % is used to indicate a variable is being called rather than explicit text/data.

 

If you are having trouble getting the GUI to populate try doing it without the index then integrate the index after you know the GUI functions.



kon
  • Members
  • 1652 posts
  • Last active:
  • Joined: 04 Mar 2013

It should look ending like a square of checkboxes

 
 

Loop, 5 {   ; set some random values for the NameABC vars
    Random, n, 0, 1
    NameABC%A_Index% := n
}

Loop 5
{
    PosY := 100 + (A_Index-1) * 20
    MsgBox, % "x150 y" PosY " checked" NameABC%A_Index% " vNameABC" A_Index    ; Shows the result of this expression
    Gui, Add, Checkbox, % "x150 y" PosY " checked" NameABC%A_Index% " vNameABC" A_Index, % SomeText%A_Index%
    Gui, Add, Checkbox, % "x200 y" PosY " checked" NameXYZ%A_Index% " vNameXYZ" A_Index
    Gui, Add, Checkbox, % "x250 y" PosY " checked" NameFFF%A_Index% " vNameFFF" A_Index
    Gui, Add, Checkbox, % "x300 y" PosY " checked" NameDDD%A_Index% " vNameDDD" A_Index
}
ExitApp


Dorian
  • Members
  • 85 posts
  • Last active: Apr 16 2016 07:57 AM
  • Joined: 16 Oct 2014

Thanks arizona, but that give me in the gui:    [ ] checked, name var

 

Kon, that is exactly! :) :)