Advertisement
BlinkerZ

Triggerbot

Mar 21st, 2018
3,420
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.53 KB | None | 1 0
  1. Imports System.Runtime.InteropServices
  2.  
  3.  
  4. Public Class Form1
  5. 'version 8
  6. 'recommended to use with Mccree
  7.  
  8. Private Declare Function GetTickCount Lib "kernel32" () As UInt32
  9. Public t As New Timer With {.Interval = 1}
  10. Public ScanRange As Long = 50
  11.  
  12. Public Pixels(ScanRange * ScanRange + ScanRange) As Integer
  13. Public Pixels_Hue(ScanRange * ScanRange + ScanRange) As Single
  14. Public Pixels_Brightness(ScanRange * ScanRange + ScanRange) As Single
  15. Public Pixels_Saturation(ScanRange * ScanRange + ScanRange) As Single
  16. Public Pixels_R(ScanRange * ScanRange + ScanRange) As Single
  17. Public LastFireTick As UInteger
  18.  
  19. Dim AmountOfPureWhiteFound As Long
  20.  
  21. 'edit values below to modify triggerbot
  22. 'autofire delay - 510 for mccree - 1400 for widow
  23. Public FireDelayRightMouseDown As UInteger = 1400 'autofire delay when right mouse is down
  24. Public FireDelayRightMouseUp As UInteger = 510 'autofire delay when right mouse is up
  25. Public ScanRangeRightMouseDown As Long = 50 'amount of pixels to scan for sniper - right click down
  26. Public ScanRangeRightMouseUp As Long = 25 'amount of pixels to scan for right click up
  27. Public AdjustDown As Integer = -1 'optional - move scanning up/down depending on where window is - negative values allowed
  28. Public AdjustRight As Integer = -1 'optional - move scanning left/right depending on where window is - negative values allowed
  29. Public RedOrangeRange As Single = 13 ' adjust down to decrease targeting orange
  30. Public RedVioletRange As Single = 345 ' adjust up to decrease targeting violet
  31. Public MinBrightness As Single = 0.35 'minimum brightness of pixel range (0-1.00)
  32. Public MaxBrightness As Single = 0.8 'maximum brightness of pixel range (0-1.00)
  33. Public MinSaturation As Single = 0.3 'minimum saturation of pixel range (0-1.00)
  34. Public MinRed As Single = 120 'minimum red value of pixel (0-255) - set lower for darker maps
  35. 'x/y might be inverted
  36. Public DistanceFromTargetBeforeFiringX As Long = 12 ' maximum distance from target in x and y to fire
  37. Public DistanceFromTargetBeforeFiringY As Long = 5 ' maximum distance from target in x and y to fire
  38.  
  39. Public NonWhiteCrosshair As Long = 1 ' change this to 1 to stop widow from auto firing while in zoom. Detects pure white crosshair in zoom.
  40.  
  41.  
  42. <DllImport("user32.dll")>
  43. Shared Function GetAsyncKeyState(ByVal vKey As System.Windows.Forms.Keys) As Short
  44. End Function
  45.  
  46. Private Const VK_RBUTTON = &H2
  47. Private Const VK_LBUTTON = &H1
  48. Private Const VK_Q = &H51
  49.  
  50. <DllImport("user32.dll")>
  51. Private Shared Function ReleaseDC(ByVal hWnd As IntPtr, ByVal hDc As IntPtr) As IntPtr
  52. End Function
  53. <DllImport("user32.dll", SetLastError:=True)>
  54. Private Shared Function GetActiveWindow() As IntPtr
  55. End Function
  56. <DllImport("gdi32")>
  57. Public Shared Function BitBlt(ByVal hDestDC As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As IntPtr, ByVal SrcX As Integer, ByVal SrcY As Integer, ByVal Rop As Integer) As Boolean
  58. End Function
  59. Dim GCH As GCHandle = GCHandle.Alloc(Pixels, GCHandleType.Pinned)
  60.  
  61. Dim Bmp As New Drawing.Bitmap(ScanRange, ScanRange, 4 * ScanRange,
  62. Imaging.PixelFormat.Format32bppArgb,
  63. GCH.AddrOfPinnedObject)
  64.  
  65. <DllImport("user32.dll")>
  66. Private Shared Function GetWindowDC(ByVal hwnd As IntPtr) As IntPtr
  67. End Function
  68.  
  69. Declare Function GetWindowRect Lib "user32.dll" (
  70. ByVal hwnd As Int32,
  71. ByRef lpRect As Rectangle) As Int32
  72.  
  73.  
  74. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  75. If t.Enabled = 0 Then
  76. Button1.Text = "STOP"
  77. t.Enabled = 1
  78. Else
  79. Button1.Text = "START"
  80. t.Enabled = 0
  81. End If
  82. End Sub
  83.  
  84. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  85. AddHandler t.Tick, AddressOf Timer_tick
  86. If FireDelayRightMouseDown < 100 Then FireDelayRightMouseDown = 100 ' don't make this too low to avoid suspicion - to make it lower use keypressdown and keypressup
  87. If FireDelayRightMouseUp < 100 Then FireDelayRightMouseUp = 100 ' don't make this too low to avoid suspicion - to make it lower use keypressdown and keypressup
  88. End Sub
  89. Private Sub Timer_tick(sender As Object, e As EventArgs)
  90. RunAimbot()
  91. End Sub
  92.  
  93.  
  94. Public Sub RunAimbot()
  95.  
  96. Dim Amountfound As Long
  97. Dim AmountfoundCC1 As Long
  98. Dim CCAmount(0 To 1000) As Long
  99. Dim I As Long
  100.  
  101. Dim lowestX As Long
  102. Dim lowestY As Long
  103. Dim highestX As Long
  104. Dim highestY As Long
  105.  
  106. Dim TargetX As Long
  107. Dim TargetY As Long
  108. Dim TargetAmountFound As Long
  109.  
  110. lowestX = 900
  111. lowestY = 900
  112.  
  113. Dim avgHUE As Single
  114. Dim avgBrightness As Single
  115. Dim avgsaturation As Single
  116. Dim AMountOfPixels As Single
  117. Dim FireTriggered As Single
  118.  
  119. Dim YW As Single
  120. Dim X As Single
  121. Dim Y As Single
  122.  
  123. Dim YW2 As Single
  124. Dim X2 As Single
  125. Dim Y2 As Single
  126. Dim YWY As Integer
  127. Dim YW2Y2 As Integer
  128. Dim CombinedLineFigure As Long
  129.  
  130. Dim screenwidth = CInt(Screen.PrimaryScreen.Bounds.Width)
  131. Dim screenheight = CInt(Screen.PrimaryScreen.Bounds.Height)
  132.  
  133. Dim g As Graphics
  134. Dim hdcDest As IntPtr = IntPtr.Zero
  135. Dim desktopHandleDC As IntPtr = IntPtr.Zero
  136. Dim desktopHandle As IntPtr
  137.  
  138. 'change scan size based on whether mouse in down or up
  139.  
  140. SetScanRange()
  141.  
  142.  
  143.  
  144.  
  145. desktopHandle = GetActiveWindow()
  146.  
  147.  
  148. Dim R As Rectangle = New Rectangle(CInt((Screen.PrimaryScreen.Bounds.Width / 2) - (ScanRange / 2)) + AdjustRight, CInt((Screen.PrimaryScreen.Bounds.Height / 2) - (ScanRange / 2)) + AdjustDown, ScanRange, ScanRange)
  149.  
  150.  
  151. Bmp = New Bitmap(ScanRange, ScanRange, 4 * ScanRange,
  152. Imaging.PixelFormat.Format32bppArgb,
  153. GCH.AddrOfPinnedObject)
  154.  
  155.  
  156.  
  157. g = Graphics.FromImage(Bmp)
  158. desktopHandleDC = GetWindowDC(desktopHandle)
  159. hdcDest = g.GetHdc
  160.  
  161. Dim gf As Integer
  162. Dim GH As Rectangle
  163.  
  164.  
  165. gf = GetWindowRect(desktopHandle, GH)
  166.  
  167.  
  168.  
  169. Dim NewRectWidth As Integer
  170. Dim NewRectheight As Integer
  171. NewRectWidth = GH.Width - GH.Left
  172. NewRectheight = GH.Height - GH.Top
  173.  
  174.  
  175. BitBlt(hdcDest, 0, 0, ScanRange, ScanRange, desktopHandleDC, CInt((screenwidth / 2) - (ScanRange / 2) + AdjustRight), CInt((screenheight / 2) - (ScanRange / 2) + AdjustDown), CopyPixelOperation.SourceCopy)
  176.  
  177.  
  178. g.ReleaseHdc(hdcDest)
  179. ReleaseDC(desktopHandle, desktopHandleDC)
  180. Bmp.Dispose()
  181. g.Dispose() : g = Nothing
  182.  
  183.  
  184.  
  185. Dim myColor As Color
  186.  
  187.  
  188. AMountOfPixels = ScanRange * ScanRange
  189.  
  190. For X = 3 To ScanRange - 4
  191. YW = X * ScanRange
  192. For Y = 3 To ScanRange - 4
  193. YWY = YW + Y
  194. myColor = Color.FromArgb((Pixels(YWY)))
  195.  
  196. Pixels_Hue(YWY) = myColor.GetHue
  197. Pixels_Brightness(YWY) = myColor.GetBrightness
  198. Pixels_Saturation(YWY) = myColor.GetSaturation
  199. Pixels_R(YWY) = myColor.R
  200.  
  201. avgHUE = avgHUE + Pixels_Hue(YWY)
  202. avgBrightness = avgBrightness + Pixels_Brightness(YWY)
  203. avgsaturation = avgsaturation + Pixels_Saturation(YWY)
  204.  
  205. If NonWhiteCrosshair = 1 Then
  206. 'sniper zoom fix
  207. If Pixels_Hue(YWY) = 0 And Pixels_Saturation(YWY) = 0 And Pixels_Brightness(YWY) = 1 And CheckRightMouse() = 1 And (LastFireTick + FireDelayRightMouseDown) <= GetTickCount Then
  208. AmountOfPureWhiteFound = AmountOfPureWhiteFound + 1
  209. If AmountOfPureWhiteFound > 20 Then
  210. 'fix for sniper red in zoom with large scan range =/
  211.  
  212. LastFireTick = LastFireTick + 150
  213. End If
  214. End If
  215. End If
  216.  
  217. If Pixels_Hue(YWY) < RedOrangeRange Or Pixels_Hue(YWY) > RedVioletRange Then
  218. If Pixels_Brightness(YWY) > MinBrightness And Pixels_Brightness(YWY) < MaxBrightness And Pixels_Saturation(YWY) > MinSaturation And Pixels_R(YWY) > MinRed Then ' Target by hue to bypass 1.12
  219.  
  220. Amountfound = Amountfound + 1
  221.  
  222. 'DEBUG
  223. 'RichTextBox1.AppendText("HUE=" & (myColor.GetHue()).ToString & vbTab & "SAT=" & myColor.GetSaturation().ToString & vbTab & "BGT=" & (myColor.GetBrightness()).ToString & vbTab & myColor.R & vbNewLine)
  224.  
  225. If lowestX > X Then
  226. lowestX = X
  227. End If
  228. If lowestY > Y Then
  229. lowestY = Y
  230. End If
  231. If highestY < Y Then
  232. highestY = Y
  233. End If
  234. If highestX < X Then
  235. highestX = X
  236. End If
  237.  
  238. 'advanced comparison
  239.  
  240. For X2 = (X - 3) To (X + 3)
  241. YW2 = X2 * ScanRange
  242. For Y2 = (Y - 3) To (Y + 3)
  243. YW2Y2 = YW2 + Y2
  244. 'x2=0 and y2=0 produces additional triggered pixel
  245.  
  246. If Pixels_Hue(YW2Y2) < RedOrangeRange Or Pixels_Hue(YW2Y2) > RedVioletRange Then
  247. If Pixels_Brightness(YW2Y2) > MinBrightness And Pixels_Brightness(YW2Y2) < MaxBrightness And Pixels_Saturation(YW2Y2) > MinSaturation And Pixels_R(YW2Y2) > MinRed Then ' Target by hue to bypass 1.12
  248. AmountfoundCC1 = AmountfoundCC1 + 1
  249. End If
  250. End If
  251.  
  252. Next Y2
  253. Next X2
  254.  
  255.  
  256. CCAmount(AmountfoundCC1) = CCAmount(AmountfoundCC1) + 1
  257. AmountfoundCC1 = 0
  258.  
  259. 'target x/y
  260. If CheckRightMouse() = 0 Then
  261. For I = 1 To 13
  262. TargetY = TargetY + Y 'settings for right mouse up
  263. TargetX = TargetX + X
  264. TargetAmountFound = TargetAmountFound + 1
  265. Next I
  266. Else
  267. For I = 2 To 19
  268. TargetY = TargetY + Y 'settings for right mouse down
  269. TargetX = TargetX + X
  270. TargetAmountFound = TargetAmountFound + 1
  271. Next I
  272. End If
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279. End If
  280. End If
  281. NExtY:
  282. Next Y
  283. Next X
  284. 'combine line figures together
  285. If CheckRightMouse() = 0 Then
  286. For I = 1 To 13
  287. CombinedLineFigure = CombinedLineFigure + CCAmount(I) 'settings for right mouse up
  288. Next I
  289. Else
  290. For I = 2 To 19
  291. CombinedLineFigure = CombinedLineFigure + CCAmount(I) 'settings for right mouse down
  292. Next I
  293. End If
  294.  
  295.  
  296. ' CombinedLineFigure = CombinedLineFigure * 10
  297. ' RichTextBox1.AppendText("CombinedLineFigure=" & CombinedLineFigure & vbTab & "Amountfound=" & Amountfound & vbNewLine)
  298.  
  299.  
  300. If CombinedLineFigure >= (ScanRange * 0.15) And (CombinedLineFigure * 1.33) >= Amountfound Then
  301.  
  302.  
  303.  
  304. If (lowestX + (ScanRange * 0.15)) <= highestX And (lowestY + (ScanRange * 0.15)) <= highestY Then
  305.  
  306. FireTriggered = 1
  307. ' RichTextBox1.AppendText("CombinedLineFigure=" & CombinedLineFigure & vbTab & "Amountfound=" & Amountfound & vbNewLine)
  308. ' RichTextBox1.AppendText("Fire" & vbNewLine)
  309.  
  310. End If
  311.  
  312. End If
  313.  
  314.  
  315. avgHUE = avgHUE / AMountOfPixels
  316. avgBrightness = avgBrightness / AMountOfPixels
  317. avgsaturation = avgsaturation / AMountOfPixels
  318.  
  319. If avgHUE > 2 And avgHUE < 14 And avgBrightness < 0.45 And avgsaturation < 0.45 Then
  320. FireTriggered = 0 ' don't fire
  321. End If
  322.  
  323. If CheckRightMouse() = 0 Then 'adjust for zoom
  324.  
  325. If Math.Abs((TargetX / TargetAmountFound) - (ScanRange / 2)) > DistanceFromTargetBeforeFiringX Then
  326. FireTriggered = 0 ' don't fire
  327. End If
  328.  
  329. If Math.Abs((TargetY / TargetAmountFound) - (ScanRange / 2)) > DistanceFromTargetBeforeFiringY Then
  330. FireTriggered = 0 ' don't fire
  331. End If
  332. Else 'while zoomed / hold down right click
  333. If Math.Abs((TargetX / TargetAmountFound) - (ScanRange / 2)) > (DistanceFromTargetBeforeFiringX * 2) Then
  334. FireTriggered = 0 ' don't fire
  335. End If
  336.  
  337. If Math.Abs((TargetY / TargetAmountFound) - (ScanRange / 2)) > (DistanceFromTargetBeforeFiringY * 2) Then
  338. FireTriggered = 0 ' don't fire
  339. End If
  340.  
  341.  
  342. End If
  343.  
  344. If CheckKeyQ() = 1 And CheckRightMouse() = 0 Then
  345. LastFireTick = GetTickCount + 5000 'pressing Q for ultimate delays firing by 5 secs when mouse is up. With widow use ultimate while zoomed to avoid delay.
  346. End If
  347.  
  348. If FireTriggered = 1 Then
  349. Fire()
  350. End If
  351.  
  352.  
  353.  
  354.  
  355. 'debug and testing
  356. If LastFireTick = GetTickCount Then
  357. ' RichTextBox1.AppendText("CombinedLineFigure=" & CombinedLineFigure & vbTab & "Amountfound=" & Amountfound & vbNewLine)
  358. ' RichTextBox1.Text = ("avgHUE=" & avgHUE & vbTab & "avgSAT=" & avgsaturation & vbTab & "avgBGT=" & avgBrightness)
  359. 'RichTextBox1.AppendText("avgHUE=" & avgHUE & vbTab & "avgSAT=" & avgsaturation & vbTab & "avgBGT=" & avgBrightness & vbNewLine)
  360. 'RichTextBox1.AppendText("low_x= " & lowestX & "high_x= " & highestX & "low_y= " & lowestY & "high_y= " & highestY)
  361.  
  362. ' Dim i2 As Long
  363. ' For i2 = 0 To 30
  364. ' RichTextBox1.AppendText(CCAmount(i2) & vbTab)
  365. ' Next
  366. 'RichTextBox1.AppendText(vbNewLine)
  367. ' RichTextBox1.AppendText(Math.Round((TargetX / TargetAmountFound) - ScanRange / 2) & " " & (Math.Round((TargetY / TargetAmountFound)) - ScanRange / 2) & vbNewLine)
  368.  
  369. 'moving mouse settings
  370. 'aimbot target X = Math.Round((screenwidth / 2) + (TargetX / TargetAmountFound) - ScanRange / 2) + AdjustRight - not tested
  371. 'aimbot target Y = Math.Round((screenheight / 2) + (TargetY / TargetAmountFound) - ScanRange / 2) + AdjustDown- not tested
  372. 'Y axis might be reversed - (Y * -1) to fix
  373.  
  374.  
  375. ' RichTextBox1.AppendText(Math.Round((screenheight / 2) + (TargetX / TargetAmountFound) - ScanRange / 2) + AdjustRight & vbNewLine)
  376.  
  377.  
  378. End If
  379.  
  380. End Sub
  381. Public Sub Fire()
  382. If (LastFireTick + FireDelayRightMouseDown) <= GetTickCount And CheckRightMouse() = 1 Then GoTo Fire
  383. If (LastFireTick + FireDelayRightMouseUp) <= GetTickCount And CheckRightMouse() = 0 Then
  384. Fire:
  385. If CheckLeftMouse() = 0 Then 'don't fire when mouse is being manually clicked
  386. SendKeys.Send("k")
  387. ' RichTextBox1.AppendText("avgHUE=" & avgHUE & vbTab & "avgSAT=" & avgsaturation & vbTab & "avgBGT=" & avgBrightness & vbNewLine)
  388. End If
  389. LastFireTick = GetTickCount
  390. End If
  391. End Sub
  392. Public Function CheckRightMouse() As Long
  393. If GetAsyncKeyState(VK_RBUTTON) <> 0 Then
  394. Return 1
  395. End If
  396. Return 0
  397. End Function
  398. Public Function CheckLeftMouse() As Long
  399. If GetAsyncKeyState(VK_LBUTTON) <> 0 Then
  400. Return 1
  401. End If
  402. Return 0
  403. End Function
  404. Public Function CheckKeyQ() As Long
  405. If GetAsyncKeyState(VK_Q) <> 0 Then
  406. Return 1
  407. End If
  408. Return 0
  409. End Function
  410. Public Sub SetScanRange()
  411. If CheckRightMouse() = 0 Then
  412. ScanRange = ScanRangeRightMouseUp 'settings for right mouse up
  413. Else
  414. ScanRange = ScanRangeRightMouseDown 'settings for right mouse down
  415. End If
  416.  
  417. End Sub
  418.  
  419.  
  420. Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
  421. Dim i As Long
  422.  
  423. Application.DoEvents()
  424. Using g As Graphics = Graphics.FromHwnd(IntPtr.Zero)
  425. For i = 0 To 999
  426. SetScanRange()
  427. Dim rect As Rectangle = New Rectangle((Screen.PrimaryScreen.Bounds.Width / 2) - (ScanRange / 2) + AdjustRight, (Screen.PrimaryScreen.Bounds.Height / 2) - (ScanRange / 2) + AdjustDown, ScanRange, ScanRange)
  428. Using lgb As New Drawing2D.LinearGradientBrush(rect, Color.Blue, Color.Blue, 90, True)
  429.  
  430. g.FillRectangle(lgb, rect)
  431. Application.DoEvents()
  432. If Not CheckBox1.CheckState = CheckState.Checked Then Exit Sub
  433. End Using
  434. Next i
  435. End Using
  436.  
  437. CheckBox1.CheckState = CheckState.Unchecked
  438. End Sub
  439.  
  440.  
  441. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement