Jump to content

Suggestions for this please


ChrisL
 Share

Recommended Posts

I've got this script which looks for error windows on a computer, if a specific window appears it grabs the text and sends it via TCP/IP to another computer, which then displays the message and asks the user if they wish to connect to the computer with the error on. Via a 3rd party application.

My question is..

Currently there are 4 windows which are looked for, they are hard coded. The script has the begining part of the text I know appears, if that window appears it gets the text and sends it. It also sends the computer name and a Title to use based on the pc name, these are split by pipes and split into an array at the other end. (you didn't need to know that but I thought I might get questions)

What I would like to do is to be able to make the list of error windows expandable via an ini file, but I don't know how to go about making it happen in the script dynamically based on ini entries.

Can someone give me a hand in doing this.. Thanks

$Server = "Bay6server" 
$Port = "8000" 
Global $MainSocket

While 1
    
    If WinExists ("", "W-") then 
        $Textread = WinGetText ( "" , "W-" )
        SendData($TextRead)
        WinWaitClose ("", "W-")
        
            Elseif WinExists ("", "I-") then
            $Textread = WinGetText ( "" , "I-" )
            SendData($TextRead)
            WinWaitClose ("", "I-")
            
                Elseif WinExists ("", "E-") then
                $Textread = WinGetText ( "" , "E-" )
                SendData($TextRead)
                WinWaitClose ("", "E-")
                
                    Elseif WinExists ("", "X-") then
                    $Textread = WinGetText ( "" , "X-" )
                    SendData($TextRead)
                    WinWaitClose ("", "X-")
    Else
        $Textread = ""
        
        Endif
SLEEP (500)
Wend


Func SendData($Data)
TCPStartup()
    $MainSocket = TCPConnect(TCPNameToIP($Server), $Port)
    TCPSend($MainSocket, @computername & "|" & "Error on " & @computername & "|" & $Data  )
    TCPCloseSocket($MainSocket)
    TCPShutdown()   
    Endfunc
    
Func OnAutoItExit()
    TCPCloseSocket($MainSocket)
    TCPShutdown()
EndFunc;==>OnAutoItExit
Link to comment
Share on other sites

Don't necessarly need an ini file. A file with each window title on a separate line could suffice

W-

I-

E-

X-

Then use arrays. Note: I didn't test this code.

#include <File.au3>

Global $listOfErrors = @ScriptDir & "\errorList.txt";set path as needed
Global $windowTitle
_FileReadToArray($listOfErrors, ByRef $windowTitle)

$Server = "Bay6server"
$Port = "8000"
Global $MainSocket

While 1
    
    For $i = 0 to UBound($listOfErrors)-1
        If WinExists($windowTitle[$i]) Then
            $Textread = WinGetText ( "" , $windowTitle[$i] )
            SendData($TextRead)
            WinWaitClose ("", $windowTitle[$i])
        EndIf
        sleep(100); prevent maxing out the CPU
    Next

    SLEEP (500)
Wend
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

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...