#cs ----------------------------------------------------------------------------

	AutoIt Version: 3.3.6.0
	Author:         Dietrich Markus
	Version:		1.1

	Script Function:
	Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

$Fritz7_Title = "Fritz 7"
$Fritz7_Class = "[CLASS:Afx:400000:0]"

$Fritz7_InfoFenster1_Title = "Info"
$Fritz7_InfoFenster1_Class = "[CLASS:#32770]"

$Fritz7_InfoFenster2_Title = "Technische Meldungen" ;bei Houdini
$Fritz7_InfoFenster2_Class = "[CLASS:#32770]"

$Fritz7_InfoFenster3_Title = "Fritz 7" ;bei HIARCS
$Fritz7_InfoFenster3_Class = "[CLASS:#32770]"

$Startzeit_Fritz7_oeffnen = TimerInit()

If ProcessExists("Houdini_20_w32.exe") Or ProcessExists("ChessProgram7.exe") Then
	While 1
		If ProcessExists("Houdini_20_w32.exe") Then
			$PID = ProcessClose("Houdini_20_w32.exe")
			If $PID Then ProcessClose($PID)
		ElseIf ProcessExists("ChessProgram7.exe") Then
			$PID = ProcessClose("ChessProgram7.exe")
			If $PID Then ProcessClose($PID)
		ElseIf ProcessExists("Hiarcs13.1MP.exe") Then
			$PID = ProcessClose("Hiarcs13.1MP.exe")
			If $PID Then ProcessClose($PID)
		ElseIf ProcessExists("Deep Rybka 4.1 w32.exe") Then
			$PID = ProcessClose("Deep Rybka 4.1 w32.exe")
			If $PID Then ProcessClose($PID)
		Else
			ExitLoop
		EndIf
	WEnd
	ToolTip("Fritz7 GUI closed in " & Round(TimerDiff($Startzeit_Fritz7_oeffnen)/1000, 1) & "  seconds", @DesktopWidth/2, @DesktopHeight/2)
Else
	Fritz7_starten() ;
	ToolTip("Fritz7 GUI opened in " & Round(TimerDiff($Startzeit_Fritz7_oeffnen)/1000, 1) & "  seconds", @DesktopWidth/2, @DesktopHeight/2)
EndIf

Sleep(2000)

; Fritz7_starten
; -----------------------------------
Func Fritz7_starten()
	Run("G:\ChessBase\Fritz7\ChessProgram7.exe", "G:\ChessBase\Fritz7\")

	WinWait($Fritz7_Class, "", 5000)
	Activate_Window($Fritz7_Title) ;

	Send("{SPACE 2}")

	$Timer = TimerInit()
	Do
		Sleep(20)
	Until ProcessExists("Houdini_20_w32.exe") <> 0 Or ProcessExists("Hiarcs13.1MP.exe") <> 0 Or ProcessExists("Deep Rybka 4.1 w32.exe") <> 0 Or TimerDiff($Timer) > 5000

	If ProcessExists("Houdini_20_w32.exe") Or ProcessExists("Deep Rybka 4.1 w32.exe") Then
		WinWait($Fritz7_InfoFenster2_Title, "", 5000)
		Activate_Window($Fritz7_InfoFenster2_Title) ;
		ControlClick($Fritz7_InfoFenster2_Title, "&Schließen", "[ID:1]")
	EndIf

	If ProcessExists("Hiarcs13.1MP.exe") Then
		WinWaitClose($Fritz7_InfoFenster3_Title, "Lade HIARCS", 5000)
	EndIf

	Send("^n") ;neue Partie
	WinSetOnTop("Neue Partie", "", 1)
	WinMove("Neue Partie", "", @DesktopWidth / 2 - 720 / 2, 80, 720, 1000)
	WinActivate("Neue Partie")
	Send("!{F2}") ;Daueranalyse aktivieren
Endfunc
; Fritz7_starten
; -----------------------------------

; Activate_Window
; -----------------------------------
Func Activate_Window($i)
	WinSetOnTop($i, "", 1)
	WinActivate($i)
	WinWaitActive($i)
Endfunc
; Activate_Window
; -----------------------------------