Jump to content

Multiple GUIs?


modernes
 Share

Recommended Posts

Hi All,

I have a script that has 2 GUIs - however I cannot close one without having the other one close at the same time. I can't seem to figure out how to make the two windows to act independantly.

#include <GuiConstants.au3>

;-----------------------------------------------------  GUI Creation  ----------------------------------------------------------------------------------------
Func createEmailGUI()

;This is the function that will create the GUI which will read the email info

Dim $strEmail, $strName, $intProb, $strDesc ;values to be read in through the GUI

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

$guiEmail = GuiCreate("FFIC COM3 Email Writer", 362, 330,(@DesktopWidth-362)/2, (@DesktopHeight-300)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$txtEmail = GuiCtrlCreateInput("", 150, 10, 190, 20)
$txtName = GuiCtrlCreateInput("", 150, 40, 190, 20)
$txtProb = GuiCtrlCreateInput("", 150, 70, 190, 20)

$lblEmail = GuiCtrlCreateLabel("Email Address", 10, 10, 120, 20, $SS_RIGHT )
$lblName = GuiCtrlCreateLabel("Name of Recipient", 10, 40, 120, 20, $SS_RIGHT )
$lblProb = GuiCtrlCreateLabel("Problem No.", 10, 70, 120, 20, $SS_RIGHT )

$lblDesc = GuiCtrlCreateLabel("Decription of request", 10, 120, 140, 20)
$txtDesc = GuiCtrlCreateEdit("", 10, 150, 340, 140)

$cbOk = GUICtrlCreateButton("Create Email", 130, 297, 100, 30, $BS_DEFPUSHBUTTON)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $cbOk
        
        $strEmail = GUICtrlRead($txtEmail)
        $strName = GUICtrlRead($txtName)
        $intProb = GUICtrlRead($txtProb)
        $strDesc = GUICtrlRead($txtDesc)
        
        GUIDelete($guiEmail)
        createEmail($strEmail, $strName, $intProb, $strDesc)
        
    Case Else
    ;;;
    EndSelect
WEnd

EndFunc
;------------------------------------------------------------------------------------------------------------------------------------------------------------
Func createEmail($strEmail, $strName, $intProb, $strDesc)

;This is the function which will type the email address out after all the info has been provided in the main GUI

Dim $isValid

WinActivate("New Memo - Lotus Notes")

$isValid = MsgBox(1,"Create Delivery Email","Please make sure you have focus on the blank email page")
    
    If $isValid = 1 Then
        Send($strEmail & "{TAB 3}" & "Ticket " & $intProb & " Completion" & "{TAB}")
        Send("Dear " & $strName & "{ENTER 2}We are following up with you regarding ticket number " & $intProb & " which you opened for:" & "{ENTER 2}" & $strDesc)
        Send("{ENTER 2}" & "Thanks," & "{ENTER 2}")
    EndIf

EndFunc
;------------------------------------------------------------------------------------------------------------------------------------------------------------
;Begin Main GUI creation

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

$winMain = GuiCreate("FFIC", 150, 30,(@DesktopWidth-131)/2, (@DesktopHeight-40)/2 ,  -1, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW)

$mnuIMAC = GUICtrlCreateMenu("IMAC")
$mnuIMACEmail = GUICtrlCreateMenuitem("Create Email" & @TAB & "Shift+Alt+C",$mnuIMAC)

GuiSetState()

While 1
    
    HotKeySet("!+c","createEmailGUI")
    
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
        
    Case $msg = $mnuIMACEmail
        createEmailGUI()
        
    Case Else
    ;;;
        
    EndSelect
WEnd

Exit

Any ideas?

Link to comment
Share on other sites

Hi All,

I have a script that has 2 GUIs - however I cannot close one without having the other one close at the same time. I can't seem to figure out how to make the two windows to act independantly.

#include <GuiConstants.au3>

;-----------------------------------------------------  GUI Creation  ----------------------------------------------------------------------------------------
Func createEmailGUI()

;This is the function that will create the GUI which will read the email info

Dim $strEmail, $strName, $intProb, $strDesc   ;values to be read in through the GUI

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

$guiEmail = GuiCreate("FFIC COM3 Email Writer", 362, 330,(@DesktopWidth-362)/2, (@DesktopHeight-300)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$txtEmail = GuiCtrlCreateInput("", 150, 10, 190, 20)
$txtName = GuiCtrlCreateInput("", 150, 40, 190, 20)
$txtProb = GuiCtrlCreateInput("", 150, 70, 190, 20)

$lblEmail = GuiCtrlCreateLabel("Email Address", 10, 10, 120, 20, $SS_RIGHT )
$lblName = GuiCtrlCreateLabel("Name of Recipient", 10, 40, 120, 20, $SS_RIGHT )
$lblProb = GuiCtrlCreateLabel("Problem No.", 10, 70, 120, 20, $SS_RIGHT )

$lblDesc = GuiCtrlCreateLabel("Decription of request", 10, 120, 140, 20)
$txtDesc = GuiCtrlCreateEdit("", 10, 150, 340, 140)

$cbOk = GUICtrlCreateButton("Create Email", 130, 297, 100, 30, $BS_DEFPUSHBUTTON)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $cbOk
        
        $strEmail = GUICtrlRead($txtEmail)
        $strName = GUICtrlRead($txtName)
        $intProb = GUICtrlRead($txtProb)
        $strDesc = GUICtrlRead($txtDesc)
        
        GUIDelete($guiEmail)
        createEmail($strEmail, $strName, $intProb, $strDesc)
        
    Case Else
   ;;;
    EndSelect
WEnd

EndFunc
;------------------------------------------------------------------------------------------------------------------------------------------------------------
Func createEmail($strEmail, $strName, $intProb, $strDesc)

;This is the function which will type the email address out after all the info has been provided in the main GUI

Dim $isValid

WinActivate("New Memo - Lotus Notes")

$isValid = MsgBox(1,"Create Delivery Email","Please make sure you have focus on the blank email page")
    
    If $isValid = 1 Then
        Send($strEmail & "{TAB 3}" & "Ticket " & $intProb & " Completion" & "{TAB}")
        Send("Dear " & $strName & "{ENTER 2}We are following up with you regarding ticket number " & $intProb & " which you opened for:" & "{ENTER 2}" & $strDesc)
        Send("{ENTER 2}" & "Thanks," & "{ENTER 2}")
    EndIf

EndFunc
;------------------------------------------------------------------------------------------------------------------------------------------------------------
;Begin Main GUI creation

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

$winMain = GuiCreate("FFIC", 150, 30,(@DesktopWidth-131)/2, (@DesktopHeight-40)/2 ,  -1, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW)

$mnuIMAC = GUICtrlCreateMenu("IMAC")
$mnuIMACEmail = GUICtrlCreateMenuitem("Create Email" & @TAB & "Shift+Alt+C",$mnuIMAC)

GuiSetState()

While 1
    
    HotKeySet("!+c","createEmailGUI")
    
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
        
    Case $msg = $mnuIMACEmail
        createEmailGUI()
        
    Case Else
   ;;;
        
    EndSelect
WEnd

Exit

Any ideas?

change all the references from $msg to $msg2 in second gui

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • Moderators

Disable the first gui GUISetState($Main_GUI, $GUI_DISABLE) Right before you call the other function that will create the 2nd one / Then use GUIDelete($2nd_GUI) / the 2nd one as your leaving and exiting the loop / Then use GUISetState($Main_GUI, $GUI_ENABLE) on the 1st one right after the function call you made to get to the 2nd GUI.

GUISetState($Main_GUI, $GUI_DISABLE)
SecondGUIFunction()
GUISetState($Main_GUI, $GUI_ENABLE)

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...