 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
VibrantLife
Joined: 29 Oct 2009 Posts: 50
|
Posted: Sun Dec 13, 2009 3:20 am Post subject: Checkbox behave like a Radiobutton |
|
|
What a let-down,
I tried to get 2 Checkboxes behave like a Radiobutton:
But it isn't switching
| Code: |
CheckBox12:
Gui, Submit, NoHide
if Checkbox12 = 1
{
GuiControl,, CheckBox13, 0
}
return
CheckBox13:
Gui, Submit, NoHide
if Checkbox13 = 1
{
GuiControl,, CheckBox12, 0
}
return |
_________________ 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: Sun Dec 13, 2009 3:27 am Post subject: |
|
|
| Code: | Gui, Add, CheckBox, vCheckBox12 gCheckBox12
Gui, Add, CheckBox, vCheckBox13 gCheckBox13
Gui, Show
return
GuiClose:
ExitApp
CheckBox12:
Gui, Submit, NoHide
if Checkbox12
GuiControl,,CheckBox13, 0
return
CheckBox13:
Gui, Submit, NoHide
if Checkbox13
GuiControl,,CheckBox12, 0
return | ...but why not just use radio buttons? |
|
| Back to top |
|
 |
VibrantLife
Joined: 29 Oct 2009 Posts: 50
|
Posted: Sun Dec 13, 2009 3:46 am Post subject: |
|
|
| jaco0646 wrote: | | Code: | Gui, Add, CheckBox, vCheckBox12 gCheckBox12
Gui, Add, CheckBox, vCheckBox13 gCheckBox13
Gui, Show
return
GuiClose:
ExitApp
CheckBox12:
Gui, Submit, NoHide
if Checkbox12
GuiControl,,CheckBox13, 0
return
CheckBox13:
Gui, Submit, NoHide
if Checkbox13
GuiControl,,CheckBox12, 0
return | ...but why not just use radio buttons? |
Because The Checkboxes are created with an Array
I didn't know how to incorporate it in the script.
i know that Checkbox12 & 13 are the one's i need(its a switch between Male & Female)
| 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, MS CRM 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, Hide
Labels = LabelOne|LabelTwo|LabelThree
StringSplit, LabelArray, Labels, |
Loop, %ItemArray0%
{
If (Checkbox%A_Index% = 1) and IsLabel(LabelArray%A_Index%)
GoSub, % LabelArray%A_Index%
}
Return
CheckBox12:
Gui, Submit, NoHide
if Checkbox12
GuiControl,,CheckBox13, 0
return
CheckBox13:
Gui, Submit, NoHide
if Checkbox13
GuiControl,,CheckBox12, 0
return
LabelOne:
#Persistent
ToolTip, you checked LastName
SetTimer, RemoveToolTip1, 1500
sleep, 1000
return
RemoveToolTip1:
SetTimer, RemoveToolTip1, Off
ToolTip
return
LabelTwo:
msgbox, gelukt
#Persistent
ToolTip, you checked FirstName
SetTimer, RemoveToolTip2, 1500
sleep, 1000
return
RemoveToolTip2:
SetTimer, RemoveToolTip2, Off
ToolTip
return
LabelThree:
msgbox, ItemArray%A_Index%
#Persistent
ToolTip, you checked MiddleName
SetTimer, RemoveToolTip3, 1500
sleep, 1000
return
RemoveToolTip3:
SetTimer, RemoveToolTip3, Off
ToolTip
return
|
_________________ 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: Sun Dec 13, 2009 4:17 am Post subject: |
|
|
You can change the variables names or labels if you desire...
| 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%
{
If (A_Index = 12 or A_Index = 13)
Gui, Add, Radio , x%xVal% y%yVal% w150 h32 Checked vCheckbox%A_Index% gHandlerLabel, % ItemArray%A_Index%
else
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, MS CRM 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, Hide
Labels = LabelOne|LabelTwo|LabelThree
StringSplit, LabelArray, Labels, |
Loop, %ItemArray0%
{
If (Checkbox%A_Index% = 1) and IsLabel(LabelArray%A_Index%)
GoSub, % LabelArray%A_Index%
}
Return
CheckBox12:
Gui, Submit, NoHide
if Checkbox12
GuiControl,,CheckBox13, 0
return
CheckBox13:
Gui, Submit, NoHide
if Checkbox13
GuiControl,,CheckBox12, 0
return
LabelOne:
#Persistent
ToolTip, you checked LastName
SetTimer, RemoveToolTip1, 1500
sleep, 1000
return
RemoveToolTip1:
SetTimer, RemoveToolTip1, Off
ToolTip
return
LabelTwo:
msgbox, gelukt
#Persistent
ToolTip, you checked FirstName
SetTimer, RemoveToolTip2, 1500
sleep, 1000
return
RemoveToolTip2:
SetTimer, RemoveToolTip2, Off
ToolTip
return
LabelThree:
msgbox, ItemArray%A_Index%
#Persistent
ToolTip, you checked MiddleName
SetTimer, RemoveToolTip3, 1500
sleep, 1000
return
RemoveToolTip3:
SetTimer, RemoveToolTip3, Off
ToolTip
return
|
|
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Sun Dec 13, 2009 4:30 am Post subject: |
|
|
Wouldn't this work to set up the checkboxes?
| 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
xStep = 150
xStart = 10
xVal := xStart
yStep = 27
yStart = 67
yVal := yStart
Loop, Parse, Items, |
{
if !Mod(A_Index,8)
xVal+=xStep, yVal:=yStart
Gui, Add, Checkbox, x%xVal% y%yVal% w150 h32 vCheckbox%A_Index% gCheckbox%A_Index%, %A_LoopField%
yVal += yStep
}
Loop, Parse, CheckVals, |
GuiControl, , CheckBox%A_Index%, %A_LoopField% |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Sun Dec 13, 2009 4:52 am Post subject: |
|
|
Yeah, I would definitely use a parsing loop rather than StringSplit. | 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
Gui, +AlwaysOnTop
Gui, Font, s13 Cwhite w40, Arial BOLD
Gui, Add, Button, Default xm+80 w280 gToevoegen, Toevoegen :-D
Loop, Parse, Items, |
{
If A_Index in 13,19
on = 0
Else on = 1
If A_Index in 12,13
control = Radio
Else control = CheckBox
; Start a new column after each 8 controls
y := A_Index=1 ? "Section xm":Mod(A_Index-1, 8) ? "":"ys"
Gui, Add, %control%, %y% Checked%on% vCheckBox%A_Index% gToolTip, %A_LoopField%
count := A_Index ;Count the items
}
Gui, Add, Button, xm+80 gSelect, Selecteer Alles
Gui, Add, Button, x+10 gDeselect, Selecteer Niets
Gui, Show, NoActivate, MS CRM Veld selectie
Gui, Color, 63769b
return
;___________________________________________________________
Select:
Deselect:
Loop,%count%
GuiControl,,CheckBox%A_Index%,% A_ThisLabel="Select" ? 1:0
return
Toevoegen:
ToolTip
Gui, Submit
return
ToolTip:
Gui, Submit, NoHide
If !%A_GuiControl%
return
GuiControlGet, txt,,%A_GuiControl%, Text
ToolTip, You checked "%txt%"
SetTimer, RemoveTip, -5000
return
RemoveTip:
ToolTip
return |
|
|
| Back to top |
|
 |
VibrantLife
Joined: 29 Oct 2009 Posts: 50
|
Posted: Sun Dec 13, 2009 6:14 pm Post subject: |
|
|
Great crash course GUI controls
Thank you so much!
I understood the old code almost,
How to define here an separate action for each Gui Control..?
Like, for example perform on checked Radiobutton item Man:
| Code: |
Man:
COM_init()
iweb_init()
WinWait, Invoeren persoon,
IfWinNotActive, Invoeren persoon, , WinActivate, Invoeren persoon ,
WinWaitActive, Invoeren persoon,
sleep 50
pwb:=iWeb_getwin("Invoeren persoon")
COM_Invoke(pwb, "document.all.item[ctl00xKxHxMAxFAxIAxgeslachtEdit_input].focus")
sleep, 100
Send, Man
sleep, 100
COM_Release(pwb)
iWeb_Term()
COM_Term()
return
|
| Code: |
Vrouw:
COM_init()
iweb_init()
WinWait, Invoeren persoon,
IfWinNotActive, Invoeren persoon, , WinActivate, Invoeren persoon ,
WinWaitActive, Invoeren persoon,
sleep 50
pwb:=iWeb_getwin("Invoeren persoon")
COM_Invoke(pwb, "document.all.item[ctl00xKxHxMAxFAxIAxgeslachtEdit_input].focus")
sleep, 100
Send, Vrouw
sleep, 100
COM_Release(pwb)
iWeb_Term()
COM_Term()
return
|
_________________ The signature is away at the moment, please leave a message after the beep... |
|
| Back to top |
|
 |
VibrantLife
Joined: 29 Oct 2009 Posts: 50
|
Posted: Tue Dec 15, 2009 1:45 am Post subject: |
|
|
Why is it, that, When i Check CheckBox1(Lastname) And CheckBox2(Firstname) and Press Toevoegen(Add) button,
I not see any messagebox below appearing: ??
| Code: |
Msgbox, LastName action is performed
Msgbox, FirstName action is performed |
Why is Button Toevoegen(add) seems dead?
| 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
Gui, +AlwaysOnTop
Gui, Font, s13 Cwhite w40, Arial BOLD
Gui, Add, Button, Default xm+80 w280 gToevoegen, Toevoegen :-D ; means add!!
Loop, Parse, Items, |
{
If A_Index in 13,19
on = 0
Else on = 1
If A_Index in 12,13
control = Radio
Else control = CheckBox
; Start a new column after each 8 controls
y := A_Index=1 ? "Section xm":Mod(A_Index-1, 8) ? "":"ys"
Gui, Add, %control%, %y% Checked%on% vCheckBox%A_Index% gToolTip, %A_LoopField%
count := A_Index ;Count the items
}
Gui, Add, Button, xm+80 gSelect, Selecteer Alles
Gui, Add, Button, x+10 gDeselect, Selecteer Niets
Gui, Show, x0 y665 NoActivate, MS CRM Veld selectie
Gui, Color, 63769b
return
;___________________________________________________________
Select:
Deselect:
Loop,%count%
GuiControl,,CheckBox%A_Index%,% A_ThisLabel="Select" ? 1:0
return
Toevoegen:
Gui, Submit, nohide
Loop {
If(CheckBox%A_Index% and IsLabel(CheckBox%A_Index%))
Gosub, CheckBox%A_Index%
Else if CheckBox%A_Index% =
Break
}
return
ToolTip:
Gui, Submit, NoHide
If !%A_GuiControl%
return
GuiControlGet, txt,,%A_GuiControl%, Text
ToolTip, You checked "%txt%"
SetTimer, RemoveTip, -5000
return
RemoveTip:
ToolTip
return
Checkbox1:
Gui, Submit, NoHide
Msgbox, Lastname is performed ;just for testing
return
CheckBox2:
Gui, Submit, NoHide
Msgbox, First name action is performed ;just for testing
return
|
_________________ The signature is away at the moment, please leave a message after the beep... |
|
| Back to top |
|
 |
VibrantLife
Joined: 29 Oct 2009 Posts: 50
|
Posted: Tue Dec 15, 2009 3:14 pm Post subject: |
|
|
Can someone please look at my post/code above this message?
How can this be fixed?  |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Tue Dec 15, 2009 5:40 pm Post subject: |
|
|
Remove the check for IsLabel(). Your coding logic should dictate that if the checkbox exists then the subroutine exists, so there's no need to check if both exist.
And if you're going to set GUI item attributes by using a variable anyway, this will probably keep your parsing loop much cleaner:
| Code: | Loop, Parse, Items, |
{
y:=A_Index=1 ? "Section xm":Mod(A_Index-1, 8) ? "":"ys"
ctrl:=A_Index=12 || A_Index=13 ? "Radio" : "CheckBox"
chckd:=A_Index=13 || A_Index=19 ? "" : "Checked"
Gui, Add, %ctrl%, %y% %chckd% vCheckBox%A_Index% gToolTip, %A_LoopField%
count := A_Index ;Count the items
} |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
VibrantLife
Joined: 29 Oct 2009 Posts: 50
|
Posted: Tue Dec 15, 2009 7:26 pm Post subject: |
|
|
Ah your fabulous, that works like a dream! 
I learn so much from this
The other guys also:...Gracias! _________________ 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
|