开发者

Capture global keyboard with Mouse in QT

开发者 https://www.devze.com 2023-04-02 14:23 出处:网络
In my Qt app when my app is minimize or in tray, i want to monitor global keyboard and mouse that when user use CTRL+Right click keys,my apps visible stat开发者_StackOverflow社区us set to shown.

In my Qt app when my app is minimize or in tray, i want to monitor global keyboard and mouse that when user use CTRL+Right click keys, my apps visible stat开发者_StackOverflow社区us set to shown.

How can i implement it.


There are a lot of good reasons not to write this kind of app (such as the moment you have two programs who both get such an idea with global behavior, they will conflict with each other and do something random-seeming). In fact, globally trapping Ctrl+Right click and popping up an app sounds like a really bad idea, as many programs already have an important behavior defined for that.

Usually a better thing to is to instead let the user assign a hotkey through the mechanisms of the operating system:

http://lifehacker.com/343328/create-a-keyboard-shortcut-for-any-menu-action-in-any-program

Or suggest the user use some third party program that's already got it figured out and will let them move conflicting global hotkeys around to suit their tastes:

http://lifehacker.com/software/hack-attack/turn-any-action-into-a-keyboard-shortcut-316589.php

There are some programs out there that tackle providing services at the touch of the button that have pretty nice user interface metaphors, which might be able to convince you that they're better than hooking right-click. Quicksilver on Macs would be a good thing to look at for ideas.

If you are going to tackle it anyway, you'll probably have to do it in different ways for each platform. On Windows, you'd want a global WH_MOUSE hook:

http://msdn.microsoft.com/en-us/library/ms644960(VS.85).aspx


While I agree with HostileFork, this might help you: http://libqxt.bitbucket.org/doc/tip/qxtglobalshortcut.html

0

精彩评论

暂无评论...
验证码 换一张
取 消