Esempio n. 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);
        }
Esempio n. 2
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);
     return win;
 }
Esempio n. 3
0
        public static void InstallHook()
        {
            threadId = WinAPI.GetCurrentThreadId();
            if (threadId > 0)
            {
                Window.EnumThreadWindows(threadId, EnumCallback, IntPtr.Zero);
            }

            var hModule = WinAPI.GetModuleHandle(null);

            m_Hook = WinAPI.SetWindowsHookEx(HookType.WH_GETMESSAGE, Callback, hModule, threadId);
            // Allow dragging of files onto the main window. generates the WM_DROPFILES message
            WinAPI.DragAcceptFiles(mainWindow, true);
        }
Esempio n. 4
0
        public static void InstallHook(IntPtr m)
        {
            mainWindow  = m;
            m_ClassName = UnityEngine.Application.productName;
            threadId    = WinAPI.GetCurrentThreadId();
            if (threadId > 0)
            {
                Window.EnumThreadWindows(threadId, EnumCallback, IntPtr.Zero);
            }


            //  nextClipboardViewer = (IntPtr)WinAPI.SetClipboardViewer(mainWindow);

            var hModule = WinAPI.GetModuleHandle(null);

            m_Hook = WinAPI.SetWindowsHookEx(HookType.WH_GETMESSAGE, Callback, hModule, threadId);
            //  m_Hook = WinAPI.SetWindowsHookEx(HookType.WH_GETMESSAGE, Callback, hModule, threadId);
            // Allow dragging of files onto the main window. generates the WM_DROPFILES message
            WinAPI.DragAcceptFiles(mainWindow, true);
        }