Advertisement
STANAANDREY

sInput

Mar 24th, 2020
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #define WINVER 0x0500
  2. #include <windows.h>
  3. void SendKbInp(const char *str, const DWORD delayT = 0, const DWORD delayT2 = 0, bool pressEnter = true)
  4. {
  5.     INPUT ip;
  6.     Sleep(delayT);
  7.     ip.type = INPUT_KEYBOARD;
  8.     ip.ki.wScan = 0;
  9.     ip.ki.time = 0;
  10.     ip.ki.dwExtraInfo = 0;
  11.     for (int i = 0;;)
  12.     {
  13.         char c;
  14.         if (!str[i]){
  15.             if (!pressEnter)
  16.                 return;
  17.             c = VK_RETURN;
  18.             pressEnter = false;
  19.         }
  20.         else
  21.             c = str[i++];
  22.  
  23.         ip.ki.wVk = VkKeyScanA(c);
  24.         ip.ki.dwFlags = false;
  25.         SendInput(1, &ip, sizeof(INPUT));
  26.         ip.ki.dwFlags = KEYEVENTF_KEYUP;
  27.         SendInput(1, &ip, sizeof(INPUT));
  28.         Sleep(1);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement