Jump to content
Sign in to follow this  
Natig

AutoIt automation freezes

Recommended Posts

Natig

Hi All,

I'm using AutoIt script in order to press O.K on windows popup every 10-60 minutes,

before pressing the O.K button the script runs a batch file that perform several tasks...

The problem is that after about 3 hours the script stops pressing on the O.K button.

If i'm closing the script and restart it, it works O.K for another 2-3 hours...

I tried adding "watch-dog" to the script that restart the script every 30 minutes,

in order to avoid this "freeze", but it doesn't work.

I'll appriciate all the help i can get,

Thanks in advance,

Nati.

Share this post


Link to post
Share on other sites
Tvern

I think you need to supply more information. At least a code example.

Share this post


Link to post
Share on other sites
water

You can use the AutoIt3Wrapper directive

#AutoIt3Wrapper_Run_Debug_Mode=Y

so your script writes every executed statement to the console.

Or you could use

AutoItSetOption ( "TrayIconDebug" , 1 )

So the tray icon always shows the currently executed script line.

But as stated before: Source code would help most.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Natig

Sure...

Here is the problematic code -

While (True)

;wating for the window

WinWait($String_For_Popup_Title)

; Setting Focus on the window

if Not WinActive($String_For_Popup_Title) Then _

WinActivate($String_For_Popup_Title)

WinWaitActive($String_For_Popup_Title)

;getting the window handle

$CurrentWindowHandle = WinGetHandle($String_For_Popup_Title,"")

;reading data from window in order to choose the proper board settings

$CurrentWindowData = ControlGetText($CurrentWindowHandle,"",$Static_Text_ControlID)

;parsing the data

; 5MHz or 10 MHz

$Use5MHZ = False ;Default value

if (StringInStr($CurrentWindowData,$String_For_5MHZ)>0) Then

$Use5MHZ = True

EndIf

; Mimo or No Mimo

$UseMimo = False ;Default value

;if (StringInStr($CurrentWindowData,$String_For_MIMO) >0) Then

; $UseMimo = True

;EndIf

; Frequency

$UseFreq = $FreqDefaultValue ; Default value

If ($Use5MHZ) Then

If (StringInStr($CurrentWindowData,$String_For_F8_Freq_5MHZ)>0) Then $UseFreq = $F8_5MHz_Enum

If (StringInStr($CurrentWindowData,$String_For_F7_Freq_5MHZ)>0) Then $UseFreq = $F7_5MHz_Enum

If (StringInStr($CurrentWindowData,$String_For_F6_Freq_5MHZ)>0) Then $UseFreq = $F6_5MHz_Enum

If (StringInStr($CurrentWindowData,$String_For_F5_Freq_5MHZ)>0) Then $UseFreq = $F5_5MHz_Enum

If (StringInStr($CurrentWindowData,$String_For_F4_Freq_5MHZ)>0) Then $UseFreq = $F4_5MHz_Enum

If (StringInStr($CurrentWindowData,$String_For_F3_Freq_5MHZ)>0) Then $UseFreq = $F3_5MHz_Enum

If (StringInStr($CurrentWindowData,$String_For_F2_Freq_5MHZ)>0) Then $UseFreq = $F2_5MHz_Enum

If (StringInStr($CurrentWindowData,$String_For_F1_Freq_5MHZ)>0) Then $UseFreq = $F1_5MHz_Enum

Else

If (StringInStr($CurrentWindowData,$String_For_F10_Freq_10MHZ)>0) Then $UseFreq = $F10_10MHz_Enum

If (StringInStr($CurrentWindowData,$String_For_F9_Freq_10MHZ)>0) Then $UseFreq = $F9_10MHz_Enum

If (StringInStr($CurrentWindowData,$String_For_F8_Freq_10MHZ)>0) Then $UseFreq = $F8_10MHz_Enum

If (StringInStr($CurrentWindowData,$String_For_F7_Freq_10MHZ)>0) Then $UseFreq = $F7_10MHz_Enum

If (StringInStr($CurrentWindowData,$String_For_F6_Freq_10MHZ)>0) Then $UseFreq = $F6_10MHz_Enum

If (StringInStr($CurrentWindowData,$String_For_F5_Freq_10MHZ)>0) Then $UseFreq = $F5_10MHz_Enum

If (StringInStr($CurrentWindowData,$String_For_F4_Freq_10MHZ)>0) Then $UseFreq = $F4_10MHz_Enum

If (StringInStr($CurrentWindowData,$String_For_F3_Freq_10MHZ)>0) Then $UseFreq = $F3_10MHz_Enum

If (StringInStr($CurrentWindowData,$String_For_F2_Freq_10MHz)>0) Then $UseFreq = $F2_10MHz_Enum

If (StringInStr($CurrentWindowData,$String_For_F1_Freq_10MHZ)>0) Then $UseFreq = $F1_10MHz_Enum

EndIf

;Releasing the Popup Window

ControlClick($CurrentWindowHandle,"",$OK_Button_String)

;reseting the board and sending CLI commands

; Nati - There is no MIMO in the RRT

If ($Use5MHZ) Then

Switch($UseFreq)

Case $F1_5MHz_Enum

RunWait($Batch_5MHZ_F1)

Case $F2_5MHz_Enum

RunWait($Batch_5MHZ_F2)

Case $F3_5MHz_Enum

RunWait($Batch_5MHZ_F3)

Case $F4_5MHz_Enum

RunWait($Batch_5MHZ_F4)

Case $F5_5MHz_Enum

RunWait($Batch_5MHZ_F5)

Case $F6_5MHz_Enum

RunWait($Batch_5MHZ_F6)

Case $F7_5MHz_Enum

RunWait($Batch_5MHZ_F7)

Case $F8_5MHz_Enum

RunWait($Batch_5MHZ_F8)

EndSwitch

Else

Switch($UseFreq)

Case $F1_10MHz_Enum

RunWait($Batch_10MHZ_F1)

Case $F2_10MHz_Enum

RunWait($Batch_10MHZ_F2)

Case $F3_10MHz_Enum

RunWait($Batch_10MHZ_F3)

Case $F4_10MHz_Enum

RunWait($Batch_10MHZ_F4)

Case $F5_10MHz_Enum

RunWait($Batch_10MHZ_F5)

Case $F6_10MHz_Enum

RunWait($Batch_10MHZ_F6)

Case $F7_10MHz_Enum

RunWait($Batch_10MHZ_F7)

Case $F8_10MHz_Enum

RunWait($Batch_10MHZ_F8)

Case $F9_10MHz_Enum

RunWait($Batch_10MHZ_F9)

Case $F10_10MHz_Enum

RunWait($Batch_10MHZ_F10)

EndSwitch

EndIf

WEnd

Marked in red is the problematic sections,

Do you think the problem is because i'm using WinWaitActive ?

How can i improve this code?

The ControlClick section should work on a locked workstation as well (using the popup title)?

Thanks!!!!

Share this post


Link to post
Share on other sites
MHz

Do you think the problem is because i'm using WinWaitActive ?

How can i improve this code?

The ControlClick section should work on a locked workstation as well (using the popup title)?

If you wish the script to function on a locked workstation then active window functions may fail as they cannot activate above the locked screen.

Try removing the block of code below

; Setting Focus on the window
    If Not WinActive($String_For_Popup_Title) Then _
            WinActivate($String_For_Popup_Title)
    WinWaitActive($String_For_Popup_Title)

Control* functions should still operate OK on non active windows.

Share this post


Link to post
Share on other sites
BrettF

Share this post


Link to post
Share on other sites
Natig

Please read the FAQ regarding running code on a locked workstation and the problems you may encounter.

There is a sticky in this forum.

Thanks!

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.