Script bleibt Zeitweise hängen

  • Ich habe mich mal nach einiger Zeit wieder mit Autoit beschäftigt und schon hänge ich wieder am ersten Problem :D.
    Und zwar bastel ich mir im Moment ein kleines Tool, um häufig verwendete Texte zu schreiben und um Abkürzungen zu verwenden ( Beispiel MfG -> Mit freundlichen Grüßen ).
    Leider muss ich es öfters neu starten. Vor allem, wenn ich mal eine Stunde nicht am PC war und der Bildschirm gesperrt wird.
    Aber der Fehler will sich mir nicht offenbaren.

    Nun hoffe ich das ihr vielleicht eine Idee habt woran es liegen könnte.
    Bin für jeden Tip Dankbar :)

    Spoiler anzeigen
    [autoit]

    #region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIT3Wrapper_UseUpx=n
    #endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include "HotString.au3"
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    Local $sIniFile = @ScriptDir & "\config.ini"
    Local $bConvertermenu = False
    Local $sVersion = "01.00.03"
    Local $bConfigsave = False, $iConfigPID = ""
    Opt("SendKeyDelay", IniRead($sIniFile, "Delay", "SendKeyDelay", "5"))
    Opt("SendKeyDownDelay", IniRead($sIniFile, "Delay", "SendKeyDownDelay", "5"))
    Opt("TrayAutoPause", 0)
    Opt("TrayMenuMode", 1 + 2 + 8)
    FileInstall(".\config.ini", ".\config.ini")
    ReadControlSendFunctions()
    ReadSendFunctions()
    ReadCopyPasteFunctions()
    #region Tray Menue
    $trayConfig = TrayCreateItem("Konfiguration öffnen", -1, -1, 1)
    $trayConverter = TrayCreateItem("Absätze umwandeln", -1, -1, 1)
    TrayCreateItem("")
    $trayHelp = TrayCreateItem("Hilfe", -1, -1, 1)
    $trayChangelog = TrayCreateItem("Letzte Änderungen", -1, -1, 1)
    TrayCreateItem("")
    $trayExit = TrayCreateItem("Beenden", -1, -1, 1)
    While True
    If $bConfigsave = True Then
    If Not ProcessExists($iConfigPID) Then
    Local $_hotString_hotkeys[1]
    Local $_hotString_hotfuncs[1]
    Local $_hotString_hottext[1]
    ReadControlSendFunctions()
    ReadSendFunctions()
    ReadCopyPasteFunctions()
    Opt("SendKeyDelay", IniRead($sIniFile, "Delay", "SendKeyDelay", "5"))
    Opt("SendKeyDownDelay", IniRead($sIniFile, "Delay", "SendKeyDownDelay", "5"))
    $bConfigsave = False
    EndIf
    EndIf
    Local $tray = TrayGetMsg()
    Switch $tray
    Case $trayExit
    Exit 0
    Case $trayConfig
    $iConfigPID = Run("notepad.exe " & $sIniFile)
    TrayTip("Achtung!", "Änderungen werden erst übernommen, nachdem die Konfiguration gespeichert und geschlossen worden ist!", 10)
    $bConfigsave = True
    Case $trayConverter
    MsgBox(0, "Converter", "Mit Bestätigung dieses Dialogs wird der Text aus der Zwischenablage angepasst und wieder in Ihre Zwischenablage eingefügt.")
    ClipPut(StringReplace(StringReplace(ClipGet(), @CR, ""), @LF, "§br"))
    Case $trayHelp
    ShellExecute("http://****")
    Case $trayChangelog
    ShellExecute("http://****")
    EndSwitch
    WEnd
    Func ReplacerArray()
    Local $aReplArrayFunc[11][2] = [["§year", @YEAR],["§mon", @MON],["§mday", @MDAY],["§hour", @HOUR],["§min", @MIN],["§sec", @SEC],["§scriptdir", @ScriptDir],["§br", @LF],["§tab", "{TAB}"],["§winuser", @UserName],["§clip", ClipGet()]]
    Return $aReplArrayFunc
    EndFunc ;==>ReplacerArray
    Func ReplacerArrayClip()
    Local $aReplArrayFunc[11][2] = [["§year", @YEAR],["§mon", @MON],["§mday", @MDAY],["§hour", @HOUR],["§min", @MIN],["§sec", @SEC],["§scriptdir", @ScriptDir],["§br", @CRLF],["§tab", "{TAB}"],["§winuser", @UserName],["§clip", ClipGet()]]
    Return $aReplArrayFunc
    EndFunc ;==>ReplacerArray
    Func ControlSendText($iSendKeyLenght, $sSendText)
    $cut = ""
    Local $aReplArray = ReplacerArray()
    For $i = 1 To $iSendKeyLenght
    $cut &= "{BS}"
    Next
    For $iCSr = 0 To UBound($aReplArray) - 1
    $sSendText = StringReplace($sSendText, $aReplArray[$iCSr][0], $aReplArray[$iCSr][1])
    Next
    BlockInput(1)
    ControlSend("", "", "", $cut & $sSendText)
    BlockInput(0)
    EndFunc ;==>ControlSendText
    Func SendText($iSendKeyLenght, $sSendText)
    $cut = ""
    Local $aReplArray = ReplacerArray()
    For $i = 1 To $iSendKeyLenght
    $cut &= "{BS}"
    Next
    For $iCSr = 0 To UBound($aReplArray) - 1
    $sSendText = StringReplace($sSendText, $aReplArray[$iCSr][0], $aReplArray[$iCSr][1])
    Next
    BlockInput(1)
    Send($cut & $sSendText)
    BlockInput(0)
    EndFunc ;==>SendText
    Func CopyPasteText($iSendKeyLenght, $sSendText)
    $cut = ""
    Local $aReplArray = ReplacerArrayClip()
    For $i = 1 To $iSendKeyLenght
    $cut &= "{BS}"
    Next
    For $iCSr = 0 To UBound($aReplArray) - 1
    $sSendText = StringReplace($sSendText, $aReplArray[$iCSr][0], $aReplArray[$iCSr][1])
    Next
    BlockInput(1)
    $tempClip = ClipGet()
    ClipPut($sSendText)
    Send($cut)
    Send("^v")
    BlockInput(0)
    ClipPut($tempClip)
    EndFunc ;==>CopyPasteText
    Func ReadCopyPasteFunctions()
    Local $aCopyPaste = IniReadSection($sIniFile, "CopyPaste")
    If Not IsArray($aCopyPaste) Then Return
    For $iCS = 1 To $aCopyPaste[0][0]
    HotStringset($aCopyPaste[$iCS][0], "CopyPasteText", $aCopyPaste[$iCS][1])
    Next
    EndFunc ;==>ReadCopyPasteFunctions
    Func ReadControlSendFunctions()
    Local $aSendSection = IniReadSection($sIniFile, "ControlSend")
    If Not IsArray($aSendSection) Then Return
    For $iCS = 1 To $aSendSection[0][0]
    HotStringset($aSendSection[$iCS][0], "ControlSendText", $aSendSection[$iCS][1])
    Next
    EndFunc ;==>ReadControlSendFunctions
    Func ReadSendFunctions()
    Local $aControlSendSection = IniReadSection($sIniFile, "Send")
    If Not IsArray($aControlSendSection) Then Return
    For $iCS = 1 To $aControlSendSection[0][0]
    HotStringset($aControlSendSection[$iCS][0], "SendText", $aControlSendSection[$iCS][1])
    Next
    EndFunc ;==>ReadSendFunctions
    Func _GetDateTime($iDateFormat = 0)
    If $iDateFormat = 0 Then
    Return @MDAY & "." & @MON & "." & @YEAR
    ElseIf $iDateFormat = 1 Then
    Return @YEAR & "/" & @MON & "/" & @MDAY
    ElseIf $iDateFormat = 2 Then
    Return @YEAR & @MON & @MDAY
    ElseIf $iDateFormat = 3 Then
    Return @HOUR & ":" & @MIN
    Else
    Return @MDAY & "." & @MON & "." & @YEAR & " " & @HOUR & ":" & @MIN
    EndIf
    EndFunc ;==>_GetDateTime

    [/autoit]