Danke Jungs, diese Interrupting a running function https://www.autoitscript.com/wiki/Interrupt…unning_function und Managing Multiple GUIs https://www.autoitscript.com/wiki/Managing_Multiple_GUIs Geschichte kann je nach Situation echt kompliziert werden. Habe zum Glück zu meiner Situation eine passende Lösung gefunden, inspiriert habe ich mich dabei an _ArrayDisplay().
[autoit]#include-once
[/autoit][autoit][/autoit][autoit]Func SuccessesErrorsGUI($gui, $oErrorList, $oSuccessList)
[/autoit][autoit][/autoit][autoit]#Region - Take Screenshot
_GDIPlus_Startup()
Local $hBmp = _ScreenCapture_CaptureWnd("", $gui, 0, 0, -1, -1, False) ; create screenshot of gui without cursor
Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp)
Local $iX = _GDIPlus_ImageGetWidth($hBitmap)
Local $iY = _GDIPlus_ImageGetHeight($hBitmap)
Local $hResizedBitmap = _GDIPlus_ImageResize($hBitmap, $iX-($iX*0.65), $iY-($iX*0.65))
; release data
_GDIPlus_BitmapDispose($hBitmap)
_WinAPI_DeleteObject($hBmp)
#EndRegion - Take Screenshot
Local $hGUI = GUICreate("Show Successes/Errors", 240, 130 ,-1, -1) ; will create a dialog box that when displayed is centered
Local $oSuccessesErrors = ObjCreate("Scripting.Dictionary")
$oSuccessesErrors.add("bExpand", False)
$oSuccessesErrors.add("hBitmap", $hResizedBitmap)
Local $oCoord = _Coord_GetDimensions($hGUI, 0, True) ; get proper coordinates
Opt("GUICoordMode", 1) ; absolute position
Local $idSuccessButton = GUICtrlCreateButton("Successes", $oCoord("g1_left"), 10, 180, 50, $BS_COMMANDLINK)
_GUICtrlButton_SetImage(_GUIGetLastCtrlID(), "ieframe.dll", 38, False)
_GUICtrlButton_SetNote(_GUIGetLastCtrlID(), "Count: " & $oSuccessList.Count)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
Opt("GUICoordMode", 2) ; relative to cell mode
Local $idErrorButton = GUICtrlCreateButton("Errors", -1, 10, 180, 50, $BS_COMMANDLINK)
_GUICtrlButton_SetImage(_GUIGetLastCtrlID(), "imageres.dll", 93, False)
_GUICtrlButton_SetNote(_GUIGetLastCtrlID(), "Count: " & $oErrorList.Count)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUISetState(@SW_SHOW)
; switch to GetMessage mode
Local $iOnEventMode = Opt("GUIOnEventMode", 0)
Local $iMsg, $oSuccessesErrorsList
$oSuccessesErrors.add("idPrevButton", 0)
$oSuccessesErrors.add("idNextButton", 0)
$oSuccessesErrors.add("idEdit", 0)
$oSuccessesErrors.add("sText", 0)
While 1
$iMsg = GUIGetMsg()
Switch $iMsg
Case $idSuccessButton
$oSuccessesErrorsList = $oSuccessList
$oSuccessesErrors("sText") = "Successes"
ResizeGUI($oSuccessesErrors)
Case $idErrorButton
$oSuccessesErrorsList = $oErrorList
$oSuccessesErrors("sText") = "Errors"
ResizeGUI($oSuccessesErrors)
Case $oSuccessesErrors("idPrevButton")
If IsHWnd(GUICtrlGetHandle($oSuccessesErrors("idPrevButton"))) Then ToggleMsg($oSuccessesErrors, $oSuccessesErrorsList, -1)
Case $oSuccessesErrors("idNextButton")
If IsHWnd(GUICtrlGetHandle($oSuccessesErrors("idNextButton"))) Then ToggleMsg($oSuccessesErrors, $oSuccessesErrorsList, 1)
Case -3
ExitLoop
EndSwitch
WEnd
; clear up
GUIDelete($hGUI)
Opt("GUIOnEventMode", $iOnEventMode) ; reset original GUI mode
EndFunc
Func ResizeGUI(ByRef $oSuccessesErrors)
If $oSuccessesErrors("bExpand") = False Then ExpandGUI($oSuccessesErrors, Ptr($oSuccessesErrors("hBitmap"))) ; expand GUI first time
$oSuccessesErrors("bExpand") = True
#Region - Reset toggle data
_Dict_UpdateSetKey($oSuccessesErrors, "iIndex", 0)
_Dict_UpdateSetKey($oSuccessesErrors, "iLastDirection", 0)
#EndRegion - Reset toggle data
GUICtrlSetData($oSuccessesErrors("idGroup"), $oSuccessesErrors("sText")) ; update group text
GUICtrlSetData($oSuccessesErrors("idEdit"), "") ; reset edit text
EndFunc
Func ExpandGUI(ByRef $oSuccessesErrors, $hBitmap)
WinMove("", "", Default, Default, 430, 500)
Local $iTHICKFRAME = 7 ; border of thickframe
Local $oCoord = _Coord_GetDimensions(WinGetHandle("", ""), 0, True) ; get proper coordinates of resized window
$oSuccessesErrors.add("idGroup", GUICtrlCreateGroup("", -1, 50, $oCoord("g1_width"), $oCoord("GuiClient_height")-50*2-10-10-50-$oCoord("ctrl_s2")*2-35))
Local $aPos = ControlGetPos("", "", _GUIGetLastCtrlID())
$oSuccessesErrors("idPrevButton") = GUICtrlCreateButton("", -1, $oCoord("ctrl_s2"), 35, 35, $BS_COMMANDLINK)
_GUICtrlButton_SetImage(_GUIGetLastCtrlID(), "wmploc.dll", 201)
$oSuccessesErrors("idNextButton") = GUICtrlCreateButton("", $oCoord("g1_width")-35*2, -1, 35, 35, $BS_COMMANDLINK)
_GUICtrlButton_SetImage(_GUIGetLastCtrlID(), "wmploc.dll", 200)
Opt("GUICoordMode", 1) ; absolute position
Local $iWidth = _GDIPlus_ImageGetWidth($hBitmap) ; get new width
Local $iHeight = _GDIPlus_ImageGetHeight($hBitmap) ; get new height
Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ; convert bitmap object to bitmap handle
Local $idPic = GUICtrlCreatePic("", $oCoord("g1_width")+$oCoord("g1_left")-$iWidth-$iTHICKFRAME*2, 10, $iWidth, $iHeight, $WS_THICKFRAME)
GUICtrlSendMsg(-1, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp)
$oSuccessesErrors("idEdit") = GUICtrlCreateEdit("", $oCoord("g2_left"), $aPos[1]+$oCoord("g1_top"), $oCoord("g1_width")-$oCoord("g2_left"), $aPos[3]-$oCoord("g1_top")*2, _
BitOR($ES_WANTRETURN,$WS_BORDER))
; release data
_GDIPlus_BitmapDispose($hBitmap)
_WinAPI_DeleteObject($hBmp)
_GDIPlus_Shutdown()
EndFunc
Func ToggleMsg(Byref $oSuccessesErrors, $oSuccessesErrorsList, $iDirection)
If $oSuccessesErrors("iLastDirection") = $iDirection And $oSuccessesErrors("iIndex")+$iDirection >= $oSuccessesErrorsList.Count Then Return ; if out of index
If $oSuccessesErrors("iIndex")+$iDirection < 0 Then Return
If $oSuccessesErrors("iLastDirection") <> 0 Then $oSuccessesErrors("iIndex")+=$iDirection ; chnage index second time
GUICtrlSetData($oSuccessesErrors("idEdit"), $oSuccessesErrorsList.Item($oSuccessesErrors("iIndex"))) ; override message with new message
$oSuccessesErrors("iLastDirection") = $iDirection
EndFunc
Schickes GUI, was in einer OnEvent Funktion aufgerufen (hier nicht mit aufgeführt) wird und auf Interaktion wartet. Wird die GUI geschlossen werden die restlichen Befehle in der Funktion abgearbeitet. Außerhalb der GUI ist der OnEventMode nach wie vor aktiv.
@Matricus Die GUI vorher zu laden halte ich für ineffizient. (Offtopic) Ich denke dabei gerade an eine javascript library, die ich in meine Seite einbinden möchte, die aber nur an bestimmten Stellen eingebunden werden sollen und nicht bei jedem Seitenaufruf -> ineffizient.