Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.48 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <cstdlib>
  4. #include <ctime>
  5. #include <thread>
  6. #include <Windows.h>
  7.  
  8. int Random(int Min, int Max)
  9. {
  10. int Result = rand() % Max + Min;
  11. return Result;
  12. }
  13.  
  14. void RandomNumber(int* Number, int Min, int Max)
  15. {
  16. *Number = Random(Min, Max);
  17. }
  18.  
  19. void ActiveCheck(bool* Active)
  20. {
  21. while(true)
  22. {
  23. std::this_thread::sleep_for(std::chrono::milliseconds(5));
  24. if (GetAsyncKeyState(0x77))
  25. {
  26. *Active = false;
  27. }
  28. std::this_thread::sleep_for(std::chrono::milliseconds(5));
  29. }
  30. }
  31.  
  32.  
  33. class Action
  34. {
  35. public:
  36.  
  37. void Delay(int ms)
  38. {
  39. std::this_thread::sleep_for(std::chrono::milliseconds(ms));
  40. }
  41.  
  42. void KeyboradInput(int VirtualCode , int DwFlags)
  43. {
  44. int HumanDelay;
  45. RandomNumber(&HumanDelay, 110, 250);
  46. Delay(HumanDelay);
  47. INPUT input;
  48. input.type = INPUT_KEYBOARD;
  49. input.ki.wScan = MapVirtualKey(VirtualCode , MAPVK_VK_TO_VSC);
  50. input.ki.time = NULL;
  51. input.ki.dwExtraInfo = NULL;
  52. input.ki.wVk = VirtualCode;
  53. input.ki.dwFlags = DwFlags;
  54. SendInput(1, &input, sizeof(INPUT));
  55. }
  56.  
  57. void MouseInput(int x , int y , int DwFlags)
  58. {
  59. int HumanDelay;
  60. RandomNumber(&HumanDelay, 110, 250);
  61. Delay(HumanDelay);
  62. INPUT input;
  63. input.type = INPUT_MOUSE;
  64. input.mi.dx = x;
  65. input.mi.dy = y;
  66. input.mi.mouseData = NULL;
  67. input.mi.dwFlags = DwFlags;
  68. input.mi.time = NULL;
  69. input.mi.dwExtraInfo = NULL;
  70. SendInput(1, &input, sizeof(INPUT));
  71. }
  72. };
  73.  
  74. void InputAction(int ActionNumber , int UseKeyInput, int UseMouseInput , int VirtualCode, int MouseDwFlags , int MouseDwFlags2, int UseDelayBetweenKeyInput, int UseDelayBetweenMouseInput)
  75. {
  76. int RandomPixelsX, RandomPixelsY , RandomDelay , HumanDelay;
  77. RandomNumber(&HumanDelay, 110, 250);
  78. RandomNumber(&RandomDelay, 700, 1200);
  79. RandomNumber(&RandomPixelsX, -750, 1400);
  80. RandomNumber(&RandomPixelsY, -300, 600);
  81. Action t1;
  82. std::cout << ActionNumber << "\t Key:" << "\t " << VirtualCode << std::endl;
  83. if (UseKeyInput == 1)
  84. {
  85. t1.KeyboradInput(VirtualCode, NULL);
  86. }
  87. if (UseDelayBetweenKeyInput == 1)
  88. {
  89. t1.Delay(HumanDelay);
  90. }
  91. if (UseDelayBetweenKeyInput == 2)
  92. {
  93. t1.Delay(RandomDelay);
  94. }
  95. if (UseKeyInput == 1)
  96. {
  97. t1.KeyboradInput(VirtualCode, KEYEVENTF_KEYUP);
  98. }
  99. if (UseMouseInput == 1 || UseMouseInput == 2)
  100. {
  101. t1.MouseInput(RandomPixelsX, RandomPixelsY, MouseDwFlags);
  102. }
  103. if (UseDelayBetweenMouseInput == 1)
  104. {
  105. t1.Delay(HumanDelay);
  106. }
  107. if (UseDelayBetweenMouseInput == 2)
  108. {
  109. t1.Delay(RandomDelay);
  110. }
  111. if (UseMouseInput == 2)
  112. {
  113. t1.MouseInput(RandomPixelsX, RandomPixelsY, MouseDwFlags2);
  114. }
  115. }
  116.  
  117.  
  118.  
  119. int main(int RandomAction , int LoopDelay , bool Active = false)
  120. {
  121. SetConsoleTitle("Afk Bot");
  122. while (true)
  123. {
  124. Action Delay;
  125. Delay.Delay(1);
  126. while (true)
  127. {
  128. Delay.Delay(100);
  129. std::thread t1(ActiveCheck, &Active);
  130. t1.detach();
  131. while (GetAsyncKeyState(0x76))
  132. {
  133. Active = true;
  134. while (Active == true)
  135. {
  136. srand(Random(1, 100));
  137. RandomNumber(&LoopDelay, 100, 200);
  138. RandomNumber(&RandomAction, 1, 250);
  139. std::cout << "Delay: " << LoopDelay << std::endl;
  140. Delay.Delay(LoopDelay);
  141.  
  142. if (RandomAction <= 25)
  143. {
  144. InputAction(1 , 1, 1, 0x57, MOUSEEVENTF_MOVE, NULL, 2, 1);
  145. }
  146. if (RandomAction >= 26 && RandomAction <=50)
  147. {
  148. InputAction(2 , 1, 1, 0x44, MOUSEEVENTF_MOVE, NULL, 2, 1);
  149. }
  150. if (RandomAction >= 51 && RandomAction <= 75)
  151. {
  152. InputAction(3 , 1, 1, 0x20, MOUSEEVENTF_MOVE, NULL, 1, 1);
  153. }
  154. if (RandomAction >= 76 && RandomAction <= 100)
  155. {
  156. InputAction(4 , 1, 1, 0x57, MOUSEEVENTF_MOVE, NULL, 2, 1);
  157. }
  158. if (RandomAction >= 101 && RandomAction <= 125)
  159. {
  160. InputAction(5 , 1, 1, 0x53, MOUSEEVENTF_MOVE, NULL, 1, 1);
  161. }
  162. if (RandomAction >= 126 && RandomAction <= 135)
  163. {
  164. InputAction(6 , 1, 1, 0x51, MOUSEEVENTF_MOVE, NULL, 1, 1);
  165. }
  166. if (RandomAction >= 136 && RandomAction <= 150)
  167. {
  168. InputAction(7 , 1, 1, 0x51, MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP, 1, 2);
  169. }
  170. if (RandomAction >= 151 && RandomAction <= 175)
  171. {
  172. InputAction(8 , 1, 1, 0x41, MOUSEEVENTF_MOVE, NULL, 2, 1);
  173. }
  174. else if (RandomAction >= 176 && RandomAction <= 200)
  175. {
  176. InputAction(9 , 1, 1, 0x11, MOUSEEVENTF_MOVE, NULL, 2, 1);
  177. }
  178. if (RandomAction >= 201 && RandomAction <= 250)
  179. {
  180. InputAction(10 , 1, 1, 0x57, MOUSEEVENTF_MOVE, NULL, 2, 1);
  181. }
  182. }
  183. }
  184.  
  185. break;
  186. }
  187. }
  188. return 0;
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement