AutoHotkey Community

It is currently May 27th, 2012, 12:34 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: December 13th, 2009, 4:20 am 
Offline

Joined: October 29th, 2009, 10:03 pm
Posts: 50
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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2009, 4:27 am 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2009, 4:46 am 
Offline

Joined: October 29th, 2009, 10:03 pm
Posts: 50
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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2009, 5:17 am 
Offline

Joined: December 21st, 2008, 7:29 pm
Posts: 181
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2009, 5:30 am 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
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%

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2009, 5:52 am 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2009, 7:14 pm 
Offline

Joined: October 29th, 2009, 10:03 pm
Posts: 50
Great crash course GUI controls :lol:

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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2009, 2:45 am 
Offline

Joined: October 29th, 2009, 10:03 pm
Posts: 50
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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2009, 4:14 pm 
Offline

Joined: October 29th, 2009, 10:03 pm
Posts: 50
Can someone please look at my post/code above this message?
How can this be fixed? :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2009, 6:40 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
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
}

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2009, 8:26 pm 
Offline

Joined: October 29th, 2009, 10:03 pm
Posts: 50
Ah your fabulous, that works like a dream! ImageImage

I learn so much from this :D

The other guys also:...Gracias!

_________________
The signature is away at the moment, please leave a message after the beep...


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: iDrug, Leef_me, Ohnitiel, rjgatito, Yahoo [Bot] and 24 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group