drx Posted May 27, 2011 Share Posted May 27, 2011 Well, i've been staring at this script for four days on and off.....The first part works as it should calling my second form.....but the second form just sits there, all buttons do nothing, even the close button. I thought i was over looking something, so i re-wrote the whole thing i another script to just test the form, same result. WHAT am i missing :[ expandcollapse popupFunc first() $frmfirst = GUICreate("Post-Installer", 199, 160, -1, -1) $dsk = GUICtrlCreateButton("DESKTOP", 8, 32, 177, 49, 0) GUICtrlSetOnEvent(-1, "dsk") $lap = GUICtrlCreateButton("LAPTOP", 8, 88, 177, 57, 0) GUICtrlSetOnEvent(-1, "lap") $lbl1 = GUICtrlCreateLabel("Please Choose Workstation Type", 16, 8, 162, 17) GUISetState() While 1 $rt1 = GUIGetMsg() Select Case $rt1 = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd EndFunc Func dsk() $choice = 1 GUISetState(@SW_HIDE, $frmfirst) second() EndFunc func lap() $choice = 2 GUISetState(@SW_HIDE, $frmfirst) second() EndFunc Func second() $frmsecond = GUICreate('Pre-Installer Options',400,150) GUISetOnEvent($GUI_EVENT_CLOSE, "x") $CBav = GUICtrlCreateCheckbox("FIRST PROGRAM",10,20,150,20) GUICtrlSetState($CBav,$GUI_CHECKED) $CBsee = GUICtrlCreateCheckbox("SECOND PROGRAM",10,40,150,20) GUICtrlSetState($CBsee,$GUI_CHECKED) $CBsee2 = GUICtrlCreateCheckbox("THIRD PROGRAM (Laptops ONLY!)",10,60,250,20) $BTbck = GUICtrlCreateButton("< BACK", 256, 111, 57, 25, 0) GUICtrlSetOnEvent(-1, "back") $BTnxt = GUICtrlCreateButton("NEXT >", 325, 111, 57, 25, 0) GUICtrlSetOnEvent(-1, "process") GUISetState() if $choice = 1 Then GUICtrlSetState($CBsee2,$GUI_DISABLE) Else GUICtrlSetState($CBsee2,$GUI_ENABLE) GUICtrlSetState($CBsee2,$GUI_CHECKED) EndIf $rt2 = GUIGetMsg() If $rt2 = -3 Then Exit EndIf If GUICtrlRead($CBav) = 1 Then $av = 1 Else $av = 0 EndIf if GUICtrlRead($CBsee) = 1 Then $see = 1 Else $see = 0 EndIf if GUICtrlRead($CBsee2) = 1 Then $see2 = 1 Else $see2 = 0 EndIf While GUIGetMsg() <> $GUI_EVENT_CLOSE sleep(1000) WEnd EndFunc The Func "process" just runs the installs with runwaits.... Why oh why do these not work :/ Link to comment Share on other sites More sharing options...
November Posted May 27, 2011 Share Posted May 27, 2011 Hi there, expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <Timers.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Dim $frmfirst, $choice $frmfirst = GUICreate("Post-Installer", 199, 160, -1, -1) $dsk = GUICtrlCreateButton("DESKTOP", 8, 32, 177, 49, 0) GUICtrlSetOnEvent(-1, "dsk") $lap = GUICtrlCreateButton("LAPTOP", 8, 88, 177, 57, 0) GUICtrlSetOnEvent(-1, "lap") $lbl1 = GUICtrlCreateLabel("Please Choose Workstation Type", 16, 8, 162, 17) GUISetState() first() Func first() While 1 $rt1 = GUIGetMsg() Select Case $rt1 = $GUI_EVENT_CLOSE ExitLoop case $rt1 = $dsk dsk() case $rt1 = $lap lap() EndSelect Sleep(100) WEnd EndFunc Func dsk() $choice = 1 GUISetState(@SW_HIDE, $frmfirst) second() EndFunc func lap() $choice = 2 GUISetState(@SW_HIDE, $frmfirst) second() EndFunc Func second() $frmsecond = GUICreate('Pre-Installer Options',400,150) GUISetOnEvent($GUI_EVENT_CLOSE, "x") $CBav = GUICtrlCreateCheckbox("FIRST PROGRAM",10,20,150,20) GUICtrlSetState($CBav,$GUI_CHECKED) $CBsee = GUICtrlCreateCheckbox("SECOND PROGRAM",10,40,150,20) GUICtrlSetState($CBsee,$GUI_CHECKED) $CBsee2 = GUICtrlCreateCheckbox("THIRD PROGRAM (Laptops ONLY!)",10,60,250,20) $BTbck = GUICtrlCreateButton("< BACK", 256, 111, 57, 25, 0) GUICtrlSetOnEvent(-1, "back") $BTnxt = GUICtrlCreateButton("NEXT >", 325, 111, 57, 25, 0) GUICtrlSetOnEvent(-1, "process") GUISetState() if $choice = 1 Then GUICtrlSetState($CBsee2,$GUI_DISABLE) Else GUICtrlSetState($CBsee2,$GUI_ENABLE) GUICtrlSetState($CBsee2,$GUI_CHECKED) EndIf $rt2 = GUIGetMsg() If $rt2 = -3 Then Exit EndIf If GUICtrlRead($CBav) = 1 Then $av = 1 Else $av = 0 EndIf if GUICtrlRead($CBsee) = 1 Then $see = 1 Else $see = 0 EndIf if GUICtrlRead($CBsee2) = 1 Then $see2 = 1 Else $see2 = 0 EndIf While GUIGetMsg() <> $GUI_EVENT_CLOSE sleep(1000) WEnd EndFunc func x() EndFunc func back() EndFunc func process() endfunc Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 27, 2011 Moderators Share Posted May 27, 2011 drx,WHAT am i missingThe fact that you cannot mix OnEvent and MessageLoop modes in the same script*. Unless you have an Opt("GUIOnEventMode", 1) line somewhere else in your script, your GUICtrlSetOnEvent lines are ignored. And if you do have that line, then GUIGetMsg will always return 0.Rewrite your script to use one or other of the modes and thing will begin to work. If you let me know which mode you wish to use, i can give you a quick starter for 10. M23* Actually you can mix them in the same script, but there is usually little need to do so and you need to take extreme care when you do. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
November Posted May 27, 2011 Share Posted May 27, 2011 drx,The fact that you cannot mix OnEvent and MessageLoop modes in the same script*. Unless you have an Opt("GUIOnEventMode", 1) line somewhere else in your script, your GUICtrlSetOnEvent lines are ignored. And if you do have that line, then GUIGetMsg will always return 0.Rewrite your script to use one or other of the modes and thing will begin to work. If you let me know which mode you wish to use, i can give you a quick starter for 10. M23* Actually you can mix them in the same script, but there is usually little need to do so and you need to take extreme care when you do. Melba,They would be amazed and shocked if they hit F1 over a command in Scite! Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
drx Posted May 27, 2011 Author Share Posted May 27, 2011 What would i use instead of GUIgetmsg for the checkboxes? OnEvent can only be used to call a function correct? What about just setting the variable? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 28, 2011 Moderators Share Posted May 28, 2011 drx,Here is your script rewritten in the 2 modes so you can see the difference.First OnEvent mode:expandcollapse popup; OnEvent mode #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $frmfirst, $frmsecond, $choice = 0, $CBav, $CBsee, $CBsee2 first() While 1 Sleep(10) WEnd Func first() $frmfirst = GUICreate("Post-Installer", 199, 160, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "On_Exit") $dsk = GUICtrlCreateButton("DESKTOP", 8, 32, 177, 49, 0) GUICtrlSetOnEvent(-1, "dsk") $lap = GUICtrlCreateButton("LAPTOP", 8, 88, 177, 57, 0) GUICtrlSetOnEvent(-1, "lap") $lbl1 = GUICtrlCreateLabel("Please Choose Workstation Type", 16, 8, 162, 17) GUISetState() EndFunc Func dsk() $choice = 1 second() EndFunc func lap() $choice = 2 second() EndFunc Func second() GUISetState(@SW_HIDE, $frmfirst) $frmsecond = GUICreate('Pre-Installer Options',400,150) GUISetOnEvent($GUI_EVENT_CLOSE, "back") $CBav = GUICtrlCreateCheckbox("FIRST PROGRAM",10,20,150,20) GUICtrlSetState($CBav,$GUI_CHECKED) $CBsee = GUICtrlCreateCheckbox("SECOND PROGRAM",10,40,150,20) GUICtrlSetState($CBsee,$GUI_CHECKED) $CBsee2 = GUICtrlCreateCheckbox("THIRD PROGRAM (Laptops ONLY!)",10,60,250,20) If $choice = 1 Then GUICtrlSetState($CBsee2,$GUI_DISABLE) Else GUICtrlSetState($CBsee2,$GUI_ENABLE) GUICtrlSetState($CBsee2,$GUI_CHECKED) EndIf $BTbck = GUICtrlCreateButton("< BACK", 256, 111, 57, 25, 0) GUICtrlSetOnEvent(-1, "back") $BTnxt = GUICtrlCreateButton("NEXT >", 325, 111, 57, 25, 0) GUICtrlSetOnEvent(-1, "process") GUISetState() EndFunc Func back() GUISetState(@SW_SHOW, $frmfirst) GUIDelete($frmsecond) $choice = 0 EndFunc Func process() Local $av = 0, $see = 0, $see2 = 0 If GUICtrlRead($CBav) = 1 Then $av = 1 EndIf If GUICtrlRead($CBsee) = 1 Then $see = 1 EndIf If GUICtrlRead($CBsee2) = 1 Then $see2 = 1 EndIf MsgBox(0, "State", "$av:" & @TAB & $av & @CRLF & "$see:" & @TAB & $see & @CRLF & "$see2:" & @TAB & $see2) Exit EndFunc Func On_Exit() Exit EndFuncAnd now MessageLoop mode:expandcollapse popup; MessageLoop mode #include <GUIConstantsEx.au3> Global $frmfirst first() Func first() $frmfirst = GUICreate("Post-Installer", 199, 160, -1, -1) $dsk = GUICtrlCreateButton("DESKTOP", 8, 32, 177, 49, 0) $lap = GUICtrlCreateButton("LAPTOP", 8, 88, 177, 57, 0) $lbl1 = GUICtrlCreateLabel("Please Choose Workstation Type", 16, 8, 162, 17) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $dsk second(1) Case $lap second(2) EndSwitch WEnd EndFunc Func second($choice) GUISetState(@SW_HIDE, $frmfirst) $frmsecond = GUICreate('Pre-Installer Options',400,150) $CBav = GUICtrlCreateCheckbox("FIRST PROGRAM",10,20,150,20) GUICtrlSetState($CBav,$GUI_CHECKED) $CBsee = GUICtrlCreateCheckbox("SECOND PROGRAM",10,40,150,20) GUICtrlSetState($CBsee,$GUI_CHECKED) $CBsee2 = GUICtrlCreateCheckbox("THIRD PROGRAM (Laptops ONLY!)",10,60,250,20) If $choice = 1 Then GUICtrlSetState($CBsee2,$GUI_DISABLE) Else GUICtrlSetState($CBsee2,$GUI_ENABLE) GUICtrlSetState($CBsee2,$GUI_CHECKED) EndIf $BTbck = GUICtrlCreateButton("< BACK", 256, 111, 57, 25, 0) $BTnxt = GUICtrlCreateButton("NEXT >", 325, 111, 57, 25, 0) GUISetState() While 1 Switch GUIGetMsg() Case $BTnxt Local $av = 0, $see = 0, $see2 = 0 If GUICtrlRead($CBav) = 1 Then $av = 1 EndIf If GUICtrlRead($CBsee) = 1 Then $see = 1 EndIf If GUICtrlRead($CBsee2) = 1 Then $see2 = 1 EndIf MsgBox(0, "State", "$av:" & @TAB & $av & @CRLF & "$see:" & @TAB & $see & @CRLF & "$see2:" & @TAB & $see2) Exit Case $GUI_EVENT_CLOSE, $BTbck GUISetState(@SW_SHOW, $frmfirst) GUIDelete($frmsecond) ExitLoop EndSwitch WEnd EndFuncThese 2 scripts are functionally identical, but as you can see they are very different in coding terms.Please study them carefully in conjunction with the <GUI Reference> pages in the Help file. Then if you have any questions, please ask and I will try to explain. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
drx Posted May 31, 2011 Author Share Posted May 31, 2011 Thank you Melba23, you steered me into the right direction. I had the mindset that the button variable would not transfer data between functions for some reason :] After re-writing my code using your example, I figured out my stonewall Now time to debug a few little quarks.... Thanks again! 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