diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..9792623
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,24 @@
+{
+ // Use IntelliSense to learn about possible attributes.
+ // Hover to view descriptions of existing attributes.
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": ".NET Core Launch (console)",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ "program": "${workspaceFolder}/Example/bin/Debug/net8.0/Example.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}/Example",
+ "console": "internalConsole",
+ "stopAtEntry": false
+ },
+ {
+ "name": ".NET Core Attach",
+ "type": "coreclr",
+ "request": "attach"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 4bf1aaf..dfb3edd 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -21,6 +21,42 @@
"isDefault": true
},
"detail": "Task generated by Debugger."
+ },
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build",
+ "${workspaceFolder}/Desktop.Robot.sln",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary;ForceNoAlign"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "publish",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "publish",
+ "${workspaceFolder}/Desktop.Robot.sln",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary;ForceNoAlign"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "watch",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "watch",
+ "run",
+ "--project",
+ "${workspaceFolder}/Desktop.Robot.sln"
+ ],
+ "problemMatcher": "$msCompile"
}
],
"version": "2.0.0"
diff --git a/Desktop.Robot.TestApp/Desktop.Robot.TestApp.fsproj b/Desktop.Robot.TestApp/Desktop.Robot.TestApp.fsproj
index 8b74aa8..8c02849 100644
--- a/Desktop.Robot.TestApp/Desktop.Robot.TestApp.fsproj
+++ b/Desktop.Robot.TestApp/Desktop.Robot.TestApp.fsproj
@@ -1,7 +1,7 @@
Exe
- net6.0
+ net8.0
3390;$(WarnOn)
@@ -14,10 +14,11 @@
-
-
-
-
+
+
+
+
-
+
+
\ No newline at end of file
diff --git a/Desktop.Robot.sln b/Desktop.Robot.sln
index 69cb8aa..dacca3d 100644
--- a/Desktop.Robot.sln
+++ b/Desktop.Robot.sln
@@ -7,8 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Desktop.Robot", "Desktop.Ro
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "Example\Example.csproj", "{9B7B0021-B931-4488-84E7-D4DD4C74A555}"
EndProject
-Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Desktop.Robot.TestApp", "Desktop.Robot.TestApp\Desktop.Robot.TestApp.fsproj", "{05C9255A-C2BE-4F80-9EA1-9038DE424FB4}"
-EndProject
+#Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Desktop.Robot.TestApp", "Desktop.Robot.TestApp\Desktop.Robot.TestApp.fsproj", "{05C9255A-C2BE-4F80-9EA1-9038DE424FB4}"
+#EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -46,17 +46,17 @@ Global
{9B7B0021-B931-4488-84E7-D4DD4C74A555}.Release|x64.Build.0 = Release|Any CPU
{9B7B0021-B931-4488-84E7-D4DD4C74A555}.Release|x86.ActiveCfg = Release|Any CPU
{9B7B0021-B931-4488-84E7-D4DD4C74A555}.Release|x86.Build.0 = Release|Any CPU
- {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Debug|x64.ActiveCfg = Debug|Any CPU
- {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Debug|x64.Build.0 = Debug|Any CPU
- {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Debug|x86.ActiveCfg = Debug|Any CPU
- {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Debug|x86.Build.0 = Debug|Any CPU
- {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Release|Any CPU.Build.0 = Release|Any CPU
- {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Release|x64.ActiveCfg = Release|Any CPU
- {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Release|x64.Build.0 = Release|Any CPU
- {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Release|x86.ActiveCfg = Release|Any CPU
- {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Release|x86.Build.0 = Release|Any CPU
+# {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+# {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+# {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Debug|x64.ActiveCfg = Debug|Any CPU
+# {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Debug|x64.Build.0 = Debug|Any CPU
+# {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Debug|x86.ActiveCfg = Debug|Any CPU
+# {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Debug|x86.Build.0 = Debug|Any CPU
+# {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+# {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Release|Any CPU.Build.0 = Release|Any CPU
+# {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Release|x64.ActiveCfg = Release|Any CPU
+# {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Release|x64.Build.0 = Release|Any CPU
+# {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Release|x86.ActiveCfg = Release|Any CPU
+# {05C9255A-C2BE-4F80-9EA1-9038DE424FB4}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/Desktop.Robot/Desktop.Robot.csproj b/Desktop.Robot/Desktop.Robot.csproj
index acfee29..b1eba90 100644
--- a/Desktop.Robot/Desktop.Robot.csproj
+++ b/Desktop.Robot/Desktop.Robot.csproj
@@ -1,15 +1,18 @@
- net6.0
- 1.5.0
+ net8.0
+ 1.5.2
true
- Lucas Simas
- A library used to control your mouse and keyboard programmatically in .NET Core
+ Lucas Simas, Christoph Döllinger
+ A library used to control your mouse and keyboard programmatically in .NET Core
+Updated to .NET 8
https://lucassklp.github.io/Desktop.Robot/
- https://github.com/lucassklp/Desktop.Robot
+ https://github.com/MrDoe/Desktop.Robot
logo.mini.png
LICENSE
README.md
+ $(AssemblyName)_Net8_v
+ $(AssemblyName)_Net8_v
@@ -19,8 +22,8 @@
-
-
+
+
diff --git a/Desktop.Robot/Linux/Robot.cs b/Desktop.Robot/Linux/Robot.cs
index 9500b80..1eb2816 100644
--- a/Desktop.Robot/Linux/Robot.cs
+++ b/Desktop.Robot/Linux/Robot.cs
@@ -44,9 +44,38 @@ public override void KeyPress(Key key)
public override void KeyPress(char key)
{
ApplyAutoDelay();
- var flags = char.IsUpper(key) ? (1 << 0) : 0;
- pressKey(key, true, flags);
- pressKey(key, false, flags);
+ // Get the high order byte of the result to check for Ctrl and Alt keys
+ var highOrderByte = char.IsUpper(key) ? (1 << 0) : 0;
+
+ // Check if the key is uppercase or if AltGr (Ctrl + Alt) is needed
+ if ((highOrderByte & 1) == 1) // Shift
+ {
+ KeyDown(Key.Shift);
+ }
+ if ((highOrderByte & 2) == 2) // Ctrl
+ {
+ KeyDown(Key.Control);
+ }
+ if ((highOrderByte & 4) == 4) // Alt
+ {
+ KeyDown(Key.Alt);
+ }
+
+ pressKey(key, true, highOrderByte);
+ pressKey(key, false, highOrderByte);
+
+ if ((highOrderByte & 1) == 1) // Shift
+ {
+ KeyUp(Key.Shift);
+ }
+ if ((highOrderByte & 2) == 2) // Ctrl
+ {
+ KeyUp(Key.Control);
+ }
+ if ((highOrderByte & 4) == 4) // Alt
+ {
+ KeyUp(Key.Alt);
+ }
}
public override void KeyUp(Key key)
@@ -69,7 +98,6 @@ public override void MouseMove(int x, int y)
moveMouse(x, y);
}
-
public override void MouseScroll(int value)
{
ApplyAutoDelay();
@@ -84,7 +112,7 @@ public override void MouseScroll(int value, TimeSpan duration)
public override void MouseScroll(int value, TimeSpan duration, int steps)
{
ApplyAutoDelay();
- for (int i = 0; i < steps; i++)
+ for (int i = 0; i < steps; ++i)
{
DoMouseScroll(value / steps, Convert.ToInt32(duration.TotalMilliseconds) / steps);
}
diff --git a/Desktop.Robot/Windows/Robot.cs b/Desktop.Robot/Windows/Robot.cs
index 0db03c4..6d678e1 100644
--- a/Desktop.Robot/Windows/Robot.cs
+++ b/Desktop.Robot/Windows/Robot.cs
@@ -2,6 +2,7 @@
using System.Drawing;
using System.Runtime.InteropServices;
using System.Threading;
+using System.Threading.Tasks;
namespace Desktop.Robot.Windows
{
@@ -42,13 +43,44 @@ public override void KeyPress(Key key)
public override void KeyPress(char key)
{
- ApplyAutoDelay();
- var keycode = (byte)VkKeyScan(key);
- keybd_event(keycode, 0, 0, 0);
- keybd_event(keycode, 0, 2, 0);
- }
+ ApplyAutoDelay();
+ short result = VkKeyScan(key);
+
+ // Get the high order byte of the result to check for Ctrl and Alt keys
+ var highOrderByte = (result >> 8) & 0xFF;
+
+ // Check if the key is uppercase or if AltGr (Ctrl + Alt) is needed
+ if ((highOrderByte & 1) == 1) // Shift
+ {
+ KeyDown(Key.Shift);
+ }
+ if ((highOrderByte & 2) == 2) // Ctrl
+ {
+ KeyDown(Key.Control);
+ }
+ if ((highOrderByte & 4) == 4) // Alt
+ {
+ KeyDown(Key.Alt);
+ }
+
+ keybd_event((byte)result, 0, 0, 0); // key down
+ keybd_event((byte)result, 0, 2, 0); // key up
+
+ if ((highOrderByte & 1) == 1) // Shift
+ {
+ KeyUp(Key.Shift);
+ }
+ if ((highOrderByte & 2) == 2) // Ctrl
+ {
+ KeyUp(Key.Control);
+ }
+ if ((highOrderByte & 4) == 4) // Alt
+ {
+ KeyUp(Key.Alt);
+ }
+ }
- public override void KeyUp(Key key)
+ public override void KeyUp(Key key)
{
ApplyAutoDelay();
var metadata = key.GetKeycode();
diff --git a/Example/Example.csproj b/Example/Example.csproj
index e50c7a2..98b5fec 100644
--- a/Example/Example.csproj
+++ b/Example/Example.csproj
@@ -2,7 +2,7 @@
Exe
- net6.0
+ net8.0
diff --git a/README.md b/README.md
index fdd3fce..bb674de 100644
--- a/README.md
+++ b/README.md
@@ -20,13 +20,13 @@ I made this library because the dotnet SDK doesn't support simulation of mouse a
If you are using Package Manager:
```bash
-Install-Package Desktop.Robot -Version 1.5.0
+Install-Package Desktop.Robot -Version 1.5.2
```
If you are using .NET CLI
```bash
-dotnet add package Desktop.Robot --version 1.5.0
+dotnet add package Desktop.Robot --version 1.5.2
```
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj
index c3717b2..3858941 100644
--- a/Tests/Tests.csproj
+++ b/Tests/Tests.csproj
@@ -6,7 +6,7 @@
-
+