SuperFletch Posted June 26, 2008 Share Posted June 26, 2008 Hi, Been away for a while but now I'm having a bit of difficulty with trying to get AutoIt to do what I want. What I'm trying to achieve is this. I have searched similar threads and can see people have answered this in one way or another before but I really couldn't make sense of what it is I need to do. I have 6 checkboxes in a GUI and for each one (in sequence) I want my code to first check whether the box is ticked or not and then call a particular function, my script should work a bit like this: If the first check box is checked it does function A, if it isn't checked then funtion B. It should then check the second box... If the second check box is checked it does function C, if it isn't checked then funtion D. It should then check the third box... If the third check box is checked it does function E, if it isn't checked then funtion F. and so on through to the last (sixth) checkbox. To begin with I tried assigning variables to the GUICtrlRead results and passed them into notepad to check them. I found that the GUIctrlRead was passing (I think) the correct result wheras the varible was not. I'll try and explain a bit more - If a box was ticked then GUICtrlRead would pass a 4 to notepad, but if it wasn't it would pass a 1. However the data stored in the variables (Which I thought I was correctly assigning the value of GuiCtrlRead) would always pass a 4 to notepad whether the box was ticked or not. So my question is really this.... Can someone help me get my code to determine whether a box is actually checked or not. Then based on that information tell it to process either task A or task B before moving on to the next check box to carry out a similar routine. I've been messing around with GuiCtrlRead, Call, Func and a few other commands to do with variables but I'm starting to get frustrated now. From reading the help file I think I need to be working with the GUICtrlRead command to get values of $GUI_CHECKED, or $GUI_UNCHECKED but I'm having trouble doing it. If someone can just show me how to get that info and maybe store it in a variable for when the initial GUI window closes that would be great. I know AutoIt can do what I want but I seem to be missing something. I can post code if needed but in fairness I had some decent code before and have now probably taken a backward step in trying to adapt it!! TIA Matt. Link to comment Share on other sites More sharing options...
monoceres Posted June 26, 2008 Share Posted June 26, 2008 A little sample expandcollapse popup#include <GUIConstantsEx.au3> Opt("GUIOnEventMode",1) GUICreate("Sample",300,200) $checkbox=GUICtrlCreateCheckbox("Check me!",10,10) GUICtrlSetOnEvent(-1,"_CheckBoxChecked") $checkbox2=GUICtrlCreateCheckbox("Check me too!",10,40) GUICtrlSetOnEvent(-1,"_CheckBoxChecked") GUISetOnEvent(-3,"close") GUISetState() Do Sleep(100) Until False Func close() Exit EndFunc Func _CheckBoxChecked() If BitAND(GUICtrlRead($checkbox),$GUI_CHECKED)=$GUI_CHECKED Then ; do something Msgbox(0,"Checkbox 1","The button is checked") Else ; do something else Msgbox(0,"Checkbox 1","The button is not checked") EndIf If BitAND(GUICtrlRead($checkbox2),$GUI_CHECKED)=$GUI_CHECKED Then ; do something Msgbox(0,"Checkbox 2","The button is checked") Else ; do something else Msgbox(0,"Checkbox 2","The button is not checked") EndIf EndFunc Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
SuperFletch Posted June 26, 2008 Author Share Posted June 26, 2008 Thanks Monoceres, I'll give that a go tonight. I can follow what you are doing with what you posted so I'll let you know how it goes. Cheers, Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now