因按鍵眾多,所以列出部分按鍵語法,其他都是重複套用就可以了。
程式碼
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 OnScreenKeyboard
{
public partial class OnScreenKeys : Form
{
protected override CreateParams CreateParams
{
get
{
CreateParams param = base.CreateParams;
param.ExStyle |= 0x08000000;
return param;
}
}
public OnScreenKeys()
{
InitializeComponent();
}
private void buttonQ_Click(object sender, EventArgs e)
{
if (checkBoxCaps.Checked)
{
textBoxInput.Focus();
SendKeys.Send("Q");
}
else
{
textBoxInput.Focus();
SendKeys.Send("q");
}
}
private void buttonW_Click(object sender, EventArgs e)
{
if (checkBoxCaps.Checked)
{
textBoxInput.Focus();
SendKeys.Send("W");
}
else
{
textBoxInput.Focus();
SendKeys.Send("w");
}
}
成果呈現
參考資源: