ActivateKeyboardLayout() 개인적인 메소드

private ActivateKeyboardLayout ( HKL hkl, uint Flags ) : HKL
hkl HKL
Flags uint
리턴 HKL
예제 #1
0
        public static void CheckForChanges()
        {
            // Detect keyboard layout changes by querying the foreground window
            // for its layout, and apply the same layout to WinCompose itself.
            Window.Hwnd = NativeMethods.GetForegroundWindow();

            var tid           = NativeMethods.GetWindowThreadProcessId(Window.Hwnd, out var pid);
            var active_layout = NativeMethods.GetKeyboardLayout(tid);

            if (active_layout != m_current_layout)
            {
                m_transformed_hkl = m_current_layout = active_layout;

                Log.Debug("Active window layout tid:{0} handle:0x{1:X} lang:0x{2:X}",
                          tid, (uint)active_layout >> 16, (uint)active_layout & 0xffff);

                if (active_layout != (IntPtr)0)
                {
                    NativeMethods.ActivateKeyboardLayout(active_layout, 0);
                }

                tid           = NativeMethods.GetCurrentThreadId();
                active_layout = NativeMethods.GetKeyboardLayout(tid);

                Log.Debug("WinCompose process layout tid:{0} handle:0x{1:X} lang:0x{2:X}",
                          tid, (uint)active_layout >> 16, (uint)active_layout & 0xffff);

                // We need to rebuild the list of dead keys
                AnalyzeLayout();
            }
        }
예제 #2
0
파일: Composer.cs 프로젝트: wget/wincompose
        private static void CheckKeyboardLayout()
        {
            // Detect keyboard layout changes by querying the foreground window,
            // and apply the same layout to WinCompose itself.
            IntPtr hwnd = NativeMethods.GetForegroundWindow();
            uint   pid, tid = NativeMethods.GetWindowThreadProcessId(hwnd, out pid);
            IntPtr active_layout = NativeMethods.GetKeyboardLayout(tid);

            m_window_is_gtk           = false;
            m_window_is_office        = false;
            m_window_is_other_desktop = false;

            const int     len = 256;
            StringBuilder buf = new StringBuilder(len);

            if (NativeMethods.GetClassName(hwnd, buf, len) > 0)
            {
                string wclass = buf.ToString();

                if (wclass == "gdkWindowToplevel" || wclass == "xchatWindowToplevel" ||
                    wclass == "hexchatWindowToplevel")
                {
                    m_window_is_gtk = true;
                }

                if (wclass == "rctrl_renwnd32" || wclass == "OpusApp")
                {
                    m_window_is_office = true;
                }

                if (Regex.Match(wclass, "^(SynergyDesk|cygwin/x.*)$").Success)
                {
                    m_window_is_other_desktop = true;
                }
            }

            if (active_layout != m_current_layout)
            {
                m_current_layout = active_layout;

                Log.Debug("Active window layout tid:{0} handle:0x{1:X} lang:0x{2:X}",
                          tid, (uint)active_layout >> 16, (uint)active_layout & 0xffff);

                if (active_layout != (IntPtr)0)
                {
                    NativeMethods.ActivateKeyboardLayout(active_layout, 0);
                }

                tid           = NativeMethods.GetCurrentThreadId();
                active_layout = NativeMethods.GetKeyboardLayout(tid);

                Log.Debug("WinCompose process layout tid:{0} handle:0x{1:X} lang:0x{2:X}",
                          tid, (uint)active_layout >> 16, (uint)active_layout & 0xffff);

                // We need to rebuild the list of dead keys
                AnalyzeKeyboardLayout();
            }
        }
예제 #3
0
        public static void CheckForChanges()
        {
            // Detect keyboard layout changes by querying the foreground window,
            // and apply the same layout to WinCompose itself.
            IntPtr hwnd = NativeMethods.GetForegroundWindow();
            uint   pid, tid = NativeMethods.GetWindowThreadProcessId(hwnd, out pid);
            IntPtr active_layout = NativeMethods.GetKeyboardLayout(tid);

            if (hwnd != m_current_hwnd)
            {
                Window.IsGtk          = false;
                Window.IsNPPOrLO      = false;
                Window.IsOffice       = false;
                Window.IsOtherDesktop = false;

                const int     len = 256;
                StringBuilder buf = new StringBuilder(len);
                if (NativeMethods.GetClassName(hwnd, buf, len) > 0)
                {
                    string wclass = buf.ToString();
                    Log.Debug($"Window {hwnd} ({wclass}) got focus");

                    if (wclass == "gdkWindowToplevel" || wclass == "xchatWindowToplevel" ||
                        wclass == "hexchatWindowToplevel")
                    {
                        Window.IsGtk = true;
                    }

                    /* Notepad++ or LibreOffice */
                    if (wclass == "Notepad++" || wclass == "SALFRAME")
                    {
                        Window.IsNPPOrLO = true;
                    }

                    if (wclass == "rctrl_renwnd32" || wclass == "OpusApp")
                    {
                        Window.IsOffice = true;
                    }

                    if (Regex.Match(wclass, "^(SynergyDesk|cygwin/x.*)$").Success)
                    {
                        Window.IsOtherDesktop = true;
                    }
                }

                m_current_hwnd = hwnd;
            }

            if (active_layout != m_current_layout)
            {
                m_current_layout = active_layout;

                Log.Debug("Active window layout tid:{0} handle:0x{1:X} lang:0x{2:X}",
                          tid, (uint)active_layout >> 16, (uint)active_layout & 0xffff);

                if (active_layout != (IntPtr)0)
                {
                    NativeMethods.ActivateKeyboardLayout(active_layout, 0);
                }

                tid           = NativeMethods.GetCurrentThreadId();
                active_layout = NativeMethods.GetKeyboardLayout(tid);

                Log.Debug("WinCompose process layout tid:{0} handle:0x{1:X} lang:0x{2:X}",
                          tid, (uint)active_layout >> 16, (uint)active_layout & 0xffff);

                // We need to rebuild the list of dead keys
                AnalyzeLayout();
            }
        }