RegisterHotKey 详解

RegisterHotKey 详解TheRegisterH widehotkey BOOLRegister HWNDhWnd 接受热键通知的窗口句柄 intid 热键标示 UINTfsModifi 组合键标示

The
RegisterHotKey function defines a system-wide hot key.

BOOL RegisterHotKey(  HWND hWnd,//接受热键通知的窗口句柄 
 int id,// 热键标示 
 UINT fsModifiers, // 组合键标示 
 UINT vk // 虚拟键码); 

Parameters

hWnd

Handle to the window that will receive WM_HOTKEY messages generated by the hot key. If this parameter is NULL, WM_HOTKEY messages are posted to the message queue of the calling thread and must be processed in the message loop.

如果为空,放到调用线程消息队列中,用消息循环处理


id

Specifies the identifier of the hot key. No other hot key in the calling thread should have the same identifier. An application must specify a value in the range 0x0000 through 0xBFFF. A shared dynamic-link library (DLL) must specify a value in the range 0xC000 through 0xFFFF (the range returned by the

GlobalAddAtom function). To avoid conflicts with hot-key identifiers defined by other shared DLLs, a DLL should use the
GlobalAddAtom function to obtain the hot-key identifier.
同一个线程中不能有相同的标示,(0x0000-0xBFFF)
共享库的范围(0xC000-0xFFFF), 要用
GlobalAddAtom返回标示,避免冲突。

fsModifiers

Specifies keys that must be pressed in combination with the key specified by the
nVirtKey parameter in order to generate the WM_HOTKEY message. The
fsModifiers parameter can be a combination of the following values. 组合键码

Value Meaning
MOD_ALT Either alt key must be held down.
MOD_CONTROL Either ctrl key must be held down.
MOD_SHIFT Either shift key must be held down.
MOD_WIN Either WINDOWS key was held down. These keys are labeled with the Microsoft Windows logo.



vk

Specifies the virtual-key code of the hot key.

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, callGetLastError.

Remarks

RegisterHotKey fails if the keystrokes specified for the hot key have already been registered by another hot key.
        如果组合键被注册了,就会失败

If the window identified by the hWnd parameter already registered a hot key with the same identifier as that specified by the id parameter, the new values for the fsModifiers and vk parameters replace the previously specified values for these parameters. 如果这个线程的这个窗体已经注册了某热键,热键标示会代替那个热键

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/210314.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月19日 上午7:51
下一篇 2026年3月19日 上午7:51


相关推荐

  • DevOps 与 CICD 详解

    DevOps 与 CICD 详解DevOpsDevOps是Development(开发)和Operations(运维)的组合,是一种方法论,是一组过程、方法与系统的统称,用于促进应用开发、应用运维和质量保障(QA)部门之间的沟通、协作与整合,以期打破传统开发和运营之间的壁垒和鸿沟;DevOps是一种重视软件开发人员(Dev)和IT运维技术人员(Ops)之间沟通合作的文化、运动或惯例,通过自动化软件交付和架构变更的流程…

    2022年6月6日
    57
  • C语言小游戏,游戏设计,500+行代码

    C语言小游戏,游戏设计,500+行代码自学c语言有2个月了,自己给自己做了个毕业设计。希望大家可以参考学习,也欢迎有大佬提出自己的见解。(注:本程序为纯C语言)c语言毕业设计…

    2022年5月12日
    46
  • 微信video 视频

    <videowidth=”320″height=”240″controls><sourcesrc=”movie.mp4″type=”video/mp4″></video>这是很正常的video写法,我们查看微信是什么样式  这样种video控件样式并不是我们想要的。所有我们需要自己来写视频封面的样式。…

    2022年4月4日
    58
  • 字节跳动AI神器Coze正式开源了,手把手教你本地部署

    字节跳动AI神器Coze正式开源了,手把手教你本地部署

    2026年3月13日
    3
  • ROS中启动超声波雷达节点「建议收藏」

    ROS中启动超声波雷达节点「建议收藏」超声波雷达型号为KS136,KS136使用I2C接口与主机通信,自动响应主机的I2C控制指令。指令为8位数据,指令发送流程如下,先接收I2C控制指令,寄存器2接收控制指令,选择超声波探头号(因为主控板接12个收发一体式防水探头,每个探头独立工作,每个探头占据8位地址,分别对应8种不同的数据收发方式),流程图如下所示:超声波与主控之间通过串口通信代码如下: r…

    2025年9月7日
    8
  • jedispool 连接池_redis-cli连接redis数据库

    jedispool 连接池_redis-cli连接redis数据库一、连接前的准备1.确保windows能够ping通linux,linux能够ping通windows。2.开放CentOS7的端口6379。firewall-cmd–add-port=6379/tcp–permanent3.注释掉redis.conf文件中的bind。#bind127.0.0.14….

    2025年9月12日
    10

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号