├── .gitignore
├── Installer
├── RemoteDesktop.Client.aip
└── RemoteDesktop.Server.aip
├── LICENSE
├── README.md
├── RemoteDesktop.Client
├── App.config
├── App.xaml
├── App.xaml.cs
├── Images
│ ├── AppIcon.ico
│ ├── AppIcon.png
│ └── NotConnected.png
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── RemoteDesktop.Client.csproj
├── SettingOverlay.xaml
├── SettingOverlay.xaml.cs
└── Settings.xml
├── RemoteDesktop.Core
├── DataSocket.cs
├── DebugLog.cs
├── NetworkDiscovery.cs
├── Properties
│ └── AssemblyInfo.cs
├── RemoteDesktop.Core.csproj
└── Utils.cs
├── RemoteDesktop.Server
├── App.config
├── Images
│ └── AppIcon.ico
├── MainApplicationContext.cs
├── MainForm.Designer.cs
├── MainForm.cs
├── MainForm.resx
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── RemoteDesktop.Server.csproj
├── app.manifest
└── app_debug.manifest
├── RemoteDesktop.sln
└── inputsimulator
├── .gitignore
├── .nuget
├── NuGet.Config
├── NuGet.exe
└── NuGet.targets
├── BuildProcessTemplates
├── DefaultTemplate.xaml
└── UpgradeTemplate.xaml
├── README.md
├── WindowsInput.SampleClient.Wpf
├── App.xaml
├── App.xaml.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
└── WindowsInput.SampleClient.Wpf.csproj
├── WindowsInput.Tests
├── InputBuilderTests.cs
├── InputSimulatorExamples.cs
├── Properties
│ └── AssemblyInfo.cs
├── UnicodeText
│ ├── UnicodeRange.cs
│ ├── UnicodeTestForm.Designer.cs
│ ├── UnicodeTestForm.cs
│ ├── UnicodeTestForm.resx
│ └── UnicodeTextTests.cs
├── WindowsInput.Tests.csproj
├── WindowsInput.Tests.snk
└── packages.config
├── WindowsInput.sln
└── WindowsInput
├── IInputDeviceStateAdaptor.cs
├── IInputMessageDispatcher.cs
├── IInputSimulator.cs
├── IKeyboardSimulator.cs
├── IMouseSimulator.cs
├── InputBuilder.cs
├── InputSimulator.cs
├── KeyboardSimulator.cs
├── MouseButton.cs
├── MouseSimulator.cs
├── Native
├── HARDWAREINPUT.cs
├── INPUT.cs
├── InputType.cs
├── KEYBDINPUT.cs
├── KeyboardFlag.cs
├── MOUSEINPUT.cs
├── MOUSEKEYBDHARDWAREINPUT.cs
├── MouseFlag.cs
├── NativeMethods.cs
├── VirtualKeyCode.cs
└── XButton.cs
├── Properties
└── AssemblyInfo.cs
├── WindowsInput.csproj
├── WindowsInput.nuspec
├── WindowsInput.snk
├── WindowsInputDeviceStateAdaptor.cs
└── WindowsInputMessageDispatcher.cs
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | [Xx]64/
19 | [Xx]86/
20 | [Bb]uild/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 | [Bb]uilds/
25 | [Bb]uild/
26 | Installer/RemoteDesktop.Client-cache
27 | Installer/RemoteDesktop.Client-SetupFiles
28 | Installer/RemoteDesktop.Server-cache
29 | Installer/RemoteDesktop.Server-SetupFiles
30 |
31 | # Visual Studio 2015 cache/options directory
32 | .vs/
33 | # Uncomment if you have tasks that create the project's static files in wwwroot
34 | #wwwroot/
35 |
36 | # MSTest test Results
37 | [Tt]est[Rr]esult*/
38 | [Bb]uild[Ll]og.*
39 |
40 | # NUNIT
41 | *.VisualState.xml
42 | TestResult.xml
43 |
44 | # Build Results of an ATL Project
45 | [Dd]ebugPS/
46 | [Rr]eleasePS/
47 | dlldata.c
48 |
49 | # DNX
50 | project.lock.json
51 | artifacts/
52 |
53 | *_i.c
54 | *_p.c
55 | *_i.h
56 | *.ilk
57 | *.meta
58 | *.obj
59 | *.pch
60 | *.pdb
61 | *.pgc
62 | *.pgd
63 | *.rsp
64 | *.sbr
65 | *.tlb
66 | *.tli
67 | *.tlh
68 | *.tmp
69 | *.tmp_proj
70 | *.log
71 | *.vspscc
72 | *.vssscc
73 | .builds
74 | *.pidb
75 | *.svclog
76 | *.scc
77 |
78 | # Chutzpah Test files
79 | _Chutzpah*
80 |
81 | # Visual C++ cache files
82 | ipch/
83 | *.aps
84 | *.ncb
85 | *.opendb
86 | *.opensdf
87 | *.sdf
88 | *.cachefile
89 | *.VC.db
90 |
91 | # Visual Studio profiler
92 | *.psess
93 | *.vsp
94 | *.vspx
95 | *.sap
96 |
97 | # TFS 2012 Local Workspace
98 | $tf/
99 |
100 | # Guidance Automation Toolkit
101 | *.gpState
102 |
103 | # ReSharper is a .NET coding add-in
104 | _ReSharper*/
105 | *.[Rr]e[Ss]harper
106 | *.DotSettings.user
107 |
108 | # JustCode is a .NET coding add-in
109 | .JustCode
110 |
111 | # TeamCity is a build add-in
112 | _TeamCity*
113 |
114 | # DotCover is a Code Coverage Tool
115 | *.dotCover
116 |
117 | # NCrunch
118 | _NCrunch_*
119 | .*crunch*.local.xml
120 | nCrunchTemp_*
121 |
122 | # MightyMoose
123 | *.mm.*
124 | AutoTest.Net/
125 |
126 | # Web workbench (sass)
127 | .sass-cache/
128 |
129 | # Installshield output folder
130 | [Ee]xpress/
131 |
132 | # DocProject is a documentation generator add-in
133 | DocProject/buildhelp/
134 | DocProject/Help/*.HxT
135 | DocProject/Help/*.HxC
136 | DocProject/Help/*.hhc
137 | DocProject/Help/*.hhk
138 | DocProject/Help/*.hhp
139 | DocProject/Help/Html2
140 | DocProject/Help/html
141 |
142 | # Click-Once directory
143 | publish/
144 |
145 | # Publish Web Output
146 | *.[Pp]ublish.xml
147 | *.azurePubxml
148 |
149 | # TODO: Un-comment the next line if you do not want to checkin
150 | # your web deploy settings because they may include unencrypted
151 | # passwords
152 | #*.pubxml
153 | *.publishproj
154 |
155 | # NuGet Packages
156 | *.nupkg
157 | # The packages folder can be ignored because of Package Restore
158 | **/packages/*
159 | # except build/, which is used as an MSBuild target.
160 | !**/packages/build/
161 | # Uncomment if necessary however generally it will be regenerated when needed
162 | #!**/packages/repositories.config
163 | # NuGet v3's project.json files produces more ignoreable files
164 | *.nuget.props
165 | *.nuget.targets
166 |
167 | # Microsoft Azure Build Output
168 | csx/
169 | *.build.csdef
170 |
171 | # Microsoft Azure Emulator
172 | ecf/
173 | rcf/
174 |
175 | # Microsoft Azure ApplicationInsights config file
176 | ApplicationInsights.config
177 |
178 | # Windows Store app package directory
179 | AppPackages/
180 | BundleArtifacts/
181 |
182 | # Visual Studio cache files
183 | # files ending in .cache can be ignored
184 | *.[Cc]ache
185 | # but keep track of directories ending in .cache
186 | !*.[Cc]ache/
187 |
188 | # Others
189 | ClientBin/
190 | [Ss]tyle[Cc]op.*
191 | ~$*
192 | *~
193 | *.dbmdl
194 | *.dbproj.schemaview
195 | *.pfx
196 | *.publishsettings
197 | node_modules/
198 | orleans.codegen.cs
199 |
200 | # RIA/Silverlight projects
201 | Generated_Code/
202 |
203 | # Backup & report files from converting an old project file
204 | # to a newer Visual Studio version. Backup files are not needed,
205 | # because we have git ;-)
206 | _UpgradeReport_Files/
207 | Backup*/
208 | UpgradeLog*.XML
209 | UpgradeLog*.htm
210 |
211 | # SQL Server files
212 | *.mdf
213 | *.ldf
214 |
215 | # Business Intelligence projects
216 | *.rdl.data
217 | *.bim.layout
218 | *.bim_*.settings
219 |
220 | # Microsoft Fakes
221 | FakesAssemblies/
222 |
223 | # GhostDoc plugin setting file
224 | *.GhostDoc.xml
225 |
226 | # Node.js Tools for Visual Studio
227 | .ntvs_analysis.dat
228 |
229 | # Visual Studio 6 build log
230 | *.plg
231 |
232 | # Visual Studio 6 workspace options file
233 | *.opt
234 |
235 | # Visual Studio LightSwitch build output
236 | **/*.HTMLClient/GeneratedArtifacts
237 | **/*.DesktopClient/GeneratedArtifacts
238 | **/*.DesktopClient/ModelManifest.xml
239 | **/*.Server/GeneratedArtifacts
240 | **/*.Server/ModelManifest.xml
241 | _Pvt_Extensions
242 |
243 | # LightSwitch generated files
244 | GeneratedArtifacts/
245 | ModelManifest.xml
246 |
247 | # Paket dependency manager
248 | .paket/paket.exe
249 |
250 | # FAKE - F# Make
251 | .fake/
252 |
253 | # Installer
254 | Installer/Setup Files/
255 | Installer/Git-It-GUI_Installer-cache/
256 |
257 | *.gititgui
258 | *.gititgui-user
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Remote Desktop (Zero Configuration / P2P)
2 | A simple remote desktop P2P server/client application for Windows
3 |
--------------------------------------------------------------------------------
/RemoteDesktop.Client/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/RemoteDesktop.Client/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/RemoteDesktop.Client/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace RemoteDesktop.Client
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/RemoteDesktop.Client/Images/AppIcon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zezba9000/RemoteDesktop/1e57faabf6056e2692711dbffa0982fbb1975eac/RemoteDesktop.Client/Images/AppIcon.ico
--------------------------------------------------------------------------------
/RemoteDesktop.Client/Images/AppIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zezba9000/RemoteDesktop/1e57faabf6056e2692711dbffa0982fbb1975eac/RemoteDesktop.Client/Images/AppIcon.png
--------------------------------------------------------------------------------
/RemoteDesktop.Client/Images/NotConnected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zezba9000/RemoteDesktop/1e57faabf6056e2692711dbffa0982fbb1975eac/RemoteDesktop.Client/Images/NotConnected.png
--------------------------------------------------------------------------------
/RemoteDesktop.Client/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/RemoteDesktop.Client/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("RemoteDesktop.Client")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("RemoteDesktop.Client")]
15 | [assembly: AssemblyCopyright("Copyright © 2017")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/RemoteDesktop.Client/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 RemoteDesktop.Client.Properties
12 | {
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", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RemoteDesktop.Client.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/RemoteDesktop.Client/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 |
--------------------------------------------------------------------------------
/RemoteDesktop.Client/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 RemoteDesktop.Client.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/RemoteDesktop.Client/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/RemoteDesktop.Client/RemoteDesktop.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {D13130D1-0C98-43F6-8221-23F607D618E2}
8 | WinExe
9 | RemoteDesktop.Client
10 | RemoteDesktop.Client
11 | v4.7
12 | 512
13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
14 | 4
15 | true
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 | true
27 |
28 |
29 | AnyCPU
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 | true
37 |
38 |
39 | Images\AppIcon.ico
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | 4.0
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | MSBuild:Compile
61 | Designer
62 |
63 |
64 | SettingOverlay.xaml
65 |
66 |
67 | MSBuild:Compile
68 | Designer
69 |
70 |
71 | App.xaml
72 | Code
73 |
74 |
75 | MainWindow.xaml
76 | Code
77 |
78 |
79 | Designer
80 | MSBuild:Compile
81 |
82 |
83 |
84 |
85 | Code
86 |
87 |
88 | True
89 | True
90 | Resources.resx
91 |
92 |
93 | True
94 | Settings.settings
95 | True
96 |
97 |
98 | ResXFileCodeGenerator
99 | Resources.Designer.cs
100 |
101 |
102 | SettingsSingleFileGenerator
103 | Settings.Designer.cs
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 | {b53e8545-94ca-466b-98d4-d6b46422f2f2}
112 | RemoteDesktop.Core
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 | PreserveNewest
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/RemoteDesktop.Client/SettingOverlay.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 | 16 bit
15 | 24 bit
16 |
17 |
18 |
19 |
20 | 100%
21 | 75%
22 | 50%
23 | 25%
24 |
25 |
26 |
27 |
28 | 5
29 | 10
30 | 15
31 | 30
32 | 60
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/RemoteDesktop.Client/SettingOverlay.xaml.cs:
--------------------------------------------------------------------------------
1 | using RemoteDesktop.Core;
2 | using System;
3 | using System.IO;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Xml.Serialization;
7 |
8 | namespace RemoteDesktop.Client
9 | {
10 | namespace XML
11 | {
12 | public class CustomSocketAddress
13 | {
14 | [XmlAttribute("Enabled")] public bool enabled = false;
15 | [XmlText] public string address;
16 | }
17 |
18 | [XmlRoot]
19 | public class Settings
20 | {
21 | [XmlElement("ImageBit")] public int imageBit = 16;
22 | [XmlElement("ImageScale")] public float imageScale = .75f;
23 | [XmlElement("CompressImageFrames")] public bool compressImageFrames = true;
24 | [XmlElement("CustomSocketAddress")] public CustomSocketAddress customSocketAddress = new CustomSocketAddress();
25 | [XmlElement("TargetFPS")] public int targetFPS = 10;
26 | }
27 | }
28 |
29 | ///
30 | /// Interaction logic for SettingOverlay.xaml
31 | ///
32 | public partial class SettingOverlay : UserControl
33 | {
34 | public delegate void ApplyCallbackMethod();
35 | public event ApplyCallbackMethod ApplyCallback;
36 |
37 | private string filePath;
38 | public XML.Settings settings;
39 |
40 | public SettingOverlay()
41 | {
42 | InitializeComponent();
43 |
44 | string dataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RemoteDesktop");
45 | if (!Directory.Exists(dataPath)) Directory.CreateDirectory(dataPath);
46 | filePath = Path.Combine(dataPath, "Settings.xml");
47 | if (File.Exists(filePath))
48 | {
49 | try
50 | {
51 | using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.None))
52 | {
53 | var xml = new XmlSerializer(typeof(XML.Settings));
54 | settings = (XML.Settings)xml.Deserialize(stream);
55 | }
56 | }
57 | catch (Exception e)
58 | {
59 | DebugLog.LogError("Failed to load settings file: " + e.Message);
60 | settings = new XML.Settings();
61 | }
62 | }
63 | else
64 | {
65 | settings = new XML.Settings();
66 | }
67 | }
68 |
69 | public void SaveSettings()
70 | {
71 | try
72 | {
73 | using (var stream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None))
74 | {
75 | var xml = new XmlSerializer(typeof(XML.Settings));
76 | xml.Serialize(stream, settings);
77 | }
78 | }
79 | catch (Exception e)
80 | {
81 | DebugLog.LogError("Failed to save settings file: " + e.Message);
82 | }
83 | }
84 |
85 | public void Show()
86 | {
87 | imageBitComboBox.SelectedIndex = settings.imageBit == 24 ? 1 : 0;
88 |
89 | switch (settings.imageScale)
90 | {
91 | case 1.0f: imageScaleComboBox.SelectedIndex = 0; break;
92 | case .75f: imageScaleComboBox.SelectedIndex = 1; break;
93 | case .5f: imageScaleComboBox.SelectedIndex = 2; break;
94 | case .25f: imageScaleComboBox.SelectedIndex = 3; break;
95 | }
96 |
97 | switch (settings.targetFPS)
98 | {
99 | case 5: targetFPSComboBox.SelectedIndex = 0; break;
100 | case 10: targetFPSComboBox.SelectedIndex = 1; break;
101 | case 15: targetFPSComboBox.SelectedIndex = 2; break;
102 | case 30: targetFPSComboBox.SelectedIndex = 3; break;
103 | case 60: targetFPSComboBox.SelectedIndex = 4; break;
104 | }
105 |
106 | compressCheckBox.IsChecked = settings.compressImageFrames;
107 | customAddressCheckBox.IsChecked = settings.customSocketAddress.enabled;
108 |
109 | Visibility = Visibility.Visible;
110 | }
111 |
112 | private void applyButton_Click(object sender, RoutedEventArgs e)
113 | {
114 | settings.imageBit = imageBitComboBox.SelectedIndex == 0 ? 16 : 24;
115 |
116 | switch (imageScaleComboBox.SelectedIndex)
117 | {
118 | case 0: settings.imageScale = 1.0f; break;
119 | case 1: settings.imageScale = .75f; break;
120 | case 2: settings.imageScale = .5f; break;
121 | case 3: settings.imageScale = .25f; break;
122 | }
123 |
124 | switch (targetFPSComboBox.SelectedIndex)
125 | {
126 | case 0: settings.targetFPS = 5; break;
127 | case 1: settings.targetFPS = 10; break;
128 | case 2: settings.targetFPS = 15; break;
129 | case 3: settings.targetFPS = 30; break;
130 | case 4: settings.targetFPS = 60; break;
131 | }
132 |
133 | settings.compressImageFrames = compressCheckBox.IsChecked == true;
134 | settings.customSocketAddress.enabled = customAddressCheckBox.IsChecked == true;
135 |
136 | Visibility = Visibility.Hidden;
137 | if (ApplyCallback != null) ApplyCallback();
138 | }
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/RemoteDesktop.Client/Settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16
4 | 0.75
5 | true
6 | 0.0.0.0
7 | 10
8 |
--------------------------------------------------------------------------------
/RemoteDesktop.Core/DebugLog.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace RemoteDesktop.Core
4 | {
5 | public static class DebugLog
6 | {
7 | private static void Write(string message)
8 | {
9 | Console.WriteLine(message);
10 | }
11 |
12 | public static void Log(string message)
13 | {
14 | Write(message);
15 | }
16 |
17 | public static void LogWarning(string message)
18 | {
19 | Write("WARNING: " + message);
20 | }
21 |
22 | public static void LogError(string message)
23 | {
24 | Write("ERROR: " + message);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/RemoteDesktop.Core/NetworkDiscovery.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | using System.Net;
5 | using System.Net.PeerToPeer;
6 | using System.Net.Sockets;
7 |
8 | namespace RemoteDesktop.Core
9 | {
10 | public enum NetworkTypes
11 | {
12 | Server,
13 | Client
14 | }
15 |
16 | public class NetworkHost
17 | {
18 | public List endpoints;
19 | public string name;
20 |
21 | public NetworkHost(string name)
22 | {
23 | this.name = name;
24 | endpoints = new List();
25 | }
26 |
27 | public override string ToString()
28 | {
29 | return name;
30 | }
31 | }
32 |
33 | public class NetworkDiscovery : IDisposable
34 | {
35 | private NetworkTypes type;
36 |
37 | // server
38 | private PeerName peerName;
39 | private PeerNameRegistration peerNameRegistration;
40 |
41 | // client
42 | private PeerNameResolver peerNameResolver;
43 |
44 | public NetworkDiscovery(NetworkTypes type)
45 | {
46 | this.type = type;
47 | }
48 |
49 | public void Register(string name, int port)
50 | {
51 | if (type != NetworkTypes.Server) throw new Exception("Only allowed for server!");
52 |
53 | peerName = new PeerName(name, PeerNameType.Unsecured);
54 | peerNameRegistration = new PeerNameRegistration();
55 | peerNameRegistration.PeerName = peerName;
56 | peerNameRegistration.Comment = Dns.GetHostName();
57 | peerNameRegistration.Port = port;
58 | peerNameRegistration.Start();
59 | }
60 |
61 | public List Find(string name)
62 | {
63 | if (type != NetworkTypes.Client) throw new Exception("Only allowed for client!");
64 |
65 | var hosts = new List();
66 | peerNameResolver = new PeerNameResolver();
67 | peerName = new PeerName(name, PeerNameType.Unsecured);
68 | var results = peerNameResolver.Resolve(peerName);
69 | foreach (var record in results)
70 | {
71 | var host = new NetworkHost(record.Comment);
72 | foreach (var endpoint in record.EndPointCollection)
73 | {
74 | if (endpoint.AddressFamily == AddressFamily.InterNetwork)
75 | {
76 | Console.WriteLine(string.Format("Found EndPoint {0}:{1}", endpoint.Address, endpoint.Port));
77 | host.endpoints.Add(endpoint);
78 | }
79 | }
80 |
81 | if (host.endpoints.Count != 0) hosts.Add(host);
82 | }
83 |
84 | return hosts;
85 | }
86 |
87 | public void Dispose()
88 | {
89 | if (peerNameRegistration != null)
90 | {
91 | peerNameRegistration.Stop();
92 | peerNameRegistration = null;
93 | }
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/RemoteDesktop.Core/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("RemoteDesktop.Core")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("RemoteDesktop.Core")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("b53e8545-94ca-466b-98d4-d6b46422f2f2")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/RemoteDesktop.Core/RemoteDesktop.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {B53E8545-94CA-466B-98D4-D6B46422F2F2}
8 | Library
9 | Properties
10 | RemoteDesktop.Core
11 | RemoteDesktop.Core
12 | v4.7
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 | true
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 | true
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/RemoteDesktop.Core/Utils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 | using System.Security;
4 |
5 | namespace RemoteDesktop.Core
6 | {
7 | public static class Utils
8 | {
9 | [SuppressUnmanagedCodeSecurity]
10 | [DllImport("kernel32.dll", CallingConvention = CallingConvention.StdCall)]
11 | public static extern void RtlZeroMemory(IntPtr dst, IntPtr length);
12 |
13 | [SuppressUnmanagedCodeSecurity]
14 | [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
15 | public static extern IntPtr memset(IntPtr dest, int c, IntPtr count);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/RemoteDesktop.Server/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/RemoteDesktop.Server/Images/AppIcon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zezba9000/RemoteDesktop/1e57faabf6056e2692711dbffa0982fbb1975eac/RemoteDesktop.Server/Images/AppIcon.ico
--------------------------------------------------------------------------------
/RemoteDesktop.Server/MainForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace RemoteDesktop.Server
2 | {
3 | partial class MainForm
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.pictureBox = new System.Windows.Forms.PictureBox();
32 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
33 | this.SuspendLayout();
34 | //
35 | // pictureBox
36 | //
37 | this.pictureBox.Location = new System.Drawing.Point(12, 12);
38 | this.pictureBox.Name = "pictureBox";
39 | this.pictureBox.Size = new System.Drawing.Size(569, 317);
40 | this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
41 | this.pictureBox.TabIndex = 1;
42 | this.pictureBox.TabStop = false;
43 | //
44 | // MainForm
45 | //
46 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
47 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
48 | this.ClientSize = new System.Drawing.Size(593, 341);
49 | this.Controls.Add(this.pictureBox);
50 | this.Name = "MainForm";
51 | this.Text = "Remote Desktop";
52 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
53 | this.ResumeLayout(false);
54 |
55 | }
56 |
57 | #endregion
58 | private System.Windows.Forms.PictureBox pictureBox;
59 | }
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/RemoteDesktop.Server/MainForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 | using System.Drawing.Imaging;
11 |
12 | using RemoteDesktop.Core;
13 |
14 | namespace RemoteDesktop.Server
15 | {
16 | // NOTE: this window is only for debugging
17 | public partial class MainForm : Form
18 | {
19 | private Bitmap bitmap;
20 | private Graphics graphics;
21 | private Timer timer;
22 |
23 | public MainForm()
24 | {
25 | InitializeComponent();
26 |
27 | timer = new Timer();
28 | timer.Interval = 1000 / 60;
29 | timer.Tick += Timer_Tick;
30 | timer.Start();
31 | }
32 |
33 | protected override void OnSizeChanged(EventArgs e)
34 | {
35 | var size = this.ClientSize;
36 | pictureBox.Size = new Size(size.Width - 20, size.Height - 20);
37 | pictureBox.Location = new Point(10, 10);
38 | base.OnSizeChanged(e);
39 | }
40 |
41 | protected override void OnClosing(CancelEventArgs e)
42 | {
43 | if (graphics != null)
44 | {
45 | graphics.Dispose();
46 | graphics = null;
47 | }
48 |
49 | if (bitmap != null)
50 | {
51 | bitmap.Dispose();
52 | bitmap = null;
53 | }
54 |
55 | base.OnClosing(e);
56 | }
57 |
58 | private void Timer_Tick(object sender, EventArgs e)
59 | {
60 | CaptureScreen();
61 | if (pictureBox.Image == null) pictureBox.Image = bitmap;
62 | else pictureBox.Refresh();
63 | }
64 |
65 | private void CaptureScreen()
66 | {
67 | if (bitmap == null)
68 | {
69 | var screen = Screen.FromControl(this);
70 | var screenRect = screen.WorkingArea;
71 |
72 | bitmap = new Bitmap(screenRect.Width, screenRect.Height, PixelFormat.Format32bppRgb);
73 | graphics = Graphics.FromImage(bitmap);
74 | }
75 |
76 | graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/RemoteDesktop.Server/MainForm.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 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/RemoteDesktop.Server/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace RemoteDesktop.Server
5 | {
6 | static class Program
7 | {
8 | [STAThread]
9 | static void Main(string[] args)
10 | {
11 | // parse args
12 | bool isDebugMode = false;
13 | int port = 8888;
14 | foreach (var arg in args)
15 | {
16 | if (arg == "debug") isDebugMode = true;
17 | else if (arg.StartsWith("port=")) port = int.Parse(arg.Split('=')[1]);
18 | }
19 |
20 | // start app
21 | Application.EnableVisualStyles();
22 | Application.SetCompatibleTextRenderingDefault(false);
23 | if (isDebugMode) Application.Run(new MainForm());
24 | else Application.Run(new MainApplicationContext(port));
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/RemoteDesktop.Server/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("RemoteDesktop.Server")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("RemoteDesktop.Server")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("ccd86430-e6f8-4b8c-81cc-c2376eef0c6d")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/RemoteDesktop.Server/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 RemoteDesktop.Server.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", "15.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("RemoteDesktop.Server.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 |
--------------------------------------------------------------------------------
/RemoteDesktop.Server/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 |
--------------------------------------------------------------------------------
/RemoteDesktop.Server/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 RemoteDesktop.Server.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.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 |
--------------------------------------------------------------------------------
/RemoteDesktop.Server/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/RemoteDesktop.Server/RemoteDesktop.Server.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {CCD86430-E6F8-4B8C-81CC-C2376EEF0C6D}
8 | WinExe
9 | RemoteDesktop.Server
10 | RemoteDesktop.Server
11 | v4.7
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 | app_debug.manifest
36 |
37 |
38 | app.manifest
39 |
40 |
41 | Images\AppIcon.ico
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | Form
62 |
63 |
64 | MainForm.cs
65 |
66 |
67 |
68 |
69 | MainForm.cs
70 |
71 |
72 | ResXFileCodeGenerator
73 | Resources.Designer.cs
74 | Designer
75 |
76 |
77 | True
78 | Resources.resx
79 | True
80 |
81 |
82 |
83 |
84 | SettingsSingleFileGenerator
85 | Settings.Designer.cs
86 |
87 |
88 | True
89 | Settings.settings
90 | True
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 | {3549cd6f-80f8-450f-b99e-cf0a736b1f2a}
99 | WindowsInput
100 |
101 |
102 | {b53e8545-94ca-466b-98d4-d6b46422f2f2}
103 | RemoteDesktop.Core
104 |
105 |
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/RemoteDesktop.Server/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
52 |
59 |
60 |
61 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/RemoteDesktop.Server/app_debug.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
52 |
59 |
60 |
61 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/RemoteDesktop.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26730.15
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemoteDesktop.Core", "RemoteDesktop.Core\RemoteDesktop.Core.csproj", "{B53E8545-94CA-466B-98D4-D6B46422F2F2}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemoteDesktop.Client", "RemoteDesktop.Client\RemoteDesktop.Client.csproj", "{D13130D1-0C98-43F6-8221-23F607D618E2}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemoteDesktop.Server", "RemoteDesktop.Server\RemoteDesktop.Server.csproj", "{CCD86430-E6F8-4B8C-81CC-C2376EEF0C6D}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsInput", "inputsimulator\WindowsInput\WindowsInput.csproj", "{3549CD6F-80F8-450F-B99E-CF0A736B1F2A}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Any CPU = Debug|Any CPU
17 | Release|Any CPU = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {B53E8545-94CA-466B-98D4-D6B46422F2F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {B53E8545-94CA-466B-98D4-D6B46422F2F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {B53E8545-94CA-466B-98D4-D6B46422F2F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {B53E8545-94CA-466B-98D4-D6B46422F2F2}.Release|Any CPU.Build.0 = Release|Any CPU
24 | {D13130D1-0C98-43F6-8221-23F607D618E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {D13130D1-0C98-43F6-8221-23F607D618E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {D13130D1-0C98-43F6-8221-23F607D618E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {D13130D1-0C98-43F6-8221-23F607D618E2}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {CCD86430-E6F8-4B8C-81CC-C2376EEF0C6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {CCD86430-E6F8-4B8C-81CC-C2376EEF0C6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {CCD86430-E6F8-4B8C-81CC-C2376EEF0C6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {CCD86430-E6F8-4B8C-81CC-C2376EEF0C6D}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {3549CD6F-80F8-450F-B99E-CF0A736B1F2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {3549CD6F-80F8-450F-B99E-CF0A736B1F2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {3549CD6F-80F8-450F-B99E-CF0A736B1F2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
35 | {3549CD6F-80F8-450F-B99E-CF0A736B1F2A}.Release|Any CPU.Build.0 = Release|Any CPU
36 | EndGlobalSection
37 | GlobalSection(SolutionProperties) = preSolution
38 | HideSolutionNode = FALSE
39 | EndGlobalSection
40 | GlobalSection(ExtensibilityGlobals) = postSolution
41 | SolutionGuid = {83C1738E-2C11-4CDF-8A3A-944D3AC6C600}
42 | EndGlobalSection
43 | EndGlobal
44 |
--------------------------------------------------------------------------------
/inputsimulator/.gitignore:
--------------------------------------------------------------------------------
1 | #OS junk files
2 | [Tt]humbs.db
3 | *.DS_Store
4 |
5 | #Visual Studio files
6 | *.[Oo]bj
7 | *.user
8 | *.aps
9 | *.pch
10 | *.vspscc
11 | *.vssscc
12 | *_i.c
13 | *_p.c
14 | *.ncb
15 | *.suo
16 | *.tlb
17 | *.tlh
18 | *.bak
19 | *.[Cc]ache
20 | *.ilk
21 | *.log
22 | *.lib
23 | *.sbr
24 | *.sdf
25 | *.opensdf
26 | *.unsuccessfulbuild
27 | ipch/
28 | obj/
29 | [Bb]in
30 | [Dd]ebug*/
31 | [Rr]elease*/
32 | Ankh.NoLoad
33 |
34 | #MonoDevelop
35 | *.pidb
36 | *.userprefs
37 |
38 | #Tooling
39 | _ReSharper*/
40 | *.resharper
41 | [Tt]est[Rr]esult*
42 | *.sass-cache
43 |
44 | #Project files
45 | [Bb]uild/
46 |
47 | #Subversion files
48 | .svn
49 |
50 | # Office Temp Files
51 | ~$*
52 |
53 | #NuGet
54 | packages/
55 |
56 | #ncrunch
57 | *ncrunch*
58 | *crunch*.local.xml
59 |
60 | # visual studio database projects
61 | *.dbmdl
62 |
63 | #Test files
64 | *.testsettings
65 |
--------------------------------------------------------------------------------
/inputsimulator/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/inputsimulator/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zezba9000/RemoteDesktop/1e57faabf6056e2692711dbffa0982fbb1975eac/inputsimulator/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/inputsimulator/.nuget/NuGet.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildProjectDirectory)\..\
5 |
6 |
7 | false
8 |
9 |
10 | false
11 |
12 |
13 | true
14 |
15 |
16 | false
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
29 |
30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
31 | $([System.IO.Path]::Combine($(ProjectDir), "packages.config"))
32 | $([System.IO.Path]::Combine($(SolutionDir), "packages"))
33 |
34 |
35 |
36 |
37 | $(SolutionDir).nuget
38 | packages.config
39 | $(SolutionDir)packages
40 |
41 |
42 |
43 |
44 | $(NuGetToolsPath)\nuget.exe
45 | @(PackageSource)
46 |
47 | "$(NuGetExePath)"
48 | mono --runtime=v4.0.30319 $(NuGetExePath)
49 |
50 | $(TargetDir.Trim('\\'))
51 |
52 | -RequireConsent
53 |
54 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -o "$(PackagesDir)"
55 | $(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols
56 |
57 |
58 |
59 | RestorePackages;
60 | $(BuildDependsOn);
61 |
62 |
63 |
64 |
65 | $(BuildDependsOn);
66 | BuildPackage;
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
89 |
90 |
93 |
94 |
95 |
96 |
98 |
99 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
150 |
151 |
152 |
153 |
--------------------------------------------------------------------------------
/inputsimulator/BuildProcessTemplates/UpgradeTemplate.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | [New Microsoft.TeamFoundation.Build.Workflow.Activities.AgentSettings() With {.MaxWaitTime = New System.TimeSpan(4, 0, 0), .MaxExecutionTime = New System.TimeSpan(0, 0, 0), .TagComparison = Microsoft.TeamFoundation.Build.Workflow.Activities.TagComparison.MatchExactly }]
21 |
22 |
23 |
24 | [Microsoft.TeamFoundation.Build.Workflow.Activities.ToolPlatform.Auto]
25 | [False]
26 | [False]
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | [Microsoft.TeamFoundation.VersionControl.Client.RecursionType.OneLevel]
37 | [Microsoft.TeamFoundation.Build.Workflow.BuildVerbosity.Normal]
38 |
39 |
40 |
41 | All
42 | Assembly references and imported namespaces serialized as XML namespaces
43 |
44 |
45 |
46 |
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 |
--------------------------------------------------------------------------------
/inputsimulator/README.md:
--------------------------------------------------------------------------------
1 | Windows Input Simulator (C# SendInput Wrapper - Simulate Keyboard and Mouse)
2 | ============================================================================
3 | The Windows Input Simulator provides a simple .NET (C#) interface to simulate Keyboard or Mouse input using the Win32 SendInput method. All of the Interop is done for you and there's a simple programming model for sending multiple keystrokes.
4 |
5 | Windows Forms provides the SendKeys method which can simulate text entry, but not actual key strokes. Windows Input Simulator can be used in WPF, Windows Forms and Console Applications to synthesize or simulate any Keyboard input including Control, Alt, Shift, Tab, Enter, Space, Backspace, the Windows Key, Caps Lock, Num Lock, Scroll Lock, Volume Up/Down and Mute, Web, Mail, Search, Favorites, Function Keys, Back and Forward navigation keys, Programmable keys and any other key defined in the Virtual Key table. It provides a simple API to simulate text entry, key down, key up, key press and complex modified key strokes and chords.
6 |
7 | Examples
8 | ==========
9 |
10 | Example: Single key press
11 | -------------
12 | ```csharp
13 | public void PressTheSpacebar()
14 | {
15 | InputSimulator.SimulateKeyPress(VirtualKeyCode.SPACE);
16 | }
17 | ```
18 |
19 | Example: Key-down and Key-up
20 | ------------
21 | ```csharp
22 | public void ShoutHello()
23 | {
24 | // Simulate each key stroke
25 | InputSimulator.SimulateKeyDown(VirtualKeyCode.SHIFT);
26 | InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_H);
27 | InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_E);
28 | InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_L);
29 | InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_L);
30 | InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_O);
31 | InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_1);
32 | InputSimulator.SimulateKeyUp(VirtualKeyCode.SHIFT);
33 |
34 | // Alternatively you can simulate text entry to acheive the same end result
35 | InputSimulator.SimulateTextEntry("HELLO!");
36 | }
37 | ```
38 |
39 | Example: Modified keystrokes such as CTRL-C
40 | --------------
41 | ```csharp
42 | public void SimulateSomeModifiedKeystrokes()
43 | {
44 | // CTRL-C (effectively a copy command in many situations)
45 | InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_C);
46 |
47 | // You can simulate chords with multiple modifiers
48 | // For example CTRL-K-C whic is simulated as
49 | // CTRL-down, K, C, CTRL-up
50 | InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, new [] {VirtualKeyCode.VK_K, VirtualKeyCode.VK_C});
51 |
52 | // You can simulate complex chords with multiple modifiers and key presses
53 | // For example CTRL-ALT-SHIFT-ESC-K which is simulated as
54 | // CTRL-down, ALT-down, SHIFT-down, press ESC, press K, SHIFT-up, ALT-up, CTRL-up
55 | InputSimulator.SimulateModifiedKeyStroke(
56 | new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.MENU, VirtualKeyCode.SHIFT },
57 | new[] { VirtualKeyCode.ESCAPE, VirtualKeyCode.VK_K });
58 | }
59 | ```
60 |
61 | Example: Simulate text entry
62 | --------
63 | ```csharp
64 | public void SayHello()
65 | {
66 | InputSimulator.SimulateTextEntry("Say hello!");
67 | }
68 | ```
69 |
70 | Example: Determine the state of different types of keys
71 | ------------
72 | ```csharp
73 | public void GetKeyStatus()
74 | {
75 | // Determines if the shift key is currently down
76 | var isShiftKeyDown = InputSimulator.IsKeyDown(VirtualKeyCode.SHIFT);
77 |
78 | // Determines if the caps lock key is currently in effect (toggled on)
79 | var isCapsLockOn = InputSimulator.IsTogglingKeyInEffect(VirtualKeyCode.CAPITAL);
80 | }
81 | ```
82 |
83 | History
84 | ============
85 | It was originally written for use in the WpfKB (WPF Touch Screen Keyboard) project to simulate real keyboard entry to the active window. After looking for a comprehensive wrapper for the Win32 and User32 input simulation methods and coming up dry I decided to write and open-source this project. I hope it helps someone out there!
86 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.SampleClient.Wpf/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.SampleClient.Wpf/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Windows;
7 |
8 | namespace InputSimulator.SampleClient.Wpf
9 | {
10 | ///
11 | /// Interaction logic for App.xaml
12 | ///
13 | public partial class App : Application
14 | {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.SampleClient.Wpf/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.SampleClient.Wpf/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Data;
8 | using System.Windows.Documents;
9 | using System.Windows.Input;
10 | using System.Windows.Media;
11 | using System.Windows.Media.Imaging;
12 | using System.Windows.Navigation;
13 | using System.Windows.Shapes;
14 |
15 | namespace InputSimulator.SampleClient.Wpf
16 | {
17 | ///
18 | /// Interaction logic for MainWindow.xaml
19 | ///
20 | public partial class MainWindow : Window
21 | {
22 | public MainWindow()
23 | {
24 | InitializeComponent();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.SampleClient.Wpf/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("InputSimulator.SampleClient.Wpf")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("Microsoft")]
14 | [assembly: AssemblyProduct("InputSimulator.SampleClient.Wpf")]
15 | [assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.SampleClient.Wpf/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30128.1
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 InputSimulator.SampleClient.Wpf.Properties
12 | {
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", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("InputSimulator.SampleClient.Wpf.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.SampleClient.Wpf/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 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.SampleClient.Wpf/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30128.1
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 InputSimulator.SampleClient.Wpf.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.SampleClient.Wpf/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.SampleClient.Wpf/WindowsInput.SampleClient.Wpf.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {DE70B414-25CB-4C64-82EE-3955FECDF762}
9 | WinExe
10 | Properties
11 | InputSimulator.SampleClient.Wpf
12 | InputSimulator.SampleClient.Wpf
13 | v4.0
14 | Client
15 | 512
16 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
17 | 4
18 |
19 |
20 | x86
21 | true
22 | full
23 | false
24 | bin\Debug\
25 | DEBUG;TRACE
26 | prompt
27 | 4
28 |
29 |
30 | x86
31 | pdbonly
32 | true
33 | bin\Release\
34 | TRACE
35 | prompt
36 | 4
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | 4.0
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | MSBuild:Compile
56 | Designer
57 |
58 |
59 | MSBuild:Compile
60 | Designer
61 |
62 |
63 | App.xaml
64 | Code
65 |
66 |
67 | MainWindow.xaml
68 | Code
69 |
70 |
71 |
72 |
73 | Code
74 |
75 |
76 | True
77 | True
78 | Resources.resx
79 |
80 |
81 | True
82 | Settings.settings
83 | True
84 |
85 |
86 | ResXFileCodeGenerator
87 | Resources.Designer.cs
88 |
89 |
90 | SettingsSingleFileGenerator
91 | Settings.Designer.cs
92 |
93 |
94 |
95 |
96 |
97 | {3549CD6F-80F8-450F-B99E-CF0A736B1F2A}
98 | InputSimulator
99 |
100 |
101 |
102 |
109 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.Tests/InputBuilderTests.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using NUnit.Framework;
3 | using WindowsInput.Native;
4 |
5 | namespace WindowsInput.Tests
6 | {
7 | [TestFixture]
8 | public class InputBuilderTests
9 | {
10 | [Test]
11 | public void AddKeyDown()
12 | {
13 | var builder = new InputBuilder();
14 | Assert.That(builder.ToArray(), Is.Empty);
15 | builder.AddKeyDown(VirtualKeyCode.VK_A);
16 | Assert.That(builder.Count(), Is.EqualTo(1));
17 | Assert.That(builder[0].Type, Is.EqualTo((uint)InputType.Keyboard));
18 | Assert.That(builder[0].Data.Keyboard.KeyCode, Is.EqualTo((ushort)VirtualKeyCode.VK_A));
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.Tests/InputSimulatorExamples.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 | using WindowsInput.Native;
3 |
4 | namespace WindowsInput.Tests
5 | {
6 | [TestFixture]
7 | public class InputSimulatorExamples
8 | {
9 | [Test]
10 | [Explicit]
11 | public void OpenWindowsExplorer()
12 | {
13 | var sim = new InputSimulator();
14 | sim.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_E);
15 | }
16 |
17 | [Test]
18 | [Explicit]
19 | public void SayHello()
20 | {
21 | var sim = new InputSimulator();
22 | sim.Keyboard
23 | .ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_R)
24 | .Sleep(1000)
25 | .TextEntry("notepad")
26 | .Sleep(1000)
27 | .KeyPress(VirtualKeyCode.RETURN)
28 | .Sleep(1000)
29 | .TextEntry("These are your orders if you choose to accept them...")
30 | .TextEntry("This message will self destruct in 5 seconds.")
31 | .Sleep(5000)
32 | .ModifiedKeyStroke(VirtualKeyCode.MENU, VirtualKeyCode.SPACE)
33 | .KeyPress(VirtualKeyCode.DOWN)
34 | .KeyPress(VirtualKeyCode.RETURN);
35 |
36 | var i = 10;
37 | while (i-- > 0)
38 | {
39 | sim.Keyboard.KeyPress(VirtualKeyCode.DOWN).Sleep(100);
40 | }
41 |
42 | sim.Keyboard
43 | .KeyPress(VirtualKeyCode.RETURN)
44 | .Sleep(1000)
45 | .ModifiedKeyStroke(VirtualKeyCode.MENU, VirtualKeyCode.F4)
46 | .KeyPress(VirtualKeyCode.VK_N);
47 | }
48 |
49 | [Test]
50 | [Explicit]
51 | public void AnotherTest()
52 | {
53 | var sim = new InputSimulator();
54 | sim.Keyboard.KeyPress(VirtualKeyCode.SPACE);
55 |
56 | sim.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_R)
57 | .Sleep(1000)
58 | .TextEntry("mspaint")
59 | .Sleep(1000)
60 | .KeyPress(VirtualKeyCode.RETURN)
61 | .Sleep(1000)
62 | .Mouse
63 | .LeftButtonDown()
64 | .MoveMouseToPositionOnVirtualDesktop(65535/2, 65535/2)
65 | .LeftButtonUp();
66 |
67 | }
68 |
69 | [Test]
70 | [Explicit]
71 | public void TestMouseMoveTo()
72 | {
73 | var sim = new InputSimulator();
74 | sim.Mouse
75 | .MoveMouseTo(0, 0)
76 | .Sleep(1000)
77 | .MoveMouseTo(65535, 65535)
78 | .Sleep(1000)
79 | .MoveMouseTo(65535/2, 65535/2);
80 | }
81 | }
82 | }
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("WindowsInput.UnitTests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("WindowsInput.UnitTests")]
13 | [assembly: AssemblyCopyright("Copyright © michaelnoonan 2010")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("9e1ff335-ed74-4135-92cf-5e4cf1d38344")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("0.2.0.0")]
36 | [assembly: AssemblyFileVersion("0.2.0.0")]
37 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.Tests/UnicodeText/UnicodeRange.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace WindowsInput.Tests.UnicodeText
4 | {
5 | public class UnicodeRange
6 | {
7 | public string Name { get; set; }
8 | public int Low { get; set; }
9 | public int High { get; set; }
10 |
11 | public string Characters
12 | {
13 | get
14 | {
15 | var i = Low;
16 | var sb = new StringBuilder(High - Low + 10);
17 | while (i <= High)
18 | {
19 | sb.Append(char.ConvertFromUtf32(i));
20 | i++;
21 | }
22 | return sb.ToString();
23 | }
24 | }
25 |
26 | public UnicodeRange(string name, int low, int high)
27 | {
28 | Name = name;
29 | Low = low;
30 | High = high;
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.Tests/UnicodeText/UnicodeTestForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsInput.Tests.UnicodeText
2 | {
3 | partial class UnicodeTestForm
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.RecievedTextBox = new System.Windows.Forms.TextBox();
32 | this.ExpectedTextBox = new System.Windows.Forms.TextBox();
33 | this.SuspendLayout();
34 | //
35 | // RecievedTextBox
36 | //
37 | this.RecievedTextBox.Dock = System.Windows.Forms.DockStyle.Top;
38 | this.RecievedTextBox.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
39 | this.RecievedTextBox.Location = new System.Drawing.Point(0, 0);
40 | this.RecievedTextBox.Name = "RecievedTextBox";
41 | this.RecievedTextBox.Size = new System.Drawing.Size(981, 39);
42 | this.RecievedTextBox.TabIndex = 0;
43 | //
44 | // ExpectedTextBox
45 | //
46 | this.ExpectedTextBox.Dock = System.Windows.Forms.DockStyle.Bottom;
47 | this.ExpectedTextBox.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
48 | this.ExpectedTextBox.Location = new System.Drawing.Point(0, 40);
49 | this.ExpectedTextBox.Name = "ExpectedTextBox";
50 | this.ExpectedTextBox.ReadOnly = true;
51 | this.ExpectedTextBox.Size = new System.Drawing.Size(981, 39);
52 | this.ExpectedTextBox.TabIndex = 1;
53 | //
54 | // UnicodeTestForm
55 | //
56 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
57 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
58 | this.ClientSize = new System.Drawing.Size(981, 79);
59 | this.Controls.Add(this.ExpectedTextBox);
60 | this.Controls.Add(this.RecievedTextBox);
61 | this.Name = "UnicodeTestForm";
62 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
63 | this.Text = "UnicodeTestForm";
64 | this.TopMost = true;
65 | this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
66 | this.ResumeLayout(false);
67 | this.PerformLayout();
68 |
69 | }
70 |
71 | #endregion
72 |
73 | private System.Windows.Forms.TextBox RecievedTextBox;
74 | private System.Windows.Forms.TextBox ExpectedTextBox;
75 | }
76 | }
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.Tests/UnicodeText/UnicodeTestForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace WindowsInput.Tests.UnicodeText
5 | {
6 | public partial class UnicodeTestForm : Form
7 | {
8 | public UnicodeTestForm()
9 | {
10 | InitializeComponent();
11 | }
12 |
13 | public string Expected
14 | {
15 | get { return ExpectedTextBox.Text; }
16 | set { ExpectedTextBox.Text = value; }
17 | }
18 |
19 | public string Recieved { get { return RecievedTextBox.Text; } }
20 |
21 | protected override void OnLoad(EventArgs e)
22 | {
23 | base.OnLoad(e);
24 | RecievedTextBox.Focus();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.Tests/UnicodeText/UnicodeTestForm.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 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.Tests/WindowsInput.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {93982D2F-BEAD-49F7-86A9-C68159410F28}
9 | Library
10 | Properties
11 | WindowsInput.Tests
12 | WindowsInput.Tests
13 | v4.7
14 | 512
15 |
16 | ..\
17 | true
18 |
19 |
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 | false
28 |
29 |
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 | false
37 |
38 |
39 | true
40 |
41 |
42 | WindowsInput.Tests.snk
43 |
44 |
45 |
46 | ..\packages\HtmlAgilityPack.1.4.6\lib\Net45\HtmlAgilityPack.dll
47 |
48 |
49 | ..\packages\NUnit.2.6.2\lib\nunit.framework.dll
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | Form
67 |
68 |
69 | UnicodeTestForm.cs
70 |
71 |
72 |
73 |
74 |
75 | {3549CD6F-80F8-450F-B99E-CF0A736B1F2A}
76 | WindowsInput
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 | UnicodeTestForm.cs
86 |
87 |
88 |
89 |
90 |
97 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.Tests/WindowsInput.Tests.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zezba9000/RemoteDesktop/1e57faabf6056e2692711dbffa0982fbb1975eac/inputsimulator/WindowsInput.Tests/WindowsInput.Tests.snk
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsInput", "WindowsInput\WindowsInput.csproj", "{3549CD6F-80F8-450F-B99E-CF0A736B1F2A}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsInput.Tests", "WindowsInput.Tests\WindowsInput.Tests.csproj", "{93982D2F-BEAD-49F7-86A9-C68159410F28}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{C2945350-728A-4D62-93D6-FA5F5015A7C6}"
9 | ProjectSection(SolutionItems) = preProject
10 | .nuget\NuGet.Config = .nuget\NuGet.Config
11 | .nuget\NuGet.exe = .nuget\NuGet.exe
12 | .nuget\NuGet.targets = .nuget\NuGet.targets
13 | EndProjectSection
14 | EndProject
15 | Global
16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
17 | Debug|Any CPU = Debug|Any CPU
18 | Release|Any CPU = Release|Any CPU
19 | EndGlobalSection
20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
21 | {3549CD6F-80F8-450F-B99E-CF0A736B1F2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22 | {3549CD6F-80F8-450F-B99E-CF0A736B1F2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
23 | {3549CD6F-80F8-450F-B99E-CF0A736B1F2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
24 | {3549CD6F-80F8-450F-B99E-CF0A736B1F2A}.Release|Any CPU.Build.0 = Release|Any CPU
25 | {93982D2F-BEAD-49F7-86A9-C68159410F28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26 | {93982D2F-BEAD-49F7-86A9-C68159410F28}.Debug|Any CPU.Build.0 = Debug|Any CPU
27 | {93982D2F-BEAD-49F7-86A9-C68159410F28}.Release|Any CPU.ActiveCfg = Release|Any CPU
28 | {93982D2F-BEAD-49F7-86A9-C68159410F28}.Release|Any CPU.Build.0 = Release|Any CPU
29 | EndGlobalSection
30 | GlobalSection(SolutionProperties) = preSolution
31 | HideSolutionNode = FALSE
32 | EndGlobalSection
33 | EndGlobal
34 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/IInputDeviceStateAdaptor.cs:
--------------------------------------------------------------------------------
1 | using WindowsInput.Native;
2 |
3 | namespace WindowsInput
4 | {
5 | ///
6 | /// The contract for a service that interprets the state of input devices.
7 | ///
8 | public interface IInputDeviceStateAdaptor
9 | {
10 | ///
11 | /// Determines whether the specified key is up or down.
12 | ///
13 | /// The for the key.
14 | ///
15 | /// true if the key is down; otherwise, false.
16 | ///
17 | bool IsKeyDown(VirtualKeyCode keyCode);
18 |
19 | ///
20 | /// Determines whether the specified key is up or down.
21 | ///
22 | /// The for the key.
23 | ///
24 | /// true if the key is up; otherwise, false.
25 | ///
26 | bool IsKeyUp(VirtualKeyCode keyCode);
27 |
28 | ///
29 | /// Determines whether the physical key is up or down at the time the function is called regardless of whether the application thread has read the keyboard event from the message pump.
30 | ///
31 | /// The for the key.
32 | ///
33 | /// true if the key is down; otherwise, false.
34 | ///
35 | bool IsHardwareKeyDown(VirtualKeyCode keyCode);
36 |
37 | ///
38 | /// Determines whether the physical key is up or down at the time the function is called regardless of whether the application thread has read the keyboard event from the message pump.
39 | ///
40 | /// The for the key.
41 | ///
42 | /// true if the key is up; otherwise, false.
43 | ///
44 | bool IsHardwareKeyUp(VirtualKeyCode keyCode);
45 |
46 | ///
47 | /// Determines whether the toggling key is toggled on (in-effect) or not.
48 | ///
49 | /// The for the key.
50 | ///
51 | /// true if the toggling key is toggled on (in-effect); otherwise, false.
52 | ///
53 | bool IsTogglingKeyInEffect(VirtualKeyCode keyCode);
54 | }
55 | }
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/IInputMessageDispatcher.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using WindowsInput.Native;
3 |
4 | namespace WindowsInput
5 | {
6 | ///
7 | /// The contract for a service that dispatches messages to the appropriate destination.
8 | ///
9 | internal interface IInputMessageDispatcher
10 | {
11 | ///
12 | /// Dispatches the specified list of messages in their specified order.
13 | ///
14 | /// The list of messages to be dispatched.
15 | /// If the array is empty.
16 | /// If the array is null.
17 | /// If the any of the commands in the array could not be sent successfully.
18 | void DispatchInput(INPUT[] inputs);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/IInputSimulator.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsInput
2 | {
3 | ///
4 | /// The contract for a service that simulates Keyboard and Mouse input and Hardware Input Device state detection for the Windows Platform.
5 | ///
6 | public interface IInputSimulator
7 | {
8 | ///
9 | /// Gets the instance for simulating Keyboard input.
10 | ///
11 | /// The instance.
12 | IKeyboardSimulator Keyboard { get; }
13 |
14 | ///
15 | /// Gets the instance for simulating Mouse input.
16 | ///
17 | /// The instance.
18 | IMouseSimulator Mouse { get; }
19 |
20 | ///
21 | /// Gets the instance for determining the state of the various input devices.
22 | ///
23 | /// The instance.
24 | IInputDeviceStateAdaptor InputDeviceState { get; }
25 | }
26 | }
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/IKeyboardSimulator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using WindowsInput.Native;
4 |
5 | namespace WindowsInput
6 | {
7 | ///
8 | /// The service contract for a keyboard simulator for the Windows platform.
9 | ///
10 | public interface IKeyboardSimulator
11 | {
12 | ///
13 | /// Gets the instance for simulating Mouse input.
14 | ///
15 | /// The instance.
16 | IMouseSimulator Mouse { get; }
17 |
18 | ///
19 | /// Simulates the key down gesture for the specified key.
20 | ///
21 | /// The for the key.
22 | IKeyboardSimulator KeyDown(VirtualKeyCode keyCode);
23 |
24 | ///
25 | /// Simulates the key press gesture for the specified key.
26 | ///
27 | /// The for the key.
28 | IKeyboardSimulator KeyPress(VirtualKeyCode keyCode);
29 |
30 | ///
31 | /// Simulates a key press for each of the specified key codes in the order they are specified.
32 | ///
33 | ///
34 | IKeyboardSimulator KeyPress(params VirtualKeyCode[] keyCodes);
35 |
36 | ///
37 | /// Simulates the key up gesture for the specified key.
38 | ///
39 | /// The for the key.
40 | IKeyboardSimulator KeyUp(VirtualKeyCode keyCode);
41 |
42 | ///
43 | /// Simulates a modified keystroke where there are multiple modifiers and multiple keys like CTRL-ALT-K-C where CTRL and ALT are the modifierKeys and K and C are the keys.
44 | /// The flow is Modifiers KeyDown in order, Keys Press in order, Modifiers KeyUp in reverse order.
45 | ///
46 | /// The list of s for the modifier keys.
47 | /// The list of s for the keys to simulate.
48 | IKeyboardSimulator ModifiedKeyStroke(IEnumerable modifierKeyCodes, IEnumerable keyCodes);
49 |
50 | ///
51 | /// Simulates a modified keystroke where there are multiple modifiers and one key like CTRL-ALT-C where CTRL and ALT are the modifierKeys and C is the key.
52 | /// The flow is Modifiers KeyDown in order, Key Press, Modifiers KeyUp in reverse order.
53 | ///
54 | /// The list of s for the modifier keys.
55 | /// The for the key.
56 | IKeyboardSimulator ModifiedKeyStroke(IEnumerable modifierKeyCodes, VirtualKeyCode keyCode);
57 |
58 | ///
59 | /// Simulates a modified keystroke where there is one modifier and multiple keys like CTRL-K-C where CTRL is the modifierKey and K and C are the keys.
60 | /// The flow is Modifier KeyDown, Keys Press in order, Modifier KeyUp.
61 | ///
62 | /// The for the modifier key.
63 | /// The list of s for the keys to simulate.
64 | IKeyboardSimulator ModifiedKeyStroke(VirtualKeyCode modifierKey, IEnumerable keyCodes);
65 |
66 | ///
67 | /// Simulates a simple modified keystroke like CTRL-C where CTRL is the modifierKey and C is the key.
68 | /// The flow is Modifier KeyDown, Key Press, Modifier KeyUp.
69 | ///
70 | /// The for the modifier key.
71 | /// The for the key.
72 | IKeyboardSimulator ModifiedKeyStroke(VirtualKeyCode modifierKeyCode, VirtualKeyCode keyCode);
73 |
74 | ///
75 | /// Simulates uninterrupted text entry via the keyboard.
76 | ///
77 | /// The text to be simulated.
78 | IKeyboardSimulator TextEntry(string text);
79 |
80 | ///
81 | /// Simulates a single character text entry via the keyboard.
82 | ///
83 | /// The unicode character to be simulated.
84 | IKeyboardSimulator TextEntry(char character);
85 |
86 | ///
87 | /// Sleeps the executing thread to create a pause between simulated inputs.
88 | ///
89 | /// The number of milliseconds to wait.
90 | IKeyboardSimulator Sleep(int millsecondsTimeout);
91 |
92 | ///
93 | /// Sleeps the executing thread to create a pause between simulated inputs.
94 | ///
95 | /// The time to wait.
96 | IKeyboardSimulator Sleep(TimeSpan timeout);
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/IMouseSimulator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WindowsInput
4 | {
5 | ///
6 | /// The service contract for a mouse simulator for the Windows platform.
7 | ///
8 | public interface IMouseSimulator
9 | {
10 | ///
11 | /// Gets the instance for simulating Keyboard input.
12 | ///
13 | /// The instance.
14 | IKeyboardSimulator Keyboard { get; }
15 |
16 | ///
17 | /// Simulates mouse movement by the specified distance measured as a delta from the current mouse location in pixels.
18 | ///
19 | /// The distance in pixels to move the mouse horizontally.
20 | /// The distance in pixels to move the mouse vertically.
21 | IMouseSimulator MoveMouseBy(int pixelDeltaX, int pixelDeltaY);
22 |
23 | ///
24 | /// Simulates mouse movement to the specified location on the primary display device.
25 | ///
26 | /// The destination's absolute X-coordinate on the primary display device where 0 is the extreme left hand side of the display device and 65535 is the extreme right hand side of the display device.
27 | /// The destination's absolute Y-coordinate on the primary display device where 0 is the top of the display device and 65535 is the bottom of the display device.
28 | IMouseSimulator MoveMouseTo(double absoluteX, double absoluteY);
29 |
30 | ///
31 | /// Simulates mouse movement to the specified location on the Virtual Desktop which includes all active displays.
32 | ///
33 | /// The destination's absolute X-coordinate on the virtual desktop where 0 is the left hand side of the virtual desktop and 65535 is the extreme right hand side of the virtual desktop.
34 | /// The destination's absolute Y-coordinate on the virtual desktop where 0 is the top of the virtual desktop and 65535 is the bottom of the virtual desktop.
35 | IMouseSimulator MoveMouseToPositionOnVirtualDesktop(double absoluteX, double absoluteY);
36 |
37 | ///
38 | /// Simulates a mouse left button down gesture.
39 | ///
40 | IMouseSimulator LeftButtonDown();
41 |
42 | ///
43 | /// Simulates a mouse left button up gesture.
44 | ///
45 | IMouseSimulator LeftButtonUp();
46 |
47 | ///
48 | /// Simulates a mouse left button click gesture.
49 | ///
50 | IMouseSimulator LeftButtonClick();
51 |
52 | ///
53 | /// Simulates a mouse left button double-click gesture.
54 | ///
55 | IMouseSimulator LeftButtonDoubleClick();
56 |
57 | ///
58 | /// Simulates a mouse right button down gesture.
59 | ///
60 | IMouseSimulator RightButtonDown();
61 |
62 | ///
63 | /// Simulates a mouse right button up gesture.
64 | ///
65 | IMouseSimulator RightButtonUp();
66 |
67 | ///
68 | /// Simulates a mouse right button click gesture.
69 | ///
70 | IMouseSimulator RightButtonClick();
71 |
72 | ///
73 | /// Simulates a mouse right button double-click gesture.
74 | ///
75 | IMouseSimulator RightButtonDoubleClick();
76 |
77 | ///
78 | /// Simulates a mouse X button down gesture.
79 | ///
80 | /// The button id.
81 | IMouseSimulator XButtonDown(int buttonId);
82 |
83 | ///
84 | /// Simulates a mouse X button up gesture.
85 | ///
86 | /// The button id.
87 | IMouseSimulator XButtonUp(int buttonId);
88 |
89 | ///
90 | /// Simulates a mouse X button click gesture.
91 | ///
92 | /// The button id.
93 | IMouseSimulator XButtonClick(int buttonId);
94 |
95 | ///
96 | /// Simulates a mouse X button double-click gesture.
97 | ///
98 | /// The button id.
99 | IMouseSimulator XButtonDoubleClick(int buttonId);
100 |
101 | ///
102 | /// Simulates mouse vertical wheel scroll gesture.
103 | ///
104 | /// The amount to scroll in clicks. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user.
105 | IMouseSimulator VerticalScroll(int scrollAmountInClicks);
106 |
107 | ///
108 | /// Simulates a mouse horizontal wheel scroll gesture. Supported by Windows Vista and later.
109 | ///
110 | /// The amount to scroll in clicks. A positive value indicates that the wheel was rotated to the right; a negative value indicates that the wheel was rotated to the left.
111 | IMouseSimulator HorizontalScroll(int scrollAmountInClicks);
112 |
113 | ///
114 | /// Sleeps the executing thread to create a pause between simulated inputs.
115 | ///
116 | /// The number of milliseconds to wait.
117 | IMouseSimulator Sleep(int millsecondsTimeout);
118 |
119 | ///
120 | /// Sleeps the executing thread to create a pause between simulated inputs.
121 | ///
122 | /// The time to wait.
123 | IMouseSimulator Sleep(TimeSpan timeout);
124 | }
125 | }
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/InputSimulator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WindowsInput
4 | {
5 | ///
6 | /// Implements the interface to simulate Keyboard and Mouse input and provide the state of those input devices.
7 | ///
8 | public class InputSimulator : IInputSimulator
9 | {
10 | ///
11 | /// The instance to use for simulating keyboard input.
12 | ///
13 | private readonly IKeyboardSimulator _keyboardSimulator;
14 |
15 | ///
16 | /// The instance to use for simulating mouse input.
17 | ///
18 | private readonly IMouseSimulator _mouseSimulator;
19 |
20 | ///
21 | /// The instance to use for interpreting the state of the input devices.
22 | ///
23 | private readonly IInputDeviceStateAdaptor _inputDeviceState;
24 |
25 | ///
26 | /// Initializes a new instance of the class using the specified , and instances.
27 | ///
28 | /// The instance to use for simulating keyboard input.
29 | /// The instance to use for simulating mouse input.
30 | /// The instance to use for interpreting the state of input devices.
31 | public InputSimulator(IKeyboardSimulator keyboardSimulator, IMouseSimulator mouseSimulator, IInputDeviceStateAdaptor inputDeviceStateAdaptor)
32 | {
33 | _keyboardSimulator = keyboardSimulator;
34 | _mouseSimulator = mouseSimulator;
35 | _inputDeviceState = inputDeviceStateAdaptor;
36 | }
37 |
38 | ///
39 | /// Initializes a new instance of the class using the default , and instances.
40 | ///
41 | public InputSimulator()
42 | {
43 | _keyboardSimulator = new KeyboardSimulator(this);
44 | _mouseSimulator = new MouseSimulator(this);
45 | _inputDeviceState = new WindowsInputDeviceStateAdaptor();
46 | }
47 |
48 | ///
49 | /// Gets the instance for simulating Keyboard input.
50 | ///
51 | /// The instance.
52 | public IKeyboardSimulator Keyboard
53 | {
54 | get { return _keyboardSimulator; }
55 | }
56 |
57 | ///
58 | /// Gets the instance for simulating Mouse input.
59 | ///
60 | /// The instance.
61 | public IMouseSimulator Mouse
62 | {
63 | get { return _mouseSimulator; }
64 | }
65 |
66 | ///
67 | /// Gets the instance for determining the state of the various input devices.
68 | ///
69 | /// The instance.
70 | public IInputDeviceStateAdaptor InputDeviceState
71 | {
72 | get { return _inputDeviceState; }
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/KeyboardSimulator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Threading;
4 | using WindowsInput.Native;
5 |
6 | namespace WindowsInput
7 | {
8 | ///
9 | /// Implements the interface by calling the an to simulate Keyboard gestures.
10 | ///
11 | public class KeyboardSimulator : IKeyboardSimulator
12 | {
13 | private readonly IInputSimulator _inputSimulator;
14 |
15 | ///
16 | /// The instance of the to use for dispatching messages.
17 | ///
18 | private readonly IInputMessageDispatcher _messageDispatcher;
19 |
20 | ///
21 | /// Initializes a new instance of the class using an instance of a for dispatching messages.
22 | ///
23 | /// The that owns this instance.
24 | public KeyboardSimulator(IInputSimulator inputSimulator)
25 | {
26 | if (inputSimulator == null) throw new ArgumentNullException("inputSimulator");
27 |
28 | _inputSimulator = inputSimulator;
29 | _messageDispatcher = new WindowsInputMessageDispatcher();
30 | }
31 |
32 | ///
33 | /// Initializes a new instance of the class using the specified for dispatching messages.
34 | ///
35 | /// The that owns this instance.
36 | /// The to use for dispatching messages.
37 | /// If null is passed as the .
38 | internal KeyboardSimulator(IInputSimulator inputSimulator, IInputMessageDispatcher messageDispatcher)
39 | {
40 | if (inputSimulator == null) throw new ArgumentNullException("inputSimulator");
41 |
42 | if (messageDispatcher == null)
43 | throw new InvalidOperationException(
44 | string.Format("The {0} cannot operate with a null {1}. Please provide a valid {1} instance to use for dispatching {2} messages.",
45 | typeof(KeyboardSimulator).Name, typeof(IInputMessageDispatcher).Name, typeof(INPUT).Name));
46 |
47 | _inputSimulator = inputSimulator;
48 | _messageDispatcher = messageDispatcher;
49 | }
50 |
51 | ///
52 | /// Gets the instance for simulating Mouse input.
53 | ///
54 | /// The instance.
55 | public IMouseSimulator Mouse { get { return _inputSimulator.Mouse; } }
56 |
57 | private void ModifiersDown(InputBuilder builder, IEnumerable modifierKeyCodes)
58 | {
59 | if (modifierKeyCodes == null) return;
60 | foreach (var key in modifierKeyCodes) builder.AddKeyDown(key);
61 | }
62 |
63 | private void ModifiersUp(InputBuilder builder, IEnumerable modifierKeyCodes)
64 | {
65 | if (modifierKeyCodes == null) return;
66 |
67 | // Key up in reverse (I miss LINQ)
68 | var stack = new Stack(modifierKeyCodes);
69 | while (stack.Count > 0) builder.AddKeyUp(stack.Pop());
70 | }
71 |
72 | private void KeysPress(InputBuilder builder, IEnumerable keyCodes)
73 | {
74 | if (keyCodes == null) return;
75 | foreach (var key in keyCodes) builder.AddKeyPress(key);
76 | }
77 |
78 | ///
79 | /// Sends the list of messages using the instance.
80 | ///
81 | /// The of messages to send.
82 | private void SendSimulatedInput(INPUT[] inputList)
83 | {
84 | _messageDispatcher.DispatchInput(inputList);
85 | }
86 |
87 | ///
88 | /// Calls the Win32 SendInput method to simulate a KeyDown.
89 | ///
90 | /// The to press
91 | public IKeyboardSimulator KeyDown(VirtualKeyCode keyCode)
92 | {
93 | var inputList = new InputBuilder().AddKeyDown(keyCode).ToArray();
94 | SendSimulatedInput(inputList);
95 | return this;
96 | }
97 |
98 | ///
99 | /// Calls the Win32 SendInput method to simulate a KeyUp.
100 | ///
101 | /// The to lift up
102 | public IKeyboardSimulator KeyUp(VirtualKeyCode keyCode)
103 | {
104 | var inputList = new InputBuilder().AddKeyUp(keyCode).ToArray();
105 | SendSimulatedInput(inputList);
106 | return this;
107 | }
108 |
109 | ///
110 | /// Calls the Win32 SendInput method with a KeyDown and KeyUp message in the same input sequence in order to simulate a Key PRESS.
111 | ///
112 | /// The to press
113 | public IKeyboardSimulator KeyPress(VirtualKeyCode keyCode)
114 | {
115 | var inputList = new InputBuilder().AddKeyPress(keyCode).ToArray();
116 | SendSimulatedInput(inputList);
117 | return this;
118 | }
119 |
120 | ///
121 | /// Simulates a key press for each of the specified key codes in the order they are specified.
122 | ///
123 | ///
124 | public IKeyboardSimulator KeyPress(params VirtualKeyCode[] keyCodes)
125 | {
126 | var builder = new InputBuilder();
127 | KeysPress(builder, keyCodes);
128 | SendSimulatedInput(builder.ToArray());
129 | return this;
130 | }
131 |
132 | ///
133 | /// Simulates a simple modified keystroke like CTRL-C where CTRL is the modifierKey and C is the key.
134 | /// The flow is Modifier KeyDown, Key Press, Modifier KeyUp.
135 | ///
136 | /// The modifier key
137 | /// The key to simulate
138 | public IKeyboardSimulator ModifiedKeyStroke(VirtualKeyCode modifierKeyCode, VirtualKeyCode keyCode)
139 | {
140 | ModifiedKeyStroke(new[] { modifierKeyCode }, new[] { keyCode });
141 | return this;
142 | }
143 |
144 | ///
145 | /// Simulates a modified keystroke where there are multiple modifiers and one key like CTRL-ALT-C where CTRL and ALT are the modifierKeys and C is the key.
146 | /// The flow is Modifiers KeyDown in order, Key Press, Modifiers KeyUp in reverse order.
147 | ///
148 | /// The list of modifier keys
149 | /// The key to simulate
150 | public IKeyboardSimulator ModifiedKeyStroke(IEnumerable modifierKeyCodes, VirtualKeyCode keyCode)
151 | {
152 | ModifiedKeyStroke(modifierKeyCodes, new[] {keyCode});
153 | return this;
154 | }
155 |
156 | ///
157 | /// Simulates a modified keystroke where there is one modifier and multiple keys like CTRL-K-C where CTRL is the modifierKey and K and C are the keys.
158 | /// The flow is Modifier KeyDown, Keys Press in order, Modifier KeyUp.
159 | ///
160 | /// The modifier key
161 | /// The list of keys to simulate
162 | public IKeyboardSimulator ModifiedKeyStroke(VirtualKeyCode modifierKey, IEnumerable keyCodes)
163 | {
164 | ModifiedKeyStroke(new [] {modifierKey}, keyCodes);
165 | return this;
166 | }
167 |
168 | ///
169 | /// Simulates a modified keystroke where there are multiple modifiers and multiple keys like CTRL-ALT-K-C where CTRL and ALT are the modifierKeys and K and C are the keys.
170 | /// The flow is Modifiers KeyDown in order, Keys Press in order, Modifiers KeyUp in reverse order.
171 | ///
172 | /// The list of modifier keys
173 | /// The list of keys to simulate
174 | public IKeyboardSimulator ModifiedKeyStroke(IEnumerable modifierKeyCodes, IEnumerable keyCodes)
175 | {
176 | var builder = new InputBuilder();
177 | ModifiersDown(builder, modifierKeyCodes);
178 | KeysPress(builder, keyCodes);
179 | ModifiersUp(builder, modifierKeyCodes);
180 |
181 | SendSimulatedInput(builder.ToArray());
182 | return this;
183 | }
184 |
185 | ///
186 | /// Calls the Win32 SendInput method with a stream of KeyDown and KeyUp messages in order to simulate uninterrupted text entry via the keyboard.
187 | ///
188 | /// The text to be simulated.
189 | public IKeyboardSimulator TextEntry(string text)
190 | {
191 | if (text.Length > UInt32.MaxValue / 2) throw new ArgumentException(string.Format("The text parameter is too long. It must be less than {0} characters.", UInt32.MaxValue / 2), "text");
192 | var inputList = new InputBuilder().AddCharacters(text).ToArray();
193 | SendSimulatedInput(inputList);
194 | return this;
195 | }
196 |
197 | ///
198 | /// Simulates a single character text entry via the keyboard.
199 | ///
200 | /// The unicode character to be simulated.
201 | public IKeyboardSimulator TextEntry(char character)
202 | {
203 | var inputList = new InputBuilder().AddCharacter(character).ToArray();
204 | SendSimulatedInput(inputList);
205 | return this;
206 | }
207 |
208 | ///
209 | /// Sleeps the executing thread to create a pause between simulated inputs.
210 | ///
211 | /// The number of milliseconds to wait.
212 | public IKeyboardSimulator Sleep(int millsecondsTimeout)
213 | {
214 | Thread.Sleep(millsecondsTimeout);
215 | return this;
216 | }
217 |
218 | ///
219 | /// Sleeps the executing thread to create a pause between simulated inputs.
220 | ///
221 | /// The time to wait.
222 | public IKeyboardSimulator Sleep(TimeSpan timeout)
223 | {
224 | Thread.Sleep(timeout);
225 | return this;
226 | }
227 | }
228 | }
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/MouseButton.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsInput
2 | {
3 | ///
4 | /// The mouse button
5 | ///
6 | public enum MouseButton
7 | {
8 | ///
9 | /// Left mouse button
10 | ///
11 | LeftButton,
12 |
13 | ///
14 | /// Middle mouse button
15 | ///
16 | MiddleButton,
17 |
18 | ///
19 | /// Right moust button
20 | ///
21 | RightButton,
22 | }
23 | }
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/Native/HARDWAREINPUT.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WindowsInput.Native
4 | {
5 | #pragma warning disable 649
6 | ///
7 | /// The HARDWAREINPUT structure contains information about a simulated message generated by an input device other than a keyboard or mouse. (see: http://msdn.microsoft.com/en-us/library/ms646269(VS.85).aspx)
8 | /// Declared in Winuser.h, include Windows.h
9 | ///
10 | internal struct HARDWAREINPUT
11 | {
12 | ///
13 | /// Value specifying the message generated by the input hardware.
14 | ///
15 | public UInt32 Msg;
16 |
17 | ///
18 | /// Specifies the low-order word of the lParam parameter for uMsg.
19 | ///
20 | public UInt16 ParamL;
21 |
22 | ///
23 | /// Specifies the high-order word of the lParam parameter for uMsg.
24 | ///
25 | public UInt16 ParamH;
26 | }
27 | #pragma warning restore 649
28 | }
29 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/Native/INPUT.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WindowsInput.Native
4 | {
5 | #pragma warning disable 649
6 | ///
7 | /// The INPUT structure is used by SendInput to store information for synthesizing input events such as keystrokes, mouse movement, and mouse clicks. (see: http://msdn.microsoft.com/en-us/library/ms646270(VS.85).aspx)
8 | /// Declared in Winuser.h, include Windows.h
9 | ///
10 | ///
11 | /// This structure contains information identical to that used in the parameter list of the keybd_event or mouse_event function.
12 | /// Windows 2000/XP: INPUT_KEYBOARD supports nonkeyboard input methods, such as handwriting recognition or voice recognition, as if it were text input by using the KEYEVENTF_UNICODE flag. For more information, see the remarks section of KEYBDINPUT.
13 | ///
14 | internal struct INPUT
15 | {
16 | ///
17 | /// Specifies the type of the input event. This member can be one of the following values.
18 | /// - The event is a mouse event. Use the mi structure of the union.
19 | /// - The event is a keyboard event. Use the ki structure of the union.
20 | /// - Windows 95/98/Me: The event is from input hardware other than a keyboard or mouse. Use the hi structure of the union.
21 | ///
22 | public UInt32 Type;
23 |
24 | ///
25 | /// The data structure that contains information about the simulated Mouse, Keyboard or Hardware event.
26 | ///
27 | public MOUSEKEYBDHARDWAREINPUT Data;
28 | }
29 | #pragma warning restore 649
30 | }
31 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/Native/InputType.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsInput.Native
2 | {
3 | ///
4 | /// Specifies the type of the input event. This member can be one of the following values.
5 | ///
6 | internal enum InputType : uint // UInt32
7 | {
8 | ///
9 | /// INPUT_MOUSE = 0x00 (The event is a mouse event. Use the mi structure of the union.)
10 | ///
11 | Mouse = 0,
12 |
13 | ///
14 | /// INPUT_KEYBOARD = 0x01 (The event is a keyboard event. Use the ki structure of the union.)
15 | ///
16 | Keyboard = 1,
17 |
18 | ///
19 | /// INPUT_HARDWARE = 0x02 (Windows 95/98/Me: The event is from input hardware other than a keyboard or mouse. Use the hi structure of the union.)
20 | ///
21 | Hardware = 2,
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/Native/KEYBDINPUT.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WindowsInput.Native
4 | {
5 | #pragma warning disable 649
6 | ///
7 | /// The KEYBDINPUT structure contains information about a simulated keyboard event. (see: http://msdn.microsoft.com/en-us/library/ms646271(VS.85).aspx)
8 | /// Declared in Winuser.h, include Windows.h
9 | ///
10 | ///
11 | /// Windows 2000/XP: INPUT_KEYBOARD supports nonkeyboard-input methodssuch as handwriting recognition or voice recognitionas if it were text input by using the KEYEVENTF_UNICODE flag. If KEYEVENTF_UNICODE is specified, SendInput sends a WM_KEYDOWN or WM_KEYUP message to the foreground thread's message queue with wParam equal to VK_PACKET. Once GetMessage or PeekMessage obtains this message, passing the message to TranslateMessage posts a WM_CHAR message with the Unicode character originally specified by wScan. This Unicode character will automatically be converted to the appropriate ANSI value if it is posted to an ANSI window.
12 | /// Windows 2000/XP: Set the KEYEVENTF_SCANCODE flag to define keyboard input in terms of the scan code. This is useful to simulate a physical keystroke regardless of which keyboard is currently being used. The virtual key value of a key may alter depending on the current keyboard layout or what other keys were pressed, but the scan code will always be the same.
13 | ///
14 | internal struct KEYBDINPUT
15 | {
16 | ///
17 | /// Specifies a virtual-key code. The code must be a value in the range 1 to 254. The Winuser.h header file provides macro definitions (VK_*) for each value. If the dwFlags member specifies KEYEVENTF_UNICODE, wVk must be 0.
18 | ///
19 | public UInt16 KeyCode;
20 |
21 | ///
22 | /// Specifies a hardware scan code for the key. If dwFlags specifies KEYEVENTF_UNICODE, wScan specifies a Unicode character which is to be sent to the foreground application.
23 | ///
24 | public UInt16 Scan;
25 |
26 | ///
27 | /// Specifies various aspects of a keystroke. This member can be certain combinations of the following values.
28 | /// KEYEVENTF_EXTENDEDKEY - If specified, the scan code was preceded by a prefix byte that has the value 0xE0 (224).
29 | /// KEYEVENTF_KEYUP - If specified, the key is being released. If not specified, the key is being pressed.
30 | /// KEYEVENTF_SCANCODE - If specified, wScan identifies the key and wVk is ignored.
31 | /// KEYEVENTF_UNICODE - Windows 2000/XP: If specified, the system synthesizes a VK_PACKET keystroke. The wVk parameter must be zero. This flag can only be combined with the KEYEVENTF_KEYUP flag. For more information, see the Remarks section.
32 | ///
33 | public UInt32 Flags;
34 |
35 | ///
36 | /// Time stamp for the event, in milliseconds. If this parameter is zero, the system will provide its own time stamp.
37 | ///
38 | public UInt32 Time;
39 |
40 | ///
41 | /// Specifies an additional value associated with the keystroke. Use the GetMessageExtraInfo function to obtain this information.
42 | ///
43 | public IntPtr ExtraInfo;
44 | }
45 | #pragma warning restore 649
46 | }
47 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/Native/KeyboardFlag.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WindowsInput.Native
4 | {
5 | ///
6 | /// Specifies various aspects of a keystroke. This member can be certain combinations of the following values.
7 | ///
8 | [Flags]
9 | internal enum KeyboardFlag : uint // UInt32
10 | {
11 | ///
12 | /// KEYEVENTF_EXTENDEDKEY = 0x0001 (If specified, the scan code was preceded by a prefix byte that has the value 0xE0 (224).)
13 | ///
14 | ExtendedKey = 0x0001,
15 |
16 | ///
17 | /// KEYEVENTF_KEYUP = 0x0002 (If specified, the key is being released. If not specified, the key is being pressed.)
18 | ///
19 | KeyUp = 0x0002,
20 |
21 | ///
22 | /// KEYEVENTF_UNICODE = 0x0004 (If specified, wScan identifies the key and wVk is ignored.)
23 | ///
24 | Unicode = 0x0004,
25 |
26 | ///
27 | /// KEYEVENTF_SCANCODE = 0x0008 (Windows 2000/XP: If specified, the system synthesizes a VK_PACKET keystroke. The wVk parameter must be zero. This flag can only be combined with the KEYEVENTF_KEYUP flag. For more information, see the Remarks section.)
28 | ///
29 | ScanCode = 0x0008,
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/Native/MOUSEINPUT.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WindowsInput.Native
4 | {
5 | #pragma warning disable 649
6 | ///
7 | /// The MOUSEINPUT structure contains information about a simulated mouse event. (see: http://msdn.microsoft.com/en-us/library/ms646273(VS.85).aspx)
8 | /// Declared in Winuser.h, include Windows.h
9 | ///
10 | ///
11 | /// If the mouse has moved, indicated by MOUSEEVENTF_MOVE, dx and dy specify information about that movement. The information is specified as absolute or relative integer values.
12 | /// If MOUSEEVENTF_ABSOLUTE value is specified, dx and dy contain normalized absolute coordinates between 0 and 65,535. The event procedure maps these coordinates onto the display surface. Coordinate (0,0) maps onto the upper-left corner of the display surface; coordinate (65535,65535) maps onto the lower-right corner. In a multimonitor system, the coordinates map to the primary monitor.
13 | /// Windows 2000/XP: If MOUSEEVENTF_VIRTUALDESK is specified, the coordinates map to the entire virtual desktop.
14 | /// If the MOUSEEVENTF_ABSOLUTE value is not specified, dx and dy specify movement relative to the previous mouse event (the last reported position). Positive values mean the mouse moved right (or down); negative values mean the mouse moved left (or up).
15 | /// Relative mouse motion is subject to the effects of the mouse speed and the two-mouse threshold values. A user sets these three values with the Pointer Speed slider of the Control Panel's Mouse Properties sheet. You can obtain and set these values using the SystemParametersInfo function.
16 | /// The system applies two tests to the specified relative mouse movement. If the specified distance along either the x or y axis is greater than the first mouse threshold value, and the mouse speed is not zero, the system doubles the distance. If the specified distance along either the x or y axis is greater than the second mouse threshold value, and the mouse speed is equal to two, the system doubles the distance that resulted from applying the first threshold test. It is thus possible for the system to multiply specified relative mouse movement along the x or y axis by up to four times.
17 | ///
18 | internal struct MOUSEINPUT
19 | {
20 | ///
21 | /// Specifies the absolute position of the mouse, or the amount of motion since the last mouse event was generated, depending on the value of the dwFlags member. Absolute data is specified as the x coordinate of the mouse; relative data is specified as the number of pixels moved.
22 | ///
23 | public Int32 X;
24 |
25 | ///
26 | /// Specifies the absolute position of the mouse, or the amount of motion since the last mouse event was generated, depending on the value of the dwFlags member. Absolute data is specified as the y coordinate of the mouse; relative data is specified as the number of pixels moved.
27 | ///
28 | public Int32 Y;
29 |
30 | ///
31 | /// If dwFlags contains MOUSEEVENTF_WHEEL, then mouseData specifies the amount of wheel movement. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. One wheel click is defined as WHEEL_DELTA, which is 120.
32 | /// Windows Vista: If dwFlags contains MOUSEEVENTF_HWHEEL, then dwData specifies the amount of wheel movement. A positive value indicates that the wheel was rotated to the right; a negative value indicates that the wheel was rotated to the left. One wheel click is defined as WHEEL_DELTA, which is 120.
33 | /// Windows 2000/XP: IfdwFlags does not contain MOUSEEVENTF_WHEEL, MOUSEEVENTF_XDOWN, or MOUSEEVENTF_XUP, then mouseData should be zero.
34 | /// If dwFlags contains MOUSEEVENTF_XDOWN or MOUSEEVENTF_XUP, then mouseData specifies which X buttons were pressed or released. This value may be any combination of the following flags.
35 | ///
36 | public UInt32 MouseData;
37 |
38 | ///
39 | /// A set of bit flags that specify various aspects of mouse motion and button clicks. The bits in this member can be any reasonable combination of the following values.
40 | /// The bit flags that specify mouse button status are set to indicate changes in status, not ongoing conditions. For example, if the left mouse button is pressed and held down, MOUSEEVENTF_LEFTDOWN is set when the left button is first pressed, but not for subsequent motions. Similarly, MOUSEEVENTF_LEFTUP is set only when the button is first released.
41 | /// You cannot specify both the MOUSEEVENTF_WHEEL flag and either MOUSEEVENTF_XDOWN or MOUSEEVENTF_XUP flags simultaneously in the dwFlags parameter, because they both require use of the mouseData field.
42 | ///
43 | public UInt32 Flags;
44 |
45 | ///
46 | /// Time stamp for the event, in milliseconds. If this parameter is 0, the system will provide its own time stamp.
47 | ///
48 | public UInt32 Time;
49 |
50 | ///
51 | /// Specifies an additional value associated with the mouse event. An application calls GetMessageExtraInfo to obtain this extra information.
52 | ///
53 | public IntPtr ExtraInfo;
54 | }
55 | #pragma warning restore 649
56 | }
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/Native/MOUSEKEYBDHARDWAREINPUT.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace WindowsInput.Native
4 | {
5 | #pragma warning disable 649
6 | ///
7 | /// The combined/overlayed structure that includes Mouse, Keyboard and Hardware Input message data (see: http://msdn.microsoft.com/en-us/library/ms646270(VS.85).aspx)
8 | ///
9 | [StructLayout(LayoutKind.Explicit)]
10 | internal struct MOUSEKEYBDHARDWAREINPUT
11 | {
12 | ///
13 | /// The definition.
14 | ///
15 | [FieldOffset(0)]
16 | public MOUSEINPUT Mouse;
17 |
18 | ///
19 | /// The definition.
20 | ///
21 | [FieldOffset(0)]
22 | public KEYBDINPUT Keyboard;
23 |
24 | ///
25 | /// The definition.
26 | ///
27 | [FieldOffset(0)]
28 | public HARDWAREINPUT Hardware;
29 | }
30 | #pragma warning restore 649
31 | }
32 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/Native/MouseFlag.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WindowsInput.Native
4 | {
5 | ///
6 | /// The set of MouseFlags for use in the Flags property of the structure. (See: http://msdn.microsoft.com/en-us/library/ms646273(VS.85).aspx)
7 | ///
8 | [Flags]
9 | internal enum MouseFlag : uint // UInt32
10 | {
11 | ///
12 | /// Specifies that movement occurred.
13 | ///
14 | Move = 0x0001,
15 |
16 | ///
17 | /// Specifies that the left button was pressed.
18 | ///
19 | LeftDown = 0x0002,
20 |
21 | ///
22 | /// Specifies that the left button was released.
23 | ///
24 | LeftUp = 0x0004,
25 |
26 | ///
27 | /// Specifies that the right button was pressed.
28 | ///
29 | RightDown = 0x0008,
30 |
31 | ///
32 | /// Specifies that the right button was released.
33 | ///
34 | RightUp = 0x0010,
35 |
36 | ///
37 | /// Specifies that the middle button was pressed.
38 | ///
39 | MiddleDown = 0x0020,
40 |
41 | ///
42 | /// Specifies that the middle button was released.
43 | ///
44 | MiddleUp = 0x0040,
45 |
46 | ///
47 | /// Windows 2000/XP: Specifies that an X button was pressed.
48 | ///
49 | XDown = 0x0080,
50 |
51 | ///
52 | /// Windows 2000/XP: Specifies that an X button was released.
53 | ///
54 | XUp = 0x0100,
55 |
56 | ///
57 | /// Windows NT/2000/XP: Specifies that the wheel was moved, if the mouse has a wheel. The amount of movement is specified in mouseData.
58 | ///
59 | VerticalWheel = 0x0800,
60 |
61 | ///
62 | /// Specifies that the wheel was moved horizontally, if the mouse has a wheel. The amount of movement is specified in mouseData. Windows 2000/XP: Not supported.
63 | ///
64 | HorizontalWheel = 0x1000,
65 |
66 | ///
67 | /// Windows 2000/XP: Maps coordinates to the entire desktop. Must be used with MOUSEEVENTF_ABSOLUTE.
68 | ///
69 | VirtualDesk = 0x4000,
70 |
71 | ///
72 | /// Specifies that the dx and dy members contain normalized absolute coordinates. If the flag is not set, dxand dy contain relative data (the change in position since the last reported position). This flag can be set, or not set, regardless of what kind of mouse or other pointing device, if any, is connected to the system. For further information about relative mouse motion, see the following Remarks section.
73 | ///
74 | Absolute = 0x8000,
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/Native/NativeMethods.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace WindowsInput.Native
5 | {
6 | ///
7 | /// References all of the Native Windows API methods for the WindowsInput functionality.
8 | ///
9 | internal static class NativeMethods
10 | {
11 | ///
12 | /// The GetAsyncKeyState function determines whether a key is up or down at the time the function is called, and whether the key was pressed after a previous call to GetAsyncKeyState. (See: http://msdn.microsoft.com/en-us/library/ms646293(VS.85).aspx)
13 | ///
14 | /// Specifies one of 256 possible virtual-key codes. For more information, see Virtual Key Codes. Windows NT/2000/XP: You can use left- and right-distinguishing constants to specify certain keys. See the Remarks section for further information.
15 | ///
16 | /// If the function succeeds, the return value specifies whether the key was pressed since the last call to GetAsyncKeyState, and whether the key is currently up or down. If the most significant bit is set, the key is down, and if the least significant bit is set, the key was pressed after the previous call to GetAsyncKeyState. However, you should not rely on this last behavior; for more information, see the Remarks.
17 | ///
18 | /// Windows NT/2000/XP: The return value is zero for the following cases:
19 | /// - The current desktop is not the active desktop
20 | /// - The foreground thread belongs to another process and the desktop does not allow the hook or the journal record.
21 | ///
22 | /// Windows 95/98/Me: The return value is the global asynchronous key state for each virtual key. The system does not check which thread has the keyboard focus.
23 | ///
24 | /// Windows 95/98/Me: Windows 95 does not support the left- and right-distinguishing constants. If you call GetAsyncKeyState with these constants, the return value is zero.
25 | ///
26 | ///
27 | /// The GetAsyncKeyState function works with mouse buttons. However, it checks on the state of the physical mouse buttons, not on the logical mouse buttons that the physical buttons are mapped to. For example, the call GetAsyncKeyState(VK_LBUTTON) always returns the state of the left physical mouse button, regardless of whether it is mapped to the left or right logical mouse button. You can determine the system's current mapping of physical mouse buttons to logical mouse buttons by calling
28 | /// Copy CodeGetSystemMetrics(SM_SWAPBUTTON) which returns TRUE if the mouse buttons have been swapped.
29 | ///
30 | /// Although the least significant bit of the return value indicates whether the key has been pressed since the last query, due to the pre-emptive multitasking nature of Windows, another application can call GetAsyncKeyState and receive the "recently pressed" bit instead of your application. The behavior of the least significant bit of the return value is retained strictly for compatibility with 16-bit Windows applications (which are non-preemptive) and should not be relied upon.
31 | ///
32 | /// You can use the virtual-key code constants VK_SHIFT, VK_CONTROL, and VK_MENU as values for the vKey parameter. This gives the state of the SHIFT, CTRL, or ALT keys without distinguishing between left and right.
33 | ///
34 | /// Windows NT/2000/XP: You can use the following virtual-key code constants as values for vKey to distinguish between the left and right instances of those keys.
35 | ///
36 | /// Code Meaning
37 | /// VK_LSHIFT Left-shift key.
38 | /// VK_RSHIFT Right-shift key.
39 | /// VK_LCONTROL Left-control key.
40 | /// VK_RCONTROL Right-control key.
41 | /// VK_LMENU Left-menu key.
42 | /// VK_RMENU Right-menu key.
43 | ///
44 | /// These left- and right-distinguishing constants are only available when you call the GetKeyboardState, SetKeyboardState, GetAsyncKeyState, GetKeyState, and MapVirtualKey functions.
45 | ///
46 | [DllImport("user32.dll", SetLastError = true)]
47 | public static extern Int16 GetAsyncKeyState(UInt16 virtualKeyCode);
48 |
49 | ///
50 | /// The GetKeyState function retrieves the status of the specified virtual key. The status specifies whether the key is up, down, or toggled (on, off alternating each time the key is pressed). (See: http://msdn.microsoft.com/en-us/library/ms646301(VS.85).aspx)
51 | ///
52 | ///
53 | /// Specifies a virtual key. If the desired virtual key is a letter or digit (A through Z, a through z, or 0 through 9), nVirtKey must be set to the ASCII value of that character. For other keys, it must be a virtual-key code.
54 | /// If a non-English keyboard layout is used, virtual keys with values in the range ASCII A through Z and 0 through 9 are used to specify most of the character keys. For example, for the German keyboard layout, the virtual key of value ASCII O (0x4F) refers to the "o" key, whereas VK_OEM_1 refers to the "o with umlaut" key.
55 | ///
56 | ///
57 | /// The return value specifies the status of the specified virtual key, as follows:
58 | /// If the high-order bit is 1, the key is down; otherwise, it is up.
59 | /// If the low-order bit is 1, the key is toggled. A key, such as the CAPS LOCK key, is toggled if it is turned on. The key is off and untoggled if the low-order bit is 0. A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled, and off when the key is untoggled.
60 | ///
61 | ///
62 | /// The key status returned from this function changes as a thread reads key messages from its message queue. The status does not reflect the interrupt-level state associated with the hardware. Use the GetAsyncKeyState function to retrieve that information.
63 | /// An application calls GetKeyState in response to a keyboard-input message. This function retrieves the state of the key when the input message was generated.
64 | /// To retrieve state information for all the virtual keys, use the GetKeyboardState function.
65 | /// An application can use the virtual-key code constants VK_SHIFT, VK_CONTROL, and VK_MENU as values for the nVirtKey parameter. This gives the status of the SHIFT, CTRL, or ALT keys without distinguishing between left and right. An application can also use the following virtual-key code constants as values for nVirtKey to distinguish between the left and right instances of those keys.
66 | /// VK_LSHIFT
67 | /// VK_RSHIFT
68 | /// VK_LCONTROL
69 | /// VK_RCONTROL
70 | /// VK_LMENU
71 | /// VK_RMENU
72 | ///
73 | /// These left- and right-distinguishing constants are available to an application only through the GetKeyboardState, SetKeyboardState, GetAsyncKeyState, GetKeyState, and MapVirtualKey functions.
74 | ///
75 | [DllImport("user32.dll", SetLastError = true)]
76 | public static extern Int16 GetKeyState(UInt16 virtualKeyCode);
77 |
78 | ///
79 | /// The SendInput function synthesizes keystrokes, mouse motions, and button clicks.
80 | ///
81 | /// Number of structures in the Inputs array.
82 | /// Pointer to an array of INPUT structures. Each structure represents an event to be inserted into the keyboard or mouse input stream.
83 | /// Specifies the size, in bytes, of an INPUT structure. If cbSize is not the size of an INPUT structure, the function fails.
84 | /// The function returns the number of events that it successfully inserted into the keyboard or mouse input stream. If the function returns zero, the input was already blocked by another thread. To get extended error information, call GetLastError.Microsoft Windows Vista. This function fails when it is blocked by User Interface Privilege Isolation (UIPI). Note that neither GetLastError nor the return value will indicate the failure was caused by UIPI blocking.
85 | ///
86 | /// Microsoft Windows Vista. This function is subject to UIPI. Applications are permitted to inject input only into applications that are at an equal or lesser integrity level.
87 | /// The SendInput function inserts the events in the INPUT structures serially into the keyboard or mouse input stream. These events are not interspersed with other keyboard or mouse input events inserted either by the user (with the keyboard or mouse) or by calls to keybd_event, mouse_event, or other calls to SendInput.
88 | /// This function does not reset the keyboard's current state. Any keys that are already pressed when the function is called might interfere with the events that this function generates. To avoid this problem, check the keyboard's state with the GetAsyncKeyState function and correct as necessary.
89 | ///
90 | [DllImport("user32.dll", SetLastError = true)]
91 | public static extern UInt32 SendInput(UInt32 numberOfInputs, INPUT[] inputs, Int32 sizeOfInputStructure);
92 |
93 | ///
94 | /// The GetMessageExtraInfo function retrieves the extra message information for the current thread. Extra message information is an application- or driver-defined value associated with the current thread's message queue.
95 | ///
96 | ///
97 | /// To set a thread's extra message information, use the SetMessageExtraInfo function.
98 | [DllImport("user32.dll")]
99 | public static extern IntPtr GetMessageExtraInfo();
100 | }
101 | }
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/Native/XButton.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsInput.Native
2 | {
3 | ///
4 | /// XButton definitions for use in the MouseData property of the structure. (See: http://msdn.microsoft.com/en-us/library/ms646273(VS.85).aspx)
5 | ///
6 | internal enum XButton : uint
7 | {
8 | ///
9 | /// Set if the first X button is pressed or released.
10 | ///
11 | XButton1 = 0x0001,
12 |
13 | ///
14 | /// Set if the second X button is pressed or released.
15 | ///
16 | XButton2 = 0x0002,
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("WindowsInput")]
10 | [assembly: AssemblyDescription("Provides a useful wrapper around the User32 SendInput and related native Windows functions for simulating Input Devices in Windows including Keyboard and Mouse.")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("michaelnoonan")]
13 | [assembly: AssemblyProduct("WindowsInput")]
14 | [assembly: AssemblyCopyright("Copyright © michaelnoonan 2010")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 | [assembly: CLSCompliant(true)]
18 | [assembly: InternalsVisibleTo("WindowsInput.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100737a78808b105748ff1251c1eb68752c2eb02dea580cade31d04fbc4081d7f420c639de2f3081461f734d48499c50133adb9dab02d828031cdec7d2941652233aefadf961658f948c13d43da9860d76ded6e959eebec0ddae03cc67dabf1aa83973602690e228c5b2d9434e62760d325d4c46a1fdf71971bb7a22f0de55b7bf0")]
19 |
20 | // Setting ComVisible to false makes the types in this assembly not visible
21 | // to COM components. If you need to access a type in this assembly from
22 | // COM, set the ComVisible attribute to true on that type.
23 | [assembly: ComVisible(false)]
24 |
25 | // The following GUID is for the ID of the typelib if this project is exposed to COM
26 | [assembly: Guid("25871eb0-27d6-42da-a3fe-cb60eb01f15a")]
27 |
28 | // Version information for an assembly consists of the following four values:
29 | //
30 | // Major Version
31 | // Minor Version
32 | // Build Number
33 | // Revision
34 | //
35 | // You can specify all the values or you can default the Build and Revision Numbers
36 | // by using the '*' as shown below:
37 | // [assembly: AssemblyVersion("1.0.*")]
38 | [assembly: AssemblyVersion("0.2.0.0")]
39 | [assembly: AssemblyFileVersion("0.2.0.0")]
40 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/WindowsInput.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.30729
7 | 2.0
8 | {3549CD6F-80F8-450F-B99E-CF0A736B1F2A}
9 | Library
10 | Properties
11 | WindowsInput
12 | WindowsInput
13 | v4.7
14 | 512
15 |
16 |
17 |
18 |
19 | 3.5
20 |
21 |
22 |
23 |
24 | true
25 | full
26 | false
27 | bin\Debug\
28 | DEBUG;TRACE
29 | prompt
30 | 4
31 | bin\Debug\WindowsInput.xml
32 | true
33 | AllRules.ruleset
34 | false
35 |
36 |
37 | pdbonly
38 | true
39 | bin\Release\
40 | TRACE
41 | prompt
42 | 4
43 | bin\Release\WindowsInput.xml
44 | AllRules.ruleset
45 | false
46 |
47 |
48 | true
49 |
50 |
51 | WindowsInput.snk
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 |
85 |
86 |
87 |
94 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/WindowsInput.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | InputSimulator
5 | 0.2.0.0
6 | Windows Input Simulator
7 | Michael Noonan
8 | Michael Noonan
9 | http://inputsimulator.codeplex.com/license
10 | http://inputsimulator.codeplex.com
11 | false
12 | The Windows Input Simulator provides a simple .NET (C#) interface to simulate Keyboard or Mouse input using the Win32 SendInput method. All of the Interop is done for you and there's a simple programming model for sending multiple keystrokes.
13 | This version introduces more comprehensive Unicode tests and support for Mouse Simulation.
14 | Copyright 2009-2013
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/WindowsInput.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zezba9000/RemoteDesktop/1e57faabf6056e2692711dbffa0982fbb1975eac/inputsimulator/WindowsInput/WindowsInput.snk
--------------------------------------------------------------------------------
/inputsimulator/WindowsInput/WindowsInputMessageDispatcher.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 | using WindowsInput.Native;
4 |
5 | namespace WindowsInput
6 | {
7 | ///
8 | /// Implements the by calling .
9 | ///
10 | internal class WindowsInputMessageDispatcher : IInputMessageDispatcher
11 | {
12 | ///
13 | /// Dispatches the specified list of messages in their specified order by issuing a single called to .
14 | ///
15 | /// The list of messages to be dispatched.
16 | /// If the array is empty.
17 | /// If the array is null.
18 | /// If the any of the commands in the array could not be sent successfully.
19 | public void DispatchInput(INPUT[] inputs)
20 | {
21 | if (inputs == null) throw new ArgumentNullException("inputs");
22 | if (inputs.Length == 0) throw new ArgumentException("The input array was empty", "inputs");
23 | var successful = NativeMethods.SendInput((UInt32)inputs.Length, inputs, Marshal.SizeOf(typeof (INPUT)));
24 | if (successful != inputs.Length)
25 | throw new Exception("Some simulated input commands were not sent successfully. The most common reason for this happening are the security features of Windows including User Interface Privacy Isolation (UIPI). Your application can only send commands to applications of the same or lower elevation. Similarly certain commands are restricted to Accessibility/UIAutomation applications. Refer to the project home page and the code samples for more information.");
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------