AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Uncheck All?? Checkbox question

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Hannibal_32



Joined: 15 May 2009
Posts: 14
Location: Tulsa, OK

PostPosted: Tue May 26, 2009 4:19 pm    Post subject: Uncheck All?? Checkbox question Reply with quote

Hey guys.. Have a really quick question that I was unable to solve by looking into previous posts. I have a script with 42 checkboxes.. I would like for the user to be able to undo all of the checkboxes with an "uncheck" box, rather than unchecking all of them individually. Is this possible??

Thanks,

H
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 5044
Location: the tunnel(?=light)

PostPosted: Tue May 26, 2009 4:35 pm    Post subject: Reply with quote

If the ClassNN of the checkboxes are an incrementing value (Button1, Button2, etc.) you should be able to run a loop to uncheck them all:

Code:
SetControlDelay -1
Loop, 42
  GuiControl, CheckBox, Button%A_Index%, 0 ; 0 indicates unchecked checkbox

_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message Send e-mail
Hannibal_32



Joined: 15 May 2009
Posts: 14
Location: Tulsa, OK

PostPosted: Tue May 26, 2009 5:14 pm    Post subject: Reply with quote

Hey Sink.. Unfortunately, my buttons are not sequentially named, nor can they be. Good idea for the future though.. Is there a way to shorten this?

Code:

ButtonUncheckAll:
GuiControl, , CB1, 0
GuiControl, , CB2, 0
GuiControl, , CB3, 0
GuiControl, , CB4, 0
GuiControl, , CB5, 0
GuiControl, , CB6, 0
GuiControl, , CB7, 0
GuiControl, , CB8, 0
GuiControl, , CB9, 0
GuiControl, , CB10, 0
GuiControl, , CB11, 0
GuiControl, , CB12, 0
GuiControl, , CB13, 0
GuiControl, , CB14, 0
GuiControl, , CB15, 0
GuiControl, , CB16, 0
GuiControl, , CB17, 0
GuiControl, , CB18, 0
GuiControl, , CB19, 0
GuiControl, , CB20, 0
GuiControl, , CB21, 0
GuiControl, , CB22, 0
GuiControl, , CB23, 0
GuiControl, , CB24, 0
GuiControl, , CB25, 0
GuiControl, , CB26, 0
GuiControl, , CB27, 0
GuiControl, , CB28, 0
GuiControl, , CB29, 0
GuiControl, , CB30, 0
GuiControl, , CB31, 0
GuiControl, , CB32, 0
GuiControl, , CB33, 0
GuiControl, , CB34, 0
GuiControl, , CB35, 0
GuiControl, , CB36, 0
GuiControl, , CB37, 0
GuiControl, , CB38, 0
GuiControl, , CB39, 0
GuiControl, , CB40, 0
GuiControl, , CB41, 0
GuiControl, , CB42, 0
return
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 5044
Location: the tunnel(?=light)

PostPosted: Tue May 26, 2009 5:26 pm    Post subject: Reply with quote

Hannibal_32 wrote:
Unfortunately, my buttons are not sequentially named, nor can they be.


Oh no what I meant was when you physically open the GUI and check the ClassNN of the checkbox controls, usually they are sequential.

Theoretically you should still be able to shorten it the same way using your variables:


Code:
ButtonUncheckAll:
SetControlDelay -1
Gui, Submit, NoHide
Loop, 42
  GuiControl, CheckBox, CB%A_Index%, 0


If that doesn't appear to work you can always clear out the 'CheckBox' section of the GUIControl command and try again but I think that will be necessary to set the checkbox properly.
_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message Send e-mail
Hannibal_32



Joined: 15 May 2009
Posts: 14
Location: Tulsa, OK

PostPosted: Tue May 26, 2009 5:38 pm    Post subject: Reply with quote

AHHHHH.. That makes a lot of sense.. I think I finally understand the loop command..

THANKS!

H
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group