Ejemplo n.º 1
0
 public static bool AppVisible(Rectangle windowBounds)
 {
     foreach (Screen screen in Screen.AllScreens)
     {
         if (screen.Bounds.Contains(windowBounds))
         {
             if (windowBounds.Equals(screen.Bounds))
             {
                 // Fullscreen, it's "visible" when AppVisibilityOnMonitor says yes
                 // Although it might be the other App, this is not "very" important
                 RECT   rect    = new RECT(screen.Bounds);
                 IntPtr monitor = User32.MonitorFromRect(ref rect, User32.MONITOR_DEFAULTTONULL);
                 if (monitor != IntPtr.Zero)
                 {
                     if (appVisibility != null)
                     {
                         MONITOR_APP_VISIBILITY monitorAppVisibility = appVisibility.GetAppVisibilityOnMonitor(monitor);
                         //LOG.DebugFormat("App {0} visible: {1} on {2}", Text, monitorAppVisibility, screen.Bounds);
                         if (monitorAppVisibility == MONITOR_APP_VISIBILITY.MAV_APP_VISIBLE)
                         {
                             return(true);
                         }
                     }
                 }
             }
             else
             {
                 // Is only partly on the screen, when this happens the app is allways visible!
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
        public long AppVisibilityOnMonitorChanged([In] IntPtr hMonitor, [In] MONITOR_APP_VISIBILITY previousMode, [In] MONITOR_APP_VISIBILITY currentMode)
        {
            AppVisibilityEventArgs args = new AppVisibilityEventArgs
            {
                MonitorHandle = hMonitor,
                PreviousMode  = previousMode,
                CurrentMode   = currentMode
            };

            AppVisibilityChanged?.Invoke(this, args);
            return(0);
        }
Ejemplo n.º 3
0
        protected override void ProcessRecord()
        {
            bool startOrAppsVisible = false;

            av.IsLauncherVisible(out startOrAppsVisible);

            if (!startOrAppsVisible)
            {
                Win32.EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, new EnumMonitorsDelegate(
                                              (IntPtr hMonitor, IntPtr hdcMonitor, ref RectStruct lprcMonitor, IntPtr dwData) =>
                {
                    MONITOR_APP_VISIBILITY mav = MONITOR_APP_VISIBILITY.MAV_UNKNOWN;
                    av.GetAppVisibilityOnMonitor(hMonitor, out mav);
                    if (mav == MONITOR_APP_VISIBILITY.MAV_APP_VISIBLE)
                    {
                        startOrAppsVisible = true;
                    }
                    return(!startOrAppsVisible);
                }), IntPtr.Zero);
            }

            WriteObject(startOrAppsVisible);
            base.ProcessRecord();
        }
Ejemplo n.º 4
0
 public HRESULT AppVisibilityOnMonitorChanged(HMONITOR hMonitor, MONITOR_APP_VISIBILITY previousMode, MONITOR_APP_VISIBILITY currentMode)
 {
     return(((delegate * unmanaged <IAppVisibilityEvents *, HMONITOR, MONITOR_APP_VISIBILITY, MONITOR_APP_VISIBILITY, int>)(lpVtbl[3]))((IAppVisibilityEvents *)Unsafe.AsPointer(ref this), hMonitor, previousMode, currentMode));
 }
Ejemplo n.º 5
0
 // Simple helper function to turn a MONITOR_APP_VISIBILITY enumeration into a string
 private static string GetMonitorAppVisibilityString(MONITOR_APP_VISIBILITY monitorAppVisibility) => monitorAppVisibility switch
 {