I've stuck with the following issue. I have automated Selenium tests that are deployed into ADO then the tests are running using Windows agents on AWS EC2. Some of the tests are require to upload a file from Windows directory into the application. We are using this commands to upload the file:
Clipboard.SetText(filePath);
InputSimulator.Keyboard.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_V);
InputSimulator.Keyboard.KeyPress(VirtualKeyCode.RETURN);
The error we are getting is this:
-> error: 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.
I tried to wait time between keyboard operation to allow a proper switch. Also, I tried to add InputSimulator.Keyboard.KeyUp(VirtualKeyCode.CONTROL) to release CTRL button. It didn't help