Jump to content

Exit Func and Start New Function


litlmike
 Share

Recommended Posts

I want to exit the GUI when the user hits 'Done' then start my next function ('Func WriteProposal()'). I spent an hour testing different ways to set up the do, if...then, while, for, etc. And I spent another hour searching the forums and reading tutorials, but I can't find the answer. The great and omnipresent 'Valuater' helped me get this far.

I marked where I think the problem is. How do I make it close the GUI, then activate my next function?

Thanks ahead of time!

;Open GUI
Func OpenGUI()
#include <GUIConstants.au3>

;Make GUI
GUICreate ( "Input Proposal Info", 225, 250)
GUISetState (@SW_SHOW)    ; will display an empty dialog box

;Make first Combo Box
$cat_1 = GUICtrlCreateCombo ( "Pick A Category", 10, 10)
            GUICtrlSetData(-1,"item1|item2|item3"); Set data in Combo Box

;Second Combo Box
$cat_2 = GUICtrlCreateCombo ( "Pick A Category", 10, 50)
            GUICtrlSetData(-1,"item1|item2|item3"); Set data in Combo Box

;Third Combo Box
$cat_3 = GUICtrlCreateCombo ( "Pick A Category", 10, 90)
            GUICtrlSetData(-1,"item1|item2|item3"); Set data in Combo Box

;Make Discount Input Box
$discount = GUICtrlCreateInput ( "Enter Discount", 10,  130)            

;Make Done Button
$done = GUICtrlCreateButton ( "Done", 75, 170,75,50)

GUISetState ()   ; will display an empty dialog box
                ; Run the GUI until the dialog is closed
Do
    $msg = GUIGetMsg()
;***** RIGHT HERE********   
    If $msg = $done Then Exit
                
    if $msg = $cat_1 then
       GUICtrlRead($cat_1); get the value
        GUICtrlRead($discount); get the value
    endif
    
    if $msg = $cat_2 then
       GUICtrlRead($cat_2); get the value
        GUICtrlRead($discount); get the value
    endif       
    
    if $msg = $cat_3 then
       GUICtrlRead($cat_3); get the value
        GUICtrlRead($discount); get the value
    endif
    
Until $msg = $GUI_EVENT_CLOSE 
EndFunc

;Write Proposal
Func WriteProposal()
...
...
...
EndFunc
Link to comment
Share on other sites

;Open GUI
;Func OpenGUI(); normally the first gui is not within a function ( depends )
#include <GUIConstants.au3>

;Make GUI
GUICreate("Input Proposal Info", 225, 250)
GUISetState(@SW_SHOW)    ; will display an empty dialog box

;Make first Combo Box
$cat_1 = GUICtrlCreateCombo("Pick A Category", 10, 10)
GUICtrlSetData(-1, "item1|item2|item3"); Set data in Combo Box

;Second Combo Box
$cat_2 = GUICtrlCreateCombo("Pick A Category", 10, 50)
GUICtrlSetData(-1, "item1|item2|item3"); Set data in Combo Box

;Third Combo Box
$cat_3 = GUICtrlCreateCombo("Pick A Category", 10, 90)
GUICtrlSetData(-1, "item1|item2|item3"); Set data in Combo Box

;Make Discount Input Box
$discount = GUICtrlCreateInput("Enter Discount", 10, 130)

;Make Buttons
$done = GUICtrlCreateButton("Done", 25, 170, 75, 50)
$Calc = GUICtrlCreateButton("Calculate", 125, 170, 75, 50)

GUISetState()   ; will display an empty dialog box
; Run the GUI until the dialog is closed
Do
    $msg = GUIGetMsg()
;***** RIGHT HERE********
    If $msg = $done Then Exit
    
    If $msg = $Calc Then WriteProposal()
    
    If $msg = $cat_1 Then
        GUICtrlRead($cat_1); get the value
        GUICtrlRead($discount); get the value
    EndIf
    
    If $msg = $cat_2 Then
        GUICtrlRead($cat_2); get the value
        GUICtrlRead($discount); get the value
    EndIf
    
    If $msg = $cat_3 Then
        GUICtrlRead($cat_3); get the value
        GUICtrlRead($discount); get the value
    EndIf
    
Until $msg = $GUI_EVENT_CLOSE
;EndFunc

;Write Proposal
Func WriteProposal()
    $cat_1A = GUICtrlRead($cat_1)
    
    
    MsgBox(64, "Proposal", "Started with " & $cat_1A)
EndFunc  ;==>WriteProposal

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

;Write Proposal
Func WriteProposal()
    $cat_1A = GUICtrlRead($cat_1)
    
    
    MsgBox(64, "Proposal", "Started with " & $cat_1A)
EndFunc ;==>WriteProposal
This should throw an error?

If $msg = $Calc Then WriteProposal($cat_1)

;Write Proposal
Func WriteProposal($cat_1)
    $cat_1A = GUICtrlRead($cat_1)
    
    
    MsgBox(64, "Proposal", "Started with " & $cat_1A)
EndFunc ;==>WriteProposal
Maybe?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...