public static bool SetCurrent(SEBDesktopController desktop)
 {
     if (desktop == null || !desktop.IsOpen)
     {
         return(false);
     }
     return(SEBDesktopController.SetThreadDesktop(desktop.DesktopHandle));
 }
 public bool Show()
 {
     this.CheckDisposed();
     if (this.m_desktop == IntPtr.Zero)
     {
         return(false);
     }
     return(SEBDesktopController.SwitchDesktop(this.m_desktop));
 }
        public static SEBDesktopController CreateDesktop(string name)
        {
            SEBDesktopController desktopController = new SEBDesktopController();

            if (!desktopController.Create(name))
            {
                return((SEBDesktopController)null);
            }
            return(desktopController);
        }
Beispiel #4
0
        /// <summary>
        /// Gets the name of a given desktop.
        /// </summary>
        /// <param name="desktop">Desktop object whos name is to be found.</param>
        /// <returns>If successful, the desktop name, otherwise, null.</returns>
        public static string GetDesktopName(SEBDesktopController desktop)
        {
            // get name.
            if (desktop.IsOpen)
            {
                return(null);
            }

            return(GetDesktopName(desktop.DesktopHandle));
        }
        public static SEBDesktopController OpenInputDesktop()
        {
            SEBDesktopController desktopController = new SEBDesktopController();

            if (!desktopController.OpenInput())
            {
                return((SEBDesktopController)null);
            }
            return(desktopController);
        }
 public static bool Show(string name)
 {
     using (SEBDesktopController desktopController = new SEBDesktopController())
     {
         if (!desktopController.Open(name))
         {
             return(false);
         }
         return(desktopController.Show());
     }
 }
        public object Clone()
        {
            this.CheckDisposed();
            SEBDesktopController desktopController = new SEBDesktopController();

            if (this.IsOpen)
            {
                desktopController.Open(this.m_desktopName);
            }
            return((object)desktopController);
        }
Beispiel #8
0
        /// <summary>
        /// Enumerates the windows on a desktop.
        /// </summary>
        /// <param name="windows">Array of Desktop.Window objects to recieve windows.</param>
        /// <returns>A window colleciton if successful, otherwise null.</returns>
        public static WindowCollection GetWindows(string desktop)
        {
            if (!SEBDesktopController.Exists(desktop))
            {
                return(null);
            }

            // get windows.
            SEBDesktopController d = SEBDesktopController.OpenDesktop(desktop);

            return(d.GetWindows());
        }
Beispiel #9
0
        /// <summary>
        /// Creates a new process on the specified desktop.
        /// </summary>
        /// <param name="path">Path to application.</param>
        /// <param name="desktop">Desktop name.</param>
        /// <returns>A Process object for the newly created process, otherwise, null.</returns>
        public static Process CreateProcess(string path, string desktop)
        {
            if (!SEBDesktopController.Exists(desktop))
            {
                return(null);
            }

            // create the process.
            SEBDesktopController d = SEBDesktopController.OpenDesktop(desktop);

            return(d.CreateProcess(path));
        }
Beispiel #10
0
        /// <summary>
        /// Opens the current input desktop.
        /// </summary>
        /// <returns>If successful, a Desktop object, otherwise, null.</returns>
        public static SEBDesktopController OpenInputDesktop()
        {
            // open the desktop.
            SEBDesktopController desktop = new SEBDesktopController();
            bool result = desktop.OpenInput();

            // somethng went wrong.
            if (!result)
            {
                return(null);
            }

            return(desktop);
        }
Beispiel #11
0
        /// <summary>
        /// Creates a new desktop.
        /// </summary>
        /// <param name="name">The name of the desktop to create.  Names are case sensitive.</param>
        /// <returns>If successful, a Desktop object, otherwise, null.</returns>
        public static SEBDesktopController CreateDesktop(string name)
        {
            // open the desktop.
            SEBDesktopController desktop = new SEBDesktopController();
            bool result = desktop.Create(name);

            // somethng went wrong.
            if (!result)
            {
                return(null);
            }

            return(desktop);
        }
Beispiel #12
0
        /// <summary>
        /// Creates a new Desktop object with the same desktop open.
        /// </summary>
        /// <returns>Cloned desktop object.</returns>
        public object Clone()
        {
            // make sure object isnt disposed.
            CheckDisposed();

            SEBDesktopController desktop = new SEBDesktopController();

            // if a desktop is open, make the clone open it.
            if (IsOpen)
            {
                desktop.Open(m_desktopName);
            }

            return(desktop);
        }
 public bool Create(string name)
 {
     this.CheckDisposed();
     if (this.m_desktop != IntPtr.Zero && !this.Close())
     {
         return(false);
     }
     if (SEBDesktopController.Exists(name))
     {
         return(this.Open(name));
     }
     this.m_desktop     = SEBDesktopController.CreateDesktop(name, IntPtr.Zero, IntPtr.Zero, 0, 511U, IntPtr.Zero);
     this.m_desktopName = name;
     return(!(this.m_desktop == IntPtr.Zero));
 }
 public bool OpenInput()
 {
     this.CheckDisposed();
     if (this.m_desktop != IntPtr.Zero && !this.Close())
     {
         return(false);
     }
     this.m_desktop = SEBDesktopController.OpenInputDesktop(0U, true, 511U);
     if (this.m_desktop == IntPtr.Zero)
     {
         return(false);
     }
     this.m_desktopName = SEBDesktopController.GetDesktopName(this.m_desktop);
     return(true);
 }
 public bool Open(string name)
 {
     this.CheckDisposed();
     if (this.m_desktop != IntPtr.Zero && !this.Close())
     {
         return(false);
     }
     this.m_desktop = SEBDesktopController.OpenDesktop(name, 0U, true, 511U);
     if (this.m_desktop == IntPtr.Zero)
     {
         return(false);
     }
     this.m_desktopName = name;
     return(true);
 }
 public Process CreateProcess(string path)
 {
     this.CheckDisposed();
     if (!this.IsOpen)
     {
         return((Process)null);
     }
     SEBDesktopController.STARTUPINFO lpStartupInfo = new SEBDesktopController.STARTUPINFO();
     lpStartupInfo.cb        = Marshal.SizeOf((object)lpStartupInfo);
     lpStartupInfo.lpDesktop = this.m_desktopName;
     SEBDesktopController.PROCESS_INFORMATION lpProcessInformation = new SEBDesktopController.PROCESS_INFORMATION();
     if (!SEBDesktopController.CreateProcess((string)null, path, IntPtr.Zero, IntPtr.Zero, true, 32, IntPtr.Zero, (string)null, ref lpStartupInfo, ref lpProcessInformation))
     {
         return((Process)null);
     }
     return(Process.GetProcessById(lpProcessInformation.dwProcessId));
 }
        public bool Close()
        {
            this.CheckDisposed();
            if (!(this.m_desktop != IntPtr.Zero))
            {
                return(true);
            }
            int num = SEBDesktopController.CloseDesktop(this.m_desktop) ? 1 : 0;

            if (num == 0)
            {
                return(num != 0);
            }
            this.m_desktop     = IntPtr.Zero;
            this.m_desktopName = string.Empty;
            return(num != 0);
        }
 public static bool Exists(string name, bool caseInsensitive)
 {
     foreach (string desktop in SEBDesktopController.GetDesktops())
     {
         if (caseInsensitive)
         {
             if (desktop.ToLower() == name.ToLower())
             {
                 return(true);
             }
         }
         else if (desktop == name)
         {
             return(true);
         }
     }
     return(false);
 }
        public static Process[] GetInputProcessesWithGI()
        {
            Process[] processes = Process.GetProcesses();
            ArrayList arrayList = new ArrayList();

            SEBDesktopController.GetDesktopName(SEBDesktopController.Input.DesktopHandle);
            foreach (Process process in processes)
            {
                if (process.MainWindowTitle.Length > 0)
                {
                    arrayList.Add((object)process);
                }
            }
            Process[] processArray = new Process[arrayList.Count];
            for (int index = 0; index < processArray.Length; ++index)
            {
                processArray[index] = (Process)arrayList[index];
            }
            return(processArray);
        }
Beispiel #20
0
        /// <summary>
        /// Switches to the specified desktop.
        /// </summary>
        /// <param name="name">Name of desktop to switch input to.</param>
        /// <returns>True if desktops were successfully switched.</returns>
        public static bool Show(string name)
        {
            // attmempt to open desktop.
            bool result = false;

            using (SEBDesktopController d = new SEBDesktopController())
            {
                result = d.Open(name);

                // something went wrong.
                if (!result)
                {
                    return(false);
                }

                // attempt to switch desktops.
                result = d.Show();
            }

            return(result);
        }
        public static string GetDesktopName(IntPtr desktopHandle)
        {
            if (desktopHandle == IntPtr.Zero)
            {
                return((string)null);
            }
            int    lpnLengthNeeded = 0;
            string empty           = string.Empty;

            SEBDesktopController.GetUserObjectInformation(desktopHandle, 2, IntPtr.Zero, 0, ref lpnLengthNeeded);
            IntPtr num1       = Marshal.AllocHGlobal(lpnLengthNeeded);
            int    num2       = SEBDesktopController.GetUserObjectInformation(desktopHandle, 2, num1, lpnLengthNeeded, ref lpnLengthNeeded) ? 1 : 0;
            string stringAnsi = Marshal.PtrToStringAnsi(num1);

            Marshal.FreeHGlobal(num1);
            if (num2 == 0)
            {
                return((string)null);
            }
            return(stringAnsi);
        }
        public static string[] GetDesktops()
        {
            IntPtr processWindowStation = SEBDesktopController.GetProcessWindowStation();

            if (processWindowStation == IntPtr.Zero)
            {
                return(new string[0]);
            }
            string[] strArray;
            lock (SEBDesktopController.m_sc = new StringCollection())
            {
                if (!SEBDesktopController.EnumDesktops(processWindowStation, new SEBDesktopController.EnumDesktopProc(SEBDesktopController.DesktopProc), IntPtr.Zero))
                {
                    return(new string[0]);
                }
                strArray = new string[SEBDesktopController.m_sc.Count];
                for (int index = 0; index < strArray.Length; ++index)
                {
                    strArray[index] = SEBDesktopController.m_sc[index];
                }
            }
            return(strArray);
        }
        public static Process[] GetInputProcesses()
        {
            Process[] processes   = Process.GetProcesses();
            ArrayList arrayList   = new ArrayList();
            string    desktopName = SEBDesktopController.GetDesktopName(SEBDesktopController.Input.DesktopHandle);

            foreach (Process process in processes)
            {
                foreach (ProcessThread thread in (ReadOnlyCollectionBase)process.Threads)
                {
                    if (SEBDesktopController.GetDesktopName(SEBDesktopController.GetThreadDesktop(thread.Id)) == desktopName)
                    {
                        arrayList.Add((object)process);
                        break;
                    }
                }
            }
            Process[] processArray = new Process[arrayList.Count];
            for (int index = 0; index < processArray.Length; ++index)
            {
                processArray[index] = (Process)arrayList[index];
            }
            return(processArray);
        }
        public SEBDesktopController.WindowCollection GetWindows()
        {
            this.CheckDisposed();
            if (!this.IsOpen)
            {
                return((SEBDesktopController.WindowCollection)null);
            }
            this.m_windows.Clear();
            SEBDesktopController.WindowCollection windowCollection1 = new SEBDesktopController.WindowCollection();
            if (!SEBDesktopController.EnumDesktopWindows(this.m_desktop, new SEBDesktopController.EnumDesktopWindowsProc(this.DesktopWindowsProc), IntPtr.Zero))
            {
                return((SEBDesktopController.WindowCollection)null);
            }
            SEBDesktopController.WindowCollection windowCollection2 = new SEBDesktopController.WindowCollection();
            IntPtr num = Marshal.AllocHGlobal(100);

            foreach (IntPtr window in this.m_windows)
            {
                SEBDesktopController.GetWindowText(window, num, 100);
                windowCollection2.Add(new SEBDesktopController.Window(window, Marshal.PtrToStringAnsi(num)));
            }
            Marshal.FreeHGlobal(num);
            return(windowCollection2);
        }
Beispiel #25
0
 /// <summary>
 /// Checks if the specified desktop exists (using a case sensitive search).
 /// </summary>
 /// <param name="name">The name of the desktop.</param>
 /// <returns>True if the desktop exists, otherwise false.</returns>
 public static bool Exists(string name)
 {
     return(SEBDesktopController.Exists(name, false));
 }
Beispiel #26
0
        /// <summary>
        /// Opens the current input desktop.
        /// </summary>
        /// <returns>If successful, a Desktop object, otherwise, null.</returns>
        public static SEBDesktopController OpenInputDesktop()
        {
            // open the desktop.
            SEBDesktopController desktop = new SEBDesktopController();
            bool result = desktop.OpenInput();

            // somethng went wrong.
            if (!result) return null;

            return desktop;
        }
Beispiel #27
0
 /// <summary>
 /// Opens the default desktop.
 /// </summary>
 /// <returns>If successful, a Desktop object, otherwise, null.</returns>
 public static SEBDesktopController OpenDefaultDesktop()
 {
     // opens the default desktop.
     return(SEBDesktopController.OpenDesktop("Default"));
 }
 public static SEBDesktopController GetCurrent()
 {
     return(new SEBDesktopController(SEBDesktopController.GetThreadDesktop(AppDomain.GetCurrentThreadId())));
 }
Beispiel #29
0
        /// <summary>
        /// Switches to the specified desktop.
        /// </summary>
        /// <param name="name">Name of desktop to switch input to.</param>
        /// <returns>True if desktops were successfully switched.</returns>
        public static bool Show(string name)
        {
            // attmempt to open desktop.
            bool result = false;

            using (SEBDesktopController d = new SEBDesktopController())
            {
                result = d.Open(name);

                // something went wrong.
                if (!result) return false;

                // attempt to switch desktops.
                result = d.Show();
            }

            return result;
        }
        public static bool DisableTaskSwitching()
        {
            IntPtr pvParam = new IntPtr(0);

            return(SEBDesktopController.SystemParametersInfo(SEBDesktopController.SPI_SETSCREENSAVERRUNNING, SEBDesktopController.TRUE, pvParam, SEBDesktopController.NULL));
        }
Beispiel #31
0
        /// <summary>
        /// Sets the desktop of the calling thread.
        /// NOTE: Function will fail if thread has hooks or windows in the current desktop.
        /// </summary>
        /// <param name="desktop">Desktop to put the thread in.</param>
        /// <returns>True if the threads desktop was successfully changed.</returns>
        public static bool SetCurrent(SEBDesktopController desktop)
        {
            // set threads desktop.
            if (desktop == null || !desktop.IsOpen) return false;

            return SetThreadDesktop(desktop.DesktopHandle);
        }
Beispiel #32
0
        /// <summary>
        /// Opens a desktop.
        /// </summary>
        /// <param name="name">The name of the desktop to open.</param>
        /// <returns>If successful, a Desktop object, otherwise, null.</returns>
        public static SEBDesktopController OpenDesktop(string name)
        {
            // open the desktop.
            SEBDesktopController desktop = new SEBDesktopController();
            bool result = desktop.Open(name);

            // something went wrong
            if (!result) return null;

            return desktop;
        }
Beispiel #33
0
        /// <summary>
        /// Creates a new Desktop object with the same desktop open.
        /// </summary>
        /// <returns>Cloned desktop object.</returns>
        public object Clone()
        {
            // make sure object isnt disposed.
            CheckDisposed();

            SEBDesktopController desktop = new SEBDesktopController();

            // if a desktop is open, make the clone open it.
            if (IsOpen) desktop.Open(m_desktopName);

            return desktop;
        }
Beispiel #34
0
        /// <summary>
        /// Gets the name of a given desktop.
        /// </summary>
        /// <param name="desktop">Desktop object whos name is to be found.</param>
        /// <returns>If successful, the desktop name, otherwise, null.</returns>
        public static string GetDesktopName(SEBDesktopController desktop)
        {
            // get name.
            if (desktop.IsOpen) return null;

            return GetDesktopName(desktop.DesktopHandle);
        }
 public static SEBDesktopController OpenDefaultDesktop()
 {
     return(SEBDesktopController.OpenDesktop("Default"));
 }