WatchDog Prg

WatchDog Prg

Postby Jeff Barnes » Wed Dec 16, 2009 8:13 pm

Hi,

I am trying to write a small app that will check every 5 seconds to see if a program is running or not.

I have tried a couple of different ways but it seems that the FWH app must have focus in order for it to work correctly.

I have tried using IsEXERunning() and also tried GetTasks() (using calculator as a sample).

Obviously I cannot have the focus always on my app ...

Has anyone got a simple solution?
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: WatchDog Prg

Postby Armando » Wed Dec 16, 2009 8:45 pm

Jeff:

I use these two functions to see if the calculator is active and they work fine, perhaps they are a good clue.

Code: Select all  Expand view

/*
* --------------------------------------------------------------------------*
* --------------------------------------------------------------------------*
*/

FUNCTION Calculadora()
LOCAL hWnd
    IF ( hWnd := SeekCalculadora() ) == 0
        WinExec( 'Calc.Exe', 0)     // SW_NORMAL )
    ELSE
        BringWindowToTop( hWnd )
        ShowWindow( hWnd, 1)            // SW_RESTORE )
    ENDIF
RETURN(NIL)


/*
* --------------------------------------------------------------------------*
* --------------------------------------------------------------------------*
*/

FUNCTION SeekCalculadora()
LOCAL aCaptions := {'Calc','Calculator','Calculadora'}
LOCAL nPos, hWnd
    FOR nPos := 1 TO LEN(aCaptions)
        IF ( hWnd := FindWindow( 0, aCaptions[nPos] ) ) > 0
            RETURN (hWnd)
        EndIf
    NEXT
RETURN(hWnd)
 


With best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3217
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: WatchDog Prg

Postby Jeff Barnes » Thu Dec 17, 2009 1:01 am

Thanks Armando. Exactly what I needed. Works perfectly.
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: WatchDog Prg

Postby Armando » Thu Dec 17, 2009 1:53 am

Jeff:

Terrific ! :wink:

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3217
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 79 guests