Sign in to follow this  
Followers 0
will88

multiple GUICreate with checkboxes.

3 posts in this topic

Hello, this is my code...

#include <GUIConstants.au3>
HotKeySet("{esc}", "quit")
GUICreate("Update Addons - Menu", 300, 300)  
GUISetState (@SW_SHOW)
$how = GUICtrlCreateButton( "How To Use", 0, 10)

$Start = GUICtrlCreateButton("Start Selected", 281, 370 , 120, 30)

$Menu = GUICtrlCreateMenu ("Menu")
$A = GUICtrlCreateMenuitem ("A",$Menu)
$B = GUICtrlCreateMenuitem ("B",$Menu)
$C = GUICtrlCreateMenuitem ("C",$Menu)
$D = GUICtrlCreateMenuitem ("D",$Menu)
$E = GUICtrlCreateMenuitem ("E",$Menu)
$F = GUICtrlCreateMenuitem ("F",$Menu)
$G = GUICtrlCreateMenuitem ("G",$Menu)
$H = GUICtrlCreateMenuitem ("H",$Menu)
$I = GUICtrlCreateMenuitem ("I",$Menu)
$J = GUICtrlCreateMenuitem ("J",$Menu)
$K = GUICtrlCreateMenuitem ("K",$Menu)
$L = GUICtrlCreateMenuitem ("L",$Menu)
$M = GUICtrlCreateMenuitem ("M",$Menu)
$N = GUICtrlCreateMenuitem ("N",$Menu)
$O = GUICtrlCreateMenuitem ("O",$Menu)
$P = GUICtrlCreateMenuitem ("P",$Menu)
$Q = GUICtrlCreateMenuitem ("Q",$Menu)
$R = GUICtrlCreateMenuitem ("R",$Menu)
$S = GUICtrlCreateMenuitem ("S",$Menu)
$T = GUICtrlCreateMenuitem ("T",$Menu)
$U = GUICtrlCreateMenuitem ("U",$Menu)
$V = GUICtrlCreateMenuitem ("V",$Menu)
$W = GUICtrlCreateMenuitem ("W",$Menu)
$X = GUICtrlCreateMenuitem ("X",$Menu)
$Y = GUICtrlCreateMenuitem ("Y",$Menu)
$Z = GUICtrlCreateMenuitem ("Z",$Menu)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $how
MsgBox(0, "How To Use", "How To Use")
Case $Msg = $Start
$Read = GUICtrlRead($Checkbox1);start
If $Read = $GUI_CHECKED Then
RunWait("notepad")
Sleep(2000)
EndIf
$Read = GUICtrlRead($Checkbox2);start
If $Read = $GUI_CHECKED Then
RunWait('"' & @ProgramFilesDir & '\Internet Explorer\IEXPLORE.EXE"')
Sleep(2000)
EndIf;end
$Read = GUICtrlRead($Checkbox3)
If $Read = $GUI_CHECKED Then
Run('"' & @ProgramFilesDir & '\uTorrent\uTorrent.exe"')
Sleep(2000)
EndIf
;A
Case $msg = $A
Guidelete("Update Addons")
Guidelete($how)
GUICreate("Update Addons - A", 700, 500)
GUISetState (@SW_SHOW)
$Checkbox1 = GUICtrlCreateCheckbox("A", 20, 5)
$Checkbox2 = GUICtrlCreateCheckbox("B", 20, 25)
$Checkbox3 = GUICtrlCreateCheckbox("C", 20, 45)
$Start = GUICtrlCreateButton("Start Selected", 281, 370 , 120, 30)
EndSelect
Wend
Func quit()
exit    
EndFunc

When it runs it guicreates a window, showing a button(How to use) and a menu at the top. Once you click the menu it shows a list A to Z. When I click A it Guideletes and makes a new gui, that shows 3 checkboxes. A, B and C and another button at the bottem(Start Selected).

When I click on checkbox A for some reason it brings up the How to use message box, the rest of them are fine.

What do I edit to make it not bring up the How To use button?

So basically I just want it to: Once A gets clicked in the Menu make a new gui with 3 checkboxes. Once they are all checked it runs them one after another(Already does that part)

Share this post


Link to post
Share on other sites



Hello, this is my code...

#include <GUIConstants.au3>
HotKeySet("{esc}", "quit")
GUICreate("Update Addons - Menu", 300, 300)  
GUISetState (@SW_SHOW)
$how = GUICtrlCreateButton( "How To Use", 0, 10)

$Start = GUICtrlCreateButton("Start Selected", 281, 370 , 120, 30)

$Menu = GUICtrlCreateMenu ("Menu")
$A = GUICtrlCreateMenuitem ("A",$Menu)
$B = GUICtrlCreateMenuitem ("B",$Menu)
$C = GUICtrlCreateMenuitem ("C",$Menu)
$D = GUICtrlCreateMenuitem ("D",$Menu)
$E = GUICtrlCreateMenuitem ("E",$Menu)
$F = GUICtrlCreateMenuitem ("F",$Menu)
$G = GUICtrlCreateMenuitem ("G",$Menu)
$H = GUICtrlCreateMenuitem ("H",$Menu)
$I = GUICtrlCreateMenuitem ("I",$Menu)
$J = GUICtrlCreateMenuitem ("J",$Menu)
$K = GUICtrlCreateMenuitem ("K",$Menu)
$L = GUICtrlCreateMenuitem ("L",$Menu)
$M = GUICtrlCreateMenuitem ("M",$Menu)
$N = GUICtrlCreateMenuitem ("N",$Menu)
$O = GUICtrlCreateMenuitem ("O",$Menu)
$P = GUICtrlCreateMenuitem ("P",$Menu)
$Q = GUICtrlCreateMenuitem ("Q",$Menu)
$R = GUICtrlCreateMenuitem ("R",$Menu)
$S = GUICtrlCreateMenuitem ("S",$Menu)
$T = GUICtrlCreateMenuitem ("T",$Menu)
$U = GUICtrlCreateMenuitem ("U",$Menu)
$V = GUICtrlCreateMenuitem ("V",$Menu)
$W = GUICtrlCreateMenuitem ("W",$Menu)
$X = GUICtrlCreateMenuitem ("X",$Menu)
$Y = GUICtrlCreateMenuitem ("Y",$Menu)
$Z = GUICtrlCreateMenuitem ("Z",$Menu)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $how
MsgBox(0, "How To Use", "How To Use")
Case $Msg = $Start
$Read = GUICtrlRead($Checkbox1);start
If $Read = $GUI_CHECKED Then
RunWait("notepad")
Sleep(2000)
EndIf
$Read = GUICtrlRead($Checkbox2);start
If $Read = $GUI_CHECKED Then
RunWait('"' & @ProgramFilesDir & '\Internet Explorer\IEXPLORE.EXE"')
Sleep(2000)
EndIf;end
$Read = GUICtrlRead($Checkbox3)
If $Read = $GUI_CHECKED Then
Run('"' & @ProgramFilesDir & '\uTorrent\uTorrent.exe"')
Sleep(2000)
EndIf
;A
Case $msg = $A
Guidelete("Update Addons")
Guidelete($how)
GUICreate("Update Addons - A", 700, 500)
GUISetState (@SW_SHOW)
$Checkbox1 = GUICtrlCreateCheckbox("A", 20, 5)
$Checkbox2 = GUICtrlCreateCheckbox("B", 20, 25)
$Checkbox3 = GUICtrlCreateCheckbox("C", 20, 45)
$Start = GUICtrlCreateButton("Start Selected", 281, 370 , 120, 30)
EndSelect
Wend
Func quit()
exit    
EndFunc

When it runs it guicreates a window, showing a button(How to use) and a menu at the top. Once you click the menu it shows a list A to Z. When I click A it Guideletes and makes a new gui, that shows 3 checkboxes. A, B and C and another button at the bottem(Start Selected).

When I click on checkbox A for some reason it brings up the How to use message box, the rest of them are fine.

What do I edit to make it not bring up the How To use button?

So basically I just want it to: Once A gets clicked in the Menu make a new gui with 3 checkboxes. Once they are all checked it runs them one after another(Already does that part)

To delete a gui you refer to the handle not the title. You do not need to delete the controls when you delete the gui, but if you do you use GuiCtrlDelete and refere to the control ID.

It is a bit confusing that your main loop contains references to controls that will not have been created at first, and then referes to controls that will have been deleted. I think it is better toi separate the two guis and the message loops like this.

#include <GUIConstants.au3>
HotKeySet("{esc}", "quit")
$gui1 = GUICreate("Update Addons - Menu", 300, 300);<-----variable for gui added here
GUISetState(@SW_SHOW)
$how = GUICtrlCreateButton("How To Use", 0, 10)

$Start = GUICtrlCreateButton("Start Selected", 281, 370, 120, 30)

$Menu = GUICtrlCreateMenu("Menu")
$A = GUICtrlCreateMenuItem("A", $Menu)
$B = GUICtrlCreateMenuItem("B", $Menu)
$C = GUICtrlCreateMenuItem("C", $Menu)
$D = GUICtrlCreateMenuItem("D", $Menu)
$E = GUICtrlCreateMenuItem("E", $Menu)
$F = GUICtrlCreateMenuItem("F", $Menu)
$G = GUICtrlCreateMenuItem("G", $Menu)
$H = GUICtrlCreateMenuItem("H", $Menu)
$I = GUICtrlCreateMenuItem("I", $Menu)
$J = GUICtrlCreateMenuItem("J", $Menu)
$K = GUICtrlCreateMenuItem("K", $Menu)
$L = GUICtrlCreateMenuItem("L", $Menu)
$M = GUICtrlCreateMenuItem("M", $Menu)
$N = GUICtrlCreateMenuItem("N", $Menu)
$O = GUICtrlCreateMenuItem("O", $Menu)
$P = GUICtrlCreateMenuItem("P", $Menu)
$Q = GUICtrlCreateMenuItem("Q", $Menu)
$R = GUICtrlCreateMenuItem("R", $Menu)
$S = GUICtrlCreateMenuItem("S", $Menu)
$T = GUICtrlCreateMenuItem("T", $Menu)
$U = GUICtrlCreateMenuItem("U", $Menu)
$V = GUICtrlCreateMenuItem("V", $Menu)
$W = GUICtrlCreateMenuItem("W", $Menu)
$X = GUICtrlCreateMenuItem("X", $Menu)
$Y = GUICtrlCreateMenuItem("Y", $Menu)
$Z = GUICtrlCreateMenuItem("Z", $Menu)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit;Loop
        Case $msg = $how
            MsgBox(0, "How To Use", "How To Use")
            
        Case $msg = $A
            GUIDelete($Gui1);corrected here
        ;GUIDelete($how);wrong but not needed
            ExitLoop
    EndSelect
WEnd

$Gui2 = GUICreate("Update Addons - A", 700, 500)
GUISetState(@SW_SHOW)
$Checkbox1 = GUICtrlCreateCheckbox("A", 20, 5)
$Checkbox2 = GUICtrlCreateCheckbox("B", 20, 25)
$Checkbox3 = GUICtrlCreateCheckbox("C", 20, 45)
$Start = GUICtrlCreateButton("Start Selected", 281, 370, 120, 30)
ConsoleWrite("startid = " & $start & ', chkbx1 id = ' & $Checkbox1 & @CRLF)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Start
            $Read = GUICtrlRead($Checkbox1);start
            If $Read = $GUI_CHECKED Then
                RunWait("notepad")
                Sleep(2000)
            EndIf
            $Read = GUICtrlRead($Checkbox2);start
            If $Read = $GUI_CHECKED Then
            ;RunWait('"' & @ProgramFilesDir & '\Internet Explorer\IEXPLORE.EXE"')
                ConsoleWrite("run ie" & @CRLF)
                Sleep(2000)
            EndIf;end
            $Read = GUICtrlRead($Checkbox3)
            If $Read = $GUI_CHECKED Then
            ;Run('"' & @ProgramFilesDir & '\uTorrent\uTorrent.exe"')
                ConsoleWrite("run torrent" & @CRLF)
                Sleep(2000)
            EndIf
    EndSelect
WEnd

Func quit()
    Exit
EndFunc  ;==>quit

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks

Edited by will88

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0