Jump to content

How to recognize text in a window


Docfxit
 Share

Recommended Posts

I have a script that needs to send the <esc> key to close a program when the text comes up saying:

"Device timeout in module MAIN"

The script I have doesn't work.

This is what I have:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
;  This is for '98
#AutoIt3Wrapper_UseAnsi=y
#AutoIt3Wrapper_Run_Debug_Mode=Y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;;#AutoIt3Wrapper_UseAnsi=y
;Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)
AutoItSetOption("TrayIconDebug", 1) ;0-off
; Set so that tray displays current line number
Dim $t
Dim $Crashed = -1
Dim $Show_Log
HotKeySet("{F8}", "Terminate")
HotKeySet("{F10}", "Show_Log")
 
MsgBox(0, "Weather Starter", "Running Main and minimizing..." & @CRLF & "")
Call("Is_Weather_Running")
 
While 1
    $t = $t + 1
    If $t = 5 Then
        Call("Is_Weather_Running")
        $t = 0
    EndIf
  
    ;***************************************************************
    ; This is where I need to recognize the text on the screen
    ;***************************************************************
    If WinExists("CMD.exe", "Device timeout in module MAIN") Then
        WinActivate("CMD.exe", "Device timeout in module MAIN")
        WinWaitActive("CMD.exe", "Device timeout in module MAIN")
        Send("{esc}")
        Call("Is_Weather_Running")
    EndIf
    Sleep(8000)
WEnd
 
Func Is_Weather_Running()
    If Not ProcessExists("CMD.exe") Then
        Run(@Comspec & ' /c  "C:\qb71\RW\MAIN.EXE"', "")
        $Crashed = $Crashed + 1
    EndIf
    Sleep(1000)
EndFunc   ;==>Is_Weather_Running
 
Func Terminate()
    Exit 0
EndFunc   ;==>Terminate
 
Func Show_Log()
    $Show_Log = Not $Show_Log
    If ($Show_Log) Then
        If (ProcessExists("Main.exe")) Then
            SplashTextOn("Weather Starter", "Main is running." & @CRLF & "Main has crashed " & $Crashed & " times.", 300, 75, 0, 0)
        Else
            SplashTextOn("Weather Starter", "Main is NOT running." & @CRLF & "Main has crashed " & $Crashed & " times.", 300, 75, 0, 0)
        EndIf
    Else
        SplashOff()
    EndIf
EndFunc   ;==>Show_Log

This is the screen I am working with:

Posted Image

Thank you,

Docfxit

Link to comment
Share on other sites

I think to get text out of a command window, you need to read it with

StdoutRead()
function

Also I think you are using the call() function unnecessarily, where just the function name would suffice.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
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
 Share

  • Recently Browsing   0 members

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