 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
VibrantLife
Joined: 29 Oct 2009 Posts: 50
|
Posted: Sat Dec 12, 2009 12:19 am Post subject: Gui with 23 Checkboxes Gosub stopped.. |
|
|
.
Hello, i have 2 questions about this Gui:
For testing i used a msgbox but it showed up only with the first checkbox checked, once!
When i uncheck the first Checkbox, and check it again, it doesn't output msgbox anymore.
1: It isn't Continue to Gosub2 & 3 or Checkbox 2 & 3 and further.
It also doesn't arrive at Gui Destroy, because the Gui stays in place.
After pressing Add(Toevoegen) button
What am i doing wrong¿
2: Is there maybe a more elegant way to put 23 checkboxes in a Gui and perform actions upon Checked? didn't come across it with several forum searches.
i did tried
| Code: | GuiControlGet, CheckBox1
If CheckBox1 = 1 |
But it did the opposite, it output every checkbox action at once
even when it isn't checked.
Thanks!
Sample of code:
| Code: |
#include COM.ahk
#include iWeb.ahk
COM_CoInitialize()
Gui, +AlwaysOnTop,
Gui, Font, s13 Cwhite w40, Arial BOLD
Gui, Add, CheckBox, x5 y67 w120 h32 Checked vCheckBox1, Lastname
Gui, Add, CheckBox, x5 y97 w120 h32 Checked vCheckBox2, First name
Gui, Add, CheckBox, x5 y127 w120 h32 Checked vCheckBox3, Middlename
Gui, Add, CheckBox, x5 y157 w130 h32 Checked vCheckBox4, Initials
Gui, Add, CheckBox, x5 y187 w120 h32 Checked vCheckBox5, Email werk
Gui, Add, CheckBox, x5 y217 w120 h32 Checked vCheckBox6, Assistant
Gui, Add, CheckBox, x5 y247 w140 h32 Checked vCheckBox7, Assistant Mail
Gui, Add, CheckBox, x5 y277 w140 h32 Checked vCheckBox8, Manager
Gui, Add, CheckBox, x145 y67 w130 h32 Checked vCheckBox9, Partner Naam
Gui, Add, CheckBox, x145 y97 w120 h32 Checked vCheckBox10, Titel
Gui, Add, CheckBox, x145 y127 w120 h32 Checked vCheckBox11, Suffix
Gui, Add, CheckBox, x145 y157 w130 h32 Checked vCheckBox12, Man
Gui, Add, CheckBox, x145 y187 w120 h32 vCheckBox13, Vrouw
Gui, Add, CheckBox, x145 y217 w140 h32 Checked vCheckBox14, Telefoon Werk
Gui, Add, CheckBox, x145 y247 w140 h32 Checked vCheckBox15, Fax
Gui, Add, CheckBox, x145 y277 w140 h32 Checked vCheckBox16, Mobiel Werk
Gui, Add, CheckBox, x285 y67 w150 h32 Checked vCheckBox17, Assistant Phone
Gui, Add, CheckBox, x285 y97 w150 h32 Checked vCheckBox18, Manager Phone
Gui, Add, CheckBox, x285 y127 w120 h32 vCheckBox19, Huisadres
Gui, Add, CheckBox, x285 y157 w130 h32 Checked vCheckBox20, Home Phone
Gui, Add, CheckBox, x285 y187 w120 h32 Checked vCheckBox21, Prive mobiel
Gui, Add, CheckBox, x285 y217 w140 h32 Checked vCheckBox22, Home Fax
Gui, Add, CheckBox, x285 y247 w140 h32 Checked vCheckBox23, Prive E-mail
Gui, Add, Button, x120 y340 w130 h30 gSelect, Selecteer Alles
Gui, Add, Button, x255 y340 w130 h30 gDeselect, Selecteer Niets
Gui, Add, Button, gGuiClose default x115 y10 w280 h50 gToevoegen, Toevoegen Maar ; Means: Add!!
Gui, Show, x0 y600 h380 w555 NoActivate, Veld selectie
Gui, Color, 63769b
Return
Select: ; select all checkboxes
Loop 50
GuiControl, , CheckBox%A_Index%, 1
return
Deselect: ; deselect all checkboxes
Loop 50
GuiControl, , CheckBox%A_Index%, 0
return
Toevoegen: ; add
gui submit,nohide
if(Checkbox1=1)
{
Gosub Check1
}
if(Checkbox2=1)
{
Gosub Check2
}
if(Checkbox3=1)
{
Gosub Check3
}
return
Check1:
msgbox, Test1 Passed!
COM_init()
iweb_init()
Clipboard:=
Clipboard:=lastname
WinWait, Invoeren persoon,
IfWinNotActive, Invoeren persoon, , WinActivate, Invoeren persoon ,
WinWaitActive, Invoeren persoon,
sleep 50
pwb:=iWeb_getwin("Invoeren persoon") ; create new pointer to 'Invoeren persoon'
COM_Invoke(pwb, "document.all.item[ctl00_K_H_MA_FA_IA_achterNaamEdit].focus"),
Send, {CtrlDown}v{CtrlUp} ; Couldn't use iwebsetDomObj it bypasses internal editbox javascripts in website
COM_Release(pwb) ; It accepts only clipboard input
iweb_Term()
Com_Term()
Check2:
msgbox, Test2 Passed!
COM_init()
iweb_init()
Clipboard:=
Clipboard:=firstname
WinWait, Invoeren persoon,
IfWinNotActive, Invoeren persoon, , WinActivate, Invoeren persoon ,
WinWaitActive, Invoeren persoon,
sleep 50
pwb:=iWeb_getwin("Invoeren persoon") ; create new pointer to 'Invoeren persoon'
COM_Invoke(pwb, "document.all.item[ctl00_K_H_MA_FA_IA_roepNaamEdit].focus"),
sleep 800
Send, {CtrlDown}v{CtrlUp}
COM_Release(pwb)
iweb_Term()
Com_Term()
Check3:
msgbox, Test3 Passed!
COM_init()
iweb_init()
Clipboard:=
Clipboard:=middlename
WinWait, Invoeren persoon,
IfWinNotActive, Invoeren persoon, , WinActivate, Invoeren persoon ,
WinWaitActive, Invoeren persoon,
sleep 50
pwb:=iWeb_getwin("Invoeren persoon") ; create new pointer to 'Invoeren persoon'
COM_Invoke(pwb, "document.all.item[ctl00_K_H_MA_FA_IA_tussenvoegselsEdit].focus"),
Send, {CtrlDown}v{CtrlUp}
COM_Release(pwb)
sleep 50
iweb_Term()
Com_Term()
; and checkbox 4..23 below
GuiClose:
Gui Destroy
Com_Term()
|
_________________ The signature is away at the moment, please leave a message after the beep... |
|
| Back to top |
|
 |
entropic
Joined: 21 Dec 2008 Posts: 181
|
Posted: Sat Dec 12, 2009 1:01 am Post subject: |
|
|
| Code: |
Items = One|Two|Three|Four|Five|Six|Seven|Eight|Nine|Ten|Eleven|Twelve|Thirteen|Fourteen|Fifteen|Sixteen|Seventeen|Eighteen|Nineteen|Twenty|Twenty One|Twenty Two
StringSplit, ItemArray, Items, | ; Split the items into an array
xStep = 145
xStart = 5
xVal := xStart
yStep = 30
yStart = 67
yVal := yStart
Gui, +AlwaysOnTop,
Gui, Font, s13 Cwhite w40, Arial BOLD
Loop, %ItemArray0%
{
Gui, Add, Checkbox, x%xVal% y%yVal% w120 h32 Checked vCheckbox%A_Index% gHandlerLabel, ItemArray%A_Index%
; Start a new column after each 8 controls
If (Mod(A_Index, 8) = 0)
{
xVal += xStep
yVal := yStart
}
else
{
yVal += yStep
}
}
Gui, Add, Button, x120 y340 w130 h30, Selecteer Alles
Gui, Add, Button, x255 y340 w130 h30, Selecteer Niets
Gui, Add, Button, default x115 y10 w280 h50, Toevoegen Maar ; Means: Add!!
Gui, Show, x0 y600 h380 w555 NoActivate, Veld selectie
Gui, Color, 63769b
Return
HandlerLabel:
GuiControlGet, CheckboxValue,, %A_GuiControl%
Msgbox % (CheckboxValue = 1 ? "You checked " A_GuiControl : "You unchecked " . A_GuiControl)
Return
|
There's one way of doing it. Each checkbox uses the same g-Label and then you differentiate between them using the A_GuiControl variable in the label. |
|
| Back to top |
|
 |
VibrantLife
Joined: 29 Oct 2009 Posts: 50
|
Posted: Sat Dec 12, 2009 1:33 am Post subject: |
|
|
Thanks entropic!! that looks more then elegant to me
2 questions:
1: The label names are changed into: ItemArray1-22 instead of own choosen labelnames like: lastname, firstname can i change? these labelnames like:
ItemArray1=lastname
ItemArray2=firstname
2:
The Add(toevoegen maar) button is dead..
Some checkboxes have to be unchecked at start
The idea was to perform several(22) actions only when that action is checked. After pressed at the Add(Toevoegen maar) button
The (msgboxes were just to test the loop)
Where can i set the actions for every checkbox? _________________ The signature is away at the moment, please leave a message after the beep... |
|
| Back to top |
|
 |
entropic
Joined: 21 Dec 2008 Posts: 181
|
Posted: Sat Dec 12, 2009 1:47 am Post subject: |
|
|
Edit: See post below. Oops 
Last edited by entropic on Sat Dec 12, 2009 2:03 am; edited 1 time in total |
|
| Back to top |
|
 |
entropic
Joined: 21 Dec 2008 Posts: 181
|
Posted: Sat Dec 12, 2009 1:59 am Post subject: |
|
|
This solves most of those, changes are in red
| Code: |
Items = One|Two|Three|Four|Five|Six|Seven|Eight|Nine|Ten|Eleven|Twelve|Thirteen|Fourteen|Fifteen|Sixteen|Seventeen|Eighteen|Nineteen|Twenty|Twenty One|Twenty Two
CheckVals = 0|1|1|0|0|0|1|1|0|1|1|1|0|1|1|0|0|1|0|1|0|1
StringSplit, ItemArray , Items , | ; Split the items into an array
StringSplit, CheckValsArray, CheckVals, |
xStep = 145
xStart = 5
xVal := xStart
yStep = 30
yStart = 67
yVal := yStart
Gui, +AlwaysOnTop,
Gui, Font, s13 Cwhite w40, Arial BOLD
Loop, %ItemArray0%
{
Gui, Add, Checkbox, x%xVal% y%yVal% w120 h32 Checked vCheckbox%A_Index% gHandlerLabel, % ItemArray%A_Index%
GuiControl,, % ItemArray%A_Index%, % CheckValsArray%A_Index%
; Start a new column after each 8 controls
If (Mod(A_Index, 8) = 0)
{
xVal += xStep
yVal := yStart
}
else
{
yVal += yStep
}
}
Gui, Add, Button, x120 y340 w130 h30, Selecteer Alles
Gui, Add, Button, x255 y340 w130 h30, Selecteer Niets
Gui, Add, Button, default x115 y10 w280 h50 gToevoegen, Toevoegen Maar ; Means: Add!!
Gui, Show, x0 y600 h380 w555 NoActivate, Veld selectie
Gui, Color, 63769b
Return
HandlerLabel:
GuiControlGet, CheckboxValue,, %A_GuiControl%
Msgbox % (CheckboxValue = 1 ? "You checked " A_GuiControl : "You unchecked " . A_GuiControl)
Return
Toevoegen:
Gui, Submit, NoHide
Labels = LabelOne|LabelTwo|LabelThree
StringSplit, LabelArray, Labels, |
Loop, %ItemArray0%
{
If (Checkbox%A_Index% = 1) and IsLabel(LabelArray%A_Index%)
GoSub, % LabelArray%A_Index%
}
Return
LabelOne:
Msgbox, At Label One
Return
LabelTwo:
Msgbox, At Label Two
Return
LabelThree:
Msgbox, At Label Three
Return
|
|
|
| Back to top |
|
 |
VibrantLife
Joined: 29 Oct 2009 Posts: 50
|
Posted: Sat Dec 12, 2009 2:17 am Post subject: |
|
|
| entropic wrote: | This solves most of those, changes are in red
| Code: |
Items = One|Two|Three|Four|Five|Six|Seven|Eight|Nine|Ten|Eleven|Twelve|Thirteen|Fourteen|Fifteen|Sixteen|Seventeen|Eighteen|Nineteen|Twenty|Twenty One|Twenty Two
CheckVals = 0|1|1|0|0|0|1|1|0|1|1|1|0|1|1|0|0|1|0|1|0|1
StringSplit, ItemArray , Items , | ; Split the items into an array
StringSplit, CheckValsArray, CheckVals, |
xStep = 145
xStart = 5
xVal := xStart
yStep = 30
yStart = 67
yVal := yStart
Gui, +AlwaysOnTop,
Gui, Font, s13 Cwhite w40, Arial BOLD
Loop, %ItemArray0%
{
Gui, Add, Checkbox, x%xVal% y%yVal% w120 h32 Checked vCheckbox%A_Index% gHandlerLabel, % ItemArray%A_Index%
GuiControl,, % ItemArray%A_Index%, % CheckValsArray%A_Index%
; Start a new column after each 8 controls
If (Mod(A_Index, 8) = 0)
{
xVal += xStep
yVal := yStart
}
else
{
yVal += yStep
}
}
Gui, Add, Button, x120 y340 w130 h30, Selecteer Alles
Gui, Add, Button, x255 y340 w130 h30, Selecteer Niets
Gui, Add, Button, default x115 y10 w280 h50 gToevoegen, Toevoegen Maar ; Means: Add!!
Gui, Show, x0 y600 h380 w555 NoActivate, Veld selectie
Gui, Color, 63769b
Return
HandlerLabel:
GuiControlGet, CheckboxValue,, %A_GuiControl%
Msgbox % (CheckboxValue = 1 ? "You checked " A_GuiControl : "You unchecked " . A_GuiControl)
Return
Toevoegen:
Gui, Submit, NoHide
Labels = LabelOne|LabelTwo|LabelThree
StringSplit, LabelArray, Labels, |
Loop, %ItemArray0%
{
If (Checkbox%A_Index% = 1) and IsLabel(LabelArray%A_Index%)
GoSub, % LabelArray%A_Index%
}
Return
LabelOne:
Msgbox, At Label One
Return
LabelTwo:
Msgbox, At Label Two
Return
LabelThree:
Msgbox, At Label Three
Return
|
|
Wow your simply amazing!!
Thats such piece of art!
Muchos Gracias!!
I luv Arrays  _________________ The signature is away at the moment, please leave a message after the beep... |
|
| Back to top |
|
 |
entropic
Joined: 21 Dec 2008 Posts: 181
|
Posted: Sat Dec 12, 2009 2:21 am Post subject: |
|
|
Gracias, y de nada  |
|
| Back to top |
|
 |
VibrantLife
Joined: 29 Oct 2009 Posts: 50
|
Posted: Sat Dec 12, 2009 7:25 pm Post subject: |
|
|
| entropic wrote: | Gracias, y de nada  |
lol when i add gGuiClose @
| Code: | | Gui, Add, Button, gGuiClose default x85 y10 w280 h50 gToevoegen, Toevoegen :-D ; Means: Add!! | and at the end
| Code: |
GuiClose:
Gui Destroy
|
To close the Gui, only at pressing the Add(Toevoegen) Button,
it doesn't disapear
why is that¿ _________________ The signature is away at the moment, please leave a message after the beep... |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Sat Dec 12, 2009 7:37 pm Post subject: |
|
|
| VibrantLife wrote: | | Code: | | Gui, Add, Button, gGuiClose default x85 y10 w280 h50 gToevoegen, Toevoegen :-D ; Means: Add!! |
|
You can't have 2 gLabels. |
|
| Back to top |
|
 |
VibrantLife
Joined: 29 Oct 2009 Posts: 50
|
Posted: Sat Dec 12, 2009 7:42 pm Post subject: |
|
|
| jaco0646 wrote: | | VibrantLife wrote: | | Code: | | Gui, Add, Button, gGuiClose default x85 y10 w280 h50 gToevoegen, Toevoegen :-D ; Means: Add!! |
|
You can't have 2 gLabels. |
Ah alright! thanks
I just put GoSub GuiClose at every Label before the return
that solved it _________________ The signature is away at the moment, please leave a message after the beep... |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Sat Dec 12, 2009 8:20 pm Post subject: |
|
|
A note about Gui, Destroy.
| VibrantLife wrote: | | I just put GoSub GuiClose at every Label | You might want to post your latest code for some pointers. It is rare that redundant code is ever necessary. It can usually be eliminated. |
|
| Back to top |
|
 |
VibrantLife
Joined: 29 Oct 2009 Posts: 50
|
Posted: Sat Dec 12, 2009 9:56 pm Post subject: |
|
|
| jaco0646 wrote: | A note about Gui, Destroy.
| VibrantLife wrote: | | I just put GoSub GuiClose at every Label | You might want to post your latest code for some pointers. It is rare that redundant code is ever necessary. It can usually be eliminated. |
Thanks for Mention that jaco
I have not done much yet but:
Just like to perform the actions at labelOne till LabelThree(and beyond) when that checkbox is Checked
and then close Gui, not Exitapp, because it has some hotkeys.
| Code: |
Items = Lastname|First Name|MiddleName|Initials|E-mail Werk|Assistant|Assistant Mail|Manager|Partner Naam|Titel|Suffix|Man|Vrouw|Telefoon Werk|Fax Werk|Mobiel Werk|Assistant Phone|Manager Phone|Huisadres|Home Phone|Mobiel Prive|Fax Home|E-mail Prive
CheckVals = 1|1|1|1|1|1|1|1|1|1|1|1|0|1|1|1|1|1|0|1|1|1|1
StringSplit, ItemArray , Items , | ; Split the items into an array
StringSplit, CheckValsArray, CheckVals, |
xStep = 150
xStart = 10
xVal := xStart
yStep = 27
yStart = 67
yVal := yStart
Gui, +AlwaysOnTop,
Gui, Font, s13 Cwhite w40, Arial BOLD
Loop, %ItemArray0%
{
Gui, Add, Checkbox, x%xVal% y%yVal% w150 h32 Checked vCheckbox%A_Index% gHandlerLabel, % ItemArray%A_Index%
GuiControl,, % ItemArray%A_Index%, % CheckValsArray%A_Index%
; Start a new column after each 8 controls
If (Mod(A_Index, 8) = 0)
{
xVal += xStep
yVal := yStart
}
else
{
yVal += yStep
}
}
Gui, Add, Button, x85 y300 w130 h30 gSelect, Selecteer Alles
Gui, Add, Button, x230 y300 w130 h30 gDeselect, Selecteer Niets
Gui, Add, Button, default x85 y10 w280 h50 gToevoegen, Toevoegen :-D ; Means: Add!!
Gui, Show, x0 y665 h330 w465 NoActivate, Veld selectie
Gui, Color, 63769b
Return
Select: ; select all checkboxes
Loop 23
GuiControl, , CheckBox%A_Index%, 1
return
Deselect: ; deselect all checkboxes
Loop 23
GuiControl, , CheckBox%A_Index%, 0
return
HandlerLabel:
GuiControlGet, CheckboxValue,, %A_GuiControl%
;Msgbox % (CheckboxValue = 1 ? "You checked " A_GuiControl : "You unchecked " . A_GuiControl)
Return
Toevoegen:
Gui, Submit, NoHide
Labels = LabelOne|LabelTwo|LabelThree
StringSplit, LabelArray, Labels, |
Loop, %ItemArray0%
{
If (Checkbox%A_Index% = 1) and IsLabel(LabelArray%A_Index%)
GoSub, % LabelArray%A_Index%
}
Return
LabelOne:
#Persistent
ToolTip, you checked LastName
SetTimer, RemoveToolTip1, 1500
sleep, 1000
return
RemoveToolTip1:
SetTimer, RemoveToolTip1, Off
ToolTip
return
LabelTwo:
#Persistent
ToolTip, you checked FirstName
SetTimer, RemoveToolTip2, 1500
sleep, 1000
return
RemoveToolTip2:
SetTimer, RemoveToolTip2, Off
ToolTip
return
LabelThree:
#Persistent
ToolTip, you checked MiddleName
SetTimer, RemoveToolTip3, 1500
sleep, 1000
return
RemoveToolTip3:
SetTimer, RemoveToolTip3, Off
ToolTip
return
|
Nevermind
When i changed NoHide into:
the Gui did also disapear
| Code: |
Toevoegen:
Gui, Submit, Hide
|
_________________ The signature is away at the moment, please leave a message after the beep... |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|