Jump to content

Recommended Posts

Posted

Hi everyone,

We are running AutoIt on a Rendering Machine. We are trying to work with different applications. Obviously, depending on the file sent, there could be Macro errors or other error that may happen at any time. What our AutoIt scripting does, it finds error messages (that we listed)  and it tries to remove them.

After a while, it doesn't click the message anymore.

As you can see in my script below, I log when an error message is found. So when that AutoIT stops clicking the error 102 Command failed it does detect it (Because it is in my log), but it doesn't seem to be taking action.

Someone was saying that maybe using ControlSend instead Send may be better, but I could not figure out how to use ControlSend to just send a "ENTER" key to the window or something of the sort...

But then again, any idea why AutoIT would stop interacting with the window? 

If I kill the exe file of AutoIT and restart the same SAME script it starts clicking the errors away again as expected.

; MsgBoxKiller Logs Variables for Logging
Global $LogDir = "C:\MsgBoxKiller\Logs"

; Logging Function for Error Check
Func ErrorCheckLog ( $Line = "" )
    If Not FileExists ( $LogDir ) Then DirCreate ( $LogDir )
    _FileWriteLog( $LogDir & "\" & "ErrorCheck-"  & @YEAR & @MON & @MDAY & ".log", @ComputerName & "# " & $Line )
EndFunc

Func SearchClick ($ErrorList = "", $LogInfo =  "", $MatchMode = 2,  $Title = "", $Msg = "", $Key = "{ENTER}", $Sleep = 0)
    AutoItSetOption("WinTitleMatchMode", $MatchMode)
    Local $MyWindowHandle = WinGetHandle($Title, $Msg)
    If not @error then
        WinActivate( $MyWindowHandle )
        Sleep(100)
        Send($Key)
        ErrorCheckLog ( $ErrorList & ": send " & $Key & " to Window """ & $Title & """ with Text """ & $LogInfo & """." )
        return 1
    Else
        return 0
    EndIf
EndFunc

func CheckOtherErrors()
    Local $ReturnCode = 0
    SearchClick ("MVB0003", "Run-time error '102':Command failed", 3, "Microsoft Visual Basic", "Command failed", "{e}", 500)
    SearchClick ("MVB0004", "Run-time error '102':Command failed", 3, "Microsoft Visual Basic", "Command failed", "{SHIFTDOWN}{TAB}{SHIFTUP}{ENTER}", 500)
EndFunc

 

Posted (edited)

I don't think it will help any, assuming your program successfully deals with error "MVB0003" normally until it stops working?  But I was wondering why you are sending an "{e}" to a (I'm assuming) pop up error window? Is this supposed to be "{ENTER}" or "{ALT}{e}" by any chance?

  Quote

SearchClick ("MVB0003", "Run-time error '102':Command failed", 3, "Microsoft Visual Basic", "Command failed", "{e}", 500)

Expand  
Edited by donnyh13

LibreOffice UDF  ; Scite4AutoIt Spell-Checker Using LibreOffice

  Reveal hidden contents

 

Posted (edited)

I'm not as knowledgeable as most on here, so don't take my input too highly, but as for ControlSend or ControlClick, you would need to use AutoItWindowInfo Tool to find the ControlID of the button you are wishing to Click or send text to. But unless it is a "Windows" window, it usually won't detect the ID. Someone else may have a suggestion for this??

Edit*

Another question, when the script stops clearing the errors, does your function SearchClick return 1 or 0? Is it still indicating it is successfully identifying the error MsgBox or not? Perhaps the Error box has a slightly different title or text?

Edited by donnyh13

LibreOffice UDF  ; Scite4AutoIt Spell-Checker Using LibreOffice

  Reveal hidden contents

 

Posted
  On 11/23/2023 at 6:35 PM, donnyh13 said:

I don't think it will help any, assuming your program successfully deals with error "MVB0003" normally until it stops working?  But I was wondering why you are sending an "{e}" to a (I'm assuming) pop up error window? Is this supposed to be "{ENTER}" or "{ALT}{e}" by any chance?

Expand  

Hi Donnyh13 thanks for your reply - The {e} is because of the End, I don't think you need to send an "{ALT}{e}" as the default key is E. (But I'll check to make sure). It was not meant for {ENTER} :) 

  On 11/23/2023 at 6:51 PM, donnyh13 said:

I'm not as knowledgeable as most on here, so don't take my input too highly, but as for ControlSend or ControlClick, you would need to use AutoItWindowInfo Tool to find the ControlID of the button you are wishing to Click or send text to. But unless it is a Windows window, it usually won't detect the ID. Someone else may have a suggestion for this??

Edit*

Another question, when the script stops clearing the errors, does your function SearchClick return 1 or 0? Is it still indicating it is successfully identifying the error MsgBox or not? Perhaps the Error box has a slightly different title or text?

Expand  

You are right on that - It's a "Microsoft" popup and I didn't find a ControlID (which seems to confirm what you're saying)

My SearchClick keeps finding the error message, as I said I can see it in my Logging that it finds it, it just does not interact with it anymore after a while.

  On 11/23/2023 at 8:39 PM, junkew said:

After your send give a sleep of a few (milli)seconds to make sure the enter is processed or several short sleeps till the window is gone. And hopefully error messages do not popup directly within split seconds.

Expand  

Because my script re-run every 5 seconds, even if it would reappear, it would find it again, and should act upon it, but the actions don't seem to happen anymore :( That's my problem.

Posted (edited)
  On 11/24/2023 at 9:18 AM, Sly01 said:

The {e} is because of the End,

Expand  

Ah, I see. I thought the End needed ALT added to make it work, but I must be mistaken. I tried it and it just send an "e" to notepad.

Maybe you could add

WinActivate( $MyWindowHandle )
 ###NEW
        If Not WinActive($MyWindowHandle) Then WinActivate( $MyWindowHandle )
        ##END NEW

Or

WinActivate( $MyWindowHandle )
        Sleep(100)
        Send($Key)
        ####NEW
        Sleep(100)
        If WinExists($MyWindowHandle) Then 
            WinActivate( $MyWindowHandle )
            Send($Key)
            Sleep(100)
        EndIf
        ###END NEW

Or --- Kind of stupid logic, but you could create a script to kill your error script every X hours and restart it?

Sorry I can't offer any other ideas.

Edited by donnyh13

LibreOffice UDF  ; Scite4AutoIt Spell-Checker Using LibreOffice

  Reveal hidden contents

 

Posted
  On 11/25/2023 at 1:59 PM, junkew said:

How do you run your script everything 5 seconds?

You should validate after winactivate if it was succesfull.

Expand  

Not a bad idea to check if it was succesfull or not - But I do think it will fix the "problem" I will to still find a way to start clicking on the window... But that validation might be the right direction to go.

The script is running constantly, and is in a loop:

;How Much time to wait between checks (Milliseconds)
Dim $LoopRepeat = 5000

; Pause not to consume too much CPU
Dim $LoopMinDuration = 5000
Dim $LoopTimer

While 1

    $LoopTimer = TimerInit()

; Excel Loop
    If TimerDiff ($ExcelChecksTimer) >= $LoopRepeat Then
        AutoItSetOption('WinTitleMatchMode', 3)
        CheckOtherErrors()
        ExcelChecks()
    EndIf

; Sleeping for less CPU usage
    If TimerDiff ($LoopTimer) < $LoopMinDuration Then
        Sleep ( $LoopMinDuration - TimerDiff ($LoopTimer) )
    EndIf

WEnd

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...