wheelsmanx

keyBoardScript

Nov 27th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3. #include <map>
  4.  
  5. using namespace std;
  6.  
  7. class key {
  8. public:
  9. map<string, WORD> keys;
  10. void add(string name, WORD input) {
  11. pair<string, WORD> temp(name, input);
  12. keys.insert(temp);
  13. }
  14. key() {
  15. this->add("tab", 0x09);
  16. this->add("alt", 0x12);
  17. this->add("up", 0x26);
  18. this->add("down", 0x28);
  19. this->add("left", 0x25);
  20. this->add("right", 0x27);
  21. this->add("a", 0x41);
  22. this->add("LCLICK", 0x01);
  23. this->add("RCLICK", 0x02);
  24. }
  25.  
  26. WORD operator[](string input) {
  27. WORD returnObject = this->keys[input];
  28. return returnObject;
  29. }
  30. };
  31.  
  32.  
  33. class keyboardInput{
  34. public:
  35. INPUT ip;
  36. key keys;
  37. keyboardInput() {
  38. Sleep(5000);
  39. ip.type = INPUT_KEYBOARD;
  40. ip.ki.wScan = 0;
  41. ip.ki.time = 0;
  42. ip.ki.dwExtraInfo = 0;
  43. }
  44. void mouse(int x , int y) {
  45. ip.type = INPUT_MOUSE;
  46. ip.mi.mouseData = 0;
  47. ip.mi.dx = x * (65536 / GetSystemMetrics(SM_CXSCREEN));
  48. ip.mi.dy = y * (65536 / GetSystemMetrics(SM_CXSCREEN));
  49. ip.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
  50. SendInput(1, &ip, sizeof(INPUT));
  51. Sleep(500);
  52. ip.type = INPUT_KEYBOARD;
  53. }
  54. void press(WORD keyPress) {
  55. ip.ki.wVk = keyPress;
  56. ip.ki.dwFlags = 0;
  57. SendInput(1, &ip, sizeof(INPUT));
  58. }
  59. void press(string input) {
  60. WORD keyPress = this->keys[input];
  61. ip.ki.wVk = keyPress;
  62. ip.ki.dwFlags = 0;
  63. SendInput(1, &ip, sizeof(INPUT));
  64. }
  65. void press(WORD keyPress ,WORD keyPress2) {
  66. ip.ki.wVk = keyPress;
  67. ip.ki.dwFlags = 0;
  68. SendInput(1, &ip, sizeof(INPUT));
  69. ip.ki.wVk = keyPress2;
  70. ip.ki.dwFlags = 0;
  71. SendInput(1, &ip, sizeof(INPUT));
  72.  
  73. }
  74. void press(WORD keyPress, int numberOfSeconds) {
  75. ip.ki.wVk = keyPress;
  76. ip.ki.dwFlags = 0;
  77. SendInput(1, &ip, sizeof(INPUT));
  78. Sleep(numberOfSeconds);
  79. ip.ki.wVk = keyPress;
  80. ip.ki.dwFlags = KEYEVENTF_KEYUP;
  81. SendInput(1, &ip, sizeof(INPUT));
  82. }
  83. void release(WORD keyPress) {
  84. ip.ki.wVk = keyPress;
  85. ip.ki.dwFlags = KEYEVENTF_KEYUP;
  86. SendInput(1, &ip, sizeof(INPUT));
  87. }
  88. void release(string input) {
  89. WORD keyPress = this->keys[input];
  90. ip.ki.wVk = keyPress;
  91. ip.ki.dwFlags = KEYEVENTF_KEYUP;
  92. SendInput(1, &ip, sizeof(INPUT));
  93. }
  94. void release(WORD keyPress ,WORD keyPress2) {
  95. ip.ki.wVk = keyPress;
  96. ip.ki.dwFlags = KEYEVENTF_KEYUP;
  97. SendInput(1, &ip, sizeof(INPUT));
  98. ip.ki.wVk = keyPress2;
  99. ip.ki.dwFlags = KEYEVENTF_KEYUP;
  100. SendInput(1, &ip, sizeof(INPUT));
  101. }
  102. void tap(WORD keyPress) {
  103. ip.ki.wVk = keyPress;
  104. ip.ki.dwFlags = 0;
  105. SendInput(1, &ip, sizeof(INPUT));
  106. Sleep(500);
  107. ip.ki.wVk = keyPress;
  108. ip.ki.dwFlags = KEYEVENTF_KEYUP;
  109. SendInput(1, &ip, sizeof(INPUT));
  110. }
  111. void tap(string input) {
  112. WORD tempWord = this->keys[input];
  113. ip.ki.wVk = tempWord;
  114. ip.ki.dwFlags = 0;
  115. SendInput(1, &ip, sizeof(INPUT));
  116. Sleep(500);
  117. ip.ki.wVk = tempWord;
  118. ip.ki.dwFlags = KEYEVENTF_KEYUP;
  119. SendInput(1, &ip, sizeof(INPUT));
  120. }
  121. void hold(WORD keyPress, int time) {
  122. ip.ki.wVk = keyPress;
  123. ip.ki.dwFlags = 0;
  124. SendInput(1, &ip, sizeof(INPUT));
  125. Sleep(time);
  126. ip.ki.wVk = keyPress;
  127. ip.ki.dwFlags = KEYEVENTF_KEYUP;
  128. SendInput(1, &ip, sizeof(INPUT));
  129. }
  130. };
  131.  
  132. void main() {
  133. keyboardInput temp;
  134. key key;
  135.  
  136. temp.tap(key["alt"]);
  137.  
  138. system("pause");
  139. }
Advertisement
Add Comment
Please, Sign In to add comment