unsafe HRESULT IOleControlSite.TranslateAccelerator(User32.MSG* pMsg, KEYMODIFIERS grfModifiers)
            {
                if (pMsg is null)
                {
                    return HRESULT.E_POINTER;
                }

                Debug.Assert(!_host.GetAxState(s_siteProcessedInputKey), "Re-entering IOleControlSite.TranslateAccelerator!!!");
                _host.SetAxState(s_siteProcessedInputKey, true);

                Message msg = *pMsg;
                try
                {
                    bool f = _host.PreProcessMessage(ref msg);
                    return f ? HRESULT.S_OK : HRESULT.S_FALSE;
                }
                finally
                {
                    _host.SetAxState(s_siteProcessedInputKey, false);
                }
            }
Exemple #2
0
        // SRC: https://www.fluxbytes.com/csharp/how-to-register-a-global-hotkey-for-your-application-in-c/
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);

            if (m.Msg == 0x0312)
            {
                Keys         key      = (Keys)(((int)m.LParam >> 16) & 0xFFFF);     // The key of the hotkey that was pressed.
                KEYMODIFIERS modifier = (KEYMODIFIERS)((int)m.LParam & 0xFFFF);     // The modifier of the hotkey that was pressed.
                int          id       = m.WParam.ToInt32();                         // The id of the hotkey that was pressed.

                string file = "";
                foreach (int keyset in keysets.Keys)
                {
                    if (KeyConfig.GetOnlyKey(keyset) == (int)key)
                    {
                        file = keysets[keyset];
                    }
                }
                requests.PlayRequest(file);
            }
        }
        unsafe HRESULT IOleControlSite.TranslateAccelerator(User32.MSG *pMsg, KEYMODIFIERS grfModifiers)
        {
            if (pMsg == null)
            {
                return(HRESULT.E_POINTER);
            }

            Debug.Assert(!Host.GetAXHostState(WebBrowserHelper.siteProcessedInputKey), "Re-entering IOleControlSite.TranslateAccelerator!!!");
            Host.SetAXHostState(WebBrowserHelper.siteProcessedInputKey, true);

            Message msg = *pMsg;

            try
            {
                bool f = ((Control)Host).PreProcessControlMessage(ref msg) == PreProcessControlState.MessageProcessed;
                return(f ? HRESULT.S_OK : HRESULT.S_FALSE);
            }
            finally
            {
                Host.SetAXHostState(WebBrowserHelper.siteProcessedInputKey, false);
            }
        }