Jump to content

Checkig process status inside a While


Recommended Posts

I have a structure like

while 1
 Case $msg[0] = ...
    run program A
 Case $msg[0] = ...
    run program B
 Case $msg[0] = ...
    do another thing
 Case $msg[0] = ...
    do another thing
 Case $msg[0] = ...
   do another thing
wend

i created a routine to check every 30 secs if "program A" is active (if not relaunch it) and if "program B" is active (if not relaunch it):

func _checkA
   sleep (30000)
 $valueA  = processexists (programA)
  if $value = 0 then _launchA
endfunc

func _checkB
 same as func A

and i put the 2 _func inside the while BUT outsie the select

...
...
 endselect
  _checkA
 _checkB
wend

But now i have a loop i can't interrupt since once i launch the .au3 he goes to _check, polls every (sleep 30000) and i'm not able to click any button on my form.

What i think is i need a parallel procedure that checks if programs are active while i still have full control on my au3 and can run/manage other "case"

Please help!

Thanks,

Marco

Edited by marko001
Link to comment
Share on other sites

Try AdLibEnable in the helpfile..

well, i used it,

AdlibEnable("_checkgameA",20000)
AdlibEnable("_checkgameB",20000)

While 1
    $msg = GUIGetMsg(1)
    Select
...
...
wend

and

func _checkgameA()
    if $controlforchecking1 = true Then
        _tcpsend(1,"/status")
        sleep(1000)
            $msg = TCPRecv($oSocket1, 1500)
        If StringInStr($msg, "True") Then
            _status(1,"Game is still up!")
        Else
            _status(1,"Game closed! Relogging...")          
            GUICtrlSetData($g1start, "Game1")
            _Launch(1)
            _Start(1)
        EndIf
        return 1
    Else
    return 0
    EndIf
EndFunc

But (i checked with msgbox to test it) the func is never called.... either if controlforchecking1 is true or false.

Any suggestions?

Link to comment
Share on other sites

well, i used it,

AdlibEnable("_checkgameA",20000)
AdlibEnable("_checkgameB",20000)

While 1
    $msg = GUIGetMsg(1)
    Select
...
...
wend

and

func _checkgameA()
    if $controlforchecking1 = true Then
        _tcpsend(1,"/status")
        sleep(1000)
            $msg = TCPRecv($oSocket1, 1500)
        If StringInStr($msg, "True") Then
            _status(1,"Game is still up!")
        Else
            _status(1,"Game closed! Relogging...")          
            GUICtrlSetData($g1start, "Game1")
            _Launch(1)
            _Start(1)
        EndIf
        return 1
    Else
    return 0
    EndIf
EndFunc

But (i checked with msgbox to test it) the func is never called.... either if controlforchecking1 is true or false.

Any suggestions?

You cab have 1 function only for AdLibEnable. Since you want both to run every 20 seconds you could could do something like this

Global $gameA = true
AdlibEnable("AorB",10000)

Func AorB()

if $gameA then
  _checkgameA()
else
 _checkgameB()
endif
$gameA = not $gameA

endfunc

Or

Adlibenable("AandB",20000)

Func AandB()
_checkgameA()
_checkgameB()
endfunc
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...