Sign in to follow this  
Followers 0
wfish

Shows guis then contiues without input from gui

3 posts in this topic

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=..\..\..\Documents and Settings\wayne.salmond\Desktop\buggedCases.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <UpDownConstants.au3>
#include <IE.au3>
Local $Caseholder;
Local $emailSleep = True;
local $imputemail
local $iepage
Local $customEmailAddress;
Local $caseNumber
Local $emailCounter=0;
Local $skipEmailCounter=0;
Local $skippedTicket;

SendMail();
    While 1
  Sleep(500)  ; Idle around
WEnd

func SendMail()
    Do
        $emailaddress = "";
        If $emailaddress == "" Then
            emptyEmail();
        Else
            ;other code
        EndIf
    Until (True);$caseNumber=="")
    MsgBox(0,"Finished",$emailCounter&" emails Sent and "&$skipEmailCounter&" tickets skipped")
EndFunc


#cs
I want SendEmail() to stop while empty email is running. Instead it just shows the gui then contineus with the rest of the code in send email.
#ce

func emptyEmail()
    Opt("GUIOnEventMode", 1)
    $emailGui = GUICreate("Email Address");
    GUISetOnEvent($GUI_EVENT_CLOSE, "cancelButton")
    GUICtrlCreateLabel("Sorry no email address was found for ticket "&$caseNumber,10,20);
    GUICtrlCreateLabel("Please Enter and Email or select Skip Ticket",10,40)
    $imputemail = GUICtrlCreateInput("Type Email here",10,60);
    $submitButton = GUICtrlCreateButton("Submit",10,85)
    GUICtrlSetOnEvent($submitButton,"submitEmail")
    $skipButton = GUICtrlCreateButton("Skip Ticket",50,85)
    GUICtrlSetOnEvent($skipButton,"skipEmail")
    GUISetState(@SW_SHOW)
    EndFunc



Func submitEmail()
    cancelButton();
    Return
EndFunc

Func skipEmail()
    cancelButton();
    Return
EndFunc

  Func cancelButton()
  ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
  ;and @GUI_WINHANDLE would equal $mainwindow
  ;MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...")
  Exit
EndFunc

In the code I want it to stop SendEmail() while waiting for user input from emptyemail(). But it shows the gui in empty() then continues with SendEmail(). If I put a while 1 sleep(500) wend it stops but never continues it stays stuck in the loop.

I am very new and appreciate any help.

Share this post


Link to post
Share on other sites



wfish,

I have made a few changes to the script, but I think it now does what you want. Look for the <<<<<<<<<<<<<< lines:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=..\..\..\Documents and Settings\wayne.salmond\Desktop\buggedCases.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <UpDownConstants.au3>
#include <IE.au3>

Opt("GUIOnEventMode", 1) ; Put this at the beginning, not in a function <<<<<<<<<<<<<<<<<<

; These are all Global variables becasue they are in the main body of the script <<<<<<<<<<<<<
Local $Caseholder;
Local $emailSleep = True;
Local $imputemail
Local $iepage
Local $customEmailAddress;
Local $caseNumber
Local $emailCounter = 0;
Local $skipEmailCounter = 0;
Local $skippedTicket;

; Added these <<<<<<<<<<<<<<<<<<<<<<
Global $femailSubmitted = False
Global $emailGui, $caseLabel

; Create the GUI here, but keep it hidden  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
emptyEmail()

SendMail();

While 1
    Sleep(10) ; Idle around
WEnd

Func SendMail()
    ;Do ; No need for this <<<<<<<<<<<<<<<<<<<<<
        $emailaddress = "";
        If $emailaddress == "" Then
            writeEmail();
        Else
            ;other code
        EndIf
    ;Until (True);$caseNumber=="") ; Or this <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    MsgBox(0, "Finished", $emailCounter & " emails Sent and " & $skipEmailCounter & " tickets skipped")
EndFunc   ;==>SendMail

#cs
    I want SendEmail() to stop while empty email is running. Instead it just shows the gui then contineus with the rest of the code in send email.
#ce

Func writeEmail()

    GUISetState(@SW_SHOW, $emailGui) ; Show the GUI <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    GUICtrlSetData($caseLabel, "Sorry no email address found for ticket " & $caseNumber) ; Put the current $caseNumber in the label <<<<<<<<<<<<
    $femailSubmitted = False ; Clear the flag <<<<<<<<<<<<<<<<<<<
    Do
        Sleep(10)
    Until $femailSubmitted = True ; Wait until the flag is set <<<<<<<<<<<<<<<<<<<<<
    GUISetState(@SW_HIDE, $emailGui) ; Hide the GUI until it is needed again <<<<<<<<<<<<<<<<<<<
    GUICtrlSetData($imputemail, "Type Email here") ; Reset the input hint <<<<<<<<<<<<<<<<<<<<

EndFunc

Func emptyEmail()

    $emailGui = GUICreate("Email Address", 250, 130);
    GUISetOnEvent($GUI_EVENT_CLOSE, "cancelButton")
    $caseLabel = GUICtrlCreateLabel("", 10, 20, 230, 20) ; Just create an empty label to fill each time <<<<<<<<<<<<
    GUICtrlCreateLabel("Please Enter an Email or select Skip Ticket", 10, 40)
    $imputemail = GUICtrlCreateInput("Type Email here", 10, 60);
    $submitButton = GUICtrlCreateButton("Submit", 10, 85)
    GUICtrlSetOnEvent($submitButton, "submitEmail") ; Now a separate function <<<<<<<<<<<<<<<<<<<<<
    $skipButton = GUICtrlCreateButton("Skip Ticket", 50, 85)
    GUICtrlSetOnEvent($skipButton, "skipEmail")
    GUISetState(@SW_HIDE, $emailGui)

EndFunc   ;==>emptyEmail

Func submitEmail()
    $femailSubmitted = True ; Set the flag <<<<<<<<<<<<<<<<<<<<<<<<
    ;Return ; Not required
EndFunc   ;==>submitEmail

Func skipEmail()
    cancelButton();
    GUISetState(@SW_HIDE, $emailGui) ; Hide the GUI until it is needed again <<<<<<<<<<<<<<<<<<<
    GUICtrlSetData($imputemail, "Type Email here") ; Reset the input hint <<<<<<<<<<<<<<<<<<<<
EndFunc   ;==>skipEmail

Func cancelButton()
    ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
    ;and @GUI_WINHANDLE would equal $mainwindow
    ;MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...")
    Exit
EndFunc   ;==>cancelButton

A couple of points:

I assume you might want to reuse the GUI while the script is so I have created it once and then hidden/shown it as required.

I have introduced a flag to show when the Submit button is pressed - until this is set the emailGUI remains visible.

Please ask if anything is unclear. :blink:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

You code is exactly what I was looking for. Just was confused on how and when to use the sleep. Is much clearer now.

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