Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    [DELPHI 5] determinare se un task ha finestra attiva

    Salve a tutti,
    Vorrei sapere se esiste un metodo per sapere se un determinato task è uttilizzato dall'utente , ovvero se la sua finestra è quella attiva.
    Esempio : quando la finestra attiva appartiene a WORD vorrei avviare un mio processo.
    Grazie a chiunque risponda fin da ora !

  2. #2
    ... sono arrivato a capire che con GetForeGroundWindow ho l'hadle.. ma a questo punto mi serve l'exename dell'handle.. qualche idea ?

  3. #3
    easy man
    una ricercuzza su google ed avresti trovato quello che cercavi!!!
    codice:
    function ActiveCaption: string;
    var
      Handle: THandle;
      Len: LongInt;
      Title: string;
    begin
      Result := '';
      Handle := GetForegroundWindow;
      if Handle <> 0 then
      begin
        Len := GetWindowTextLength(Handle) + 1;
        SetLength(Title, Len);
        GetWindowText(Handle, PChar(Title), Len);
        Result := TrimRight(Title);
      end;
    end;

  4. #4
    per ricavare il percorso dell'eseguibile dall'handle (sempre il frutto di una ricercuzza ):
    codice:
    function GetAppName(hwindow: HWND): string;
    var
      h : HMODULE;
    begin
      SetLength(Result, 100);
      h:=GetClassLong(hwindow, GCL_HMODULE);
      GetModuleFileName(h, PChar(Result), 100);
    end;

  5. #5
    Gazie per l'aiuto.. facendo ricerche avevo trovato molto materiale ma inutile.. non sono granchè come googolaro... cmq alla fine GetModuleFileName non mi funziona come vorrei.. il tutto l'ho risolto così (maccheronico)
    l'activate della form ttiva il timer2 che a sua volta .. :

    procedure TScreenShotForm.Timer2Timer(Sender: TObject);
    begin
    Timer2.Interval := 5000;
    GetMem(cname,256);
    ahnd := GetForegroundWindow();
    GetClassName(ahnd,cname,256);
    If cName = 'quello_che_cerco' Then beep;
    freemem (cname);
    end;

    Il problema ora è che se lo shut down di windows non funziona più, sono costretto a chiudere l'applicazione . Pedr ovviare a questo devo intercettare il messagio di shut down di windows e terminare l'applicazione oppure è il timer che da fastidio?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.