isexerunning (Solved)

isexerunning (Solved)

Postby norberto » Fri May 04, 2012 4:57 pm

HI, this code: (by EMG)

IF ISEXERUNNING( CFILENOEXT( HB_ARGV( 0 ) ) )
SHOWWINDOW( FINDWINDOW( 0, "Titolo tua finestra" ), 9 )
SETFOREGROUNDWINDOW( FINDWINDOW( 0, "Titolo tua finestra" ) )
RETURN NIL
ENDIF

works before build window of exe?
Last edited by norberto on Sun May 06, 2012 6:09 pm, edited 1 time in total.
norberto
 
Posts: 566
Joined: Thu Aug 30, 2007 3:40 pm
Location: BR

Re: isexerunning

Postby Antonio Linares » Fri May 04, 2012 5:59 pm

Norberto,

It requires the main window to exist already
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: isexerunning

Postby norberto » Fri May 04, 2012 6:09 pm

Antonio,

i need some method to before creation of the main window. I need detect it is already running and put the focus on open application.
norberto
 
Posts: 566
Joined: Thu Aug 30, 2007 3:40 pm
Location: BR

Re: isexerunning

Postby Antonio Linares » Fri May 04, 2012 6:27 pm

Norberto,

Try to use:
Code: Select all  Expand view

if GetModuleHandle( HB_ARGV( 0 ) ) != 0
   MsgInfo( "App already running" )
   return 0
endif
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: isexerunning

Postby norberto » Fri May 04, 2012 6:43 pm

Antonio, isexerunning works without main window, but i cant put focus in already open appl.

thanks
norberto
 
Posts: 566
Joined: Thu Aug 30, 2007 3:40 pm
Location: BR

Re: isexerunning

Postby Antonio Linares » Fri May 04, 2012 7:23 pm

Norberto,

If there is no user input in the already running app, what do you mean/expect giving it the focus ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: isexerunning

Postby norberto » Fri May 04, 2012 7:39 pm

Antonio,

I need detect another instance of the same application, and if there is another instance, transfer focus to it, maybe showing the screen in the foreground, but I wanted to do this before the initial window, perhaps checking the name of the executable and not the window title.

thanks
norberto
 
Posts: 566
Joined: Thu Aug 30, 2007 3:40 pm
Location: BR

Re: isexerunning

Postby Kleyber » Sat May 05, 2012 12:51 pm

Norberto,

Try it:

Code: Select all  Expand view

pTitulo:="Nome do teu sistema que fica na barra de cima da Window"
If IsExeRunning( cFilename( hb_Argv(0) ) )
   SHOWWINDOW( FINDWINDOW( 0, pTitulo ), 3 )
   SETFOREGROUNDWINDOW( FINDWINDOW( 0, pTitulo ) )
   return nil
Endif
 
Kleyber Derick

FWH / xHb / xDevStudio / SQLLIB
User avatar
Kleyber
 
Posts: 581
Joined: Tue Oct 11, 2005 11:28 am
Location: São Luiz, Brasil

Re: isexerunning

Postby norberto » Sat May 05, 2012 1:16 pm

Kleyber, this works after build main window, i need before.
i need something using the name of exe, not main windows title, because at this point , it not create.

Thanks
norberto
 
Posts: 566
Joined: Thu Aug 30, 2007 3:40 pm
Location: BR

Re: isexerunning

Postby Otto » Sat May 05, 2012 8:18 pm

Norberto,
this is working for me.
Best regards,
Otto

Code: Select all  Expand view
FUNCTION main
    if IsExeRunning( cFileName( HB_ARGV( 0 ) ) )
      ShowApplication()
   else
   
        DEFINE WINDOW oWnd

 
    WritePProString( "Programm" , "RECHNUNG", oWnd:cTitle(), ".\ini\whLink.ini" )
     
        ACTIVATE WINDOW oWnd MAXIMIZED
   
   
   
   endif
   
   return
 //----------------------------------------------------------------------------//
   
   
   
function ShowApplication()
   local hWnd := 0
   local cFileNoExt := ""
    local uVar = GetPvProfString( "Programm", "RECHNUNG", "WINHOTEL",".\ini\whLink.ini" )
   
   hWnd := FindWnd( uVar )

   if hWnd != nil
        if IsIconic( hWnd )
            ShowWindow( hWnd, SW_RESTORE )
        endif
        SetFocus( hWnd )
        SetForeGroundWindow( hWnd )
   endif

return nil
//----------------------------------------------------------------------------//

function FindWnd( cTitle )
   local hWnd := GetWindow( GetDesktopWindow(), GW_CHILD )

   while hWnd != 0
      if Upper( cTitle ) $ Upper( GetWindowText( hWnd ) )
         return hWnd
      endif

      hWnd = GetWindow( hWnd, GW_HWNDNEXT )
   end

return nil
//----------------------------------------------------------------------------//
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: isexerunning

Postby Enrico Maria Giordano » Sat May 05, 2012 10:59 pm

Can we see a little but complete sample showing your problem? I didn't understand it.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: isexerunning

Postby norberto » Sat May 05, 2012 11:21 pm

Enrico, Otto, thanks, but dont work to me.
I wanted check the existence of another instance the application before creating the main window, before checking the User, open files, etc.
all the solutions posted work after the main window created .I wanted first of all, at the beginning of the system.
May have to get the handle of the system and not the name (caption)
i wanted to check the existence of another instance, move the focus to it, and leave the second instance (quit).

but thanks to all.
norberto
 
Posts: 566
Joined: Thu Aug 30, 2007 3:40 pm
Location: BR

Re: isexerunning

Postby Enrico Maria Giordano » Sun May 06, 2012 8:57 am

My sample works before the main windows is created.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: isexerunning

Postby Kleyber » Sun May 06, 2012 2:05 pm

norberto wrote:Kleyber, this works after build main window, i need before.
i need something using the name of exe, not main windows title, because at this point , it not create.

Thanks


Norberto,

I would like to understand it better: If you have another instance of your program, how is this running in you computer? I think it means the ohter instance is working and if it is working it has already a main window. Or not?
Kleyber Derick

FWH / xHb / xDevStudio / SQLLIB
User avatar
Kleyber
 
Posts: 581
Joined: Tue Oct 11, 2005 11:28 am
Location: São Luiz, Brasil

Re: isexerunning

Postby norberto » Sun May 06, 2012 3:11 pm

hI, isexerunning detects another instance, but i cant put this in foreground (focus).
norberto
 
Posts: 566
Joined: Thu Aug 30, 2007 3:40 pm
Location: BR

Next

Return to FiveWin for Harbour/xHarbour

Who is online

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