VK_SHIFT的GetKeyState最近失败 [英] GetKeyState recently fails for VK_SHIFT

查看:141
本文介绍了VK_SHIFT的GetKeyState最近失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windoes Forms应用程序,该应用程序使用带有单击处理程序的工具栏按钮.对于其中的某些按钮,如果在单击按钮的同时按下Shift键,则有另一种含义.这一直有效.我最后一次知道是16岁 十一月.今天,它不再起作用了.我怀疑某些Windows更新破坏了该功能.

I have a Windoes Forms application that uses toolbar buttons with click handlers. For some of these buttons, there's an alternate meaning if the Shift key is pressed while clicking the button. This has always worked. The last time I know it did was on 16 November. Today it doesn't work anymore. I suspect some Windows update has broken that functionality.

这是我的一些代码:

private void AddToolbutton_Click(object sender, EventArgs e)
{
	if (WinApi.GetKeyState(WinApi.VK.SHIFT) < 0)
	{
		...
	}
}

[DllImport("user32.dll")]
public static extern short GetKeyState(VK nVirtKey);

public enum VK: short
{
	SHIFT = 0x10
}



现在,无论如何按下该键,该函数始终返回0.



The function now always returns 0, no matter how the key is pressed.

有人可以向我解释这里出了什么问题吗?

Can somebody explain me what's going wrong here?

推荐答案

使用包含控制键的键事件之一.
Use one of the key events that includes the control keys.


这篇关于VK_SHIFT的GetKeyState最近失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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