示例#1
0
        private void *TryGetConEmuHwnd()
        {
            if (!IsHandleCreated)            // Without this check, getting the Handle would cause the control to be loaded, and AutoStartInfo be executed right in the .ctor, because the first call into this func goes in the .ctor
            {
                return(null);
            }
            void *hwndConEmu = null;

            WinApi.EnumWindowsProc callback = (hwnd, param) =>
            {
                *((void **)param) = hwnd;
                return(0);
            };
            WinApi.EnumChildWindows((void *)Handle, (void *)Marshal.GetFunctionPointerForDelegate(callback), (IntPtr)(&hwndConEmu));
            GC.KeepAlive(callback);
            return(hwndConEmu);
        }
示例#2
0
        /// <summary> Find all windows that match the given filter </summary>
        /// <param name="filter"> A delegate that returns true for windows
        ///    that should be returned and false for windows that should
        ///    not be returned </param>
        private static IEnumerable <IntPtr> FindWindows(WinApi.EnumWindowsProc filter)
        {
            IntPtr        found   = IntPtr.Zero;
            List <IntPtr> windows = new List <IntPtr>();


            WinApi.EnumWindows(delegate(IntPtr wnd, IntPtr param)
            {
                if (filter(wnd, param))
                {
                    // only add the windows that pass the filter
                    windows.Add(wnd);
                }

                // but return true here so that we iterate all windows
                return(true);
            }, IntPtr.Zero);

            return(windows);
        }
示例#3
0
 private static void GetOpeningWindows()
 {
     openingWindows = new List <SystemWindow>();
     WinApi.EnumWindowsProc callback = EnumWindows;
     WinApi.EnumWindows(callback, 0);
 }