![](/img/trans.png)
[英]How can I send a single Downkey key when my user taps the numpad Enter key?
[英]How can I send Numpad Keys through my program
我只是想创建一个程序,每隔几秒钟按一次Numpad 0。 到目前为止,这就是我所拥有的。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
int enabled = 0;
public Form1()
{
InitializeComponent();
}
private void Start_Click(object sender, EventArgs e)
{
if (enabled == 0)
{
Start.Text = "Stop";
Timer.Enabled = true;
enabled = 1;
}
else
{
Start.Text = "Start";
Timer.Enabled = false;
enabled = 0;
label2.Text = "0";
}
}
private void Timer_Tick(object sender, EventArgs e)
{
SendKeys.Send("{NumpadIns}");
label2.Text = Convert.ToString(Convert.ToInt32(label2.Text) + 1);
}
}
}
到目前为止,我已经尝试过了
{NumpadIns}
{NumIns}
{Num0}
{INS}
似乎没有任何效果,我正在使用的程序绑定到Num Zero,因此它必须是Num Zero,而不是第一行或Insert的0。 谢谢(是的,我已经用谷歌搜索,但是由于某种原因,这真的很难找到)。
根据我的经验,您应该使用Input Simulator之类的包装器 。 它易于使用,并且具有许多预定义的枚举,因此您无需传递String参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.