2 Problems with SendKeys ^ escaped with "{^}" output & on DE key layout and ctrl was used in all escaped cases to the end of line
Since SendKeys probably does not represent the functionality needed for such a task, I have searched for an alternative to sendKeys and also found. The nuget InputSimulator brings the necessary functionality. https://csharp.hotexamples.com/de/examples/WindowsInput/InputSimulator/-/php-inputsimulator-class-examples.html
using WindowsInput;
using WindowsInput.Native;
[DllImport("User32.dll")]
static extern int SetForegroundWindow(IntPtr point);
var sim = new InputSimulator();
string sProcess = "notepad";
string sTest = "!7(!X)um()-JDTd^/m+;s~ff()~+%^";
int PIDCount = Process.GetProcessesByName(sProcess).Count();
if (PIDCount == 1)
{
if (p != null)
{
IntPtr h = p.MainWindowHandle;
SetForegroundWindow(h);
Process p = Process.GetProcessesByName(sProcess).FirstOrDefault();
sim.Keyboard.TextEntry(sTest);
}
}