Jump to content
Gtek

GUIcreate open a GUIcreate, But

Recommended Posts

Hi y'all!

I'm trying to understand why the new GUicreate don't work. it does this. the 2nd windows open, but no buttons work.  You guys can probably see right through it ;)

So thank you for all your help in advance ūüėĀ

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include "GUIConstants.au3"


Opt('MustDeclareVars', 1)
Opt("GUIOnEventMode", 1)

Global $ExitID, $ibase, $scustomer, $parent1, $parent2
_Main()


Func _Main()
    Local $installID

    $parent1 = GUICreate("Imaging", 435, 300)

    GUICtrlCreateLabel("Please select a action!", 10, 10)
    $InstallID = GUICtrlCreateButton("Install Image", 10, 50, 70, 20)
    GUICtrlSetOnEvent($InstallID, "OnYes")

    GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit")

    GUISetState()  ; display the GUI

    While 1
        Sleep(1000)
    WEnd
EndFunc   ;==>_Main

;--------------- Functions ---------------

Func OnYes()
    $parent2 = GUICreate("Fineman Imaging", 435, 300)

    GUICtrlCreateLabel("Please select a action!", 10, 10)
    GUICtrlCreateButton("Install Image", 10, 50, 70, 20)
    GUICtrlSetOnEvent(-1, "instpre")
    GUICtrlCreateButton("Make Image", 90, 50, 70, 20)
    GUICtrlSetOnEvent(-1, "makecus")
    $ExitID = GUICtrlCreateButton("Exit", 350, 50, 50, 20)
    GUICtrlSetOnEvent($ExitID, "OnExit")

    GUIDelete($Parent1)
    GUISetState(@SW_SHOW, $parent2)

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Main")

    ;GUISetState()  ; display the GUI

    While 1
        Sleep(10)
    WEnd
 EndFunc


;Start conimg Function
Func instpre()
Local $iLoop = 1
             While $iLoop = 1
                     $ibase = InputBox("Install With 10Ltsb19 Licens", "Enter module name" & @CRLF & "" & @CRLF & " f. eks. Si22" & @CRLF & " Don't add .gho/_10Ltsb19_")
                        If @error = 1 Then
                            MsgBox(0x0,"You Pressed Cancel", "Reture to main menu - pressed 'OK'")
                              Return _main
                              Else
                     $scustomer = InputBox("Choose which Customer", "Enter name of customers image" & @CRLF & "" & @CRLF & " f. eks. Scala/combine/WZF" & @CRLF & " Don't add .gho/_10Ltsb19_")
                        If @error = 1 Then
                            MsgBox(0x0,"You Pressed Cancel", "Reture to main menu - pressed 'OK'")
                              Return _main
                        Else
                           if 0 = FileExists("\\10.0.1.17\public\teknik_images\ibase\" & $ibase & "\" & $ibase & "_10ltsc19_" & $scustomer & ".gho") Then
                              MsgBox(0x5,"Error", "File name doesn't exist" & @CRLF & "Or"& @CRLF & "Network connection is missing" & @CRLF & "Else" & @CRLF & "Examine path: \\FINESTORAGE\Public\Teknik_Images\ibase")
    Else
         $iLoop = 0
    EndIf
                        EndIf
                        EndIf

WEnd

RunWait(@ComSpec & " /C " & 'Ghost64.exe -clone,mode=restore,src=\\10.0.1.17\public\teknik_images\ibase\'& $ibase &'\'& $ibase &'_10ltsc19_'& $scustomer &'.gho,dst=1 -ntexact -sure -auto',"")
EndFunc; Stop

;Start preimg Function
Func makecus()
Local $iLoop = 1
             While $iLoop = 1
                     $ibase = InputBox("Install With 10Ltsb19 Licens", "Enter module name" & @CRLF & "" & @CRLF & " f. eks. Si22" & @CRLF & " Don't add .gho/_10Ltsb19_")
                        If @error = 1 Then
                            MsgBox(0x0,"You Pressed Cancel", "Reture to main menu - pressed 'OK'")
                              Return _main
                              Else
                     $scustomer = InputBox("Choose which Customer", "Enter name of customers image" & @CRLF & "" & @CRLF & " f. eks. Scala/combine/WZF" & @CRLF & " Don't add .gho/_10Ltsb19_")
                        If @error = 1 Then
                            MsgBox(0x0,"You Pressed Cancel", "Reture to main menu - pressed 'OK'")
                              Return _main
                        Else
                           if 0 = FileExists("\\10.0.1.17\public\teknik_images\ibase\" & $ibase & "\" & $ibase & "_10ltsc19_.gho") Then
                              MsgBox(0x5,"Error", "File name doesn't exist" & @CRLF & "Or"& @CRLF & "Network connection is missing" & @CRLF & "Else" & @CRLF & "Examine path: \\FINESTORAGE\Public\Teknik_Images\ibase")
    Else
         $iLoop = 0
    EndIf
                        EndIf
                        EndIf

WEnd

RunWait(@ComSpec & " /C " & 'Ghost64.exe -clone,mode=restore,src=\\10.0.1.17\public\teknik_images\ibase\'& $ibase &'\'& $ibase &'_10ltsc19_.gho,dst=1 -ntexact -sure -auto',"")
                    if 0 = FileExists("\\10.0.1.17\public\teknik_images\dokumentation\Kundetilpassede\" & $scustomer & "\BG" & $scustomer & "\BG.jpg") Then
                        Exit
                        Else
                    DirCopy("\\10.0.1.17\public\teknik_images\dokumentation\Kundetilpassede\"& $scustomer &"\BG"& $scustomer &"", "d:\FineDir")
                    FileCopy("d:\Finedir\BG"& $scustomer &".bat", "d:\Users\player\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\bg"& $scustomer &".bat")
                 EndIf
              EndFunc ; Stop


Func OnExit()
    If @GUI_CtrlId = $ExitID Then
        MsgBox(64, "Exit", "Imaging Canceled")
    Else
        MsgBox(64, "Cancel", "Action Canceled")
    EndIf

    Exit
 EndFunc   ;==>OnExit2

 

Share this post


Link to post
Share on other sites

Gtek,

You need to move the idle loop out of the 2 functions - AutoIt will not run another function while one is still running:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include "GUIConstants.au3"


Opt('MustDeclareVars', 1)
Opt("GUIOnEventMode", 1)

Global $ExitID, $ibase, $scustomer, $parent1, $parent2

_Main()

; Put the idle loop here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
While 1
    Sleep(10)
WEnd

Func _Main()
    Local $installID

    $parent1 = GUICreate("Imaging", 435, 300)

    GUICtrlCreateLabel("Please select a action!", 10, 10)
    $installID = GUICtrlCreateButton("Install Image", 10, 50, 70, 20)
    GUICtrlSetOnEvent($installID, "OnYes")

    GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit")

    GUISetState()  ; display the GUI

EndFunc   ;==>_Main

;--------------- Functions ---------------

Func OnYes()
    $parent2 = GUICreate("Fineman Imaging", 435, 300)

    GUICtrlCreateLabel("Please select a action!", 10, 10)
    GUICtrlCreateButton("Install Image", 10, 50, 70, 20)
    GUICtrlSetOnEvent(-1, "instpre")
    GUICtrlCreateButton("Make Image", 90, 50, 70, 20)
    GUICtrlSetOnEvent(-1, "makecus")
    $ExitID = GUICtrlCreateButton("Exit", 350, 50, 50, 20)
    GUICtrlSetOnEvent($ExitID, "OnExit")

    GUIDelete($parent1)
    GUISetState(@SW_SHOW, $parent2)

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Main")

EndFunc   ;==>OnYes


;Start conimg Function
Func instpre()

    ConsoleWrite("instpre2" & @CRLF)

EndFunc   ;==>instpre

;Start preimg Function
Func makecus()

    ConsoleWrite("makeus" & @CRLF)

EndFunc   ;==>makecus


Func OnExit()
    If @GUI_CtrlId = $ExitID Then
        MsgBox(64, "Exit", "Imaging Canceled")
    Else
        MsgBox(64, "Cancel", "Action Canceled")
    EndIf

    Exit
EndFunc   ;==>OnExit

For a more detailed explanation on how AutoIt runs functions, please read the Interrupting a running function tutorial in the Wiki.

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...