Probleme mit If Winexist() then

  • Hi Leute !
    hab mal wieder ein kleines Problem :(

    Ich muss in der Nacht einen Export (ins SAP) aus einer Reisebüroanwendung machen.

    gut und schön

    meistens funktioniert es (wenn viele Daten da sind) aber manchmal wenn relativ wenig daten da sind bleibt er hängen :(

    So ich häng mal mein Script an:

    Spoiler anzeigen
    [autoit]


    #Region converted Directives from D:\Scripts_KBHSRV\Export_SAP.au3.ini
    #AutoIt3Wrapper_aut2exe=C:\Programme\AutoIt3\Aut2Exe\Aut2Exe.exe
    #AutoIt3Wrapper_outfile=\\kbhsrv.eurotours.lan\e$\Scripts\Export_SAP.exe
    #AutoIt3Wrapper_Res_Comment=(C) Garnreiter
    #AutoIt3Wrapper_Res_Description=Export SAP Daten
    #AutoIt3Wrapper_Res_Fileversion=5.0.0.1
    #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
    #AutoIt3Wrapper_Res_LegalCopyright=(C) Garnreiter
    #AutoIt3Wrapper_Run_AU3Check=1
    #EndRegion converted Directives from D:\Scripts_KBHSRV\Export_SAP.au3.ini
    ;
    #comments-start
    CopyRight 2007 (c) Garnreiter
    Version 5.0.0.1
    #comments-end
    Opt("WinWaitDelay", 100)
    Opt("WinTitleMatchMode", 4)
    Opt("WinDetectHiddenText", 1)
    Opt("MouseCoordMode", 0)
    #include <file.au3>
    Global $root = IniRead(@ScriptDir & "\Export.ini", "PFADE", "root", "keine Pfad konfiguriert") ; E:\
    Global $PFAD = IniRead(@ScriptDir & "\Export.ini", "SAP", "pfad", "keine Pfad konfiguriert"); Exportpfad für die Weiterverarbeitung SAP
    Global $VON = IniRead(@ScriptDir & "\Export.ini", "SAP", "von", "keine Pfad konfiguriert"); derzeit kein eintrag
    Global $BIS = IniRead(@ScriptDir & "\Export.ini", "SAP", "bis", "keine Pfad konfiguriert"); derzeit kein eintrag
    Global $CRS = IniRead(@ScriptDir & "\Export.ini", "PFADE", "CRS", "keine Pfad konfiguriert"); Pfad zur Weiterverarbeitungsmaschine
    Global $JACDAT = IniRead(@ScriptDir & "\Export.ini", "PFADE", "JACDAT", "keine Pfad konfiguriert"); Programmdatenpfad
    Global $JACOFC = IniRead(@ScriptDir & "\Export.ini", "PFADE", "JACOFC", "keine Pfad konfiguriert"); ProgrammPfad
    Global $pw = IniRead(@ScriptDir & "\Export.ini", "PW", "pw", "NotFound"); Passwort
    Global $MAN = IniRead(@ScriptDir & "\Export.ini", "MANDANT", "MAN", "keine Pfad konfiguriert"); Mandant

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

    $PID = ProcessExists("Jackv30.exe") ; Will return the PID or 0 if the process isn't found.
    If $PID Then ProcessClose($PID)
    _FileWriteLog($root & "\log\SAP_Export.log", "SAP Export Beginn")

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

    Run($JACOFC & "\Jackv30.exe", $JACDAT); Programm start
    ;---------------- Passwortabfrage----------------------------------------
    WinWait("Paßwort", "Sollten die obigen L")
    If Not WinActive("Paßwort", "Sollten die obigen L") Then WinActivate("Paßwort", "Sollten die obigen L")
    WinWaitActive("Paßwort", "Sollten die obigen L")
    Sleep(2000)
    ControlSend("Paßwort", "Sollten die obigen L", 303, "admin")
    ControlSend("Paßwort", "Sollten die obigen L", 100, $pw)
    ControlClick("Paßwort", "Sollten die obigen L", 301)

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

    If WinExists("Rückfrage", "&Ja") Then
    WinWait("Rückfrage", "&Ja")
    If Not WinActive("Rückfrage", "&Ja") Then WinActivate("Rückfrage", "&Ja")
    WinWaitActive("Rückfrage", "&Ja")
    ControlClick("Rückfrage", "&Ja", 6)
    Else
    Sleep(1)
    EndIf
    ;---------------- Passwortabfrage Ende-----------------------------------

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

    WinWait("Jack / X6.03", "Buchhaltung")
    If Not WinActive("Jack / X6.03", "Buchhaltung") Then WinActivate("Jack / X6.03", "Buchhaltung")
    WinWaitActive("Jack / X6.03", "Buchhaltung")
    ;---------------- SAP Export Aufruf--------------------------------------
    Send("{ALTDOWN}{F5}{ALTUP}")
    WinWait("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze")
    If Not WinActive("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze") Then WinActivate("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze")
    WinWaitActive("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze")

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

    ControlClick("Vorgangsexport - MIS / SAP", "", 3926)
    ControlSend("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze", 3921, $MAN)
    ControlSend("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze", 3922, $MAN)

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

    ControlSetText("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze", 3928, $PFAD ) ; Pfad angabe wohin er exportieren soll
    ControlCommand("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze", 1068, "Check", "")
    ControlSend("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze", 3944, $VON) ; Von wann
    ControlSend("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze", 3946, $BIS) ; Bis wann
    ControlClick("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze", 1)
    WinWait("Rückfrage", "Wollen Sie die Daten")
    If Not WinActive("Rückfrage", "Wollen Sie die Daten") Then WinActivate("Rückfrage", "Wollen Sie die Daten")
    WinWaitActive("Rückfrage", "Wollen Sie die Daten")
    ControlClick("Rückfrage", "Wollen Sie die Daten", 6)
    ;---------------- SAP Exportaufruf Ende-----------------------------------

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

    WinWait("Export in eine Datei", "",7)
    ; Process Balken "Export in eine Datei"
    While 1
    Sleep(1)
    If Not WinExists("Export in eine Datei", "") Then
    ExitLoop
    EndIf
    WEnd

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

    ; Process Balken "Exportieren Satzart 21"

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

    While 1
    Sleep(1)
    If Not WinExists("Exportieren", "") Then
    ExitLoop
    EndIf
    WEnd

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

    ; Process Balken "Exportieren der VA-Eingangsrechnungen"

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

    While 1
    Sleep(1)
    If Not WinExists("Exportieren", "") Then
    ExitLoop
    EndIf
    WEnd

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

    ; Hinweis GUI wieviel Daten exportiert sind"

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

    While 1
    Sleep(1)
    If WinExists("Hinweis", "") Then
    ExitLoop
    EndIf
    WEnd

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

    If WinExists("Hinweis", "") Then
    $handle = WinGetHandle("Hinweis", "")
    ControlClick($handle, "", 2)
    EndIf

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

    WinWait("Jack / X6.03","Buchhaltung")
    If Not WinActive("Jack / X6.03","Buchhaltung") Then WinActivate("Jack / X6.03","Buchhaltung")
    WinWaitActive("Jack / X6.03","Buchhaltung")

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

    #comments-start ; alte version

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

    ;~ While 1
    ;~ Sleep(200)
    ;~ If Not WinExists("Export in eine Datei", "") Then
    ;~ ExitLoop
    ;~ EndIf
    ;~ WEnd

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

    ;~ While 1
    ;~ Sleep(200)
    ;~ If Not WinExists("Exportieren Satzart 21", "") Then
    ;~ ExitLoop
    ;~ EndIf
    ;~ WEnd

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

    ;~ While 1
    ;~ Sleep(200)
    ;~ If not WinExists("Exportieren der VA-Eingangsrechnungen", "") then
    ;~ ExitLoop
    ;~ EndIf
    ;~ WEnd

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

    ;~ While 1
    ;~ Sleep(200)
    ;~ If WinExists("Hinweis", "") Then
    ;~ ExitLoop
    ;~ EndIf
    ;~ WEnd

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

    ;~ $handle = WinGetHandle("Hinweis", "")
    ;~ ControlClick($handle, "", 2)
    ;~ WinWait("Jack / X6.03", "Buchhaltung")
    ;~ If Not WinActive("Jack / X6.03", "Buchhaltung") Then WinActivate("Jack / X6.03", "Buchhaltung")
    ;~ WinWaitActive("Jack / X6.03", "Buchhaltung")

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

    #comments-end

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

    $PID = ProcessExists("Jackv30.exe") ; Will return the PID or 0 if the process isn't found.
    If $PID Then ProcessClose($PID)
    _FileWriteLog($root & "\log\SAP_Export.log", "SAP Export Ende")
    Exit

    [/autoit]

    So mein Problem ist das die Process Balken "Exportieren Satzart 21" und "Exportieren der VA-Eingangsrechnungen" teilweise so extrem kurz laufen das ich sie nicht abfragen kann .......
    Auch das "Hinweis" Fenster ist hinundwieder nicht vorhanden (wenn keine Daten exportiert wurden)

    Dieses Script läuft auf 4 verschiedenen Servern mit mal mehr und auch mal weniger Daten. im großen und ganzen sehr sauber

    kann mir jemand bitte ein bischen Helfen ?
    Ich werd in 14Tagen auf Urlaub gehen und bin der einzige der sich soweit im AutoIt auskennt. (hab das WINBATCH ausgemustert :P :rock: :rock: )

    Mein Kollegen sollen auch nicht unbedingt in der Nacht beim Script sitzen und zuschauen (wos dann wenn man zuschaut eh funktioniert grrrr )

    :EDIT: Wer Screenshot's brauch kann ich gerne liefern :)

    Danke für eure Hilfe :)

    TOMTOM

    • Offizieller Beitrag

    Hallo,

    Ich würde es so lösen:

    Spoiler anzeigen
    [autoit]

    #Region converted Directives from D:\Scripts_KBHSRV\Export_SAP.au3.ini
    #AutoIt3Wrapper_aut2exe=C:\Programme\AutoIt3\Aut2Exe\Aut2Exe.exe
    #AutoIt3Wrapper_outfile=\\kbhsrv.eurotours.lan\e$\Scripts\Export_SAP.exe
    #AutoIt3Wrapper_Res_Comment=(C) Garnreiter
    #AutoIt3Wrapper_Res_Description=Export SAP Daten
    #AutoIt3Wrapper_Res_Fileversion=5.0.0.1
    #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
    #AutoIt3Wrapper_Res_LegalCopyright=(C) Garnreiter
    #AutoIt3Wrapper_Run_AU3Check=1
    #EndRegion converted Directives from D:\Scripts_KBHSRV\Export_SAP.au3.ini
    ;
    #comments-start
    CopyRight 2007 (c) Garnreiter
    Version 5.0.0.1
    #comments-end
    Opt("WinWaitDelay", 100)
    Opt("WinTitleMatchMode", 4)
    Opt("WinDetectHiddenText", 1)
    Opt("MouseCoordMode", 0)
    #include <file.au3>
    Global $root = IniRead(@ScriptDir & "\Export.ini", "PFADE", "root", "keine Pfad konfiguriert") ; E:\
    Global $PFAD = IniRead(@ScriptDir & "\Export.ini", "SAP", "pfad", "keine Pfad konfiguriert"); Exportpfad für die Weiterverarbeitung SAP
    Global $VON = IniRead(@ScriptDir & "\Export.ini", "SAP", "von", "keine Pfad konfiguriert"); derzeit kein eintrag
    Global $BIS = IniRead(@ScriptDir & "\Export.ini", "SAP", "bis", "keine Pfad konfiguriert"); derzeit kein eintrag
    Global $CRS = IniRead(@ScriptDir & "\Export.ini", "PFADE", "CRS", "keine Pfad konfiguriert"); Pfad zur Weiterverarbeitungsmaschine
    Global $JACDAT = IniRead(@ScriptDir & "\Export.ini", "PFADE", "JACDAT", "keine Pfad konfiguriert"); Programmdatenpfad
    Global $JACOFC = IniRead(@ScriptDir & "\Export.ini", "PFADE", "JACOFC", "keine Pfad konfiguriert"); ProgrammPfad
    Global $pw = IniRead(@ScriptDir & "\Export.ini", "PW", "pw", "NotFound"); Passwort
    Global $MAN = IniRead(@ScriptDir & "\Export.ini", "MANDANT", "MAN", "keine Pfad konfiguriert"); Mandant

    $PID = ProcessExists("Jackv30.exe") ; Will return the PID or 0 if the process isn't found.
    If $PID Then ProcessClose($PID)
    _FileWriteLog($root & "\log\SAP_Export.log", "SAP Export Beginn")

    Run($JACOFC & "\Jackv30.exe", $JACDAT); Programm start
    ;---------------- Passwortabfrage----------------------------------------
    WinWait("Paßwort", "Sollten die obigen L")
    If Not WinActive("Paßwort", "Sollten die obigen L") Then WinActivate("Paßwort", "Sollten die obigen L")
    WinWaitActive("Paßwort", "Sollten die obigen L")
    Sleep(2000)
    ControlSend("Paßwort", "Sollten die obigen L", 303, "admin")
    ControlSend("Paßwort", "Sollten die obigen L", 100, $pw)
    ControlClick("Paßwort", "Sollten die obigen L", 301)

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

    ;~ Erscheint das folgende Fenster immer ?
    ;~ WinWait("Rückfrage", "&Ja") ; wenn Fenster immer erscheint aktivieren
    WinWait("Rückfrage", "&Ja", 10) ; wenn Fenster immer erscheint deaktivieren

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

    If WinExists("Rückfrage", "&Ja") Then
    WinWait("Rückfrage", "&Ja")
    If Not WinActive("Rückfrage", "&Ja") Then WinActivate("Rückfrage", "&Ja")
    WinWaitActive("Rückfrage", "&Ja")
    ControlClick("Rückfrage", "&Ja", 6)
    Else
    Sleep(1)
    EndIf
    ;---------------- Passwortabfrage Ende-----------------------------------


    WinWait("Jack / X6.03", "Buchhaltung")
    If Not WinActive("Jack / X6.03", "Buchhaltung") Then WinActivate("Jack / X6.03", "Buchhaltung")
    WinWaitActive("Jack / X6.03", "Buchhaltung")
    ;---------------- SAP Export Aufruf--------------------------------------
    Send("{ALTDOWN}{F5}{ALTUP}")
    WinWait("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze")
    If Not WinActive("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze") Then WinActivate("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze")
    WinWaitActive("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze")

    ControlClick("Vorgangsexport - MIS / SAP", "", 3926)
    ControlSend("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze", 3921, $MAN)
    ControlSend("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze", 3922, $MAN)

    ControlSetText("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze", 3928, $PFAD ) ; Pfad angabe wohin er exportieren soll
    ControlCommand("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze", 1068, "Check", "")
    ControlSend("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze", 3944, $VON) ; Von wann
    ControlSend("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze", 3946, $BIS) ; Bis wann
    ControlClick("Vorgangsexport - MIS / SAP", "Beträge ohne Kommaze", 1)
    WinWait("Rückfrage", "Wollen Sie die Daten")
    If Not WinActive("Rückfrage", "Wollen Sie die Daten") Then WinActivate("Rückfrage", "Wollen Sie die Daten")
    WinWaitActive("Rückfrage", "Wollen Sie die Daten")
    ControlClick("Rückfrage", "Wollen Sie die Daten", 6)
    ;---------------- SAP Exportaufruf Ende-----------------------------------

    ; Process Balken "Export in eine Datei"
    WinWait("Export in eine Datei", "",7)
    If WinExists("Export in eine Datei", "") Then WinWaitClose("Export in eine Datei", "")

    ; Process Balken "Exportieren Satzart 21"
    WinWait("Exportieren", "", 10)
    If WinExists("Exportieren", "") Then WinWaitClose("Exportieren", "")

    ; Process Balken "Exportieren der VA-Eingangsrechnungen"
    WinWait("Exportieren", "", 10)
    If WinExists("Exportieren", "") Then WinWaitClose("Exportieren", "")

    ; Hinweis GUI wieviel Daten exportiert sind"
    WinWait("Hinweis", "", 10)
    If WinExists("Hinweis", "") Then
    $handle = WinGetHandle("Hinweis", "")
    ControlClick($handle, "", 2)
    EndIf

    WinWait("Jack / X6.03","Buchhaltung")
    If Not WinActive("Jack / X6.03","Buchhaltung") Then WinActivate("Jack / X6.03","Buchhaltung")
    WinWaitActive("Jack / X6.03","Buchhaltung")



    #comments-start ; alte version

    ;~ While 1
    ;~ Sleep(200)
    ;~ If Not WinExists("Export in eine Datei", "") Then
    ;~ ExitLoop
    ;~ EndIf
    ;~ WEnd


    ;~ While 1
    ;~ Sleep(200)
    ;~ If Not WinExists("Exportieren Satzart 21", "") Then
    ;~ ExitLoop
    ;~ EndIf
    ;~ WEnd

    ;~ While 1
    ;~ Sleep(200)
    ;~ If not WinExists("Exportieren der VA-Eingangsrechnungen", "") then
    ;~ ExitLoop
    ;~ EndIf
    ;~ WEnd


    ;~ While 1
    ;~ Sleep(200)
    ;~ If WinExists("Hinweis", "") Then
    ;~ ExitLoop
    ;~ EndIf
    ;~ WEnd

    ;~ $handle = WinGetHandle("Hinweis", "")
    ;~ ControlClick($handle, "", 2)
    ;~ WinWait("Jack / X6.03", "Buchhaltung")
    ;~ If Not WinActive("Jack / X6.03", "Buchhaltung") Then WinActivate("Jack / X6.03", "Buchhaltung")
    ;~ WinWaitActive("Jack / X6.03", "Buchhaltung")


    #comments-end

    $PID = ProcessExists("Jackv30.exe") ; Will return the PID or 0 if the process isn't found.
    If $PID Then ProcessClose($PID)
    _FileWriteLog($root & "\log\SAP_Export.log", "SAP Export Ende")
    Exit

    [/autoit]
  • Die Version hatte ich auch schon mal :(
    das war leider zu unzuverlässig :(


    [autoit]

    ; Process Balken "Export in eine Datei"
    WinWait("Export in eine Datei", "",7)
    If WinExists("Export in eine Datei", "") Then WinWaitClose("Export in eine Datei", "")

    ; Process Balken "Exportieren Satzart 21"
    WinWait("Exportieren", "", 10)
    If WinExists("Exportieren", "") Then WinWaitClose("Exportieren", "")

    ; Process Balken "Exportieren der VA-Eingangsrechnungen"
    WinWait("Exportieren", "", 10)
    If WinExists("Exportieren", "") Then WinWaitClose("Exportieren", "")

    [/autoit]


    des ist mir sehr oft hängen geblieben :(