Jump to content
Sign in to follow this  
ReyB

AutoIT script stop after 1 hour

Recommended Posts

Hi,

I wrote my first AutoIT script which is working fine but (there is always a but) when the script is running for more than 1 hour then it stops.

My script is automating an installer which has a step which takes more than 45 minutes to diplay next screen.

How do I know it is after 1 hour and not 1hour + 1minute? Because I've logged all actions in a file with time stamp.

How I am sure it stops ? Because when I run the rest of my script from where it stopped then it restart correctly. 

Is there a parameter somewhere which has to be set and I do not know yet?

 

Share this post


Link to post
Share on other sites

Sorry, left my crystal ball in the car, can you please post the script you're having issues with and where it stops?

Also, if it's an install have you checked to see if it has command line parameters that allow unattended installations?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

@ReyB

Post your script, so we can see how we can help you :)

By the way, you should try WinWaitActive() :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
1 minute ago, FrancescoDiMuro said:

By the way, you should try WinWaitActive() :)

I see you did get the crystal ball out since you seem to know already that function wasn't use. ;)

 


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

@Jos

Sorry, but I didn't get you... Maybe the late hour :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

Hi,

Here is the script.

The last log I have in log file is the one of line 121 and it is just 1 hour after the first log.

We could think there is something wrong in the next window detection but when I put the rest of the script in another file (to execute the remaining steps)  then it works. Next windows are correctly detected and installtion finishes.

 

MyScript.au3

Share this post


Link to post
Share on other sites

@ReyB

Did you see if you can install those application in "silent mode" as @BrewManNH suggested? 

And, we couldn't run your code because we don't have your install applications :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

I had a look in the script, looks ok in a glance. Cant run it to test as i dont have the apps , but on which line does it stop?

Share this post


Link to post
Share on other sites
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <Date.au3>
#include <ScreenCapture.au3>

#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

Hmmmm

 

I bet on Win tittle problem. Be sure i dont know the blabla and bloblo application so i am sure about the tittle is different so may you can reduce it and :

May try that ?

Opt("WinTitleMatchMode", 2)

 

Edited by caramen

My video tutorials : HERE ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...