I'm curious to know how Top RPA tools like AA and UiPath simulate keystroke to the applications. I've built a application with use of Keybd_event to simulate keystrokes but i keep facing the issue of scan code parameter of keybd_event - as it required to perform keystroke in Citrix environment.
private void PressKeyVK(int eKeys, bool bHoldKeydown, bool bRelease)
{
int lScan, lExtended;
lScan = MapVirtualKey(eKeys, 1);
lExtended = 0;
if (lScan == 0)
lExtended = (int)KeyBoardEventEnums.KEYEVENTF_EXTENDEDKEY;
lScan = MapVirtualKey(eKeys, 0);
if (!bRelease)
keybd_event((byte)eKeys, (byte)lScan, (uint)lExtended, UIntPtr.Zero);
if (!bHoldKeydown)
keybd_event((byte)eKeys, (byte)lScan, (uint)KeyBoardEventEnums.KEYEVENTF_KEYUP | (uint)lExtended, UIntPtr.Zero);
}
where as below code works well on citrix environment but have issues with local applications.
lScan = MapVirtualKey(eKeys, 1); //flag 1: returns virtual key code of scan code eKeys.
If flag 2 is used it works well in local applications but SHIFT , ESC and Function keys not working citrix applications.
Please suggest that how the flag can be used to have this code worked in both citrix and local applications.
API references :