RegisterHotKeys and global keyboard hooks?

大兔子大兔子 提交于 2019-12-04 02:06:17

问题


What are RegisterHotKeys and global keyboard hooks, and how do they work?

I want to make a key to get focused on my application's Form (when it's minimized) and then focus on a textbox, so from what I've read I need to use the RegisterHotKeys function (that's a better solution for my needs), but i couldn't find how or where I can choose my own key (only one key - ESC) and then command it to focus on my form, and then on the textbox.


回答1:


Sample on how to use hot keys.

class myform : Form
{
    public myform()
    {
        RegisterHotKey(Handle, id, modifiers, mykey);
    }
    protected override void WndProc(ref Message m)
    {
        if (m.Msg == 0x312) // this is WM_HOTKEY
        {
            Show();
        }
        base.WndProc(ref m);
    }
}


来源:https://stackoverflow.com/questions/1563849/registerhotkeys-and-global-keyboard-hooks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!