Link to home
Create AccountLog in
Avatar of dMa
dMaFlag for Germany

asked on

Detect Application running in Fullscreen mode

hi experts,

i need to detect applications running in fullscreen mode.

it's do not mattter if this is a game running in fullscreen and changed the screensize or
an flash application.

the problem here is if you have two or more monitors it's could be that the application
is fullscreend but only on one monitor.

just as example if you have 2 monitors (with extended destop on both) go to youtube and
and set you flash video to fullscreen during play.

i dont even know if there is a possibility to watch 2 different applications in fullscreen on both monitors, but i guess it's possible.

so i neet do detect the processes or windows or controls that are currently running in fullscreen mode., somthing like :

procedure getfullscreenapps ( array of handles )

any ideas?

+500 more with an A grade if you give me an working solution
Avatar of jimyX
jimyX

There are two status of windows either maximized such as for explorer, applications and similar forms, or fullscreen such as games, videos and similar software.

To detect maximized:

 
procedure TForm1.Timer1Timer(Sender: TObject);
var
  h: HWND;
begin
  h := GetForegroundWindow;
  if h = Form1.handle then
    exit;
  if (IsWindowVisible(H) and not IsIconic(H) and IsZoomed(H)) then
    begin
      showmessage('active application (' + inttostr(h) + ') is in maximized mode');
    end;
end;

Open in new window


To detect fullscreen:

 
procedure TForm1.Timer1Timer(Sender: TObject);
var
  ForegroundRect: TRect;
begin
  GetWindowRect(GetForegroundWindow, ForegroundRect);
  if (ForegroundRect.Top = 0) and (ForegroundRect.Left = 0) and (ForegroundRect.Right = Screen.Width) and (ForegroundRect.Bottom = Screen.Height) then
    begin
      showmessage('active window is in fullscreen');
    end;
end;

Open in new window


I do not have two monitors to try that.

Source:
https://www.experts-exchange.com/questions/20417652/Detect-full-screen.html
http://www.delphipages.com/forum/showthread.php?t=169206
You can detect the fullscreen windows by scanning all the processes as follows:

 
procedure TForm1.FindFullScreenAllwin;
var
  processID: DWORD;
  hwd: HWnd;
  ForegroundRect: TRect;
begin
  hwd := Form1.Handle;
  while hwd > 0 do
  begin
  GetWindowThreadProcessID(hwd, @processID);
  if processID <> GetCurrentProcessID then
    begin
      GetWindowRect(hwd, ForegroundRect);
      if (ForegroundRect.Top = 0) and (ForegroundRect.Left = 0) and (ForegroundRect.Right = Screen.Width) and (ForegroundRect.Bottom = Screen.Height) then
        begin
           Memo1.Lines.Add(inttostr(hwd)+' is full screen');
        end;
    end;
    hwd := GetNextWindow(hwd, GW_HWNDNEXT);
  end;
end;

Open in new window


And if you want to get the title of any window by its handle:

 
function FindWinTitle(Hwd:HWnd):string;
var
  Len: LongInt;
  Title: string;
begin
  Len := GetWindowTextLength(Hwd) + 1;
  SetLength(Title, Len);
  GetWindowText(Hwd, PChar(Title), Len);
  result := TrimRight(Title);
end;

Open in new window

Avatar of dMa

ASKER

hi guyz,
  sorry both of the solutions do not work.
 
 my test:
   1.  open IE move to secound monitor
   2.  start you code inside a timer
   2.  navigate to "www.youtube.com" and play custom video in fullscreen mode

getforderground window will also not work correctly when you have the 2 applications in fullscreen mode!

example:

play movie using windows media player on monitor 2
play youtube video on monitor 2
 



 1. please test it with flash animations running inside browser
example:
   start youtube,
Avatar of dMa

ASKER

sorry i should read befor post ...

dMa:
hi guyz,
  sorry both of the solutions do not work.
 
 my test:
   1.  open IE move to secound monitor
   2.  start you code inside a timer
   2.  navigate to "www.youtube.com" and play custom video in fullscreen mode

getforderground window will also not work correctly when you have 2 applications in fullscreen mode!

example:

play movie using windows media player on monitor 2 (set to fullscreen)
play youtube video on monitor 1 (set to fullscreen)
 

 1. please test it with flash animations running inside browser
example:
   start youtube,
Did you try to test the code as per the post:
https://www.experts-exchange.com/questions/26704748/Detect-Application-running-in-Fullscreen-mode.html#34440239

Soon I shall check that with YouTube and get back to you.
Avatar of dMa

ASKER

sure i did
I tried to detect the YouTube video when in fullscreen mode via the Browser but the handle of that video process was not captured even when scanning the entire processes, all what is available was the Browser handle. But normal video (via applications: Media Player...etc) even if you downloaded that YouTube video and started it with FLV Player in fullscreen that will be detected, but not when it is in the Internet Browser.
Avatar of dMa

ASKER

this is exactly the problem i also have and the reason why i posted the question in here.
i'm pretty sure there must be a solution on it.
 
ASKER CERTIFIED SOLUTION
Avatar of jimyX
jimyX

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of dMa

ASKER

ok thx, at least it works on the main monitor. i will create the code for the secound monitors than.
>  "at least it works on the main monitor."
I just came to know how to deal with two monitors, I can try making that works with dual monitors if you like.
Avatar of dMa

ASKER

thx, np. i'm fine with that. thx