childgui die 3000.

  • ich hab ja diverse probleme mit AUTOIT, aber was mich neben regex zur verzweifling bringt ist der ganze childgui kram.

    Childgui ist für mich wie ein blinker mit 3 stufen.
    geht, geht ein bisschen und geht nicht.

    zum script....
    ich habe ein fenster das per button eine childgui öfnet. soweit so gut. :rock:
    in der childgui habe ich 6 buttons und wenn ich eine funtion drauf lege, dann geht das auch. :rock:
    will ich die childgui schliessen geht das auch, ABER.... :thumbup:

    1. die MainGUI hüpft in den hintergrund. ?(
    2. Die MainGUI ist nicht mehr ansprechbar und lässt sich nicht schliessen :cursing:

    hier nun ein funktionstüchtiger ausschnitt der genau das verhalten an den tag legt.
    [hide]

    [autoit]


    #include <GUIConstants.au3>
    #include <WindowsConstants.au3>
    #include <GuiButton.au3>
    #include <GuiImageList.au3>
    #include <Array.au3>
    #include <Constants.au3>
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIEdit.au3>
    #include <Misc.au3>
    #include <ScrollBarConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <String.au3>
    #include <_GetFile.au3>

    [/autoit][autoit][/autoit][autoit]

    #region Var
    Global $sIni = @ScriptDir & "\Settings.opt"
    Global $filefoldername[1]
    $APKfolder = "nix"
    #endregion Var
    If Not FileExists($sIni) Then
    Global $sCMDLine = FileSelectFolder("Choose your starting folder.", "")
    $iMsgBoxAnswer = MsgBox(270372, "Default?", "Do you want to save this folder for the next Time you use this tool?")
    Select
    Case $iMsgBoxAnswer = 6 ;Yes
    IniWrite($sIni, "APKTOOL", "Path", $sCMDLine)
    Case $iMsgBoxAnswer = 7 ;No
    EndSelect
    Else
    $sCMDLine = IniRead($sIni, "APKTOOL", "Path", "Path not Found")
    EndIf
    #region GUI init CMD init
    $hGUI = GUICreate("Test", 800, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_CLIPCHILDREN))
    $PID = Run(@ComSpec & " /k CD " & $sCMDLine, "", @SW_HIDE)
    $hWnd = 0
    $stPID = DllStructCreate("int")

    [/autoit][autoit][/autoit][autoit]

    Do
    $WinList = WinList()
    For $i = 1 To $WinList[0][0]
    If $WinList[$i][0] <> "" Then
    DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $WinList[$i][1], "ptr", DllStructGetPtr($stPID))
    If DllStructGetData($stPID, 1) = $PID Then
    $hWnd = $WinList[$i][1]
    ExitLoop
    EndIf
    EndIf
    Next
    Sleep(100)
    Until $hWnd <> 0
    $stPID = 0
    If $hWnd <> 0 Then
    $nExStyle = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $hWnd, "int", -20)
    $nExStyle = $nExStyle[0]
    DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", -20, "int", BitOR($nExStyle, $WS_EX_MDICHILD))
    DllCall("user32.dll", "int", "SetParent", "hwnd", $hWnd, "hwnd", $hGUI)
    WinSetState($hWnd, "", @SW_SHOW)
    WinMove($hWnd, "", 0, 0, 720, 420)
    EndIf
    #endregion GUI init CMD init
    #region GUI conrtols
    Global Const $iStartx = 610, $iBtnWidth = 100, $iStarty = 10
    Global Const $idButton_Setup = GUICtrlCreateButton("Setup APKTool", $iStartx + 85, $iStarty + 270, $iBtnWidth, 40)
    Global Const $idButton_Exit = GUICtrlCreateButton("Exit", $iStartx + 85, $iStarty + 315, $iBtnWidth, 40)
    GUISetState()
    #endregion GUI conrtols
    #region Buttonaction
    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE, $idButton_Exit
    _GDIPlus_Shutdown()
    GUIDelete()
    ProcessClose($PID)
    Exit

    [/autoit][autoit][/autoit][autoit]

    Case $idButton_Setup
    _apktoolsettings()

    [/autoit][autoit][/autoit][autoit]

    EndSwitch
    WEnd
    #endregion Buttonaction
    #region Functions

    [/autoit][autoit][/autoit][autoit]

    Func _apktoolsettings()
    GUISetState(@SW_DISABLE, $hGUI)
    $child_GUI = GUICreate("Child GUI", 274, 101, 470, 212, BitOR($GUI_SS_DEFAULT_GUI, $WS_CHILD))
    $Button1 = GUICtrlCreateButton("Load actual apktool.jar", 5, 5, 129, 25)
    $Button2 = GUICtrlCreateButton("Load actual aapt.exe", 5, 35, 129, 25)
    $Button3 = GUICtrlCreateButton("Load 2.apk - 5.apk", 4, 65, 129, 25)
    $Button4 = GUICtrlCreateButton("Button1", 140, 5, 129, 25)
    $Button5 = GUICtrlCreateButton("Load actual aapt", 140, 35, 129, 25)
    $Button6 = GUICtrlCreateButton("Button 6", 140, 65, 129, 25)
    GUISetState(@SW_SHOW)

    [/autoit][autoit][/autoit][autoit]

    While 2
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    GUIDelete($child_GUI)
    GUISetState(@SW_ENABLE, $hGUI)
    Case $Button1
    ProgressOn("Download", "Downloading...", "0%")
    $url = "http://miui.connortumbleson.com/other/apktool/apktool_1.5.2.jar" ;Set URL
    $folder = @ScriptDir & "\apktool_1.5.2.jar" ;Set folder
    $hInet = InetGet($url, $folder, 1, 1) ;Forces a reload from the remote site and return immediately and download in the background
    $FileSize = InetGetSize($url) ;Get file size
    While Not InetGetInfo($hInet, 2) ;Loop until download is finished
    Sleep(500) ;Sleep for half a second to avoid flicker in the progress bar
    $BytesReceived = InetGetInfo($hInet, 0) ;Get bytes received
    $Pct = Int($BytesReceived / $FileSize * 100) ;Calculate percentage
    ProgressSet($Pct, $Pct & "%") ;Set progress bar
    WEnd
    ProgressOff()
    Case $Button2
    Case $Button3
    Case $Button4
    Case $Button5
    Case $Button6
    EndSwitch
    WEnd
    EndFunc ;==>_apktoolsettings

    [/autoit][autoit][/autoit][autoit][/autoit]


    [/hide]

    warum ist das so?
    wie muss das richtig sein?
    wie kann ich das für immer umgehen?

    I spent 10 minutes reviewing code and thinking "What kind of drugs is this guy on?" before realizing it was something I wrote.

    Einmal editiert, zuletzt von Maximus1 (12. September 2013 um 00:01)

  • das wars....

    ein exitloop nach dem @guienable bewirkt wunder.

    danke dir :)

    I spent 10 minutes reviewing code and thinking "What kind of drugs is this guy on?" before realizing it was something I wrote.

  • Alternativ eben ein Return Statement sobald die Child GUI beendet werden soll. Achja du hast im übrigen bei deiner Child GUI vergessen den Parent anzugeben (letzter Parameter bei guicreate).
    Ich würde dir außerdem nahelegen alle Variablen in Funktionen auch als local zu deklarieren, damit vermeidest du versehentliche Kollisionen mit globalen GUI Variablen, gerade wenn man seine Buttons so durchnummeriert wie du kann das gern mal passieren. Das war aber bei dir nicht der Fehler, wollte es nur angemerkt haben.

    Einmal editiert, zuletzt von misterspeed (12. September 2013 um 00:12)

  • wenn ich $hGUI angebe, dann kommt aber das childfenster nicht mehr.

    I spent 10 minutes reviewing code and thinking "What kind of drugs is this guy on?" before realizing it was something I wrote.

  • Doch klar geht das:

    [autoit]

    $child_GUI = GUICreate("Child GUI", 274, 101, 470, 212, BitOR($GUI_SS_DEFAULT_GUI, $WS_CHILD),-1,$hGUI)

    [/autoit]

    Vergleich es mit deinem Code und du wirst feststellen, dass du seither kein child window hattest (siehst du in der Taskleiste, da sollten keine child windows auftauchen).


    EDIT:

    Der Bug, dass das Hauptfenster in den Background springt liegt im Übrigen an deinem Disable und Enable. Beide Zeilen auskommentiert und du hast dieses Verhalten nicht mehr. ;)

  • das die zeile wieder geht liegt an der -1.
    was die nun bewirkt wüsste ich gern.

    I spent 10 minutes reviewing code and thinking "What kind of drugs is this guy on?" before realizing it was something I wrote.