-1

「%」と「;」を押すことをエミュレートする方法 キー

string a2 = ";:%1467";
byte[] bb = Encoding.ASCII.GetBytes(a2);

foreach (byte b in bb)
{
   InputWorkflow.SendKeyPress((ushort)b);
}

入力ワークフロー: http://pastebin.com/e9Hg24kD

4

1 に答える 1

3

Why your class isn't working

You are misusing the method described in that class; also you have to pass keyboard scan code to the InputWorkFlow.SendKeyPress(ushort keycode); method. It doesn't accept ascii bytes.

What to use:

Use the SendKeys class it works the way you want:

string a2 = ";:%1467";
byte[] bb = Encoding.ASCII.GetBytes(a2);

foreach (byte b in bb)
{
   SendKeys.Send(b);
}

If you need to wait for each key to be processed then use SendWait instead of Send

foreach (byte b in bb)
{
   SendKeys.SendWait(b);
}

Starting from .NET 3.0 on Windows Vista onwards you need to add the following in your app.config:

<appSettings>
<add key="SendKeys" value="SendInput"/>
</appSettings>
于 2013-07-09T13:10:40.480 に答える