Hallo liebe Leute,
ich habe folgende Problematik bei meinem Skript, das von der Komanndozeile mit zwei Argumenten gestartet wird:
Das Skript wird mehrfach (in 20 Sekunden Abständen gestartet).
Leider, trotz Nutzung von Handles, klappt der Ablauf nicht bei parallel laufenden Versionen des Skripts.
Ich weiß leider momentan nicht mehr weiter, warum, die "ControlSend"´s und "WinClose"`s nicht das richtige Ziel, trotz Handle,
finden.
Ich bitte um Hilfe!
Vielen Dank im Voraus.
VG
Mikee
Code
;~ Auto-It-Skript, daß eine ICA-Datei startet und die Session wieder beendet, anschließend wird eine TextDatei erzeugt
AutoItSetOption ("WinTextMatchMode", 2 )
dim $text
dim $notepadtext1
dim $notepadtext2
dim $notepadtext3
dim $handle0
dim $handle1
dim $handle2
dim $handle3
dim $handle4
$text=""
$notepadtext1=""& @ComputerName &"{TAB}ICA_"& $CmdLine[2] &"{TAB}0{TAB}Check OK. ICA-Session wurde sauber beendet."
$notepadtext2=""& @ComputerName &"{TAB}ICA_"& $CmdLine[2] &"{TAB}2{TAB}Check fehlerhaft. ICA-Session wurde nicht aufgebaut."
$notepadtext3=""& @ComputerName &"{TAB}ICA_"& $CmdLine[2] &"{TAB}1{TAB}Check mit Problemen. ICA-Session noch offen."
Func _WinWaitActivate($title,$text,$timeout=0)
WinWait($title,$text,$timeout)
If Not WinActive($title,$text) Then WinActivate($title,$text)
WinWaitActive($title,$text,$timeout)
EndFunc
Func _NotepadSession($notepadtext1)
Run("notepad.exe c:\temp\autoit\status-files\"& $CmdLine[2] &".txt")
WinWaitActive("[CLASS:Static; INSTANCE:2; '"& $CmdLine[2] &".txt']")
$handle1 = ControlGetHandle("[CLASS:Static; INSTANCE:2]", ""& $CmdLine[2] &".txt", "")
ControlSend( "", "", $handle1, "j")
WinWaitActive("[TITLE:"& $CmdLine[2] &"; CLASS:Notepad; ""]")
$handle2 = ControlGetHandle("[TITLE:"& $CmdLine[2] &"; CLASS:Notepad; ""]", "", "")
ControlSend( "", "", $handle2, ""& $notepadtext1 &"")
WinClose($handle2)
WinWaitActive("[CLASS:Static; INSTANCE:2; '"& $CmdLine[2] &".txt']")
$handle3 = ControlGetHandle("[CLASS:Static; INSTANCE:2]", ""& $CmdLine[2] &".txt", "")
ControlSend( "", "", $handle3, "{ENTER}")
EndFunc
;~ Töten von alten Fenstern, die im Skript relevant sein können.
WinKill($CmdLine[2],"")
;~ MsgBox(4096, "Vor dem Start", ""& $CmdLine[2] &"", 2)
;~ Start der ICA-Session
Run($CmdLine[1])
_WinWaitActivate($CmdLine[2],"")
$handle0 = ControlGetHandle(""& $CmdLine[2] &"", "", "")
;~ MsgBox(4096, "Information", ""& $handle0 &"")
If WinExists ($handle0) Then
;~ MsgBox(4096, "Information", ""& $handle0 &"", 5)
Sleep(100000)
For $i = 1 to 3
;~ Senden der Enter-Taste
ControlSend( "", "", $handle0, "{ESC}")
sleep(400)
;~ Senden der Enter-Taste
ControlSend( "", "", $handle0, "{ESC}")
sleep(400)
;~ Senden Strg + Alt + Entf
ControlSend( "", "", $handle0, "{CTRLDOWN}{F1}")
sleep(100)
;~ Senden Strg lösen
ControlSend( "", "", $handle0, "{CTRLDOWN}{CTRLUP}")
sleep(400)
;~ Senden der Tab-Taste
ControlSend( "", "", $handle0, "{TAB}")
sleep(400)
;~ Senden der Enter-Taste
ControlSend( "", "", $handle0, "{ENTER}")
sleep(400)
;~ Senden der Enter-Taste
ControlSend( "", "", $handle0, "{ENTER}")
sleep(400)
;~ Senden der Enter-Taste
ControlSend( "", "", $handle0, "{ESC}")
sleep(400)
;~ Senden der Enter-Taste
ControlSend( "", "", $handle0, "{ENTER}")
sleep(200)
;~ Senden der Enter-Taste
ControlSend( "", "", $handle0, "{ENTER}")
sleep(5000)
Next
Else
_NotepadSession($notepadtext2)
Sleep(100)
Exit
EndIf
Sleep(5000)
If FileExists("c:\temp\autoit\status-files\"& $CmdLine[2] &".txt") Then
;~ MsgBox(4096, "c:\temp\autoit\"& $CmdLine[2] &".txt", "Existiert", 2)
FileDelete("c:\temp\autoit\status-files\"& $CmdLine[2] &".txt")
;~ If @error = 0 Then
;~ MsgBox(4096, "c:\temp\autoit\"& $CmdLine[2] &".txt", "wurde gelöscht", 2)
;~ Else
;~ MsgBox(4096, "c:\temp\autoit\"& $CmdLine[2] &".txt", "ist noch da!", 2)
;~ EndIf
;~ Else
;~ MsgBox(4096,"c:\temp\autoit\"& $CmdLine[2] &".txt", "existiert NICHT", 2)
EndIf
If WinExists ($handle0) Then
;~ MsgBox(4096, "Fehler", "Fenster noch geöffnet!", 2)
If @error = 0 Then
;~ MsgBox(4096, "Fehler - ICA-Session", "Erstellung der NSCA-Datei.", 2)
_NotepadSession($notepadtext3)
Sleep(100)
Exit
Else
;~ MsgBox(4096, "FEHLER - ICA-Session", "Es hat nicht geklappt, versuch es weiter!", 2)
Exit
EndIf
Else
If @error = 0 Then
;~ MsgBox(4096, "ERFOLG - ICA-Session", "Erstellung der NSCA-Datei.", 2)
_NotepadSession($notepadtext1)
Sleep(100)
Exit
Else
;~ MsgBox(4096, "FEHLER - ICA-Session", "Es hat nicht geklappt, versuch es weiter!", 2)
Exit
EndIf
EndIf
Exit
Alles anzeigen