Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #define WINVER 0x0500
  4.  
  5.  
  6. int key[] = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 };
  7.  
  8. int main()
  9. {
  10. while (1) {
  11. Sleep(1);
  12.  
  13. if(GetKeyState(key[1]) != 0) printf("%x\n", GetKeyState(key[1]));
  14.  
  15. for (int i = 0; i < 10; i++) {
  16. if (GetKeyState(key[i]) & 0x8000) {
  17.  
  18. std::cout << "Sending Key " << key[i] << " " << i << std::endl;
  19.  
  20. INPUT ip;
  21. INPUT ip_keyup;
  22. INPUT ip_shift;
  23. INPUT ip_alt;
  24.  
  25. ip.type = INPUT_KEYBOARD;
  26. ip.ki.wScan = 0;
  27. ip.ki.time = 0;
  28. ip.ki.dwExtraInfo = 0;
  29. ip.ki.wVk = key[i];
  30. ip.ki.dwFlags = 0;
  31.  
  32. ip_keyup.type = INPUT_KEYBOARD;
  33. ip_keyup.ki.wScan = 0;
  34. ip_keyup.ki.time = 0;
  35. ip_keyup.ki.dwExtraInfo = 0;
  36. ip_keyup.ki.wVk = key[i];
  37. ip_keyup.ki.dwFlags = KEYEVENTF_KEYUP;
  38.  
  39.  
  40. ip_alt.type = INPUT_KEYBOARD;
  41. ip_alt.ki.wScan = 0;
  42. ip_alt.ki.time = 0;
  43. ip_alt.ki.dwExtraInfo = 0;
  44. ip_alt.ki.wVk = VK_MENU;
  45. ip_alt.ki.dwFlags = 0;
  46.  
  47. ip_shift.type = INPUT_KEYBOARD;
  48. ip_shift.ki.wScan = 0;
  49. ip_shift.ki.time = 0;
  50. ip_shift.ki.dwExtraInfo = 0;
  51. ip_shift.ki.wVk = VK_SHIFT;
  52. ip_shift.ki.dwFlags = 0;
  53.  
  54. INPUT keyInput4[4] = { 0 };
  55. INPUT keyInput3[3] = { 0 };
  56.  
  57. if (GetKeyState(VK_SHIFT) & 0x8000) {
  58. std::cout << "With Shift" << std::endl;
  59. keyInput4[0] = ip;
  60. keyInput4[1] = ip_shift;
  61. keyInput4[2] = ip_keyup;
  62. keyInput4[3] = ip;
  63.  
  64. if (GetKeyState(key[i]) & 0x8000) {
  65. SendInput(4, keyInput4, sizeof(INPUT));
  66. }
  67. } else if (GetKeyState(VK_MENU) & 0x8000) {
  68. std::cout << "With Alt" << std::endl;
  69. keyInput4[0] = ip;
  70. keyInput4[1] = ip_alt;
  71. keyInput4[2] = ip_keyup;
  72. keyInput4[3] = ip;
  73.  
  74. if (GetKeyState(key[i]) & 0x8000) {
  75. SendInput(4, keyInput4, sizeof(INPUT));
  76. }
  77. } else {
  78. keyInput3[0] = ip;
  79. keyInput3[1] = ip_keyup;
  80. keyInput3[2] = ip;
  81.  
  82. if (GetKeyState(key[i]) & 0x8000) {
  83. SendInput(3, keyInput3, sizeof(INPUT));
  84. }
  85. }
  86.  
  87. Sleep(5);
  88. }
  89. }
  90. }
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement