c# - C#如何判断用户是否左键单击?(来自表格外)
问题描述
好的,所以我正在尝试制作一个自动点击器,当您按住鼠标左键时它会开始点击。当用户按住鼠标左键但表单无法点击时,我得到它告诉我。然后我通过添加使表单可以点击
[DllImport("user32.dll")]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
[DllImport("user32.dll", SetLastError = true)]
static extern int GetWindowLong(IntPtr hWnd, int nIndex);
和
int initialStyle = GetWindowLong(this.Handle, -20);
SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20);
this.TopMost = true;
但是一旦我让它可以点击,它并没有告诉我鼠标左键是否被按住。
所以基本上我制作了一个用户控制并设置点击速度和内容的主表单,然后我制作了第二个表单,它是屏幕的大小,并且是最顶部和透明的,所以如果你左键单击表单,它会读取我将鼠标按下功能设置为将布尔值设置为真或假,但是一旦我制作了可单击的表单,我猜它不会读取鼠标按下功能。
这是关于它如何检测是否按住鼠标左键的代码
private void Form2_MouseDown(object sender, MouseEventArgs e)
{
if (MouseButtons == MouseButtons.Left)
{
mousedownheld = true;
}
}
private void Form2_MouseUp(object sender, MouseEventArgs e)
{
mousedownheld = false;
mousedownheld2 = true;
}
解决方案
推荐阅读
- c - 使用函数创建链表的问题
- azure-devops - Azure DevOps 基于角色的菜单项
- windows - 如何从Windows cmd中的文件中打印一行的某些部分
- c# - 是否可以在 DropDownList html helper 中使用链接?
- selenium - Protracor comapare 2个字符串数组
- ansible - 在 Ansible 中安装多个包
- java - TextureView 使用 OpenGL 显示空白屏幕
- java - eclipse rap下载服务servlet错误
- aws-kms - AWS KMS 存储客户主密钥
- angular - 如何在Angular中将数据源作为输入传递?