I'm trying to simulate click and drag on the Windows 10 Touch keyboard, on its handwriting window using a C# app. I am using the following code -
class Program
{
[DllImport("user32.dll")]
public static extern bool SetCursorPos(int X, int Y);
static void Main(string[] args)
{
int x = 525;
int y = 1500;
SetCursorPos(x, y);
MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown, x, y);
for (int i=0; i<1000; i++)
{
Thread.Sleep(2);
SetCursorPos(++x, y);
}
MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp, x, y);
}
}
The MouseOperations code is from the second answer here. This works great for click and drag on MS Paint and I can see a line being drawn. But when I use the same code on the Windows 10 touch keyboard's handwriting view, it does not show a line being drawn, just one dot. I've tried different sleep times, but it does not work even though I can see the mouse cursor moving as expected - the line does not show. I tried simulating simple clicks on the keyboard view (not the handwriting view), and that also seems to work. How do I simulate mouse click and drag on the handwriting view of the keyboard? I hope to eventually use this code for Unity, so I'm not completely sure if I want to make a "UWP app" as some online links show - there seems to be a separate method for injecting events in UWP apps.