Mein Programm lässt sich nicht (mehr) schließen ;)

  • Hallo zusammen :)
    könnt ihr mir bitte sagen, warum das Programm beim Klick auf meinen
    Schließen-Button (cmdClose) nicht geschlossen wird ? :(

    Hier ein Ausschnitt aus meinem Programm:

    [autoit]


    GUICtrlSetOnEvent($cmdClose, "GUIClose")
    GUICtrlSetOnEvent($cmdMinimize,"GUIMainMinimize")
    GUICtrlSetOnEvent($cmdStart, "AIStart")

    While 1
    sleep(100)
    WEnd



    Func AIStart()
    While 1
    m_Global()
    sleep(1000)
    WEnd
    EndFunc

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

    Func GUIClose()
    $var = MsgBox(4,"Really Close???","Are you sure you want to close AIS??")
    if $var = 6 then
    GUIDelete($ParentGUI)
    GUIDelete($ChildGUI)
    exit
    endif
    EndFunc

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


    Vielen Dank im Voraus !


    €dit: Als ich früher meine AIStart Funktion nicht hatte bzw. dort keine while 1 war, funktionierte es ;)

    Einmal editiert, zuletzt von kesandal (23. August 2007 um 22:23)

  • Man entschuldige bitte den grausamen Programmierstyl :D

    Spoiler anzeigen
    [autoit]


    #include <GUIConstants.au3>
    #Include <date.au3>
    #include <Array.au3>
    #include <GuiEdit.au3>

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

    Opt("RunErrorsFatal", 0)

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

    Opt("GUIOnEventMode", 1)
    Opt("MouseCoordMode", 1);1=absolute, 0=relative, 2=client
    Opt("PixelCoordMode", 1);1=absolute, 0=relative, 2=client

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

    Dim $usr_deskW = @DesktopWidth ; Auflösung vertikal vom User
    Dim $usr_deskH = @DesktopHeight ; Auslösung horizontal vom User

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

    Dim $hostdate = "0"
    Dim $hosttime = "0"
    Dim $statusmsg = ""

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

    Global $logmsgid = 0

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

    Dim $WindowAIS_Icon_Status = 0
    Dim $WindowAIS_Icon_Blue = 1278188

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

    Dim $WindowAISStatus = 0

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

    Dim $WindowAIS_Executable = ""
    Dim $WindowAISError = 0

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

    Global $WindowAIS_find
    Global $WindowAIS_Top
    Global $WindowAIS_Bottom

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

    ;;;;;;;;;;;;;;;;; M A I N F E N S T E R S T A R T ;;;;;;;;;;;;;;;;;

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

    $ParentGUI = GUICreate(":: AIS :: Main-Window", 283, 139, 429, 568)
    $Executable = GUICtrlCreateInput("", 8, 32, 265, 21)
    $Label1 = GUICtrlCreateLabel("File", 8, 8, 61, 17)
    $cmdStart = GUICtrlCreateButton("Start AIS", 200, 104, 73, 25, 0)
    $cmdClose = GUICtrlCreateButton("Close", 40, 104, 73, 25, 0)
    $cmdMinimize = GUICtrlCreateButton("Minimize", 120, 104, 73, 25, 0)
    GUISetState(@SW_SHOW)

    ;;;;;;;;;;;;;;;;; M A I N F E N S T E R E N D E ;;;;;;;;;;;;;;;;;;

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

    ;;;;;;;;;;;;;;;;; S T A T U S F E N S T E R S T A R T ;;;;;;;;;;;;;;;;;

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

    $ChildGUI = GUICreate(":: AIS :: Status-Window", 382, 178, 270, 420)
    GUISetBkColor(0xC0DCC0)
    $ltopic = GUICtrlCreateLabel("Status-Window", 8, 8, 106, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0xC0DCC0)
    $statustext = GUICtrlCreateEdit("", 8, 32, 369, 137, BitOR($ES_AUTOVSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_VSCROLL))
    $llogs = GUICtrlCreateLabel("Logs", 352, 8, 27, 17)
    GUICtrlSetBkColor(-1, 0xC0DCC0)
    $llogsnum = GUICtrlCreateLabel("", 296, 8, 44, 12)
    GUICtrlSetBkColor(-1, 0xC0DCC0)

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

    GUISetState(@SW_SHOW)
    WinSetOnTop("Status-Window","",1)

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

    #EndRegion ### END Koda GUI section ###

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

    ;;;;;;;;;;;;;;;;; S T A T U S F E N S T E R E N D E ;;;;;;;;;;;;;;;;;;

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

    StatusText("Program started")

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

    ; Events
    GUICtrlSetOnEvent($cmdClose, "GUIClose")
    GUICtrlSetOnEvent($cmdMinimize,"GUIMainMinimize")
    GUICtrlSetOnEvent($cmdStart, "AIStart")

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

    While 1
    sleep(100)
    WEnd

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

    Func AIStart()
    Global $f_FirstLoop = 0

    While 1
    m_Global()

    sleep(1000)
    WEnd
    EndFunc

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

    Func m_Global()

    If not $WindowAISError = 1 Then
    If not $WindowAIS_FirstLoop = 1 Then
    If Not WindowAIS_Find() Then
    WindowAIS_Start()
    Else
    WindowAIS_()
    EndIf
    $WindowAIS_FirstLoop = 1
    Else
    WindowAIS_()
    EndIf
    EndIf
    EndFunc

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

    Func WindowAIS_()
    $WindowAIS_Icon_Status = PixelGetColor (13,($WindowAIS_Top+45))

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

    Select
    case $WindowAIS_Icon_Status = $WindowAIS_Icon_Blue
    ;TO-DO alles ok !
    case Else
    StatusText("WindowAIS : [WARNING] Icon unknown !")
    If Not WindowAIS_Find() Then
    WindowAIS_Start()
    EndIf
    EndSelect
    EndFunc

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

    Func WindowAIS_Start()
    StatusText("Trying to start WindowAIS ")
    $WindowAIS_Executable = GUICtrlRead($iWindowAIS_Executable)
    Run($WindowAIS_Executable)
    If @error = 1 Then
    StatusText("WindowAIS : [WARNING] Executable hasn't been found !")
    $WindowAISError= 1
    Else
    StatusText("WindowAIS started")
    sleep(2500)
    EndIf
    EndFunc

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

    Func WindowAIS_Find()
    StatusText("Searching WindowAIS ")
    $WindowAIS_find = SearchArea("0", "0", $usr_deskW, $usr_deskW, "01F3AFFDD74E", "0", "1")
    Select
    Case Not @error
    $WindowAIS_Top = ($WindowAIS_find[1]-1)
    $WindowAIS_Bottom = (($WindowAIS_find[1]+59))
    StatusText("WindowAIS : Window has been found !")
    StatusText("WindowAIS : top: " & $WindowAIS_Top)
    StatusText("WindowAIS : bottom: "& $WindowAIS_Bottom)

    Return 1
    Case @error = 1
    StatusText("[ERROR] Window not found!")
    Return 0
    EndSelect
    EndFunc

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

    Func GUIClose()
    $var = MsgBox(4,"Really Close???","Are you sure you want to close AIS??")
    if $var = 6 then
    GUIDelete($ParentGUI)
    GUIDelete($ChildGUI)
    exit
    endif
    EndFunc

    Func GUIMainMinimize()
    GUISetState(@SW_SHOW,$ChildGUI)
    EndFunc

    Func StatusText($statusmsg)
    $logmsgid += 1
    GUICtrlSetData($llogsnum,$logmsgid)
    $prefix = "[" & _NowDate() & " / " & _NowTime() & "] : "
    $log = GUICtrlRead($statustext)
    $log = $log & $prefix & $statusmsg &@CRLF
    GUICtrlSetData($statustext,$log)
    _GUICtrlEditLineScroll ($statustext, 0,1000000 )
    EndFunc

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

    EndFunc

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

    Func SearchArea($left, $top, $right, $bottom, $areavalue, $shadevariation = 0, $step = 1)
    ;===============================================================================
    ;
    ; Description: Searches a rectangle of pixels for the pixel areavalue provided.
    ; Areavalue is combination of one or more pixel point.
    ; Syntax: _PixelsSearch ( left, top, right, bottom, color [, shade-variation] [, step]] )
    ; Parameter(s): left - left coordinate of rectangle.
    ; top - top coordinate of rectangle.
    ; right - right coordinate of rectangle.
    ; bottom - coordinate of rectangle.
    ; checksum - checksum value of the region.
    ; shadevariation - A number between 0 and 255 to indicate the allowed number of shades of
    ; variation of the red, green, and blue components of the colour. Default is 0 (exact match).
    ; step - Instead of searching each pixel use a value larger than 1 to skip pixels (for speed).
    ; E.g. A value of 2 will only check every other pixel. Default is 1.
    ; Return Value(s): On Success - Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y)
    ; On Failure - Sets @error to 1 if region is not found.
    ; - Sets @error to 2 if areavalue is invalid
    ; Author(s): quixote79
    ; Note(s): Similar to PixelSearch()
    ; It works only under Opt("MouseCoordMode", 1) and Opt("PixelCoordMode", 1)
    ;
    ;===============================================================================

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

    $areavaluelength = StringLen($areavalue) / 12
    If IsInt($areavaluelength) = 1 Then
    Local $x[$areavaluelength]
    Local $y[$areavaluelength]
    Local $color[$areavaluelength]
    If $areavaluelength <> 1 Then
    Local $xg[$areavaluelength - 1]
    Local $yg[$areavaluelength - 1]
    EndIf
    For $a = 0 To $areavaluelength - 1
    $x[$a] = Dec(StringMid($areavalue, 12 * $a + 1, 3))
    $y[$a] = Dec(StringMid($areavalue, 12 * $a + 4, 3))
    $color[$a] = Dec(StringMid($areavalue, 12 * $a + 7, 6))
    Next
    For $b = $areavaluelength - 2 To 0 Step - 1
    $xg[$b] = $x[$b + 1] - $x[0]
    $yg[$b] = $y[$b + 1] - $y[0]
    Next

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

    For $c = $top To $bottom
    $mleft = $left
    Do
    $fpos = PixelSearch($mleft, $c, $right, $c, $color[0], $shadevariation, $step)
    If Not @error Then
    $state = 0
    For $d = 0 To $areavaluelength - 2
    If PixelGetColor($fpos[0] + $xg[$d], $fpos[1] + $yg[$d]) <> $color[$d + 1] Then
    $state = 1
    ExitLoop
    EndIf
    Next
    If $state = 0 Then
    Return $fpos
    ExitLoop
    Else
    $mleft = $fpos[0] + $step
    EndIf
    Else
    ExitLoop
    EndIf
    Until $mleft >= $right
    Next
    SetError(1)
    Else
    SetError(2)
    EndIf
    EndFunc ;==>_PixelsSearch

    [/autoit]
    • Offizieller Beitrag

    Hi,

    nach dem ich die Fehler rausgemacht habe - kann ich schließen

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #Include <date.au3>
    #include <Array.au3>
    #include <GuiEdit.au3>

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

    Opt("RunErrorsFatal", 0)

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

    Opt("GUIOnEventMode", 1)
    Opt("MouseCoordMode", 1);1=absolute, 0=relative, 2=client
    Opt("PixelCoordMode", 1);1=absolute, 0=relative, 2=client

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

    Dim $usr_deskW = @DesktopWidth ; Auflösung vertikal vom User
    Dim $usr_deskH = @DesktopHeight ; Auslösung horizontal vom User
    Dim $hostdate = "0"
    Dim $hosttime = "0"
    Dim $statusmsg = ""
    Global $logmsgid = 0
    Dim $WindowAIS_Icon_Status = 0
    Dim $WindowAIS_Icon_Blue = 1278188
    Dim $WindowAISStatus = 0
    Dim $WindowAIS_Executable = ""
    Dim $WindowAISError = 0
    Global $WindowAIS_find
    Global $WindowAIS_Top
    Global $WindowAIS_Bottom
    Dim $WindowAIS_FirstLoop
    Dim $WindowAIS_Executable
    Dim $iWindowAIS_Executable

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

    ;;;;;;;;;;;;;;;;; M A I N F E N S T E R S T A R T ;;;;;;;;;;;;;;;;;

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

    $ParentGUI = GUICreate(":: AIS :: Main-Window", 283, 139, 429, 568)
    $Executable = GUICtrlCreateInput("", 8, 32, 265, 21)
    $Label1 = GUICtrlCreateLabel("File", 8, 8, 61, 17)
    $cmdStart = GUICtrlCreateButton("Start AIS", 200, 104, 73, 25, 0)
    $cmdClose = GUICtrlCreateButton("Close", 40, 104, 73, 25, 0)
    $cmdMinimize = GUICtrlCreateButton("Minimize", 120, 104, 73, 25, 0)
    GUISetState(@SW_SHOW)

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

    ;;;;;;;;;;;;;;;;; M A I N F E N S T E R E N D E ;;;;;;;;;;;;;;;;;;

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

    ;;;;;;;;;;;;;;;;; S T A T U S F E N S T E R S T A R T ;;;;;;;;;;;;;;;;;

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

    $ChildGUI = GUICreate(":: AIS :: Status-Window", 382, 178, 270, 420)
    GUISetBkColor(0xC0DCC0)
    $ltopic = GUICtrlCreateLabel("Status-Window", 8, 8, 106, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0xC0DCC0)
    $statustext = GUICtrlCreateEdit("", 8, 32, 369, 137, BitOR($ES_AUTOVSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL))
    $llogs = GUICtrlCreateLabel("Logs", 352, 8, 27, 17)
    GUICtrlSetBkColor(-1, 0xC0DCC0)
    $llogsnum = GUICtrlCreateLabel("", 296, 8, 44, 12)
    GUICtrlSetBkColor(-1, 0xC0DCC0)

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

    GUISetState(@SW_SHOW)
    WinSetOnTop("Status-Window", "", 1)

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

    #EndRegion ### END Koda GUI section ###

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

    ;;;;;;;;;;;;;;;;; S T A T U S F E N S T E R E N D E ;;;;;;;;;;;;;;;;;;

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

    StatusText("Program started")

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

    ; Events
    GUICtrlSetOnEvent($cmdClose, "GUIClose")
    GUICtrlSetOnEvent($cmdMinimize, "GUIMainMinimize")
    GUICtrlSetOnEvent($cmdStart, "AIStart")

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

    While 1
    Sleep(100)
    WEnd

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

    Func AIStart()
    Global $f_FirstLoop = 0

    While 1
    m_Global()

    Sleep(1000)
    WEnd
    EndFunc ;==>AIStart

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

    Func m_Global()
    If Not $WindowAISError = 1 Then
    If Not $WindowAIS_FirstLoop = 1 Then
    If Not WindowAIS_Find() Then
    WindowAIS_Start()
    Else
    WindowAIS_()
    EndIf
    $WindowAIS_FirstLoop = 1
    Else
    WindowAIS_()
    EndIf
    EndIf
    EndFunc ;==>m_Global

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

    Func WindowAIS_()
    $WindowAIS_Icon_Status = PixelGetColor(13, ($WindowAIS_Top + 45))

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

    Select
    Case $WindowAIS_Icon_Status = $WindowAIS_Icon_Blue
    ;TO-DO alles ok !
    Case Else
    StatusText("WindowAIS : [WARNING] Icon unknown !")
    If Not WindowAIS_Find() Then
    WindowAIS_Start()
    EndIf
    EndSelect
    EndFunc ;==>WindowAIS_

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

    Func WindowAIS_Start()
    StatusText("Trying to start WindowAIS ")
    $WindowAIS_Executable = GUICtrlRead($iWindowAIS_Executable)
    Run($WindowAIS_Executable)
    If @error = 1 Then
    StatusText("WindowAIS : [WARNING] Executable hasn't been found !")
    $WindowAISError = 1
    Else
    StatusText("WindowAIS started")
    Sleep(2500)
    EndIf
    EndFunc ;==>WindowAIS_Start

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

    Func WindowAIS_Find()
    StatusText("Searching WindowAIS ")
    $WindowAIS_find = SearchArea("0", "0", $usr_deskW, $usr_deskW, "01F3AFFDD74E", "0", "1")
    Select
    Case Not @error
    $WindowAIS_Top = ($WindowAIS_find[1] - 1)
    $WindowAIS_Bottom = (($WindowAIS_find[1] + 59))
    StatusText("WindowAIS : Window has been found !")
    StatusText("WindowAIS : top: " & $WindowAIS_Top)
    StatusText("WindowAIS : bottom: " & $WindowAIS_Bottom)

    Return 1
    Case @error = 1
    StatusText("[ERROR] Window not found!")
    Return 0
    EndSelect
    EndFunc ;==>WindowAIS_Find

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

    Func GUIClose()
    $var = MsgBox(4, "Really Close???", "Are you sure you want to close AIS??")
    If $var = 6 Then
    GUIDelete($ParentGUI)
    GUIDelete($ChildGUI)
    Exit
    EndIf
    EndFunc ;==>GUIClose

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

    Func GUIMainMinimize()
    GUISetState(@SW_SHOW, $ChildGUI)
    EndFunc ;==>GUIMainMinimize

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

    Func StatusText($statusmsg)
    $logmsgid += 1
    GUICtrlSetData($llogsnum, $logmsgid)
    $prefix = "[" & _NowDate() & " / " & _NowTime() & "] : "
    $log = GUICtrlRead($statustext)
    $log = $log & $prefix & $statusmsg & @CRLF
    GUICtrlSetData($statustext, $log)
    _GUICtrlEditLineScroll($statustext, 0, 1000000)
    EndFunc ;==>StatusText

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

    Func SearchArea($left, $top, $right, $bottom, $areavalue, $shadevariation = 0, $step = 1)
    ;===============================================================================
    ;
    ; Description: Searches a rectangle of pixels for the pixel areavalue provided.
    ; Areavalue is combination of one or more pixel point.
    ; Syntax: _PixelsSearch ( left, top, right, bottom, color [, shade-variation] [, step]] )
    ; Parameter(s): left - left coordinate of rectangle.
    ; top - top coordinate of rectangle.
    ; right - right coordinate of rectangle.
    ; bottom - coordinate of rectangle.
    ; checksum - checksum value of the region.
    ; shadevariation - A number between 0 and 255 to indicate the allowed number of shades of
    ; variation of the red, green, and blue components of the colour. Default is 0 (exact match).
    ; step - Instead of searching each pixel use a value larger than 1 to skip pixels (for speed).
    ; E.g. A value of 2 will only check every other pixel. Default is 1.
    ; Return Value(s): On Success - Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y)
    ; On Failure - Sets @error to 1 if region is not found.
    ; - Sets @error to 2 if areavalue is invalid
    ; Author(s): quixote79
    ; Note(s): Similar to PixelSearch()
    ; It works only under Opt("MouseCoordMode", 1) and Opt("PixelCoordMode", 1)
    ;
    ;===============================================================================

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

    $areavaluelength = StringLen($areavalue) / 12
    If IsInt($areavaluelength) = 1 Then
    Local $x[$areavaluelength]
    Local $y[$areavaluelength]
    Local $color[$areavaluelength]
    If $areavaluelength <> 1 Then
    Local $xg[$areavaluelength - 1]
    Local $yg[$areavaluelength - 1]
    EndIf
    For $a = 0 To $areavaluelength - 1
    $x[$a] = Dec(StringMid($areavalue, 12 * $a + 1, 3))
    $y[$a] = Dec(StringMid($areavalue, 12 * $a + 4, 3))
    $color[$a] = Dec(StringMid($areavalue, 12 * $a + 7, 6))
    Next
    For $b = $areavaluelength - 2 To 0 Step - 1
    $xg[$b] = $x[$b + 1] - $x[0]
    $yg[$b] = $y[$b + 1] - $y[0]
    Next

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

    For $c = $top To $bottom
    $mleft = $left
    Do
    $fpos = PixelSearch($mleft, $c, $right, $c, $color[0], $shadevariation, $step)
    If Not @error Then
    $state = 0
    For $d = 0 To $areavaluelength - 2
    If PixelGetColor($fpos[0] + $xg[$d], $fpos[1] + $yg[$d]) <> $color[$d + 1] Then
    $state = 1
    ExitLoop
    EndIf
    Next
    If $state = 0 Then
    Return $fpos
    ExitLoop
    Else
    $mleft = $fpos[0] + $step
    EndIf
    Else
    ExitLoop
    EndIf
    Until $mleft >= $right
    Next
    SetError(1)
    Else
    SetError(2)
    EndIf
    EndFunc ;==>SearchArea

    [/autoit]

    So long,

    Mega

  • Ich muss Dich enttäuschen..
    Der Close-Button funktioniert immer noch nicht :(
    Ich klicke zunächst auf "Start AIS" und dann auf "Close"...

    Wenn ich direkt am Anfang auf "Close" klicke, funktioniert es.

    • Offizieller Beitrag

    HI,

    muss er denn in der Schleife hängen?

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #Include <date.au3>
    #include <Array.au3>
    #include <GuiEdit.au3>

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

    Opt("RunErrorsFatal", 0)
    Opt("GUIOnEventMode", 1)
    Opt("MouseCoordMode", 1);1=absolute, 0=relative, 2=client
    Opt("PixelCoordMode", 1);1=absolute, 0=relative, 2=client

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

    Dim $usr_deskW = @DesktopWidth ; Auflösung vertikal vom User
    Dim $usr_deskH = @DesktopHeight ; Auslösung horizontal vom User
    Dim $hostdate = "0"
    Dim $hosttime = "0"
    Dim $statusmsg = ""
    Global $logmsgid = 0
    Dim $WindowAIS_Icon_Status = 0
    Dim $WindowAIS_Icon_Blue = 1278188
    Dim $WindowAISStatus = 0
    Dim $WindowAIS_Executable = ""
    Dim $WindowAISError = 0
    Global $WindowAIS_find
    Global $WindowAIS_Top
    Global $WindowAIS_Bottom
    Dim $WindowAIS_FirstLoop
    Dim $WindowAIS_Executable
    Dim $iWindowAIS_Executable

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

    ;;;;;;;;;;;;;;;;; M A I N F E N S T E R S T A R T ;;;;;;;;;;;;;;;;;

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

    $ParentGUI = GUICreate(":: AIS :: Main-Window", 283, 139, 429, 568)
    $Executable = GUICtrlCreateInput("", 8, 32, 265, 21)
    $Label1 = GUICtrlCreateLabel("File", 8, 8, 61, 17)
    $cmdStart = GUICtrlCreateButton("Start AIS", 200, 104, 73, 25, 0)
    $cmdClose = GUICtrlCreateButton("Close", 40, 104, 73, 25, 0)
    $cmdMinimize = GUICtrlCreateButton("Minimize", 120, 104, 73, 25, 0)
    GUISetState(@SW_SHOW)

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

    ;;;;;;;;;;;;;;;;; M A I N F E N S T E R E N D E ;;;;;;;;;;;;;;;;;;

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

    ;;;;;;;;;;;;;;;;; S T A T U S F E N S T E R S T A R T ;;;;;;;;;;;;;;;;;

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

    $ChildGUI = GUICreate(":: AIS :: Status-Window", 382, 178, 270, 420)
    GUISetBkColor(0xC0DCC0)
    $ltopic = GUICtrlCreateLabel("Status-Window", 8, 8, 106, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0xC0DCC0)
    $statustext = GUICtrlCreateEdit("", 8, 32, 369, 137, BitOR($ES_AUTOVSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL))
    $llogs = GUICtrlCreateLabel("Logs", 352, 8, 27, 17)
    GUICtrlSetBkColor(-1, 0xC0DCC0)
    $llogsnum = GUICtrlCreateLabel("", 296, 8, 44, 12)
    GUICtrlSetBkColor(-1, 0xC0DCC0)

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

    GUISetState(@SW_SHOW)
    WinSetOnTop("Status-Window", "", 1)

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

    #EndRegion ### END Koda GUI section ###

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

    ;;;;;;;;;;;;;;;;; S T A T U S F E N S T E R E N D E ;;;;;;;;;;;;;;;;;;

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

    StatusText("Program started")

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

    ; Events
    GUICtrlSetOnEvent($cmdClose, "GUIClose")
    GUICtrlSetOnEvent($cmdMinimize, "GUIMainMinimize")
    GUICtrlSetOnEvent($cmdStart, "AIStart")

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

    While 1
    Sleep(100)
    WEnd

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

    Func AIStart()
    Global $f_FirstLoop = 0

    ;While 1
    m_Global()
    Sleep(1000)
    ;WEnd
    EndFunc ;==>AIStart

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

    Func m_Global()
    If Not $WindowAISError = 1 Then
    If Not $WindowAIS_FirstLoop = 1 Then
    If Not WindowAIS_Find() Then
    WindowAIS_Start()
    Else
    WindowAIS_()
    EndIf
    $WindowAIS_FirstLoop = 1
    Else
    WindowAIS_()
    EndIf
    EndIf
    EndFunc ;==>m_Global

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

    Func WindowAIS_()
    $WindowAIS_Icon_Status = PixelGetColor(13, ($WindowAIS_Top + 45))

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

    Select
    Case $WindowAIS_Icon_Status = $WindowAIS_Icon_Blue
    ;TO-DO alles ok !
    Case Else
    StatusText("WindowAIS : [WARNING] Icon unknown !")
    If Not WindowAIS_Find() Then
    WindowAIS_Start()
    EndIf
    EndSelect
    EndFunc ;==>WindowAIS_

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

    Func WindowAIS_Start()
    StatusText("Trying to start WindowAIS ")
    $WindowAIS_Executable = GUICtrlRead($iWindowAIS_Executable)
    Run($WindowAIS_Executable)
    If @error = 1 Then
    StatusText("WindowAIS : [WARNING] Executable hasn't been found !")
    $WindowAISError = 1
    Else
    StatusText("WindowAIS started")
    Sleep(2500)
    EndIf
    EndFunc ;==>WindowAIS_Start

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

    Func WindowAIS_Find()
    StatusText("Searching WindowAIS ")
    $WindowAIS_find = SearchArea("0", "0", $usr_deskW, $usr_deskW, "01F3AFFDD74E", "0", "1")
    Select
    Case Not @error
    $WindowAIS_Top = ($WindowAIS_find[1] - 1)
    $WindowAIS_Bottom = (($WindowAIS_find[1] + 59))
    StatusText("WindowAIS : Window has been found !")
    StatusText("WindowAIS : top: " & $WindowAIS_Top)
    StatusText("WindowAIS : bottom: " & $WindowAIS_Bottom)

    Return 1
    Case @error = 1
    StatusText("[ERROR] Window not found!")
    Return 0
    EndSelect
    EndFunc ;==>WindowAIS_Find

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

    Func GUIClose()
    ConsoleWrite('GUICLOSE' & @CRLF)
    $var = MsgBox(4, "Really Close???", "Are you sure you want to close AIS??")
    If $var = 6 Then
    GUIDelete($ParentGUI)
    GUIDelete($ChildGUI)
    Exit
    EndIf
    EndFunc ;==>GUIClose

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

    Func GUIMainMinimize()
    GUISetState(@SW_SHOW, $ChildGUI)
    EndFunc ;==>GUIMainMinimize

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

    Func StatusText($statusmsg)
    $logmsgid += 1
    GUICtrlSetData($llogsnum, $logmsgid)
    $prefix = "[" & _NowDate() & " / " & _NowTime() & "] : "
    $log = GUICtrlRead($statustext)
    $log = $log & $prefix & $statusmsg & @CRLF
    GUICtrlSetData($statustext, $log)
    _GUICtrlEditLineScroll($statustext, 0, 1000000)
    EndFunc ;==>StatusText

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

    Func SearchArea($left, $top, $right, $bottom, $areavalue, $shadevariation = 0, $step = 1)
    ;===============================================================================
    ;
    ; Description: Searches a rectangle of pixels for the pixel areavalue provided.
    ; Areavalue is combination of one or more pixel point.
    ; Syntax: _PixelsSearch ( left, top, right, bottom, color [, shade-variation] [, step]] )
    ; Parameter(s): left - left coordinate of rectangle.
    ; top - top coordinate of rectangle.
    ; right - right coordinate of rectangle.
    ; bottom - coordinate of rectangle.
    ; checksum - checksum value of the region.
    ; shadevariation - A number between 0 and 255 to indicate the allowed number of shades of
    ; variation of the red, green, and blue components of the colour. Default is 0 (exact match).
    ; step - Instead of searching each pixel use a value larger than 1 to skip pixels (for speed).
    ; E.g. A value of 2 will only check every other pixel. Default is 1.
    ; Return Value(s): On Success - Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y)
    ; On Failure - Sets @error to 1 if region is not found.
    ; - Sets @error to 2 if areavalue is invalid
    ; Author(s): quixote79
    ; Note(s): Similar to PixelSearch()
    ; It works only under Opt("MouseCoordMode", 1) and Opt("PixelCoordMode", 1)
    ;
    ;===============================================================================

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

    $areavaluelength = StringLen($areavalue) / 12
    If IsInt($areavaluelength) = 1 Then
    Local $x[$areavaluelength]
    Local $y[$areavaluelength]
    Local $color[$areavaluelength]
    If $areavaluelength <> 1 Then
    Local $xg[$areavaluelength - 1]
    Local $yg[$areavaluelength - 1]
    EndIf
    For $a = 0 To $areavaluelength - 1
    $x[$a] = Dec(StringMid($areavalue, 12 * $a + 1, 3))
    $y[$a] = Dec(StringMid($areavalue, 12 * $a + 4, 3))
    $color[$a] = Dec(StringMid($areavalue, 12 * $a + 7, 6))
    Next
    For $b = $areavaluelength - 2 To 0 Step - 1
    $xg[$b] = $x[$b + 1] - $x[0]
    $yg[$b] = $y[$b + 1] - $y[0]
    Next

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

    For $c = $top To $bottom
    $mleft = $left
    Do
    $fpos = PixelSearch($mleft, $c, $right, $c, $color[0], $shadevariation, $step)
    If Not @error Then
    $state = 0
    For $d = 0 To $areavaluelength - 2
    If PixelGetColor($fpos[0] + $xg[$d], $fpos[1] + $yg[$d]) <> $color[$d + 1] Then
    $state = 1
    ExitLoop
    EndIf
    Next
    If $state = 0 Then
    Return $fpos
    ExitLoop
    Else
    $mleft = $fpos[0] + $step
    EndIf
    Else
    ExitLoop
    EndIf
    Until $mleft >= $right
    Next
    SetError(1)
    Else
    SetError(2)
    EndIf
    EndFunc ;==>SearchArea

    [/autoit]

    So long,

    Mega

    • Offizieller Beitrag

    Hi,

    so ist doch schöner:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #Include <date.au3>
    #include <Array.au3>
    #include <GuiEdit.au3>

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

    Opt("RunErrorsFatal", 0)
    Opt("GUIOnEventMode", 1)
    Opt("MouseCoordMode", 1);1=absolute, 0=relative, 2=client
    Opt("PixelCoordMode", 1);1=absolute, 0=relative, 2=client

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

    Dim $usr_deskW = @DesktopWidth ; Auflösung vertikal vom User
    Dim $usr_deskH = @DesktopHeight ; Auslösung horizontal vom User
    Dim $hostdate = "0"
    Dim $hosttime = "0"
    Dim $statusmsg = ""
    Global $logmsgid = 0
    Dim $WindowAIS_Icon_Status = 0
    Dim $WindowAIS_Icon_Blue = 1278188
    Dim $WindowAISStatus = 0
    Dim $WindowAIS_Executable = ""
    Dim $WindowAISError = 0
    Global $WindowAIS_find
    Global $WindowAIS_Top
    Global $WindowAIS_Bottom
    Dim $WindowAIS_FirstLoop
    Dim $WindowAIS_Executable
    Dim $iWindowAIS_Executable

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

    ;;;;;;;;;;;;;;;;; M A I N F E N S T E R S T A R T ;;;;;;;;;;;;;;;;;

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

    $ParentGUI = GUICreate(":: AIS :: Main-Window", 283, 139, 429, 568)
    $Executable = GUICtrlCreateInput("", 8, 32, 265, 21)
    $Label1 = GUICtrlCreateLabel("File", 8, 8, 61, 17)
    $cmdStart = GUICtrlCreateButton("Start AIS", 200, 104, 73, 25, 0)
    $cmdClose = GUICtrlCreateButton("Close", 40, 104, 73, 25, 0)
    $cmdMinimize = GUICtrlCreateButton("Minimize", 120, 104, 73, 25, 0)
    GUISetState(@SW_SHOW)

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

    ;;;;;;;;;;;;;;;;; M A I N F E N S T E R E N D E ;;;;;;;;;;;;;;;;;;

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

    ;;;;;;;;;;;;;;;;; S T A T U S F E N S T E R S T A R T ;;;;;;;;;;;;;;;;;

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

    $ChildGUI = GUICreate(":: AIS :: Status-Window", 382, 178, 270, 420)
    GUISetBkColor(0xC0DCC0)
    $ltopic = GUICtrlCreateLabel("Status-Window", 8, 8, 106, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0xC0DCC0)
    $statustext = GUICtrlCreateEdit("", 8, 32, 369, 137, BitOR($ES_AUTOVSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL))
    $llogs = GUICtrlCreateLabel("Logs", 352, 8, 27, 17)
    GUICtrlSetBkColor(-1, 0xC0DCC0)
    $llogsnum = GUICtrlCreateLabel("", 296, 8, 44, 12)
    GUICtrlSetBkColor(-1, 0xC0DCC0)

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

    GUISetState(@SW_SHOW)
    WinSetOnTop("Status-Window", "", 1)

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

    #EndRegion ### END Koda GUI section ###

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

    ;;;;;;;;;;;;;;;;; S T A T U S F E N S T E R E N D E ;;;;;;;;;;;;;;;;;;
    StatusText("Program started")
    ; Events
    GUICtrlSetOnEvent($cmdClose, "SpecialEvents")
    GUICtrlSetOnEvent($cmdMinimize, "SpecialEvents")
    GUICtrlSetOnEvent($cmdStart, "SpecialEvents")

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

    While 1
    Sleep(100)
    WEnd

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

    Func SpecialEvents()
    Select
    Case @GUI_CtrlId = $cmdClose
    GUIClose()
    Exit
    Case @GUI_CtrlId = $cmdMinimize

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

    Case @GUI_CtrlId = $cmdStart
    AIStart()
    EndSelect
    EndFunc ;==>SpecialEvents

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

    Func AIStart()
    Global $f_FirstLoop = 0
    Do
    m_Global()
    Sleep(1000)
    Until @GUI_CtrlId = $cmdClose Or @GUI_CtrlId = $cmdMinimize Or @GUI_CtrlId = $cmdStart
    EndFunc ;==>AIStart

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

    Func m_Global()
    If Not $WindowAISError = 1 Then
    If Not $WindowAIS_FirstLoop = 1 Then
    If Not WindowAIS_Find() Then
    WindowAIS_Start()
    Else
    WindowAIS_()
    EndIf
    $WindowAIS_FirstLoop = 1
    Else
    WindowAIS_()
    EndIf
    EndIf
    EndFunc ;==>m_Global

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

    Func WindowAIS_()
    $WindowAIS_Icon_Status = PixelGetColor(13, ($WindowAIS_Top + 45))

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

    Select
    Case $WindowAIS_Icon_Status = $WindowAIS_Icon_Blue
    ;TO-DO alles ok !
    Case Else
    StatusText("WindowAIS : [WARNING] Icon unknown !")
    If Not WindowAIS_Find() Then
    WindowAIS_Start()
    EndIf
    EndSelect
    EndFunc ;==>WindowAIS_

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

    Func WindowAIS_Start()
    StatusText("Trying to start WindowAIS ")
    $WindowAIS_Executable = GUICtrlRead($iWindowAIS_Executable)
    Run($WindowAIS_Executable)
    If @error = 1 Then
    StatusText("WindowAIS : [WARNING] Executable hasn't been found !")
    $WindowAISError = 1
    Else
    StatusText("WindowAIS started")
    Sleep(2500)
    EndIf
    EndFunc ;==>WindowAIS_Start

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

    Func WindowAIS_Find()
    StatusText("Searching WindowAIS ")
    $WindowAIS_find = SearchArea("0", "0", $usr_deskW, $usr_deskW, "01F3AFFDD74E", "0", "1")
    Select
    Case Not @error
    $WindowAIS_Top = ($WindowAIS_find[1] - 1)
    $WindowAIS_Bottom = (($WindowAIS_find[1] + 59))
    StatusText("WindowAIS : Window has been found !")
    StatusText("WindowAIS : top: " & $WindowAIS_Top)
    StatusText("WindowAIS : bottom: " & $WindowAIS_Bottom)

    Return 1
    Case @error = 1
    StatusText("[ERROR] Window not found!")
    Return 0
    EndSelect
    EndFunc ;==>WindowAIS_Find

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

    Func GUIClose()
    ConsoleWrite('GUICLOSE' & @CRLF)
    $var = MsgBox(4, "Really Close???", "Are you sure you want to close AIS??")
    If $var = 6 Then
    GUIDelete($ParentGUI)
    GUIDelete($ChildGUI)
    Exit
    EndIf
    EndFunc ;==>GUIClose

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

    Func GUIMainMinimize()
    GUISetState(@SW_SHOW, $ChildGUI)
    EndFunc ;==>GUIMainMinimize

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

    Func StatusText($statusmsg)
    $logmsgid += 1
    GUICtrlSetData($llogsnum, $logmsgid)
    $prefix = "[" & _NowDate() & " / " & _NowTime() & "] : "
    $log = GUICtrlRead($statustext)
    $log = $log & $prefix & $statusmsg & @CRLF
    GUICtrlSetData($statustext, $log)
    _GUICtrlEditLineScroll($statustext, 0, 1000000)
    EndFunc ;==>StatusText

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

    Func SearchArea($left, $top, $right, $bottom, $areavalue, $shadevariation = 0, $step = 1)
    ;===============================================================================
    ;
    ; Description: Searches a rectangle of pixels for the pixel areavalue provided.
    ; Areavalue is combination of one or more pixel point.
    ; Syntax: _PixelsSearch ( left, top, right, bottom, color [, shade-variation] [, step]] )
    ; Parameter(s): left - left coordinate of rectangle.
    ; top - top coordinate of rectangle.
    ; right - right coordinate of rectangle.
    ; bottom - coordinate of rectangle.
    ; checksum - checksum value of the region.
    ; shadevariation - A number between 0 and 255 to indicate the allowed number of shades of
    ; variation of the red, green, and blue components of the colour. Default is 0 (exact match).
    ; step - Instead of searching each pixel use a value larger than 1 to skip pixels (for speed).
    ; E.g. A value of 2 will only check every other pixel. Default is 1.
    ; Return Value(s): On Success - Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y)
    ; On Failure - Sets @error to 1 if region is not found.
    ; - Sets @error to 2 if areavalue is invalid
    ; Author(s): quixote79
    ; Note(s): Similar to PixelSearch()
    ; It works only under Opt("MouseCoordMode", 1) and Opt("PixelCoordMode", 1)
    ;
    ;===============================================================================

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

    $areavaluelength = StringLen($areavalue) / 12
    If IsInt($areavaluelength) = 1 Then
    Local $x[$areavaluelength]
    Local $y[$areavaluelength]
    Local $color[$areavaluelength]
    If $areavaluelength <> 1 Then
    Local $xg[$areavaluelength - 1]
    Local $yg[$areavaluelength - 1]
    EndIf
    For $a = 0 To $areavaluelength - 1
    $x[$a] = Dec(StringMid($areavalue, 12 * $a + 1, 3))
    $y[$a] = Dec(StringMid($areavalue, 12 * $a + 4, 3))
    $color[$a] = Dec(StringMid($areavalue, 12 * $a + 7, 6))
    Next
    For $b = $areavaluelength - 2 To 0 Step - 1
    $xg[$b] = $x[$b + 1] - $x[0]
    $yg[$b] = $y[$b + 1] - $y[0]
    Next

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

    For $c = $top To $bottom
    $mleft = $left
    Do
    $fpos = PixelSearch($mleft, $c, $right, $c, $color[0], $shadevariation, $step)
    If Not @error Then
    $state = 0
    For $d = 0 To $areavaluelength - 2
    If PixelGetColor($fpos[0] + $xg[$d], $fpos[1] + $yg[$d]) <> $color[$d + 1] Then
    $state = 1
    ExitLoop
    EndIf
    Next
    If $state = 0 Then
    Return $fpos
    ExitLoop
    Else
    $mleft = $fpos[0] + $step
    EndIf
    Else
    ExitLoop
    EndIf
    Until $mleft >= $right
    Next
    SetError(1)
    Else
    SetError(2)
    EndIf
    EndFunc ;==>SearchArea

    [/autoit]

    So long,

    Mega