IsmokeIdrank Posted August 8, 2012 Share Posted August 8, 2012 I've been stuck on this for hours now and I'm completely stumped... I have 2 checkboxes that depending on which one is checked, a part of the script will be run, I have it working perfectly fine for 1 of the boxes but the 2nd one just sits there when I check it, no errors. While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $checkbox1 if GUIctrlread($Checkbox1) = $GUI_CHECKED Then EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $checkbox2 if GUIctrlread($Checkbox2) = $GUI_CHECKED Then EndIf This is an example of the code that I have on top of part 1, and part 2. What exactly am I missing? Link to comment Share on other sites More sharing options...
jdelaney Posted August 8, 2012 Share Posted August 8, 2012 (edited) use this to check if a checkbox is checked...it's possible it has many states If BitAND ( GUICtrlRead ( $Checkbox2 ), $GUI_CHECKED ) Then ; your code EndIf Edited August 8, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
IsmokeIdrank Posted August 8, 2012 Author Share Posted August 8, 2012 use this to check if a checkbox is checked...it's possible it has many states If BitAND ( GUICtrlRead ( $Checkbox2 ), $GUI_CHECKED ) Then ; your code EndIf I've tried that as well and still nothing...While 1 $bMsg = GUIGetMsg() Switch $bMsg Case $GUI_EVENT_CLOSE Exit Case $checkbox2 If BitAND (GUICtrlRead($checkbox2), $GUI_CHECKED) then mouseclick("left",760,910) EndIf Link to comment Share on other sites More sharing options...
jdelaney Posted August 8, 2012 Share Posted August 8, 2012 (edited) add a messagebox inside the If BitAnd... statement...so you can verify it works. It's possible your clicks are not doing what you want it to. If BitAND ( GUICtrlRead ( $Checkbox2 ), $GUI_CHECKED ) Then msgbox ( 1,1, "inside loop for $Checkbox2, because it is checked") EndIf Edited August 8, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
IsmokeIdrank Posted August 8, 2012 Author Share Posted August 8, 2012 add a messagebox inside the If BitAnd... statement...so you can verify it works. It's possible your clicks are not doing what you want it to. If BitAND ( GUICtrlRead ( $Checkbox2 ), $GUI_CHECKED ) Then msgbox ( 1,1, "inside loop for $Checkbox2, because it is checked") EndIf yeah even with that, nothing... Very stumped lol Link to comment Share on other sites More sharing options...
jdelaney Posted August 8, 2012 Share Posted August 8, 2012 (edited) doesn't get much simpler than this...use this to debug yours: #include <WindowsConstants.au3> #include <GuiConstants.au3> $Main_GUI = GUICreate("Main", 100, 50) GUISetState(@SW_SHOW, $Main_GUI) $checkbox = GUICtrlCreateCheckbox('Checkbox', 15, 15) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $checkbox $sCheckedState = BitAND ( GUICtrlRead ( $checkbox ), $GUI_CHECKED ) msgbox ( 1,1, "inside loop for $checkbox, IsChecked=[" & $sCheckedState & "].") EndSwitch WEnd Edited August 8, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
BrewManNH Posted August 8, 2012 Share Posted August 8, 2012 (edited) Try this. While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $checkbox1 If GUICtrlRead($checkbox1) = $GUI_CHECKED Then MsgBox(64, "", "Checkbox 1 checked") Else MsgBox(48, "", "Checkbox 1 unchecked") EndIf Case $checkbox2 If GUICtrlRead($checkbox2) = $GUI_CHECKED Then MsgBox(64, "", "Checkbox 2 checked") Else MsgBox(48, "", "Checkbox 2 unchecked) EndIf EndSwitch WEnd EDIT: Missing quote Edited August 8, 2012 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
IsmokeIdrank Posted August 8, 2012 Author Share Posted August 8, 2012 (edited) doesn't get much simpler than this...use this to debug yours: $Main_GUI = GUICreate("Main", 100, 50) GUISetState(@SW_SHOW, $Main_GUI) $checkbox = GUICtrlCreateCheckbox('Checkbox', 15, 15) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $checkbox $sCheckedState = BitAND ( GUICtrlRead ( $checkbox ), $GUI_CHECKED ) msgbox ( 1,1, "inside loop for $checkbox, IsChecked=[" & $sCheckedState & "].") EndSwitch WEnd I copied the script and it only seems to work once, if I put it in my 2nd checkbox script, it does nothing, if I remove the first checkbox, then it works, or if I flip this script with the 1st one, it works and if I have the script copied exactly other than the $checkbox1/2 it only works for 1.. I'm clearly missing something here aren't I? *edit* BrewMan ninja'd in here before I saw lol Your script is working and acknowledging when either box is click, going to incorporate it into my script and see if i can get it work, thanks Edited August 8, 2012 by IsmokeIdrank Link to comment Share on other sites More sharing options...
jdelaney Posted August 8, 2012 Share Posted August 8, 2012 with 2 checkboxes: #include <WindowsConstants.au3> #include <GuiConstants.au3> $Main_GUI = GUICreate("Main", 100, 75) GUISetState(@SW_SHOW) $checkbox = GUICtrlCreateCheckbox('Checkbox', 15, 15) $checkbox2 = GUICtrlCreateCheckbox('Checkbox2', 15, 40) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $checkbox $sCheckedState = BitAND(GUICtrlRead($checkbox), $GUI_CHECKED) MsgBox(1, 1, "inside loop for $checkbox, IsChecked=[" & $sCheckedState & "].") Case $checkbox2 $sCheckedState = BitAND(GUICtrlRead($checkbox2), $GUI_CHECKED) MsgBox(1, 1, "inside loop for $checkbox2, IsChecked=[" & $sCheckedState & "].") EndSwitch WEnd IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
IsmokeIdrank Posted August 9, 2012 Author Share Posted August 9, 2012 Now I can't get the boxes to actually start my scripts even though I had at least 1 of them working lastnight :/ So I need to know what's a reliable command to use in where I put the comments because I've tried multiple things and I think I'm just doing something wrong. expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> #include <GuiButton.au3> #include <GDIPlus.au3> global $myGUI global $paused global $checkbox1 global $checkbox2 global $wcounter = 1 global $lcounter = 1 global $dcounter = 1 Local $B HotKeySet("{ESC}", "Terminate") $myGUI = GUIcreate("Test",200,200,25,500, BitOr($WS_BORDER, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) $checkbox1 = GUICtrlCreateCheckbox(" ",50,170) $checkbox2 = GUICtrlCreateCheckbox(" ",135,170) $WDisplay = GUICtrlCreatelabel("", 0,125) $LDisplay = GUICtrlCreatelabel("", 100,125) $DDisplay = GUICtrlCreatelabel("", 180,125) $W = Guictrlcreatelabel("W",5,100) $l = Guictrlcreatelabel("L",85,100) $D = Guictrlcreatelabel("D",165,100) $B = Guictrlcreatepic("C:\Program Files\AutoIt3\Examples\GUI\Logo.jpg",0,0,200,100) $Check1 = Guictrlcreatelabel("Check1",35,155) $Check2 = guictrlcreatelabel("Check2",127,155) GUISetBkColor(0x000000) GUIctrlsetcolor($W, 0xA98D77) GUIctrlsetcolor($L, 0xA98D77) GUIctrlsetcolor($D, 0xA98D77) GUIctrlsetcolor($check1, 0xA98D77) GUIctrlsetcolor($check2, 0xA98D77) Guictrlsetcolor($WDisplay, 0xA98D77) Guictrlsetcolor($LDisplay, 0xA98D77) Guictrlsetcolor($DDisplay, 0xA98D77) GUISetState() While 1 ;Checkbox status $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $checkbox1 If GUICtrlRead($checkbox1) = $GUI_CHECKED Then MsgBox(64, "", "Check1 On") Else MsgBox(48, "", "Check1 Off") EndIf Case $checkbox2 If GUICtrlRead($checkbox2) = $GUI_CHECKED Then MsgBox(64, "", "Check2 On") Else MsgBox(48, "", "Check2 Off") EndIf EndSwitch WEnd While 1 ;Script1 ;;if Checkbox1 on then;; <=== If pixelgetcolor(914,381) = 0x227994 then mouseclick("left",1018,657) EndIf If pixelgetcolor(437,461) = 0xEBC97A Then mouseclick("left",755,767) $wcounter = $wcounter + 1 GUICtrlsetdata($winsdisplay, $Wcounter) EndIf If pixelgetcolor(630,521) = 0xFFFFFF then mouseclick("left",680,625) EndIf If pixelgetcolor(536,431) = 0x425C66 then mouseclick("left",770,720) $lcounter = $lcounter + 1 GUICtrlsetdata($losedisplay, $Lcounter) EndIf If pixelgetcolor(601,466) = 0x647556 then mouseclick("left",760,715) $dcounter = $dcounter + 1 GUICtrlsetdata($drawdisplay, $dcounter) EndIf WEnd While 1 ;Script2 ;;if Checkbox2 on then;; <=== If Pixelgetcolor(439, 679) = 0xB24C1E Then mouseclick("left",439,679) endif If pixelgetcolor(803, 736) = 0x06334A then mouseclick("left",800,800) EndIf If pixelgetcolor(437,461) = 0xEBC97A Then mouseclick("left",770,720) EndIf If pixelgetcolor(536,431) = 0x425C66 then mouseclick("left",770,720) EndIf If pixelgetcolor(601,466) = 0x647556 then mouseclick("left",760,715) EndIf sleep(1000) WEnd Func Terminate() ;Exit Exit 0 EndFunc PS> I have another topic up on this discussion board but the inputs of $wdisplay/$ldisplay/$ddisplay being counted are not working either ._. Link to comment Share on other sites More sharing options...
BrewManNH Posted August 9, 2012 Share Posted August 9, 2012 There's no way for the script to exit the first While loop, so the second one is never going to get started. You need to make the second While loop a couple of functions, or use ExitLoop to get out of the While loop. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
IsmokeIdrank Posted August 9, 2012 Author Share Posted August 9, 2012 There's no way for the script to exit the first While loop, so the second one is never going to get started. You need to make the second While loop a couple of functions, or use ExitLoop to get out of the While loop.Oh thank god finally! lol Got that all figured out, thanks a bunch Brew, now to figure out my displays 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