如何在Win32 C++中的后台运行程序时检测KeyPress [英] How to detect KeyPress while program is running in background in Win32 C++

查看:33
本文介绍了如何在Win32 C++中的后台运行程序时检测KeyPress的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序,每当我最小化它时,它就会进入系统托盘.

I got a program that whenever I minimize it, it goes to the system tray.

我想知道的是:a) 当我的程序在系统托盘中时,我怎么能检测到按键按下.b) 我怎么知道他们在键盘上按了什么,特别是功能按钮.

i want to know is this: a) how could i detect a key press while my program is in the system tray. b) how could I know what they press in the keyboard specifically the function buttons.

推荐答案

您需要使用 SetWindowsHookEx().查看 WH_KEYBOARD 和 WH_KEYBOARD_LL 钩子.

You need to set up a keyboard hook using SetWindowsHookEx(). Look at the WH_KEYBOARD and WH_KEYBOARD_LL hooks.

这篇关于如何在Win32 C++中的后台运行程序时检测KeyPress的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆