Example #1
0
        public static IntPtr GetMainWindow(uint aThreadId, string aClassName = null)
        {
            IntPtr win = IntPtr.Zero;

            // Window.EnumThreadWindows(aThreadId, (W, _) => {
            //     if (Window.IsWindowVisible(W) && (win == null || (aClassName != null && Window.GetClassName(W) == aClassName)))
            //         win = W;
            //     return true;
            // }, IntPtr.Zero);

            Window.EnumThreadWindows(aThreadId, (hWnd, lParam) =>
            {
                var classText = new StringBuilder(UnityWindowClassName.Length + 1);

                Window.GetClassName(hWnd, classText, classText.Capacity);

                if (classText.ToString() == UnityWindowClassName)
                {
                    win = hWnd;
                    return(false);
                }
                return(true);
            }, IntPtr.Zero);

            UnityEngine.Debug.Log(win == IntPtr.Zero);

            return(win);
        }
Example #2
0
        public static IntPtr GetMainWindow(uint aThreadId, string aClassName = null)
        {
            IntPtr win = IntPtr.Zero;

            Window.EnumThreadWindows(aThreadId, (W, _) => {
                if (Window.IsWindowVisible(W) && ((aClassName != null && Window.GetClassName(W) == aClassName)))
                {
                    win = W;
                }
                return(true);
            }, IntPtr.Zero);
            return(win);
        }
Example #3
0
 private static bool EnumCallback(IntPtr W, IntPtr _)
 {
     if (Window.IsWindowVisible(W) && (mainWindow == IntPtr.Zero || (m_ClassName != null && Window.GetClassName(W) == m_ClassName)))
     {
         mainWindow = W;
     }
     return(true);
 }