Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.51 KB | None | 0 0
  1. #include "Customs.h"
  2.  
  3. using namespace std; //using namespace of standard
  4.  
  5. string CHSETS; //making a varible to store setting choice in choice in
  6. string SETTR; //making a varible to store choice in
  7. void MainScan(ScanContents scan);
  8. void ScanThread(ScanContents * scan);
  9. void CheckColor(COLORREF pixel, int x, int y);
  10. bool ColorMatch(COLORREF pixel);
  11.  
  12.  
  13. int main()
  14. {
  15. string gameWindow; //making a varible to store the game window name in
  16.  
  17. cout << "Enter A Games Window Name To Trigger Against\n"; //choosing game
  18. getline(cin, gameWindow); //putting window name into "gameWindow" string
  19.  
  20. HWND appWnd = FindWindow(0, gameWindow.c_str()); //convert window name to char pointer for system to find window
  21. RECT rcClientPositioning; //A place to put the area for color scan rectangle X and Y cords
  22.  
  23. while(!appWnd) //looing for window loop
  24. {
  25. system("CLS"); //clears console
  26. appWnd = FindWindow(0, gameWindow.c_str()); //converts to char pointer and looks for window again
  27. cout << "looking for : "; //tells user it is looking for window
  28. cout << gameWindow;
  29. Sleep(2000); //tells system to wait 2000 miliseconds or 2 second before looking again for window
  30. }
  31. cout << gameWindow << " Window Has Been Found!"; //tells user the window has been found
  32. Sleep(2000); //tells system to wait 2000 miliseconds or 2 second before proceding on to the standard settings
  33.  
  34. while(atoi(CHSETS.c_str()) < 1 || atoi(CHSETS.c_str()) > 2) //tells system that if choice is less than 1 or greater than 2 to repeat
  35.  
  36. {
  37. system("CLS"); //clears console
  38. cout << "Choose What You Would Like To Set A Standard To\n" << "1. Head Shots\n" << "2. Normal\n"; //ask user for a setting choice
  39. getline(cin, CHSETS); //Getting Number For CHSETS varible
  40. }
  41. if(CHSETS == "1")SETTR = "Enemy's Head"; //If input == 1 then setting SETTR varible to Enemy's Head
  42. else if(CHSETS == "2")SETTR = "Enemy's Body"; //If input == 2 then setting SETTR varible to Enemy's Bddy
  43. system("CLS"); //clears console
  44.  
  45. cout << "TriggerBot Is Online For " << gameWindow << " Hover Around A " << SETTR << " To Shoot"; //tell user TriggerBot is online
  46.  
  47. GetWindowRect(appWnd, &rcClientPositioning); //gettng windows rectanle so system can divide it for making scan area for pixel scanning
  48.  
  49. HDC hdcMain = GetDC(HWND_DESKTOP); //Making varible to get Desktop Handle to the desktop window
  50. HDC hdcThread1 = GetDC(HWND_DESKTOP); //Making varible to get Desktop Handle to the desktop window
  51. HDC hdcThread2 = GetDC(HWND_DESKTOP); //Making varible to get Desktop Handle to the desktop window
  52. HDC hdcThread3 = GetDC(HWND_DESKTOP); //Making varible to get Desktop Handle to the desktop window
  53.  
  54. int StartX = rcClientPositioning.right - rcClientPositioning.right - ((rcClientPositioning.left)/2);//the X starting point of pixel scan
  55. int StartY = rcClientPositioning.bottom - rcClientPositioning.bottom - ((rcClientPositioning.top)/2);//the Y ending point of pixel scan
  56.  
  57. ScanContents scanM0(StartX, StartY, hdcMain, 30, 40, -30, -30); //creating the area to scan
  58. ScanContents scanM1(StartX, StartY, hdcThread1, 0, 30, -20, 10, 1); //creating the area to scan
  59. ScanContents scanM2(StartX, StartY, hdcThread2, 20, 5, 0, -20, 2); //creating the area to scan
  60. ScanContents scanM3(StartX, StartY, hdcThread3, 20, 30, 0, 10, 3); //creating the area to scan
  61.  
  62. _beginthread((void(*)(void*))ScanThread, 0, (void*)&scanM1); //starting 2nd scan of pixels
  63. _beginthread((void(*)(void*))ScanThread, 0, (void*)&scanM2); //starting 3rd scan of pixels
  64. _beginthread((void(*)(void*))ScanThread, 0, (void*)&scanM3); //starting 4th scan of pixels
  65.  
  66. MainScan(scan); //starting main scan of pixels
  67.  
  68. system("PAUSE"); //pauses system
  69. }
  70.  
  71. void ScanThread(ScanContents * scan)
  72. {
  73. // MessageBox(NULL, NULL, NULL, NULL);
  74. int debugRuntime = clock();
  75. while(true)
  76. {
  77. //scan up and down the screen
  78. for(int y = scan->StartY+scan->DeductY; y < scan->StartY+scan->CompareY; y+=3)
  79. {
  80. //scan across the screen
  81. for(int x = scan->StartX+scan->DeductX; x < scan->StartX+scan->CompareX; x+=3)
  82. {
  83. //Sleep(100);
  84. //SetCursorPos(x, y);
  85. CheckColor(GetPixel(scan->Hdc, x, y), x, y);
  86. }
  87. }
  88. //std::cout << "[THREAD "<< scan->ThreadNum << "]Took " << clock() - debugRuntime << " milliseconds to scan whole page"<< std::endl;
  89. //debugRuntime = clock();
  90. }
  91. _endthread();
  92. }
  93.  
  94. void MainScan(ScanContents scan) //function to run the trigger bot
  95. {
  96. int DebugRunTime = clock(); //time it took clock to scan pixel area
  97. while(true) //infinite loop
  98. {
  99. for(int y = scan->StartY+scan->DeductY; y < scan->StartY+scan->CompareY; y+=3) //scanning Y access 3 pixels pert time
  100. {
  101. for(int x = scan->StartX+scan->DeductX; x < scan->StartX+scan->CompareX; x+=3) //scanning X access 3 pixels pert time
  102. {
  103. //SetCursorPos(x, y); //set cursor at scan position so you know its working / not needed though
  104.  
  105. CheckColor(GetPixel(scan->Hdc, x, y), x, y); //Getting the pixel of the color and then setting cursor there to shoot
  106. if(GetAsyncKeyState(VK_DELETE)) //if delete key is pressed
  107. {
  108. exit(0); //exit programs
  109. }
  110. }
  111. }
  112. cout << "Thread " << scan->ThreadNum" scan took : " << DebugRunTime - clock() << " to scan pixel area"; //tell time it took to scan pixel area
  113. DebugRunTime = clock(); //reseting clock
  114. }
  115. }
  116.  
  117. void CheckColor(COLORREF pixel, int x, int y) //function that presses mouse button down if CoorMatch Returns True
  118. {
  119. if(ColorMatch(pixel)) // if colormatch returns true find the pixel and run the lines instide
  120. {
  121. mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0 ,0); //presses the mouse key down at the X and Y
  122. mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0 ,0); //Presses mouse key back up
  123. Sleep(50);
  124. }
  125. }
  126.  
  127. bool ColorMatch(COLORREF pixel) //making a function to store the pixel color in
  128. {
  129. int r = GetRValue(pixel);
  130. int g = GetGValue(pixel);
  131. int b = GetBValue(pixel);
  132.  
  133. //Check pixel color to see if head is found
  134. if(SETTR == "1") //if option one is chosen
  135. {
  136. if(r == 232 && g == 194 && b == 47 || r == 88 && g == 93 && b == 80) //find white or yellow pixels for phantom forces headshots
  137. {
  138. return true; //if that is true return true
  139. }
  140. }
  141. //Check pixel color to see if body is found
  142. else if(SETTR == "2") //if option two is chosen
  143. {
  144. if(r == 68 && g == 68 && b == 68 || r == 86 && g == 47 && b == 17) //find body color pixels for phantom forces body shots
  145. {
  146. return true; //if that is true return true
  147. }
  148. }
  149. return false; //if thats not found then return false
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement