#include #include #include #include #include #RequireAdmin Local Const $sFilePath = "C:\Download\AutoIT.log" Local Const $l_screenshot_directory_path_abs = "C:\Download\Screenshot" Global $g_LogFile Local $l_WindowTitle Local $l_WindowText DirCreate($l_screenshot_directory_path_abs) ; Create log file If Not FileWrite($sFilePath, "AutoIT Log file for Blabla installation" & @CRLF) Then MsgBox($MB_SYSTEMMODAL, "", "An error happened when writing log file.") Return False EndIf ; Open log file Local $g_LogFile = FileOpen($sFilePath, $FO_APPEND) If $g_LogFile = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error happened when writing log file.") Return False EndIf Run(@ScriptDir & '\Blabla_Latest_Installer.exe') AutoItSetOption('MouseCoordMode', 0) LogFile("==> Blabla Installer is starting...") ; INSTALLATION $l_WindowTitle = "Installer Language" $l_WindowText = "Please select a language." WaitWindow($l_WindowTitle, $l_WindowText, $l_screenshot_directory_path_abs) Click(145, 133, $l_screenshot_directory_path_abs) LogFile("==> Language has been selected") Sleep(300) LogFile("==> Start Installation") $l_WindowTitle = 'Blabla Setup' $l_WindowText = "Welcome to Blabla Setup" WaitWindow($l_WindowTitle, $l_WindowText, $l_screenshot_directory_path_abs) Click(360, 360, $l_screenshot_directory_path_abs) LogFile("==> Start Blabla Installation") Sleep(300) ; Blabla Settings $l_WindowTitle = 'Blabla Setup' $l_WindowText = "Choose Install Location" WaitWindow($l_WindowTitle, $l_WindowText, $l_screenshot_directory_path_abs) Click(360, 360, $l_screenshot_directory_path_abs) LogFile("==> Install location chosen") Sleep(1000) $l_WindowTitle = 'Blabla Setup' $l_WindowText = "System settings" WaitWindow($l_WindowTitle, $l_WindowText, $l_screenshot_directory_path_abs) FillIn("City", 290, 190, $l_screenshot_directory_path_abs) FillIn("Name", 290, 220, $l_screenshot_directory_path_abs) Click(360, 360, $l_screenshot_directory_path_abs) LogFile("==> System info filled in") Sleep(300) ;Bloblo INSTALLATION LogFile("==>Bloblo Installer is starting...") $l_WindowTitle = 'Bloblo Setup' $l_WindowText = "Welcome to Bloblo Setup" WaitWindow($l_WindowTitle, $l_WindowText, $l_screenshot_directory_path_abs) Click(360, 360, $l_screenshot_directory_path_abs) LogFile("==> StartBloblo System installation") Sleep(300) $l_WindowTitle = 'Bloblo Setup' $l_WindowText = "Choose Install Location" WaitWindow($l_WindowTitle, $l_WindowText, $l_screenshot_directory_path_abs) Click(360, 360, $l_screenshot_directory_path_abs) LogFile("==> Choose Install Location") Sleep(300) $l_WindowTitle = 'Bloblo Setup' $l_WindowText = "Installation Complete" WaitWindow($l_WindowTitle, $l_WindowText, $l_screenshot_directory_path_abs) Click(360, 360, $l_screenshot_directory_path_abs) LogFile("==>Bloblo installation is complete") Sleep(300) $l_WindowTitle = 'Bloblo Setup' $l_WindowText = "Completing Bloblo Setup" WaitWindow($l_WindowTitle, $l_WindowText, $l_screenshot_directory_path_abs) Click(360, 360, $l_screenshot_directory_path_abs) LogFile("==> Completing Bloblo Setup") Sleep(300) $l_WindowTitle = 'Blabla Setup' $l_WindowText = ".NET Framework not installed." WaitWindow($l_WindowTitle, $l_WindowText, $l_screenshot_directory_path_abs) Click(130, 130, $l_screenshot_directory_path_abs) LogFile("==> .NET Framework installation") Sleep(300) $l_WindowTitle = 'Blabla Setup' $l_WindowText = "Installation Complete" WaitWindow($l_WindowTitle, $l_WindowText, $l_screenshot_directory_path_abs) Click(360, 360, $l_screenshot_directory_path_abs) LogFile("==> Blabla installation is complete") Sleep(300) $l_WindowTitle = 'Blabla Setup' $l_WindowText = "Completing Blabla Setup" WaitWindow($l_WindowTitle, $l_WindowText, $l_screenshot_directory_path_abs) Click(360, 360, $l_screenshot_directory_path_abs) LogFile("==> Blabla installation finished") FileClose($hFileOpen) Func WaitWindow($p_title, $p_text, $p_screenshot_directory_path_abs) ; Take a screenshot every 2seconds when waiting for window LogFile("Wait for window |" & $p_title & "| with text |" & $p_text & "|") While WinWait($p_title, $p_text, 2) == 0 LogFile("No detection of Window |" & $p_title & "| with text |" & $p_text & "|") TakeScreenshot($p_title, $p_screenshot_directory_path_abs) Wend LogFile("Detection of Window |" & $p_title & "| with text |" & $p_text & "|") TakeScreenshot($p_title, $p_screenshot_directory_path_abs) WinActivate($p_title, $p_text) EndFunc Func Click($p_x, $p_y, $p_screenshot_directory_path_abs) LogFile("Before Click on x:" & $p_x & " | y:" & $p_y) TakeScreenshot("Before Click", $p_screenshot_directory_path_abs) MouseClick("primary", $p_x, $p_y, 1, 10) LogFile("After Click on x:" & $p_x & " | y:" & $p_y) TakeScreenshot("After Click", $p_screenshot_directory_path_abs) EndFunc Func FillIn($p_text, $p_x, $p_y, $p_screenshot_directory_path_abs) LogFile("Before Fill in x:" & $p_x & " | y:" & $p_y) TakeScreenshot("Before Fill", $p_screenshot_directory_path_abs) MouseClick("primary", $p_x, $p_y, 1, 10) Send('^a' & $p_text) LogFile("After Fill in x:" & $p_x & " | y:" & $p_y) TakeScreenshot("After Fill", $p_screenshot_directory_path_abs) EndFunc Func TakeScreenshot($p_title, $p_screenshot_directory_path_abs) $l_datetime = GetTimeStamp() $l_screenshot_filename = $l_datetime & "_" & $p_title & ".jpg" $l_screenshot_filename = ReplaceSpecialCharacter($l_screenshot_filename, "_") $l_screenshot_path_abs = $p_screenshot_directory_path_abs & "\" & $l_screenshot_filename LogFile("Take screenshot title |" & $p_title & "|") $l_ActiveWindow = WinGetHandle("[active]") _ScreenCapture_CaptureWnd($l_screenshot_path_abs, $l_ActiveWindow) EndFunc Func LogFile($p_text) $l_datetime = GetTimeStamp() FileWriteLine($g_LogFile, $l_datetime & " - " & $p_text) EndFunc Func GetTimeStamp() $l_datetime = _NowCalc() $l_datetime = RemoveSpecialCharacter($l_datetime) Return $l_datetime EndFunc Func RemoveSpecialCharacter($p_text) $l_text = $p_text $l_text = StringReplace($l_text, ":", "") $l_text = StringReplace($l_text, "/", "") $l_text = StringReplace($l_text, " ", "") Return $l_text EndFunc Func ReplaceSpecialCharacter($p_text, $p_string) $l_text = $p_text $l_text = StringReplace($l_text, ":", $p_string) $l_text = StringReplace($l_text, "/", $p_string) $l_text = StringReplace($l_text, " ", $p_string) Return $l_text EndFunc