FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour WatchDog Prg
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
WatchDog Prg
Posted: Wed Dec 16, 2009 08: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)
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: WatchDog Prg
Posted: Wed Dec 16, 2009 08: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 (fw): Select all Collapse
/*
* --------------------------------------------------------------------------*
* --------------------------------------------------------------------------*
*/
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
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: WatchDog Prg
Posted: Thu Dec 17, 2009 01:01 AM

Thanks Armando. Exactly what I needed. Works perfectly.

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: WatchDog Prg
Posted: Thu Dec 17, 2009 01: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

Continue the discussion