Jump to content

Recommended Posts

Posted

I have a script that pulls variables from other programs.

But every now & then, one of the programs will suddenly terminate or just freeze.

So what im looking for is:

1. When the program freezes, the data on the script will also freeze, so i need to make a "timeout" future, so when the variables haven't changed for a minute, then it will inform me about it.

2. When the program terminates, there script wont receive a variable, so how do i make it so when, that script dosent have a variable, then it informs me.

I know its something like If $var ="" then. or something like that, but i cant get anything to work.

Posted

I have a script that pulls variables from other programs.

But every now & then, one of the programs will suddenly terminate or just freeze.

So what im looking for is:

1. When the program freezes, the data on the script will also freeze, so i need to make a "timeout" future, so when the variables haven't changed for a minute, then it will inform me about it.

2. When the program terminates, there script wont receive a variable, so how do i make it so when, that script dosent have a variable, then it informs me.

I know its something like If $var ="" then. or something like that, but i cant get anything to work.

You could just code a loop based on TimerInit()/TimerDiff().

You could create an AdLib function (Prod: AdLibEnable(), Beta: AdLibRegister()).

You could add timers to your GUI with _Timer_SetTimer().

Exactly how are you retrieving the variables from the other apps? For example, if you use ControlGetText(), it will return @error if the GUI or control doesn't exist any more.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

Im using ControlGetHandle.

But what im looking for is.

I have a "X: $Var" and that $var should be changing ever 1 second. But if the program that im getting the var from freezes, Then the var will stay the same.

So if "X:35" and it stayed like that for 30 seconds, then the script would inform me about a possible problem.

Posted

Hi there,

And what about the process if it is an exe file?

Just an idea... we have few info about all your reality :)

Wish you the best.

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Posted

Im using ControlGetHandle.

But what im looking for is.

I have a "X: $Var" and that $var should be changing ever 1 second. But if the program that im getting the var from freezes, Then the var will stay the same.

So if "X:35" and it stayed like that for 30 seconds, then the script would inform me about a possible problem.

Well, there's not much to that... this demo monitors for the window closing, failing to read the control, or a 30sec timeout. Note that AdLibRegister() is Beta, use AdLibEnable() for Prod.
Global $iTimer = TimerInit(), $iTimeout = 30000
Global $var, $fError = False, $hYourApp, $hYourCtrl

Run("YourApp.exe")
WinWait("YourApp", "")
$hYourApp = WinGetHandle("YourApp", "")
$hYourCtrl = ControlGetHandle($hYourApp, "", "[CLASS:YourCtrlClass; INSTANCE:1]")

AdLibRegister("_CheckValue", 250)

While 1
    If $fError Then
        MsgBox(16, "Error", "Application hung/closed")
        Exit
    EndIf
    Sleep(10)
WEnd

Func _CheckValue()
    Local $CurrVar
    If WinExists($hYourApp) Then
        $CurrVar = ControlGetText($hYourApp, "", $hYourCtrl)
        If @error = 0 Then
            If $CurrVar <> $var Then
            ; Data changed
                $var = $CurrVar
                $iTimer = TimerInit()
                Return
            ElseIf TimerDiff($iTimer) < $iTimeout Then
            ; Data unchanged, time has not expired
                Return
            EndIf
        EndIf
    EndIf
    
; Error - Window closed, reading control failed, or data not changing before timeout
    $fError = True
EndFunc

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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
×
×
  • Create New...