Advertisement
Guest User

c++ strafebot

a guest
Apr 27th, 2013
1,834
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <windows.h>
  4. POINT Center, CurPos;
  5. bool FirstTime=true;
  6. int SendKeyPress(unsigned short KeyCode, bool IsDown);
  7.  
  8. int main()
  9. {
  10. printf("Mouse4 to set strafe center point");
  11. while(true)
  12. {
  13. if(GetAsyncKeyState(VK_XBUTTON1) & (1 << 15))
  14. {
  15. if(FirstTime)
  16. {
  17. GetCursorPos(&Center);
  18. FirstTime=false;
  19. printf("Strafebot activated\nHold Mouse4 to strafe\nThis is made by ongiK @hf\nCompiled this source for d3scene members - Atex");
  20. MessageBox(NULL, "Center Position Set", "Strafe Bot", NULL);
  21.  
  22. }
  23. GetCursorPos(&CurPos);
  24. if(CurPos.x > Center.x)
  25. {
  26. SendKeyPress(0x20, true);
  27. Sleep(1);
  28. SendKeyPress(0x20, false);
  29. }
  30. else if(CurPos.x < Center.x)
  31. {
  32. SendKeyPress(0x1e, true);
  33. Sleep(1);
  34. SendKeyPress(0x1e, false);
  35. }
  36. }
  37. }
  38. return 0;
  39. }
  40.  
  41. int SendKeyPress(unsigned short KeyCode, bool KeyDown)
  42. {
  43. INPUT InputData;
  44. InputData.type =INPUT_KEYBOARD;
  45. InputData.ki.wScan =KeyCode;
  46. InputData.ki.time = time(NULL));
  47. InputData.ki.dwExtraInfo = 0;
  48. if(KeyDown)
  49. InputData.ki.dwFlags = KEYEVENTF_SCANCODE;
  50. else
  51. InputData.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
  52. return SendInput(1, &InputData, sizeof(InputData));
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement