blob: 0c077f1d387a731b16ec9355317c2d88171be63e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using WindowsInput;
using WindowsInput.Native;
namespace Tango.RemoteDesktop.Input
{
public static class KeyboardController
{
private static InputSimulator simulator;
static KeyboardController()
{
simulator = new InputSimulator();
}
public static void KeyDown(Key key, bool ctrlDown, bool shitDown, bool altDown)
{
VirtualKeyCode virtualKey = (VirtualKeyCode)KeyInterop.VirtualKeyFromKey(key);
if (ctrlDown || shitDown || altDown)
{
List<VirtualKeyCode> modifierKeys = new List<VirtualKeyCode>();
if (ctrlDown)
{
modifierKeys.Add(VirtualKeyCode.LCONTROL);
}
if (shitDown)
{
modifierKeys.Add(VirtualKeyCode.LSHIFT);
}
if (altDown)
{
modifierKeys.Add(VirtualKeyCode.MENU);
}
simulator.Keyboard.ModifiedKeyStroke(modifierKeys, virtualKey);
}
else
{
simulator.Keyboard.KeyDown(virtualKey);
}
}
public static void KeyUp(Key key, bool ctrlDown, bool shitDown, bool altDown)
{
VirtualKeyCode virtualKey = (VirtualKeyCode)KeyInterop.VirtualKeyFromKey(key);
simulator.Keyboard.KeyUp(virtualKey);
}
}
}
|