├── .gitignore
├── CSInputs.csproj
├── CSInputs.sln
├── Enums
├── Input
│ ├── HidUsage.cs
│ ├── KeyFlags.cs
│ └── RawInputType.cs
├── Keyboard
│ └── KeyboardKeys.cs
└── Mouse
│ ├── MouseKeys.cs
│ └── MousePositioning.cs
├── LICENSE
├── NativeMethods
└── User32.cs
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── README.md
├── ReadInput
├── InputListener.cs
└── ModifierKey.cs
├── SendInput
├── Keyboard.cs
└── Mouse.cs
└── Structs
├── Input
├── Input.cs
├── RawInput.cs
├── RawInputDevice.cs
├── RawInputHeader.cs
└── Union.cs
├── Keyboard
├── KeyboardData.cs
├── KeyboardInput.cs
└── RawKeyboard.cs
└── Mouse
├── MouseData.cs
├── MouseInput.cs
└── RawMouse.cs
/.gitignore:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # This .gitignore file was automatically created by Microsoft(R) Visual Studio.
3 | ################################################################################
4 |
5 | /obj
6 | /.vs
7 | /bin/Debug
8 | /bin/x86/Debug
9 | /CSInputs.csproj.user
10 | /bin/Release
11 | *.pfx
12 |
--------------------------------------------------------------------------------
/CSInputs.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {3B666193-FD40-4A29-849A-8F7F8F03F197}
8 | Library
9 | CSInputs
10 | CSInputs
11 | v3.5
12 | 512
13 | true
14 |
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | false
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 | false
40 |
41 |
42 |
43 |
44 |
45 |
46 | false
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | ResXFileCodeGenerator
85 | Resources.Designer.cs
86 | Designer
87 |
88 |
89 | True
90 | Resources.resx
91 | True
92 |
93 |
94 | SettingsSingleFileGenerator
95 | Settings.Designer.cs
96 |
97 |
98 | True
99 | Settings.settings
100 | True
101 |
102 |
103 |
104 |
105 |
--------------------------------------------------------------------------------
/CSInputs.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.10.35013.160
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSInputs", "CSInputs.csproj", "{3B666193-FD40-4A29-849A-8F7F8F03F197}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {3B666193-FD40-4A29-849A-8F7F8F03F197}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {3B666193-FD40-4A29-849A-8F7F8F03F197}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {3B666193-FD40-4A29-849A-8F7F8F03F197}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {3B666193-FD40-4A29-849A-8F7F8F03F197}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {806A0772-77E2-4F56-B58F-01ED0FC3AE55}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/Enums/Input/HidUsage.cs:
--------------------------------------------------------------------------------
1 | namespace CSInputs.Enums
2 | {
3 | public enum HIDUsage : ushort
4 | {
5 | Mouse = 0x02,
6 | Keyboard = 0x06,
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Enums/Input/KeyFlags.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace CSInputs.Enums
4 | {
5 | [Flags]
6 | public enum KeyFlags : ushort
7 | {
8 | KeyDown = 0,
9 | KeyUp = 1,
10 | Movement = 2
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Enums/Input/RawInputType.cs:
--------------------------------------------------------------------------------
1 | namespace CSInputs.Enums
2 | {
3 | public enum RawInputType
4 | {
5 | Mouse,
6 | Keyboard
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Enums/Keyboard/KeyboardKeys.cs:
--------------------------------------------------------------------------------
1 | namespace CSInputs.Enums
2 | {
3 | public enum KeyboardKeys : ushort
4 | {
5 | None = 0,
6 | LeftButton = 0x01,
7 | RightButton = 0x02,
8 | Cancel = 0x03,
9 | MiddleButton = 0x04,
10 | ExtraButton1 = 0x05,
11 | ExtraButton2 = 0x06,
12 | Back = 0x08,
13 | Tab = 0x09,
14 | Clear = 0x0C,
15 | Return = 0x0D,
16 | Shift = 0x10,
17 | Ctrl = 0x11,
18 | Alt = 0x12,
19 | Pause = 0x13,
20 | CapsLock = 0x14,
21 | Kana = 0x15,
22 | Hangeul = 0x15,
23 | Hangul = 0x15,
24 | Junja = 0x17,
25 | Final = 0x18,
26 | Hanja = 0x19,
27 | Kanji = 0x19,
28 | Escape = 0x1B,
29 | Convert = 0x1C,
30 | NonConvert = 0x1D,
31 | Accept = 0x1E,
32 | ModeChange = 0x1F,
33 | Space = 0x20,
34 | PageUp = 0x21,
35 | PageDown = 0x22,
36 | End = 0x23,
37 | Home = 0x24,
38 | Left = 0x25,
39 | Up = 0x26,
40 | Right = 0x27,
41 | Down = 0x28,
42 | Select = 0x29,
43 | Print = 0x2A,
44 | Execute = 0x2B,
45 | PrintScr = 0x2C,
46 | Insert = 0x2D,
47 | Delete = 0x2E,
48 | Help = 0x2F,
49 | N0 = 0x30,
50 | N1 = 0x31,
51 | N2 = 0x32,
52 | N3 = 0x33,
53 | N4 = 0x34,
54 | N5 = 0x35,
55 | N6 = 0x36,
56 | N7 = 0x37,
57 | N8 = 0x38,
58 | N9 = 0x39,
59 | A = 0x41,
60 | B = 0x42,
61 | C = 0x43,
62 | D = 0x44,
63 | E = 0x45,
64 | F = 0x46,
65 | G = 0x47,
66 | H = 0x48,
67 | I = 0x49,
68 | J = 0x4A,
69 | K = 0x4B,
70 | L = 0x4C,
71 | M = 0x4D,
72 | N = 0x4E,
73 | O = 0x4F,
74 | P = 0x50,
75 | Q = 0x51,
76 | R = 0x52,
77 | S = 0x53,
78 | T = 0x54,
79 | U = 0x55,
80 | V = 0x56,
81 | W = 0x57,
82 | X = 0x58,
83 | Y = 0x59,
84 | Z = 0x5A,
85 | LeftWindows = 0x5B,
86 | RightWindows = 0x5C,
87 | Application = 0x5D,
88 | Sleep = 0x5F,
89 | Numpad0 = 0x60,
90 | Numpad1 = 0x61,
91 | Numpad2 = 0x62,
92 | Numpad3 = 0x63,
93 | Numpad4 = 0x64,
94 | Numpad5 = 0x65,
95 | Numpad6 = 0x66,
96 | Numpad7 = 0x67,
97 | Numpad8 = 0x68,
98 | Numpad9 = 0x69,
99 | NumEnter = 0xE0,
100 | Multiply = 0x6A,
101 | Add = 0x6B,
102 | Separator = 0x6C,
103 | Subtract = 0x6D,
104 | Decimal = 0x6E,
105 | Divide = 0x6F,
106 | F1 = 0x70,
107 | F2 = 0x71,
108 | F3 = 0x72,
109 | F4 = 0x73,
110 | F5 = 0x74,
111 | F6 = 0x75,
112 | F7 = 0x76,
113 | F8 = 0x77,
114 | F9 = 0x78,
115 | F10 = 0x79,
116 | F11 = 0x7A,
117 | F12 = 0x7B,
118 | F13 = 0x7C,
119 | F14 = 0x7D,
120 | F15 = 0x7E,
121 | F16 = 0x7F,
122 | F17 = 0x80,
123 | F18 = 0x81,
124 | F19 = 0x82,
125 | F20 = 0x83,
126 | F21 = 0x84,
127 | F22 = 0x85,
128 | F23 = 0x86,
129 | F24 = 0x87,
130 | NumLock = 0x90,
131 | ScrollLock = 0x91,
132 | NEC_Equal = 0x92,
133 | Fujitsu_Jisho = 0x92,
134 | Fujitsu_Masshou = 0x93,
135 | Fujitsu_Touroku = 0x94,
136 | Fujitsu_Loya = 0x95,
137 | Fujitsu_Roya = 0x96,
138 | LeftShift = 0xA0,
139 | RightShift = 0xA1,
140 | LeftControl = 0xA2,
141 | RightControl = 0xA3,
142 | LeftMenu = 0xA4,
143 | RightMenu = 0xA5,
144 | BrowserBack = 0xA6,
145 | BrowserForward = 0xA7,
146 | VolumeDown = 0xAE,
147 | VolumeUp = 0xAF,
148 | MediaNextTrack = 0xB0,
149 | MediaPrevTrack = 0xB1,
150 | MediaStop = 0xB2,
151 | MediaPlayPause = 0xB3,
152 | LaunchMail = 0xB4,
153 | LaunchMediaSelect = 0xB5,
154 | LaunchApplication1 = 0xB6,
155 | LaunchApplication2 = 0xB7,
156 | OEM1 = 0xBA,
157 | OEMPlus = 0xBB,
158 | OEMComma = 0xBC,
159 | OEMMinus = 0xBD,
160 | OEMPeriod = 0xBE,
161 | OEM2 = 0xBF,
162 | OEM3 = 0xC0,
163 | OEM4 = 0xDB,
164 | OEM5 = 0xDC,
165 | OEM6 = 0xDD,
166 | OEM7 = 0xDE,
167 | OEM8 = 0xDF,
168 | OEMAX = 0xE1,
169 | OEM102 = 0xE2,
170 | ICOHelp = 0xE3,
171 | ICO00 = 0xE4,
172 | ProcessKey = 0xE5,
173 | ICOClear = 0xE6,
174 | Packet = 0xE7,
175 | OEMReset = 0xE9,
176 | OEMJump = 0xEA,
177 | OEMPA1 = 0xEB,
178 | OEMPA2 = 0xEC,
179 | OEMPA3 = 0xED,
180 | OEMWSCtrl = 0xEE,
181 | OEMCUSel = 0xEF,
182 | OEMATTN = 0xF0,
183 | OEMFinish = 0xF1,
184 | OEMCopy = 0xF2,
185 | OEMAuto = 0xF3,
186 | OEMENLW = 0xF4,
187 | OEMBackTab = 0xF5,
188 | ATTN = 0xF6,
189 | CRSel = 0xF7,
190 | EXSel = 0xF8,
191 | EREOF = 0xF9,
192 | Play = 0xFA,
193 | Zoom = 0xFB,
194 | Noname = 0xFC,
195 | PA1 = 0xFD,
196 | OEMClear = 0xFE
197 | }
198 | }
199 |
--------------------------------------------------------------------------------
/Enums/Mouse/MouseKeys.cs:
--------------------------------------------------------------------------------
1 | namespace CSInputs.Enums
2 | {
3 | public enum MouseKeys : short
4 | {
5 | None = 0,
6 | MouseLeft = 1,
7 | MouseRight = 4,
8 | MouseMiddle = 16,
9 | XButton1 = 64,
10 | XButton2 = 256,
11 | MouseWheelForward = 3931,
12 | MouseWheelBackward = 3932,
13 | MouseWheelLeft = 3921,
14 | MouseWheelRight = 3922,
15 | RI_MOUSE_WHEEL = 1024,
16 | RI_MOUSE_HWHEEL = 2048
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Enums/Mouse/MousePositioning.cs:
--------------------------------------------------------------------------------
1 | namespace CSInputs.Enums
2 | {
3 | public enum MousePositioning
4 | {
5 | Absolute,
6 | Relative
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 trksyln
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/NativeMethods/User32.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace CSInputs.NativeMethods
5 | {
6 | internal class User32
7 | {
8 | [DllImport("user32.dll")]
9 | internal static extern uint MapVirtualKey(uint uCode, uint uMapType);
10 |
11 | internal static IntPtr GetCSInputsMessage = (IntPtr)new Random().Next(int.MaxValue / 2, int.MaxValue);
12 |
13 | [DllImport("user32.dll")]
14 | internal static extern IntPtr GetMessageExtraInfo();
15 |
16 | [DllImport("user32.dll", SetLastError = true)]
17 | internal static extern uint SendInput(uint nInputs, Structs.Input.Input[] pInputs, int cbSize);
18 |
19 | [DllImport("user32", SetLastError = true)]
20 | internal static extern bool RegisterRawInputDevices(Structs.Input.RawInputDevice[] pRawInputDevices, uint uiNumDevices, uint cbSize);
21 |
22 | [DllImport("user32.dll")]
23 | internal static extern int GetRawInputData(IntPtr hRawInput, uint uiCommand, out Structs.Input.RawInput pData, ref int pcbSize, int cbSizeHeader);
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 | [assembly: AssemblyTitle("CSInputs")]
8 | [assembly: AssemblyDescription("windows api input library")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("trksyln")]
11 | [assembly: AssemblyProduct("CSInputs")]
12 | [assembly: AssemblyCopyright("Copyright © 2021")]
13 | [assembly: AssemblyTrademark("trksyln")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("3b666193-fd40-4a29-849a-8f7f8f03f197")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.5.0")]
35 | [assembly: AssemblyFileVersion("1.0.5.0")]
36 |
--------------------------------------------------------------------------------
/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace CSInputs.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CSInputs.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace CSInputs.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CSInputs
2 | This library allows you to send and read mouse / keyboard inputs even when app window inactive.
3 |
4 |
5 | `WinForms / Console Application`
6 | **.NET Framework 3.5+**
7 |
8 | # Installation
9 | You can install this package from **Nuget Package Manager**.
10 | ```console
11 | Install-Package CSInputs
12 | ```
13 | **OR**
14 | ```console
15 | dotnet add package CSInputs
16 | ```
17 |
18 |
19 | # Usage Examples
20 |
21 | ### -Send Inputs
22 |
23 | >Keyboard Inputs:
24 | ```cs
25 | SendInput.Keyboard.Send(KeyboardKeys.F1);
26 | SendInput.Keyboard.Send(KeyboardKeys.F1,Enums.KeyFlags.Down);
27 | SendInput.Keyboard.Send(KeyboardKeys.F1,Enums.KeyFlags.Up);
28 | SendInput.Keyboard.SendChar('A');
29 | SendInput.Keyboard.SendString("Hello World!");
30 | ```
31 |
32 |
33 | >Mouse Inputs:
34 | ```cs
35 | SendInput.Mouse.Send(MouseKeys.MouseLeft);
36 |
37 | SendInput.Mouse.Send(MouseKeys.MouseLeft,Enums.KeyFlags.Down);
38 | SendInput.Mouse.Send(MouseKeys.MouseLeft,Enums.KeyFlags.Up);
39 |
40 | SendInput.Mouse.Send(MouseKeys.MouseLeft, KeyFlags.Down,new Point(150, 123),MousePositioning.Absolute);
41 | SendInput.Mouse.Send(MouseKeys.MouseLeft, KeyFlags.Down,new Point(-5, -30),MousePositioning.Relative);
42 |
43 | SendInput.Mouse.MoveTo(new Point(150, 123), Enums.MousePositioning.Absolute);
44 | ```
45 |
46 | ### -Listen Inputs
47 | First you need to instantiate a input listener.
48 | ```cs
49 | ReadInput.InputListener listener = new ReadInput.InputListener();
50 | ```
51 | Then you can subscribe for keyboard or mouse events to listen inputs.
52 | ```cs
53 | listener.KeyboardInputs += Listener_KeyboardInputs;
54 | listener.MouseInputs += Listener_MouseInputs;
55 | ```
56 |
57 | ### -Sample Console Application
58 | ```cs
59 | using System;
60 | //System.Windows.Forms is required to work on console applications. so dont forget to add the reference.
61 | using System.Windows.Forms;
62 | using CSInputs.Enums;
63 | using CSInputs.ReadInput;
64 | using CSInputs.Structs;
65 |
66 | internal class Program
67 | {
68 | static void Main(string[] args)
69 | {
70 | // Instantiate InputListener
71 | InputListener inputListener = new InputListener();
72 |
73 | // Subscribe to KeyboardInputs event handler to listen keyboard inputs.
74 | inputListener.KeyboardInputs += InputListener_KeyboardInputs;
75 |
76 | // Subscribe to MouseInputs event handler to listen mouse inputs.
77 | inputListener.MouseInputs += InputListener_MouseInputs;
78 | Application.Run(); // Required to work on console applications,
79 | }
80 |
81 | private static void InputListener_MouseInputs(MouseData data, ref ModifierKey modifierKey)
82 | {
83 | if (data.Key == MouseKeys.MouseRight && data.Flags == KeyFlags.KeyUp)
84 | Console.WriteLine("Someone just released the \"Right Click\"!");
85 | }
86 |
87 | private static void InputListener_KeyboardInputs(KeyboardData data, ref ModifierKey modifierKey)
88 | {
89 | if (data.Key == KeyboardKeys.Space && data.Flags == KeyFlags.KeyUp)
90 | Console.WriteLine("Someone just released the \"Space\" key!");
91 | }
92 | }
93 | ```
94 |
95 |
--------------------------------------------------------------------------------
/ReadInput/InputListener.cs:
--------------------------------------------------------------------------------
1 | using CSInputs.NativeMethods;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Runtime.InteropServices;
5 | using System.Windows.Forms;
6 |
7 | namespace CSInputs.ReadInput
8 | {
9 | public class InputListener : NativeWindow
10 | {
11 | public event KeyboardDataDel KeyboardInputs;
12 | public event MouseDataDel MouseInputs;
13 | public event MouseDataDel MouseMovements;
14 | public delegate void KeyboardDataDel(Structs.KeyboardData data, ref ModifierKey modifierKey);
15 | public delegate void MouseDataDel(Structs.MouseData data, ref ModifierKey modifierKey);
16 |
17 | private ModifierKey ModifierKeys;
18 | private readonly List keysAreDown = new List();
19 | private readonly bool NotifyKeyDownsOnce = true;
20 | private readonly bool IgnoreSelf = true;
21 | private System.Drawing.Point LastCursorPos;
22 |
23 | ///
24 | /// Input listener for mouse and keyboard
25 | ///
26 | /// When key is down, notify once or repeat until key up is sent
27 | /// Ignore keys sent from this CSInputs instance.
28 | public InputListener(bool notifyKeyDownsOnce = true, bool ignoreSelf = true)
29 | {
30 | //this.AssignHandle(Handle);
31 | NotifyKeyDownsOnce = notifyKeyDownsOnce;
32 | IgnoreSelf = ignoreSelf;
33 | CreateHandle(new CreateParams
34 | {
35 | X = 0,
36 | Y = 0,
37 | Width = 0,
38 | Height = 0,
39 | Style = 0x800000,
40 | });
41 | RegisterDevices(Handle);
42 | ModifierKeys = new ModifierKey(this);
43 | }
44 |
45 | private static void RegisterDevices(IntPtr handle)
46 | {
47 | Structs.Input.RawInputDevice[] devs = new Structs.Input.RawInputDevice[]
48 | {
49 | new Structs.Input.RawInputDevice()
50 | {
51 | Usage = (ushort)Enums.HIDUsage.Mouse,
52 | Flags = 0x00000100,
53 | UsagePage =1,
54 | HwndTarget = handle
55 | },
56 | new Structs.Input.RawInputDevice()
57 | {
58 | Usage = (ushort)Enums.HIDUsage.Keyboard,
59 | Flags = 0x00000100,
60 | UsagePage =1,
61 | HwndTarget = handle
62 | }
63 | };
64 | User32.RegisterRawInputDevices(devs, (uint)devs.Length, (uint)Marshal.SizeOf(typeof(Structs.Input.RawInputDevice)));
65 | }
66 | protected override void WndProc(ref Message m)
67 | {
68 | const int WM_INPUT = 0x00FF;
69 | if (m.Msg == WM_INPUT)
70 | {
71 | int rwSize = Marshal.SizeOf(typeof(Structs.Input.RawInput));
72 | int hdSize = Marshal.SizeOf(typeof(Structs.Input.RawInputHeader));
73 | int res = User32.GetRawInputData(m.LParam, 0x10000003, out Structs.Input.RawInput rw, ref rwSize, hdSize);
74 | if (res < 0)
75 | return;
76 |
77 | if (KeyboardInputs != null && rw.Header.dwType == Enums.RawInputType.Keyboard && Enum.IsDefined(typeof(Enums.KeyboardKeys), rw.Data.Keyboard.VirtualKey))
78 | {
79 | if (IgnoreSelf && rw.Data.Keyboard.ExtraInformation == (int)User32.GetCSInputsMessage)
80 | return;
81 |
82 | if ((rw.Data.Keyboard.Flags & Enums.KeyFlags.KeyUp) != 0)
83 | rw.Data.Keyboard.Flags = Enums.KeyFlags.KeyUp;
84 | else
85 | rw.Data.Keyboard.Flags = Enums.KeyFlags.KeyDown;
86 |
87 | if (NotifyKeyDownsOnce && rw.Data.Keyboard.Flags == Enums.KeyFlags.KeyDown && keysAreDown.Contains(rw.Data.Keyboard.VirtualKey))
88 | return;
89 |
90 | if (NotifyKeyDownsOnce && rw.Data.Keyboard.Flags == Enums.KeyFlags.KeyDown && !keysAreDown.Contains(rw.Data.Keyboard.VirtualKey))
91 | keysAreDown.Add(rw.Data.Keyboard.VirtualKey);
92 |
93 | if (NotifyKeyDownsOnce && rw.Data.Keyboard.Flags == Enums.KeyFlags.KeyUp && keysAreDown.Contains(rw.Data.Keyboard.VirtualKey))
94 | keysAreDown.Remove(rw.Data.Keyboard.VirtualKey);
95 |
96 |
97 | #region Shift key left right translation
98 | if (rw.Data.Keyboard.VirtualKey == Enums.KeyboardKeys.Shift)
99 | rw.Data.Keyboard.VirtualKey = rw.Data.Keyboard.MakeCode == 0x2A ? Enums.KeyboardKeys.LeftShift : Enums.KeyboardKeys.RightShift;
100 | #endregion
101 |
102 | KeyboardInputs?.Invoke(new Structs.KeyboardData()
103 | {
104 | Key = rw.Data.Keyboard.VirtualKey,
105 | Flags = rw.Data.Keyboard.Flags
106 | }, ref ModifierKeys);
107 |
108 | }
109 | if ((MouseMovements != null || MouseInputs != null) && rw.Header.dwType == Enums.RawInputType.Mouse)
110 | {
111 | if (IgnoreSelf && rw.Data.Mouse.ExtraInformation == (int)User32.GetCSInputsMessage)
112 | return;
113 |
114 | Structs.MouseData baseData = new Structs.MouseData
115 | {
116 | PositionRelative = new System.Drawing.Point(rw.Data.Mouse.LastX, rw.Data.Mouse.LastY),
117 | PositionAbsolute = Cursor.Position
118 | };
119 | if (rw.Data.Mouse.Buttons != Enums.MouseKeys.None)
120 | {
121 | int[,] mouseButtonFlags = new int[,]
122 | {
123 | { 0x0001, 0x0002, (int)Enums.MouseKeys.MouseLeft },
124 | { 0x0004, 0x0008, (int)Enums.MouseKeys.MouseRight },
125 | { 0x0010, 0x0020, (int)Enums.MouseKeys.MouseMiddle },
126 | { 0x0040, 0x0080, (int)Enums.MouseKeys.XButton1 },
127 | { 0x0100, 0x0200, (int)Enums.MouseKeys.XButton2 }
128 | };
129 |
130 | // vertical wheel
131 | if (rw.Data.Mouse.Buttons == Enums.MouseKeys.RI_MOUSE_WHEEL)
132 | {
133 | var data = baseData;
134 | short delta = (short)rw.Data.Mouse.ButtonData;
135 | data.Key = delta > 0 ? Enums.MouseKeys.MouseWheelForward : Enums.MouseKeys.MouseWheelBackward;
136 | data.Flags = Enums.KeyFlags.KeyDown;
137 | MouseInputs?.Invoke(data, ref ModifierKeys);
138 | data.Flags = Enums.KeyFlags.KeyUp;
139 | MouseInputs?.Invoke(data, ref ModifierKeys);
140 | }
141 |
142 | // horizontal wheel
143 | if (rw.Data.Mouse.Buttons == Enums.MouseKeys.RI_MOUSE_HWHEEL)
144 | {
145 | var data = baseData;
146 | short delta = (short)rw.Data.Mouse.ButtonData;
147 | data.Key = delta > 0 ? Enums.MouseKeys.MouseWheelRight : Enums.MouseKeys.MouseWheelLeft;
148 | data.Flags = Enums.KeyFlags.KeyDown;
149 | MouseInputs?.Invoke(data, ref ModifierKeys);
150 | data.Flags = Enums.KeyFlags.KeyUp;
151 | MouseInputs?.Invoke(data, ref ModifierKeys);
152 | }
153 |
154 | for (int i = 0; i < mouseButtonFlags.GetLength(0); i++)
155 | {
156 | if (((int)rw.Data.Mouse.Buttons & mouseButtonFlags[i, 0]) != 0)
157 | {
158 | var data = baseData;
159 | data.Key = (Enums.MouseKeys)mouseButtonFlags[i, 2];
160 | data.Flags = Enums.KeyFlags.KeyDown;
161 | MouseInputs?.Invoke(data, ref ModifierKeys);
162 | }
163 |
164 | if (((int)rw.Data.Mouse.Buttons & mouseButtonFlags[i, 1]) != 0)
165 | {
166 | var data = baseData;
167 | data.Key = (Enums.MouseKeys)mouseButtonFlags[i, 2];
168 | data.Flags = Enums.KeyFlags.KeyUp;
169 | MouseInputs?.Invoke(data, ref ModifierKeys);
170 | }
171 | }
172 |
173 | }
174 | else if (rw.Data.Mouse.Buttons == Enums.MouseKeys.None && LastCursorPos != baseData.PositionAbsolute)
175 | {
176 | LastCursorPos = baseData.PositionAbsolute;
177 | MouseMovements?.Invoke(baseData, ref ModifierKeys);
178 | }
179 | }
180 | }
181 | base.WndProc(ref m);
182 | }
183 | }
184 | }
185 |
--------------------------------------------------------------------------------
/ReadInput/ModifierKey.cs:
--------------------------------------------------------------------------------
1 | namespace CSInputs.ReadInput
2 | {
3 | public class ModifierKey
4 | {
5 | public bool LeftShift, RightShift, Control, Alt, LeftWindows, RightWindows;
6 | public ModifierKey(ReadInput.InputListener listener)
7 | {
8 | listener.KeyboardInputs += Listener_KeyboardInputs;
9 | }
10 |
11 | private void Listener_KeyboardInputs(Structs.KeyboardData data, ref ModifierKey modifierKey)
12 | {
13 | switch (data.Key)
14 | {
15 | case Enums.KeyboardKeys.LeftShift:
16 | LeftShift = (data.Flags & Enums.KeyFlags.KeyUp) == 0;
17 | break;
18 | case Enums.KeyboardKeys.RightShift:
19 | RightShift = (data.Flags & Enums.KeyFlags.KeyUp) == 0;
20 | break;
21 | case Enums.KeyboardKeys.Ctrl:
22 | Control = (data.Flags & Enums.KeyFlags.KeyUp) == 0;
23 | break;
24 | case Enums.KeyboardKeys.Alt:
25 | Alt = (data.Flags & Enums.KeyFlags.KeyUp) == 0;
26 | break;
27 | case Enums.KeyboardKeys.LeftWindows:
28 | LeftWindows = (data.Flags & Enums.KeyFlags.KeyUp) == 0;
29 | break;
30 | case Enums.KeyboardKeys.RightWindows:
31 | RightWindows = (data.Flags & Enums.KeyFlags.KeyUp) == 0;
32 | break;
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/SendInput/Keyboard.cs:
--------------------------------------------------------------------------------
1 | using CSInputs.NativeMethods;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace CSInputs.SendInput
5 | {
6 | public static class Keyboard
7 | {
8 | public static void Send(Enums.KeyboardKeys key)
9 | {
10 | Send(key, Enums.KeyFlags.KeyDown);
11 | System.Threading.Thread.Sleep(1);
12 | Send(key, Enums.KeyFlags.KeyUp);
13 | }
14 |
15 | public static void Send(Enums.KeyboardKeys key, Enums.KeyFlags flags)
16 | {
17 | uint keyFlags = 0;
18 | switch (flags)
19 | {
20 | case Enums.KeyFlags.KeyDown:
21 | keyFlags = 0x0000 | 0x0008;
22 | break;
23 | case Enums.KeyFlags.KeyUp:
24 | keyFlags = 0x0002 | 0x0008;
25 | break;
26 | }
27 |
28 | if (key == Enums.KeyboardKeys.LeftWindows || key == Enums.KeyboardKeys.RightWindows ||
29 | key == Enums.KeyboardKeys.Left || key == Enums.KeyboardKeys.Right ||
30 | key == Enums.KeyboardKeys.Up || key == Enums.KeyboardKeys.Down ||
31 | key == Enums.KeyboardKeys.Insert || key == Enums.KeyboardKeys.Delete ||
32 | key == Enums.KeyboardKeys.Home || key == Enums.KeyboardKeys.End ||
33 | key == Enums.KeyboardKeys.PageUp || key == Enums.KeyboardKeys.PageDown ||
34 | key == Enums.KeyboardKeys.NumEnter || key == Enums.KeyboardKeys.RightControl ||
35 | key == Enums.KeyboardKeys.LeftWindows || key == Enums.KeyboardKeys.RightWindows)
36 | keyFlags |= 0x0001; // KEYEVENTF_EXTENDEDKEY
37 |
38 |
39 | Structs.Input.Input input = new Structs.Input.Input();
40 | Structs.Input.Union inputUnion = new Structs.Input.Union()
41 | {
42 | keyboardInput = new Structs.KeyboardInput
43 | {
44 | wVk = (ushort)key,
45 | wScan = (ushort)User32.MapVirtualKey((uint)key, 0x00),
46 | dwFlags = keyFlags,
47 | dwExtraInfo = User32.GetCSInputsMessage
48 | }
49 | };
50 | input.type = 1;
51 | input.Data = inputUnion;
52 | User32.SendInput(1, new Structs.Input.Input[] { input }, Marshal.SizeOf(typeof(Structs.Input.Input)));
53 | }
54 |
55 | public static void SendString(string text)
56 | {
57 | for (int i = 0; i < text.Length; i++)
58 | SendChar(text[i]);
59 | }
60 | public static void SendChar(char character)
61 | {
62 | Structs.Input.Input[] inputs = new Structs.Input.Input[2];
63 | Structs.Input.Union down = new Structs.Input.Union()
64 | {
65 | keyboardInput = new Structs.KeyboardInput
66 | {
67 | wVk = 0,
68 | wScan = character,
69 | dwFlags = 0x0004,
70 | dwExtraInfo = User32.GetCSInputsMessage
71 | }
72 | };
73 | Structs.Input.Union up = new Structs.Input.Union()
74 | {
75 | keyboardInput = new Structs.KeyboardInput
76 | {
77 | wVk = 0,
78 | wScan = character,
79 | dwFlags = 0x0004 | 0x0002,
80 | dwExtraInfo = User32.GetCSInputsMessage
81 | }
82 | };
83 | inputs[0].type = 1;
84 | inputs[0].Data = down;
85 | inputs[1].type = 1;
86 | inputs[1].Data = up;
87 | User32.SendInput(2, inputs, Marshal.SizeOf(typeof(Structs.Input.Input)));
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/SendInput/Mouse.cs:
--------------------------------------------------------------------------------
1 | using CSInputs.Enums;
2 | using CSInputs.NativeMethods;
3 | using System;
4 | using System.Drawing;
5 | using System.Runtime.InteropServices;
6 |
7 | namespace CSInputs.SendInput
8 | {
9 | public static class Mouse
10 | {
11 | public static void Send(MouseKeys key, short scrollAmount = 60)
12 | {
13 | Send(key, KeyFlags.KeyDown, Point.Empty, MousePositioning.Relative, scrollAmount);
14 | if (key == MouseKeys.MouseWheelForward || key == MouseKeys.MouseWheelRight)
15 | Send(key, KeyFlags.KeyUp, Point.Empty, MousePositioning.Relative, scrollAmount);
16 | }
17 | public static void Send(MouseKeys key, KeyFlags flag, short scrollAmount = 60)
18 | {
19 | Send(key, flag, Point.Empty, MousePositioning.Relative, scrollAmount);
20 | }
21 | public static void Send(MouseKeys key, Point mousePos, MousePositioning mouseMovement, short scrollAmount = 60)
22 | {
23 | Send(key, KeyFlags.KeyDown, mousePos, mouseMovement, scrollAmount);
24 | if (key != MouseKeys.MouseWheelForward || key != MouseKeys.MouseWheelRight)
25 | Send(key, KeyFlags.KeyUp, mousePos, mouseMovement, scrollAmount);
26 | }
27 | public static void Send(MouseKeys key, KeyFlags flags, Point mousePos, MousePositioning mouseMovement, short scrollAmount = 60)
28 | {
29 |
30 | if (scrollAmount < 0)
31 | scrollAmount = Math.Abs(scrollAmount);
32 |
33 | if (key != MouseKeys.MouseWheelForward && key != MouseKeys.MouseWheelRight)
34 | scrollAmount *= -1;
35 |
36 | if (key == MouseKeys.MouseWheelForward || key == MouseKeys.MouseWheelBackward)
37 | key = (MouseKeys)2048;
38 | else if (key == MouseKeys.MouseWheelLeft || key == MouseKeys.MouseWheelRight)
39 | key = (MouseKeys)4096;
40 | else
41 | key = flags == KeyFlags.KeyUp ? (MouseKeys)((int)key * 2) : key;
42 |
43 |
44 | Structs.Input.Input input = new Structs.Input.Input();
45 | Structs.Input.Union inputUnion = new Structs.Input.Union()
46 | {
47 | mouseInput = new Structs.MouseInput
48 | {
49 | mouseData = scrollAmount,
50 | dx = CalculateAbsoluteCoordinateX(mousePos.X, mouseMovement),
51 | dy = CalculateAbsoluteCoordinateY(mousePos.Y, mouseMovement),
52 | dwFlags = (uint)(mouseMovement == MousePositioning.Absolute ? 0x0001 | 0x8000 : 0x0001) | (key != (MouseKeys)2048 && key != (MouseKeys)4096 ? (uint)key * 2 : (uint)key),
53 | dwExtraInfo = User32.GetCSInputsMessage
54 | }
55 | };
56 | input.Data = inputUnion;
57 | User32.SendInput(1, new Structs.Input.Input[] { input }, Marshal.SizeOf(typeof(Structs.Input.Input)));
58 | }
59 |
60 | public static void MoveTo(Point mousePos, MousePositioning mouseMovement)
61 | {
62 | Structs.Input.Input input = new Structs.Input.Input();
63 | Structs.Input.Union inputUnion = new Structs.Input.Union()
64 | {
65 | mouseInput = new Structs.MouseInput
66 | {
67 | mouseData = 0,
68 | dx = CalculateAbsoluteCoordinateX(mousePos.X, mouseMovement),
69 | dy = CalculateAbsoluteCoordinateY(mousePos.Y, mouseMovement),
70 | dwFlags = (uint)(mouseMovement == MousePositioning.Absolute ? 0x0001 | 0x8000 : 0x0001),
71 | dwExtraInfo = User32.GetCSInputsMessage
72 | }
73 | };
74 | input.Data = inputUnion;
75 | User32.SendInput(1, new Structs.Input.Input[] { input }, Marshal.SizeOf(typeof(Structs.Input.Input)));
76 | }
77 |
78 | private static int CalculateAbsoluteCoordinateY(int y, MousePositioning mouseMovement)
79 | {
80 | if (mouseMovement == MousePositioning.Absolute)
81 | return (((System.Windows.Forms.Screen.PrimaryScreen.Bounds.Y + y) * 65536) / System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
82 | return y;
83 | }
84 |
85 | private static int CalculateAbsoluteCoordinateX(int x, MousePositioning mouseMovement)
86 | {
87 | if (mouseMovement == MousePositioning.Absolute)
88 | return ((System.Windows.Forms.Screen.PrimaryScreen.Bounds.X + x) * 65536) / System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
89 | return x;
90 | }
91 | }
92 | }
--------------------------------------------------------------------------------
/Structs/Input/Input.cs:
--------------------------------------------------------------------------------
1 | namespace CSInputs.Structs.Input
2 | {
3 | internal struct Input
4 | {
5 | public int type;
6 | public Union Data;
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Structs/Input/RawInput.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace CSInputs.Structs.Input
4 | {
5 | [StructLayout(LayoutKind.Sequential)]
6 | internal struct RawInput
7 | {
8 | internal RawInputHeader Header;
9 | internal Union Data;
10 |
11 | [StructLayout(LayoutKind.Explicit)]
12 | internal struct Union
13 | {
14 | [FieldOffset(0)]
15 | internal RawMouse Mouse;
16 | [FieldOffset(0)]
17 | internal RawKeyboard Keyboard;
18 | }
19 | }
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/Structs/Input/RawInputDevice.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace CSInputs.Structs.Input
5 | {
6 | [StructLayout(LayoutKind.Sequential)]
7 | internal struct RawInputDevice
8 | {
9 | public ushort UsagePage;
10 | public ushort Usage;
11 | public uint Flags;
12 | public IntPtr HwndTarget;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Structs/Input/RawInputHeader.cs:
--------------------------------------------------------------------------------
1 | using CSInputs.Enums;
2 | using System;
3 |
4 | namespace CSInputs.Structs.Input
5 | {
6 | internal struct RawInputHeader
7 | {
8 | public RawInputType dwType;
9 | public int dwSize;
10 | public IntPtr hDevice;
11 | public IntPtr wParam;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Structs/Input/Union.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace CSInputs.Structs.Input
4 | {
5 | [StructLayout(LayoutKind.Explicit)]
6 | internal struct Union
7 | {
8 | [FieldOffset(0)] public MouseInput mouseInput;
9 | [FieldOffset(0)] public KeyboardInput keyboardInput;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Structs/Keyboard/KeyboardData.cs:
--------------------------------------------------------------------------------
1 | namespace CSInputs.Structs
2 | {
3 | public struct KeyboardData
4 | {
5 | public Enums.KeyboardKeys Key { get; set; }
6 | public Enums.KeyFlags Flags { get; set; }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Structs/Keyboard/KeyboardInput.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace CSInputs.Structs
5 | {
6 | [StructLayout(LayoutKind.Sequential)]
7 | internal struct KeyboardInput
8 | {
9 | public ushort wVk;
10 | public ushort wScan;
11 | public uint dwFlags;
12 | public readonly uint time;
13 | public IntPtr dwExtraInfo;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Structs/Keyboard/RawKeyboard.cs:
--------------------------------------------------------------------------------
1 | using CSInputs.Enums;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace CSInputs.Structs
5 | {
6 | [StructLayout(LayoutKind.Sequential)]
7 | internal struct RawKeyboard
8 | {
9 | public ushort MakeCode;
10 | public KeyFlags Flags;
11 | public ushort Reserved;
12 | public KeyboardKeys VirtualKey;
13 | public int Message;
14 | public int ExtraInformation;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Structs/Mouse/MouseData.cs:
--------------------------------------------------------------------------------
1 | namespace CSInputs.Structs
2 | {
3 | public struct MouseData
4 | {
5 | public Enums.MouseKeys Key { get; set; }
6 | public Enums.KeyFlags Flags { get; set; }
7 | public System.Drawing.Point PositionAbsolute { get; set; }
8 | public System.Drawing.Point PositionRelative { get; set; }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Structs/Mouse/MouseInput.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace CSInputs.Structs
5 | {
6 | [StructLayout(LayoutKind.Sequential)]
7 | internal struct MouseInput
8 | {
9 | public int dx;
10 | public int dy;
11 | public int mouseData;
12 | public uint dwFlags;
13 | public readonly uint time;
14 | public IntPtr dwExtraInfo;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Structs/Mouse/RawMouse.cs:
--------------------------------------------------------------------------------
1 | using CSInputs.Enums;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace CSInputs.Structs
5 | {
6 | [StructLayout(LayoutKind.Explicit)]
7 | internal struct RawMouse
8 | {
9 | [FieldOffset(0)] public ushort Flags;
10 | [FieldOffset(4)] public MouseKeys Buttons;
11 | [FieldOffset(6)] public readonly short ButtonData;
12 | [FieldOffset(8)] public readonly uint RawButtons;
13 | [FieldOffset(12)] public int LastX;
14 | [FieldOffset(16)] public int LastY;
15 | [FieldOffset(20)] public readonly uint ExtraInformation;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------