使用SendInput锁定计算机 [英] Use SendInput to lock the computer

查看:109
本文介绍了使用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+DELWIN+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锁定计算机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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