使用SendInput锁定计算机

编程入门 行业动态 更新时间:2024-10-24 23:21:18
本文介绍了使用SendInput锁定计算机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想通过C ++使用SendInput来锁定计算机(Windows+L).我创建了简单的keyDown/keyUp函数,在其中使用SendInput发送VK.在keyUp上,它添加flag 0x0002

I want to use SendInput via C++ to lock the computer (Windows+L). I have created simple keyDown / keyUp functions in which I use SendInput to send a VK. On keyUp, it adds the flag 0x0002

我可以模拟我的Tab键,Windows键,现在尝试使用模拟的按键锁定计算机.我发送以下消息:

I can simulate my tab key, my windows key and now I try to lock my computer with a simulated key stroke. I send the following messages:

key down: 0x5B (win key) key down: 0x4C (L) key up: 0x4C (L) key up: 0x5B (win key)

我的问题:什么都没有发生:-(

My problem: Nothing happens :-(

有人知道解决方案吗?

推荐答案

如果我没记错的话,您将无法使用SendInput()(或keybd_event())执行此操作,因为它只是将按键注入键盘中输入缓冲区,但是特殊的键序列(例如CTRL+ALT+DEL,WIN+L等)在较低的层上运行,在将键放入输入缓冲区之前由操作系统解释.

If I am not mistaken, you will not be able to do this with SendInput() (or keybd_event()) because it simply injects the keys into the keyboard input buffer, but special key sequences like CTRL+ALT+DEL, WIN+L, etc operate at a lower layer that are interpretted by the OS before keys are put in the input buffer.

锁定计算机的正确方法是使用 LockWorkStation() 函数代替.

The correct way to lock the computer is to use the LockWorkStation() function instead.

更多推荐

使用SendInput锁定计算机

本文发布于:2023-11-11 10:27:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1578165.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:计算机   SendInput

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!