As others have said, you will run into problems if you try this with the usual HID. However, there is a project called USB Rubber Ducky . From their description:
The USB Rubber Ducky isn't your ordinary HID (Human Interface Device). Coupled with a powerful 60 MHz 32-bit processor and a simple scripting language
USB Rubber Ducky looks like a USB device and is recognized as a HID, but is programmable. You can make a small script that will be printed on the screen, which will allow you to fulfill the queries that you are looking for.
With USB Rubber Ducky you can:
Read the data from the form on the screen? Yes
Find out which OS the user is on? Yes
Find out if an error message has appeared? Yes
Even to “know” what is happening visually on the screen, that is, which program is selected or is the program or full screen mode finished? Yes
If you are not hoping to buy this device, at least their firmware is on github so that it can provide you with a starting point.
source share