GUI 2 wenn GUI1 Minimiert über Func aufrufen geht das?

  • Hallo zusammen,

    ist es möglich, das wenn die Standard GUI minimiert wird eine zweite Gui sich maximiert und das ganze Über eine Func ohne die While Schleife zu benutzen? Und in der zweiten Gui soll wenn der Button geklickt wird diese zweite sich minimieren und die erste sich wieder maximieren. Alles ohne While Schleife.
    Wenn ja, könnte mir das bitte jemand an Hand eines Bsp. zeigen?

    Spoiler anzeigen

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    $Form1 = GUICreate("Form1", 250, 250, 100, 124)
    GUISetState(@SW_SHOW)

    $Form2 = GUICreate("Form1", 100, 100, 100, 124)
    $Button = GUICtrlCreateButton("Maxi", 20, 60, 60, 25)


    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitchWEnd

    Mfg Ghostleader

  • Dafür brauchst du keine Funktion sondern einfach nur GuiGetMsg ;)

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>

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

    $Form1 = GUICreate("Form1", 250, 250, 100, 124)
    GUISetState(@SW_SHOW)

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

    $Form2 = GUICreate("Form2", 100, 100, 100, 124)
    $Button = GUICtrlCreateButton("Maxi", 20, 60, 60, 25)
    GUISetState(@SW_SHOW)
    GUISetState(@SW_MINIMIZE)

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

    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1]
    Case $Form1
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    MsgBox(0,"","Hauptgui schließen")
    Exit
    Case $GUI_EVENT_MINIMIZE
    GUISetState(@SW_RESTORE, $Form2)
    EndSwitch
    Case $Form2
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    MsgBox(0,"","Nebengui schließen")
    Case $GUI_EVENT_MINIMIZE
    GUISetState(@SW_RESTORE, $Form1)
    EndSwitch
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit]
  • Hallo Schnitzel,

    danke dir erstmal für deine schnelle Antwort.

    Warum ich sagte ohne While ist, weil ich net weiss ob es in dem Script um das es geht so machbar ist, da da GUIOnEventMode verwendet wird und alles über Func´s läuft und nichts über While.

    Spoiler anzeigen

    #include <ComboConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GuiListView.au3>
    #include <ListviewConstants.au3>
    #include <EditConstants.au3>
    #include <ListboxConstants.au3>


    Opt("GUIOnEventMode", 1) ; Activate Event mode
    $Form1 = GUICreate("WarenHandelsTool", 680, 330, 192, 124)
    GUISetOnEvent($GUI_EVENT_CLOSE, "close") ; event -> if close was clicked, call function 'close'

    $PicPet = GUICtrlCreatePic(@Scriptdir & "\BackgroundStormdevil.jpg", 0, 0, 680, 330)
    GUICtrlSetState($PicPet, $GUI_DISABLE)

    Global $fileName = "StaedteHandelstool.ini"
    Global $fileNameWare = "Waren.ini"
    Dim $towns = getTowns() ; get all available towns
    Dim $ware = getWare() ; get all available Waren

    Global $comboAmountWare = 1
    Global $comboAmount = 10 ; row amount of combo boxes to be created
    Dim $combosLeft[$comboAmount][2] ; [x][0] = combo [x][1] = label
    Dim $combosRight[$comboAmount]
    Dim $comboware [$comboAmountWare][2]
    Dim $comboware1 [$comboAmountWare][2]

    ; Create List
    Global $hList = GUICtrlCreateList("", 493, 25, 180, 85, $LBS_SORT, $WS_EX_OVERLAPPEDWINDOW)
    GUICtrlSetOnEvent($hList, "itemClicked"); event -> if an item in the list was selected, call function 'itemClicked'
    GUICtrlSetState($hList, $GUI_HIDE); hide the list

    Global $wList = GUICtrlCreateList("", 493, 233, 180, 85, $LBS_SORT, $WS_EX_OVERLAPPEDWINDOW)
    GUICtrlSetState($wList, $GUI_HIDE); hide the list

    GUICtrlCreateLabel("Von Stadt", 20, 4, 95, 17, $SS_CENTER)
    GUICtrlSetFont(-1, 12, 600)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0xFFE4C4)
    GUICtrlCreateLabel("Nach Stadt", 390, 4, 95, 17, $SS_CENTER)
    GUICtrlSetFont(-1, 12, 600)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0x000000)

    ; Reference to label which needs to be set when clicking an item5
    Global $currentLabel

    #region Combos Stadtauswahl
    ; Create Combos
    Local $abstand = 30 ; distance between combo boxes
    For $i = 0 To $comboAmount - 1
    $combosLeft[$i][0] = createCombo(20, 25 + $i * $abstand, 95, 25)
    $combosLeft[$i][1] = GUICtrlCreateLabel("", 130, 27 + $i * $abstand, 250, 30, $SS_CENTER) ; Create label next to combo
    GUICtrlSetFont(-1, 10, 600)
    GUICtrlSetColor(-1, 0x000000)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    $combosRight[$i] = createCombo(390, 25 + $i * $abstand, 95, 25)
    GUICtrlSetOnEvent($combosLeft[$i][0], "comboChanged"); event -> if a combobox changed it's value, call function 'comboChanged'
    Next
    #endregion Combos Stadtauswahl
    GUISetState(@SW_SHOW)
    #region Combos Warenauswahl
    ; Create Combos
    Local $abstand = 30 ; distance between combo boxes
    For $i = 0 To $comboAmountWare - 1
    $comboware[$i][0] = createComboo(493, 205 + $i * $abstand, 180, 25)
    $comboware1[$i][1] = GUICtrlCreateLabel("", 250, 10 + $i * $abstand, 100, 15, $SS_LEFT) ; Create label next to combo
    GUICtrlSetState(-1, $GUI_HIDE)
    GUICtrlSetOnEvent($comboware[$i][0], "comboChangedd")
    Next
    #endregion Combos Warenauswahl

    ; building view done
    $hActive = WinGetHandle ("[active]", "") ; speichert das Handle des fokussierten Fensters
    ; show view
    WinSetOnTop($Form1, "", 1) ; TopMost für GUI

    $Form2 = GUICreate("Test", 100, 100, 100, 100)
    GUICtrlSetState($Form2, $GUI_HIDE)

    ;idle around..
    While 1
    Sleep(4000)
    WEnd


    #region Func Combos Stadt
    ; closes the programm
    Func close()
    _log("Closing programm")
    Exit
    EndFunc ;==>close


    ; Get all Town names
    Func getTowns()
    _log("Reading section names..")
    Local $sectioNames = IniReadSectionNames($fileName) ; Read all sections name from the ini

    If (@error) Then ; check if error occured
    Local $errorMsg = "Could not open file '" & $fileName & "'."
    _log($errorMsg, True)
    MsgBox(0, "Error", $errorMsg)
    Return -1
    EndIf

    _log("Read " & $sectioNames[0] & " section names.")
    Return $sectioNames
    EndFunc ;==>getTowns

    ; Returns string of available items in a town ( sperated by | )
    Func getItems($town)
    Local $items = IniReadSection($fileName, $town) ; read the items of a section, specified by the section name (e.g. town name)
    If (@error) Then ; check for errors
    Local $errorMsg = "Could not read section '" & $town & "'."
    _log($errorMsg, True)
    MsgBox(0, "Error", $errorMsg)
    Return -1
    EndIf

    Local $itemAmount = $items[0][0] ; items[0][0] holds amount of found items in section
    ; item definition in ini: name=value -> Apfel=0
    ; $items[x][0] = item name
    ; $items[x][1] = item value

    _log("Found '" & $itemAmount & "' items for town '" & $town & "'.")
    ; create string of items, sperated by '|'
    Local $availableItems
    For $i = 1 To $itemAmount
    $availableItems &= $items[$i][0]; get item name, because value is not of interest
    If ($i < $itemAmount) Then $availableItems &= "|"; if there are more items following, add a '|'
    Next

    Return $availableItems
    EndFunc ;==>getItems
    #endregion Func Combos Stadt

    #region Func Combos Waren
    ; closes the programm
    Func closet()
    _loge("Closing program")
    Exit
    EndFunc ;==>close


    ; Get all Waren names
    Func getWare()
    _loge("Reading section names..")
    Local $sectioNamesWare = IniReadSectionNames($fileNameWare) ; Read all sections name from the ini

    If (@error) Then ; check if error occured
    Local $errorMsg = "Could not open file '" & $fileNameWare & "'."
    _loge($errorMsg, True)
    MsgBox(0, "Error", $errorMsg)
    Return -1
    EndIf

    _loge("Read " & $sectioNamesWare[0] & " section names.")
    Return $sectioNamesWare
    EndFunc ;==>getWare

    ; Returns string of available items in a town ( sperated by | )
    Func getWareitems($ware)
    Local $itemss = IniReadSection($fileNameWare, $ware) ; read the items of a section, specified by the section name (e.g. town name)
    If (@error) Then ; check for errors
    Local $errorMsg = "Could not read section '" & $ware & "'."
    _loge($errorMsg, True)
    MsgBox(0, "Error", $errorMsg)
    Return -1
    EndIf

    Local $itemAmountt = $itemss[0][0] ; items[0][0] holds amount of found items in section
    ; item definition in ini: name=value -> Apfel=0
    ; $items[x][0] = item name
    ; $items[x][1] = item value

    _loge("Found '" & $itemAmountt & "' items for town '" & $ware & "'.")
    ; create string of items, sperated by '|'
    Local $availableItemss
    For $i = 1 To $itemAmountt
    $availableItemss &= $itemss[$i][0]; get item name, because value is not of interest
    If ($i < $itemAmountt) Then $availableItemss &= "|"; if there are more items following, add a '|'
    Next

    Return $availableItemss
    EndFunc ;==>getItems
    #endregion Func Combos Waren

    ; Creates a combo box with the given parameters
    Func createCombo($x, $y, $width, $height)
    Local $string
    For $i = 2 To $towns[0]
    $string &= $towns[$i]
    If ($i < $towns[0]) Then $string &= "|"
    Next
    $combo = GUICtrlCreateCombo($towns[1], $x, $y, $width, $height, BitOR($CBS_SORT, $CBS_AUTOHSCROLL, $CBS_DROPDOWNLIST, $WS_VSCROLL))
    GUICtrlSetData(-1, $string, "")
    Return $combo
    EndFunc ;==>createCombo

    Func createComboo($x, $y, $width, $height)
    Local $string
    For $i = 2 To $ware[0]
    $string &= $ware[$i]
    If ($i < $ware[0]) Then $string &= "|"
    Next
    $combo = GUICtrlCreateCombo($ware[1], $x, $y, $width, $height, BitOR($CBS_SORT, $CBS_AUTOHSCROLL, $CBS_DROPDOWNLIST, $WS_VSCROLL))
    GUICtrlSetData(-1, $string, "")
    GUICtrlSetState($combo, $GUI_SHOW)
    Return $combo
    EndFunc ;==>createCombo

    ; Prints message with time and @crlf
    Func _log($message, $error = False)
    If ($error) Then
    ConsoleWriteError(@HOUR & ":" & @MIN & ":" & @SEC & @TAB & $message & @CRLF)
    Else
    ConsoleWrite(@HOUR & ":" & @MIN & ":" & @SEC & @TAB & $message & @CRLF)
    EndIf

    EndFunc ;==>_log

    ; Prints message with time and @crlf
    Func _loge($message, $error = False)
    If ($error) Then
    ConsoleWriteError(@HOUR & ":" & @MIN & ":" & @SEC & @TAB & $message & @CRLF)
    Else
    ConsoleWrite(@HOUR & ":" & @MIN & ":" & @SEC & @TAB & $message & @CRLF)
    EndIf

    EndFunc ;==>_log

    ; event callback: will be called if a combo box changed its value
    Func comboChanged()
    _log("Combo " & @GUI_CtrlId & " was selected")
    Local $clickedCombo = -1
    ; find what combo was clicked
    For $i = 0 To UBound($combosLeft)
    If (@GUI_CtrlId == $combosLeft[$i][0]) Then ; check if currentCombo was the source of the event
    $clickedCombo = $combosLeft[$i][0] ; save the clicked combo, to retreive it's actual state
    $currentLabel = $combosLeft[$i][1] ; save the label, to be able to save the selected value from list in it
    ExitLoop
    EndIf
    Next

    If ($clickedCombo == -1) Then ; check if combo was found
    _log("Unknown combo was clicked..", True)
    Return -1
    EndIf

    Local $selectedItem = GUICtrlRead($clickedCombo) ; read the value of the combo
    _log("Item " & $selectedItem & " was clicked.")

    Local $items = getItems($selectedItem) ; get all items, of the selcted 'town'

    If ($items == -1) Then ; check if an error occured
    _log("Could not retreive items for town '" & $selectedItem & "'", True)
    Return -1
    EndIf

    GUICtrlSetData($hList, "");clear List
    GUICtrlSetData($hList, $items); add items
    GUICtrlSetState($hList, $GUI_SHOW) ; show List
    EndFunc ;==>comboChanged

    ; event callback: called if an item in the List was selected
    Func itemClicked()
    If (@GUI_CtrlId <> $hList) Then ; check if source of the event was our list
    _log("Unkown callback..", True)
    Return -1
    EndIf

    Local $selectedItem = GUICtrlRead($hList) ; Read what value was selcted in the list
    _log("Item '" & $selectedItem & "' in List was clicked")

    GUICtrlSetState($hList, $GUI_HIDE);clear List
    GUICtrlSetData($currentLabel, $selectedItem); set the selected item to the label, saved before
    EndFunc ;==>itemClicked
    #endregion functions Stadt -------------------------------------------------------------------------------------------------

    Func comboChangedd()
    _loge("Combo " & @GUI_CtrlId & " was selected")
    Local $clickedComboo = -1
    ; find what combo was clicked
    For $i = 0 To UBound($comboware)
    If (@GUI_CtrlId == $comboware[$i][0]) Then ; check if currentCombo was the source of the event
    $clickedComboo = $comboware[$i][0] ; save the clicked combo, to retreive it's actual state
    $currentLabel = $comboware1[$i][1] ; save the label, to be able to save the selected value from list in it
    ExitLoop
    EndIf
    Next

    If ($clickedComboo == -1) Then ; check if combo was found
    _loge("Unknown combo was clicked..", True)
    Return -1
    EndIf

    Local $selectedItem = GUICtrlRead($clickedComboo) ; read the value of the combo
    _loge("Item " & $selectedItem & " was clicked.")

    Local $itemss = getWareitems($selectedItem) ; get all items, of the selcted 'town'

    If ($itemss == -1) Then ; check if an error occured
    _loge("Could not retreive items for town '" & $selectedItem & "'", True)
    Return -1
    EndIf
    GUICtrlSetData($wList, "");clear List
    GUICtrlSetData($wList, $itemss); add items
    GUICtrlSetState($wList, $GUI_SHOW) ; show List
    EndFunc ;==>comboChanged



    Wenn du so nett wärst, könntest da mal bitte rein sehen wäre echt nett.

    Mfg Ghostleader

  • Ich habe jetzt nicht hineingesehen aber im OnEventMode ist es genauso machbar.
    (Ich persönlich finde den OnEvent sogar schöner :) )

    Du musst einfach nur das was jetzt unter Case $GUI_EVENT_MINIMIZE in eine Funktion packen und mit GUISetOnEvent($GUI_EVENT_MINIMIZE, "Func", $Form1) zuweisen.
    Falls du nicht weiter weißt kann ich mir das script schon mal ansehn ;)

  • Hallo Schnitzel,

    Danke dir vielmals hat auf Anhieb super funktioniert  :) .

    Spoiler anzeigen

    #include <ComboConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GuiListView.au3>
    #include <ListviewConstants.au3>
    #include <EditConstants.au3>
    #include <ListboxConstants.au3>


    Opt("GUIOnEventMode", 1) ; Activate Event mode
    $Form1 = GUICreate("WarenHandelsTool", 680, 330, 192, 124)
    GUISetOnEvent($GUI_EVENT_CLOSE, "close") ; event -> if close was clicked, call function 'close'
    GUISetOnEvent($GUI_EVENT_MINIMIZE, "minimizeForm1")

    $PicPet = GUICtrlCreatePic(@Scriptdir & "\BackgroundStormdevil.jpg", 0, 0, 680, 330)
    GUICtrlSetState($PicPet, $GUI_DISABLE)

    Global $fileName = "StaedteHandelstool.ini"
    Global $fileNameWare = "Waren.ini"
    Dim $towns = getTowns() ; get all available towns
    Dim $ware = getWare() ; get all available Waren

    Global $comboAmountWare = 1
    Global $comboAmount = 10 ; row amount of combo boxes to be created
    Dim $combosLeft[$comboAmount][2] ; [x][0] = combo [x][1] = label
    Dim $combosRight[$comboAmount]
    Dim $comboware [$comboAmountWare][2]
    Dim $comboware1 [$comboAmountWare][2]

    ; Create List
    Global $hList = GUICtrlCreateList("", 493, 25, 180, 85, $LBS_SORT, $WS_EX_OVERLAPPEDWINDOW)
    GUICtrlSetOnEvent($hList, "itemClicked"); event -> if an item in the list was selected, call function 'itemClicked'
    GUICtrlSetState($hList, $GUI_HIDE); hide the list

    Global $wList = GUICtrlCreateList("", 493, 233, 180, 85, $LBS_SORT, $WS_EX_OVERLAPPEDWINDOW)
    GUICtrlSetState($wList, $GUI_HIDE); hide the list

    GUICtrlCreateLabel("Von Stadt", 20, 4, 95, 17, $SS_CENTER)
    GUICtrlSetFont(-1, 12, 600)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0xFFE4C4)
    GUICtrlCreateLabel("Nach Stadt", 390, 4, 95, 17, $SS_CENTER)
    GUICtrlSetFont(-1, 12, 600)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0x000000)

    ; Reference to label which needs to be set when clicking an item5
    Global $currentLabel

    #region Combos Stadtauswahl
    ; Create Combos
    Local $abstand = 30 ; distance between combo boxes
    For $i = 0 To $comboAmount - 1
    $combosLeft[$i][0] = createCombo(20, 25 + $i * $abstand, 95, 25)
    $combosLeft[$i][1] = GUICtrlCreateLabel("", 130, 27 + $i * $abstand, 250, 30, $SS_CENTER) ; Create label next to combo
    GUICtrlSetFont(-1, 10, 600)
    GUICtrlSetColor(-1, 0x000000)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    $combosRight[$i] = createCombo(390, 25 + $i * $abstand, 95, 25)
    GUICtrlSetOnEvent($combosLeft[$i][0], "comboChanged"); event -> if a combobox changed it's value, call function 'comboChanged'
    Next
    #endregion Combos Stadtauswahl

    #region Combos Warenauswahl
    ; Create Combos
    Local $abstand = 30 ; distance between combo boxes
    For $i = 0 To $comboAmountWare - 1
    $comboware[$i][0] = createComboo(493, 205 + $i * $abstand, 180, 25)
    $comboware1[$i][1] = GUICtrlCreateLabel("", 250, 10 + $i * $abstand, 100, 15, $SS_LEFT) ; Create label next to combo
    GUICtrlSetState(-1, $GUI_HIDE)
    GUICtrlSetOnEvent($comboware[$i][0], "comboChangedd")
    Next
    #endregion Combos Warenauswahl

    GUISetState(@SW_SHOW)

    Opt("GUIOnEventMode", 1)
    $Form2 = GUICreate("Form2", 50, 43, 20, 10, $WS_POPUP)
    GUISetOnEvent($GUI_EVENT_CLOSE, "close")
    GUISetOnEvent($GUI_EVENT_MINIMIZE, "minimizeForm2")
    $PicPet = GUICtrlCreatePic(@Scriptdir & "\BackgroundStormdevil.jpg", 0, 0, 680, 330)
    GUICtrlSetState($PicPet, $GUI_DISABLE)
    GUICtrlCreateButton("test",0,0,30,18)
    GUICtrlSetOnEvent(-1, "minimizeForm2")
    GUISetState(@SW_SHOW)
    GUISetState(@SW_MINIMIZE)

    ; building view done
    $hActive = WinGetHandle ("[active]", "") ; speichert das Handle des fokussierten Fensters
    ; show view
    WinSetOnTop($Form1, "", 1) ; TopMost für GUI

    $hActive = WinGetHandle ("[active]", "") ; speichert das Handle des fokussierten Fensters
    ; show view
    WinSetOnTop($Form2, "", 1)

    ;idle around..
    While 1
    Sleep(4000)
    WEnd


    #region Func Combos Stadt
    ; closes the programm
    Func close()
    _log("Closing programm")
    Exit
    EndFunc ;==>close

    Func minimizeForm1()
    GUISetState(@SW_RESTORE, $Form2)
    EndFunc

    Func minimizeForm2()
    GUISetState(@SW_RESTORE, $Form1)
    GUISetState(@SW_MINIMIZE, $Form2)
    EndFunc

    ; Get all Town names
    Func getTowns()
    _log("Reading section names..")
    Local $sectioNames = IniReadSectionNames($fileName) ; Read all sections name from the ini

    If (@error) Then ; check if error occured
    Local $errorMsg = "Could not open file '" & $fileName & "'."
    _log($errorMsg, True)
    MsgBox(0, "Error", $errorMsg)
    Return -1
    EndIf

    _log("Read " & $sectioNames[0] & " section names.")
    Return $sectioNames
    EndFunc ;==>getTowns

    ; Returns string of available items in a town ( sperated by | )
    Func getItems($town)
    Local $items = IniReadSection($fileName, $town) ; read the items of a section, specified by the section name (e.g. town name)
    If (@error) Then ; check for errors
    Local $errorMsg = "Could not read section '" & $town & "'."
    _log($errorMsg, True)
    MsgBox(0, "Error", $errorMsg)
    Return -1
    EndIf

    Local $itemAmount = $items[0][0] ; items[0][0] holds amount of found items in section
    ; item definition in ini: name=value -> Apfel=0
    ; $items[x][0] = item name
    ; $items[x][1] = item value

    _log("Found '" & $itemAmount & "' items for town '" & $town & "'.")
    ; create string of items, sperated by '|'
    Local $availableItems
    For $i = 1 To $itemAmount
    $availableItems &= $items[$i][0]; get item name, because value is not of interest
    If ($i < $itemAmount) Then $availableItems &= "|"; if there are more items following, add a '|'
    Next

    Return $availableItems
    EndFunc ;==>getItems
    #endregion Func Combos Stadt

    #region Func Combos Waren
    ; closes the programm
    Func closet()
    _loge("Closing program")
    Exit
    EndFunc ;==>close


    ; Get all Waren names
    Func getWare()
    _loge("Reading section names..")
    Local $sectioNamesWare = IniReadSectionNames($fileNameWare) ; Read all sections name from the ini

    If (@error) Then ; check if error occured
    Local $errorMsg = "Could not open file '" & $fileNameWare & "'."
    _loge($errorMsg, True)
    MsgBox(0, "Error", $errorMsg)
    Return -1
    EndIf

    _loge("Read " & $sectioNamesWare[0] & " section names.")
    Return $sectioNamesWare
    EndFunc ;==>getWare

    ; Returns string of available items in a town ( sperated by | )
    Func getWareitems($ware)
    Local $itemss = IniReadSection($fileNameWare, $ware) ; read the items of a section, specified by the section name (e.g. town name)
    If (@error) Then ; check for errors
    Local $errorMsg = "Could not read section '" & $ware & "'."
    _loge($errorMsg, True)
    MsgBox(0, "Error", $errorMsg)
    Return -1
    EndIf

    Local $itemAmountt = $itemss[0][0] ; items[0][0] holds amount of found items in section
    ; item definition in ini: name=value -> Apfel=0
    ; $items[x][0] = item name
    ; $items[x][1] = item value

    _loge("Found '" & $itemAmountt & "' items for town '" & $ware & "'.")
    ; create string of items, sperated by '|'
    Local $availableItemss
    For $i = 1 To $itemAmountt
    $availableItemss &= $itemss[$i][0]; get item name, because value is not of interest
    If ($i < $itemAmountt) Then $availableItemss &= "|"; if there are more items following, add a '|'
    Next

    Return $availableItemss
    EndFunc ;==>getItems
    #endregion Func Combos Waren

    ; Creates a combo box with the given parameters
    Func createCombo($x, $y, $width, $height)
    Local $string
    For $i = 2 To $towns[0]
    $string &= $towns[$i]
    If ($i < $towns[0]) Then $string &= "|"
    Next
    $combo = GUICtrlCreateCombo($towns[1], $x, $y, $width, $height, BitOR($CBS_SORT, $CBS_AUTOHSCROLL, $CBS_DROPDOWNLIST, $WS_VSCROLL))
    GUICtrlSetData(-1, $string, "")
    Return $combo
    EndFunc ;==>createCombo

    Func createComboo($x, $y, $width, $height)
    Local $string
    For $i = 2 To $ware[0]
    $string &= $ware[$i]
    If ($i < $ware[0]) Then $string &= "|"
    Next
    $combo = GUICtrlCreateCombo($ware[1], $x, $y, $width, $height, BitOR($CBS_SORT, $CBS_AUTOHSCROLL, $CBS_DROPDOWNLIST, $WS_VSCROLL))
    GUICtrlSetData(-1, $string, "")
    GUICtrlSetState($combo, $GUI_SHOW)
    Return $combo
    EndFunc ;==>createCombo

    ; Prints message with time and @crlf
    Func _log($message, $error = False)
    If ($error) Then
    ConsoleWriteError(@HOUR & ":" & @MIN & ":" & @SEC & @TAB & $message & @CRLF)
    Else
    ConsoleWrite(@HOUR & ":" & @MIN & ":" & @SEC & @TAB & $message & @CRLF)
    EndIf

    EndFunc ;==>_log

    ; Prints message with time and @crlf
    Func _loge($message, $error = False)
    If ($error) Then
    ConsoleWriteError(@HOUR & ":" & @MIN & ":" & @SEC & @TAB & $message & @CRLF)
    Else
    ConsoleWrite(@HOUR & ":" & @MIN & ":" & @SEC & @TAB & $message & @CRLF)
    EndIf

    EndFunc ;==>_log

    ; event callback: will be called if a combo box changed its value
    Func comboChanged()
    _log("Combo " & @GUI_CtrlId & " was selected")
    Local $clickedCombo = -1
    ; find what combo was clicked
    For $i = 0 To UBound($combosLeft)
    If (@GUI_CtrlId == $combosLeft[$i][0]) Then ; check if currentCombo was the source of the event
    $clickedCombo = $combosLeft[$i][0] ; save the clicked combo, to retreive it's actual state
    $currentLabel = $combosLeft[$i][1] ; save the label, to be able to save the selected value from list in it
    ExitLoop
    EndIf
    Next

    If ($clickedCombo == -1) Then ; check if combo was found
    _log("Unknown combo was clicked..", True)
    Return -1
    EndIf

    Local $selectedItem = GUICtrlRead($clickedCombo) ; read the value of the combo
    _log("Item " & $selectedItem & " was clicked.")

    Local $items = getItems($selectedItem) ; get all items, of the selcted 'town'

    If ($items == -1) Then ; check if an error occured
    _log("Could not retreive items for town '" & $selectedItem & "'", True)
    Return -1
    EndIf

    GUICtrlSetData($hList, "");clear List
    GUICtrlSetData($hList, $items); add items
    GUICtrlSetState($hList, $GUI_SHOW) ; show List
    EndFunc ;==>comboChanged

    ; event callback: called if an item in the List was selected
    Func itemClicked()
    If (@GUI_CtrlId <> $hList) Then ; check if source of the event was our list
    _log("Unkown callback..", True)
    Return -1
    EndIf

    Local $selectedItem = GUICtrlRead($hList) ; Read what value was selcted in the list
    _log("Item '" & $selectedItem & "' in List was clicked")

    GUICtrlSetState($hList, $GUI_HIDE);clear List
    GUICtrlSetData($currentLabel, $selectedItem); set the selected item to the label, saved before
    EndFunc ;==>itemClicked
    #endregion functions Stadt -------------------------------------------------------------------------------------------------

    Func comboChangedd()
    _loge("Combo " & @GUI_CtrlId & " was selected")
    Local $clickedComboo = -1
    ; find what combo was clicked
    For $i = 0 To UBound($comboware)
    If (@GUI_CtrlId == $comboware[$i][0]) Then ; check if currentCombo was the source of the event
    $clickedComboo = $comboware[$i][0] ; save the clicked combo, to retreive it's actual state
    $currentLabel = $comboware1[$i][1] ; save the label, to be able to save the selected value from list in it
    ExitLoop
    EndIf
    Next

    If ($clickedComboo == -1) Then ; check if combo was found
    _loge("Unknown combo was clicked..", True)
    Return -1
    EndIf

    Local $selectedItem = GUICtrlRead($clickedComboo) ; read the value of the combo
    _loge("Item " & $selectedItem & " was clicked.")

    Local $itemss = getWareitems($selectedItem) ; get all items, of the selcted 'town'

    If ($itemss == -1) Then ; check if an error occured
    _loge("Could not retreive items for town '" & $selectedItem & "'", True)
    Return -1
    EndIf
    GUICtrlSetData($wList, "");clear List
    GUICtrlSetData($wList, $itemss); add items
    GUICtrlSetState($wList, $GUI_SHOW) ; show List
    EndFunc ;==>comboChanged




    Nun auch gleich noch ne andere Frage.


    Ich wollte eigentlich für die GUI2 den Stile $WS_POPUP verwenden, aber wie ich gerade feststellte kann man dann die GUI nicht mehr frei bewegen. Dies ist aber wichtig, da ja jeder eine andere Bildschirmauflösung hat, sodass man die Coordinaten ja nicht vorgeben kann. Nutzt man aber nen normalen Stile, sieht das ja Blöd aus.
    Ist da irgendwas machbar, oder geht das da nicht, denn eigentlich sollte die Gui2 wie ein TrayIcon fungieren wo man drauf klickt um Gui1 wieder aufzurufen,
    Ist das überhaupt möglich klicken auf eine Gui um eine andere aufzurufen quasi wie jetzt mit dem Button nur ohne diesen also rein die Gui?


    Mfg Ghostleader

  • Du könntest die Mausposition in der Gui abfragen und bei linker maustaste ein verschieben befehl senden

    Spoiler anzeigen
    [autoit]

    ; Original code - martin
    #include <GuiconstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <SendMessage.au3>

    Global Const $SC_DRAGMOVE = 0xF012

    HotKeySet("{ESC}", "On_Exit")

    $hGUI = GUICreate("X", 100, 100, -1, -1, $WS_POPUP)
    GUISetBkColor(0x00FF00, $hGUI)
    $hButton = GUICtrlCreateButton("Test", 10, 35, 80, 30)
    GUISetState()

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_PRIMARYDOWN
    _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
    Case $hButton
    On_Button()
    EndSwitch
    WEnd

    Func On_Button()
    MsgBox(0, "Hi", "Button Pressed")
    EndFunc ;==>On_Button

    Func On_Exit()
    Exit
    EndFunc ;==>On_Exit

    [/autoit]

    Besipiel von: http://www.autoitscript.com/wiki/Moving_an…zing_PopUp_GUIs

    Für die Coordinaten innerhalb des fensters kannst du

    [autoit]

    #include <WinAPI.au3>
    _WinAPI_GetMousePos(True , $hWnd);$hWnd = dein Fenster Handel

    [/autoit]

    verwenden und einen mausklick kannst du auch alternativ mit

    [autoit]

    #include <Misc.au3>
    if _IsPressed("01") Then

    [/autoit]


    erfassen

    2 Mal editiert, zuletzt von Skerg (20. November 2013 um 13:25)

  • Du kannst eine $WS_POPUP Gui schon bewegen. Dafür gibts einige Möglichkeiten:
    http://www.autoitscript.com/wiki/Moving_an…zing_PopUp_GUIs

    Ist da irgendwas machbar, oder geht das da nicht, denn eigentlich sollte die Gui2 wie ein TrayIcon fungieren wo man drauf klickt um Gui1 wieder aufzurufen,


    Warum nimmst du nicht gleich das Trayicon her?

    Ist das überhaupt möglich klicken auf eine Gui um eine andere aufzurufen quasi wie jetzt mit dem Button nur ohne diesen also rein die Gui?


    Ja ist es ^^
    z.B. mit $GUI_EVENT_PRIMARYDOWN

  • Bei einem Standard Autoitscript wird doch immer auch ein Trayicon erstellt. ( Mit Exit und Script Paused )
    Das lässt sich aber auch ändern. Du kannst genauso machen, dass ein Klick auf das Trayicon deine GUI wiederherstellt.
    Sowas willst du doch oder habe ich dich falsch verstanden?

  • Hallo,

    ja genau sowas möchte ich im Endeffekt, aber ist das Icon denn bewegbar und vor allem habe ich gerade gar keine Ahnung wie ich das umsetzen kann. :(

    Ps: Das bild müsste dann wie auch jetzt die Gui im Vordergrund beim Vollbild Modus des Spieles sein das ist wichtig.

    Mfg

    Einmal editiert, zuletzt von Ghostleader (20. November 2013 um 13:37)

  • Ps: Das bild müsste dann wie auch jetzt die Gui im Vordergrund beim Vollbild Modus des Spieles sein das ist wichtig.

    Von was genau reden wir denn hier?
    Was für ein Spiel? Was für ein Vollbildmodus? Und was macht das Script später mal?
    Das Trayicon wirst in einem Vollbildmodus nicht sehen...

  • Hallo,

    also in dem Script kann man verschiedene Routen eintragen per Klicken die man beim Handel fahren möchte, quasi als Übersicht für den Handel.

    Da aber das Script stört während des Laufens oder des Fahren, kann man es ja minimieren. Wenn man dies getan hat, soll man es aber (bei gebrauch) über ein kleines Icon was bei minimiertem Script sichtbar sein soll wieder in den Vordergrund rufen können.

    Mfg Ghostleader

    • Offizieller Beitrag

    also in dem Script kann man verschiedene Routen eintragen per Klicken die man beim Handel fahren möchte, quasi als Übersicht für den Handel.


    Ist das ein Spiel?
    Dann sende mir bitte die Erlaubnis des Spieleherstellers, dass du dieses automatisieren darfst - solange bleibt der Thread geschlossen.

    So, ist nun geklärt. Es handelt sich hierbei lediglich um eine Art grafisches Notizbuch zum Spiel. Keinerlei Interaktionen mit dem Spiel und somit alles regelkonform.
    Sorry Ghostleader für die Umstände, aber manchmal muss man halt etwas nachfragen.

  • Danke BugFix für die Klärung und wieder Öffnung des Threads.

    So nun gleich noch ein paar kleine Fragen die mir etwas Kopfzerbrechen machen und wo ich net weiter komme.

    1. Löschen der Gui und auf Anfang zurück setzen.
    Wenn Button gedrückt soll quasi alles auf Anfang gesetzt sein d.h. Alle Combos wieder Sortiert, alle Label´s gelöscht und List´s geschlossen sein, so wie bei start des Programms.
    Habe das so versucht, aber dann bricht das Tool ab:

    Spoiler anzeigen
    [autoit]

    Opt("GUIOnEventMode", 1)
    $ButtonLoeschen = GUICtrlCreateButton("Test", 550, 170, 50, 25)
    GUICtrlSetOnEvent(-1, "loeschenForm1")

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

    Func loeschenForm1()
    GUIDelete()
    EndFunc

    [/autoit]

    3. Zweite gui auch sichtbar wenn man zb. vom Vollbild Modus des Spieles auf den Desktop wechselt oder woanders hin. Kann man das anzeigen abhängig vom Spiel machen, also das die zweite Gui nur angezeigt wird, wenn das Spielfenster auch wirklich aufgerufen und nicht minimiert ist?

    Mfg Ghostleader

    Einmal editiert, zuletzt von Ghostleader (21. November 2013 um 16:35)

  • 1. Speicher dir deine ganzen Standardwerte einfach in Variablen bzw Array's. Dann kannst du in der loeschenForm1() Funktion einfach alle Controls mit ihrem Standardwert befüllen (Guictrlsetdata und so )

    3. WinGetState()