0 votes
1 view
in RPA by (5.3k points)
recategorized by

I'm working with the RPA software UIPath. UIPath simulates keystrokes and mouse clicks. What I want to do is differentiate between when I open notepad and type a keystroke manually as the user and when I run my UIPath robot and have the bot type into notepad.

The reason is I am trying to filter out the difference between a user manually typing and the UIPath bot typing. I need to do this for another piece of software that's running that is monitoring keystrokes and mouse clicks. I want the software to not record keystrokes and mouse clicks from the bot and would like to be able to find the execution path of the UIPath bot so I can set up a filter.

My solutions is I'd like to run some C# code and have the console log the different execution paths between me typing manually in the keyboard and then compare it with UIPath bot typing. I'm unsure of how to do this and all I can do is just record in the console if 'a','b','7' etc... was typed, but not exactly the path that was taken for 'a', 'b', '7', etc to be typed. Any help or other suggestions on how to solve this problem would be really appreciated.

1 Answer

0 votes
by (9.5k points)

following are the steps you can code to detect if a keyboard or mouse input is simulated or not :

  1. capture low-level keyboard and mouse events using SetWindowsHookEx() i.e.WH_KEYBOARD_LL and WH_MOUSE_LL

  2. The hook procedure for WH_KEYBOARD_LL will receive KBDLLHOOKSTRUCT structure and for WH_MOUSE_LL it will be MSLLHOOKSTRUCT structure.

  3. KBDLLHOOKSTRUCT has flags field . If LLKHF_INJECTED is set for this field , it would mean that this keyboard input was injected. Keyboard events produced by driver doesn't have this flag set.

  4. Similarly MSLLHOOKSTRUCT has flags field. If LLKHF_INJECTED is set for this field , it would mean that this mouse input was injected. Mouse events produced by driver doesn't have this flag set.

These flags are set on windows kernel level and it is not possible to change them using winapi. I had read about this technique being used by the anti-cheat system for games in the book Practical Video Game Bots. Please note that if you use C# library like globalmousekeyhook, this data might not be available in the MouseEventExtArgs/KeyboardEventArgsEx that is being passed to callback function. Please check any third party library you might be using for availability of this data




Welcome to Intellipaat Community. Get your technical queries answered by top developers !