简体   繁体   English

RegisterHotKey混淆

[英]RegisterHotKey confusion

I want to set a "global" hotkey for my program. 我想为我的程序设置一个“全局”热键。 More specifically, I want to set a key sequence (CTRL + q, CTRL + t, etc) that will do something (close program, start timer, etc) without the need for my program to be focused. 更具体地说,我想设置一个键序列(CTRL + q,CTRL + t等),该键序列将执行某些操作(关闭程序,启动计时器等),而无需关注我的程序。 I know how to set a shortcut using QShortcut, but obviously it only works when the program is being focused. 我知道如何使用QShortcut设置快捷方式,但是显然只有在程序处于焦点状态时它才有效。

I've read that it's possible using RegisterHotKey, but I don't understand how it works. 我读过可以使用RegisterHotKey,但是我不明白它是如何工作的。 For one reason or another, it's a confusing concept for me to grasp because I haven't found anything that explains it very well. 出于一个或另一个原因,这对我来说是一个令人困惑的概念,因为我还没有找到任何可以很好解释的概念。 Do I need a while loop in order to work? 我需要一个while循环才能工作吗? Can someone explain how to do this or maybe give a good example I could mess around with? 有人可以解释如何执行此操作,或者可以举一个我可以弄乱的好例子吗?

I put together a pretty thorough answer a while back. 不久前,我给出了一个相当彻底的答案。 This should get you up and running pretty quickly. 这将使您快速启动并运行。

Clipboard Shortcut/Hotkey binding with Qt outside of application 在应用程序外部使用Qt的剪贴板快捷方式/热键绑定

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM