Trigger Bot

Ask gaming related questions (AHK v1.1 and older)
shockzy
Posts: 7
Joined: 13 Dec 2023, 04:38

Trigger Bot

13 Dec 2023, 04:45

Hi all, I'm looking for a trigger bot for a game in which your crosshair turns red when it's placed over somebody. There would ideally need to be a tolerance for the exact shade of red, because this crosshair is also slightly transparent. I'm not good at coding and any sort of trigger bots I've come across all function based on what's under your cursor, not on the colour of the cursor itself! A key to toggle the triggerbot on/off would also be very useful. Thank you in advance to anybody who is able to help.
User avatar
boiler
Posts: 17336
Joined: 21 Dec 2014, 02:44

Re: Trigger Bot

13 Dec 2023, 05:42

Hopefully, it’s only very slightly transparent because if it changes significantly depending on what’s behind it, it could it make it nearly impossible to tell when it turns red. Can you post some pictures?
shockzy
Posts: 7
Joined: 13 Dec 2023, 04:38

Re: Trigger Bot

13 Dec 2023, 18:26

boiler wrote:
13 Dec 2023, 05:42
Hopefully, it’s only very slightly transparent because if it changes significantly depending on what’s behind it, it could it make it nearly impossible to tell when it turns red. Can you post some pictures?
Yes, it's only slightly transparent. Here it is over dark black vs. white. Also I should note that the crosshair isn't locked in the center of your screen.
ahkxhair.png
ahkxhair.png (1.53 KiB) Viewed 3408 times
User avatar
boiler
Posts: 17336
Joined: 21 Dec 2014, 02:44

Re: Trigger Bot

13 Dec 2023, 19:49

They may look similar to you because they're both shades of red, but they are very different in terms of the color code. Use Window Spy to see for yourself. What they have in common, of course, is that the value of the red component is quite a bit higher than the other two. That might have made it feasible if you knew where to look, but since you have to find it first, you would have to sample a lot of pixels and do the bitwise math to calculate the difference between the values of the components. Pure AHK is going to be too slow for it to happen in real time. You would need to write an algorithm in C, compile it, then call that function from your AHK script. It's quite ambitious, and then it still might not work. If you're up to taking on that task, good luck
shockzy
Posts: 7
Joined: 13 Dec 2023, 04:38

Re: Trigger Bot

13 Dec 2023, 20:14

boiler wrote:
13 Dec 2023, 19:49
They may look similar to you because they're both shades of red, but they are very different in terms of the color code. Use Window Spy to see for yourself. What they have in common, of course, is that the value of the red component is quite a bit higher than the other two. That might have made it feasible if you knew where to look, but since you have to find it first, you would have to sample a lot of pixels and do the bitwise math to calculate the difference between the values of the components. Pure AHK is going to be too slow for it to happen in real time. You would need to write an algorithm in C, compile it, then call that function from your AHK script. It's quite ambitious, and then it still might not work. If you're up to taking on that task, good luck
I see, I did manage to find one which functions based on a black pixel UNDER the crosshair. It was intended to target red but it only works for black:

Code: Select all

#Persistent
SetTimer, CheckCursorColor, 1 ; Set the timer interval to 1 millisecond
return

; Add a hotkey to stop the script when F8 is pressed
F8::
    SetTimer, CheckCursorColor, Off
    ExitApp
return

CheckCursorColor:
; Capture the screen around the cursor
CoordMode, Mouse, Screen
MouseGetPos, xpos, ypos
CoordMode, Pixel, Screen
PixelGetColor, color, %xpos%, %ypos%, RGB

; Define the target red color and tolerance level
TargetRedColor := "CF1A08"
Tolerance := 25 ; You can adjust this value based on your preference

; Extract individual RGB components
Red := "0x" SubStr(color, 1, 2)
Green := "0x" SubStr(color, 3, 2)
Blue := "0x" SubStr(color, 5, 2)

; Check if the color is within the tolerance range
if (Abs(Red - 255) <= Tolerance and Green <= Tolerance and Blue <= Tolerance)
{
    Click ; Perform a click if the cursor is within the tolerance range of red
}

return
Would it not be possible to alter this to click based on the crosshair colour instead of the colour of the target?
Last edited by gregster on 13 Dec 2023, 20:19, edited 1 time in total.
Reason: Moved topic from AHK v2 help to v1 help, based on posted v1 code.
User avatar
boiler
Posts: 17336
Joined: 21 Dec 2014, 02:44

Re: Trigger Bot

13 Dec 2023, 20:34

I was under the impression that the crosshair moves, but if you’re saying it’s stationary, then it has a much greater chance of working since you only need to sample a few pixel locations.
shockzy
Posts: 7
Joined: 13 Dec 2023, 04:38

Re: Trigger Bot

13 Dec 2023, 20:43

boiler wrote:
13 Dec 2023, 20:34
I was under the impression that the crosshair moves, but if you’re saying it’s stationary, then it has a much greater chance of working since you only need to sample a few pixel locations.
Oh, I think there was a misunderstanding. When I said it moves, I didn't mean it's a dynamic crosshair. I meant that it's not locked to the center of your screen like an FPS crosshair, you can move it freely around your screen. But it's not a dynamic crosshair - all that changes is the colour.
User avatar
boiler
Posts: 17336
Joined: 21 Dec 2014, 02:44

Re: Trigger Bot

13 Dec 2023, 21:48

Oh, then you’re not going to be able to just check some fixed positions. It sounds as difficult as I initially suspected unless its position is known even though it changes. The code you showed gets the color at the position of the mouse pointer. Is the crosshair just a big mouse pointer that’s located at the mouse position?
shockzy
Posts: 7
Joined: 13 Dec 2023, 04:38

Re: Trigger Bot

13 Dec 2023, 23:44

boiler wrote:
13 Dec 2023, 21:48
Oh, then you’re not going to be able to just check some fixed positions. It sounds as difficult as I initially suspected unless its position is known even though it changes. The code you showed gets the color at the position of the mouse pointer. Is the crosshair just a big mouse pointer that’s located at the mouse position?
Yeah it's about the same size. Like I said I'm a complete noob but how is it more difficult to determine the crosshair colour vs. the colour of the pixel that the crosshair is pointing at?
User avatar
boiler
Posts: 17336
Joined: 21 Dec 2014, 02:44

Re: Trigger Bot

14 Dec 2023, 01:09

You seem to be focusing on the “big” in my question. The key part I was asking about is this: Is the position of the crosshair exactly the same as if it were a normal mouse pointer? Does it move just like a regular mouse pointer when you move the mouse? So its position is really found by using MouseGetPos? Or does moving the mouse just sort of influence how the crosshair moves, but it’s not really moving like a regular mouse pointer?
shockzy
Posts: 7
Joined: 13 Dec 2023, 04:38

Re: Trigger Bot

14 Dec 2023, 01:34

boiler wrote:
14 Dec 2023, 01:09
You seem to be focusing on the “big” in my question. The key part I was asking about is this: Is the position of the crosshair exactly the same as if it were a normal mouse pointer? Does it move just like a regular mouse pointer when you move the mouse? So its position is really found by using MouseGetPos? Or does moving the mouse just sort of influence how the crosshair moves, but it’s not really moving like a regular mouse pointer?
It's 1:1 movement, it moves exactly like a mouse pointer.
User avatar
boiler
Posts: 17336
Joined: 21 Dec 2014, 02:44

Re: Trigger Bot

14 Dec 2023, 01:53

OK, then it has a chance of working in that scenario since you know which pixels to check.However, that brings up the prospect that only the color of the mouse pointer itself is changing, and getting the color at that position likely gets the color of whatever is behind it. You can try it and see.
geldingminibus
Posts: 1
Joined: 30 Aug 2023, 06:13

Re: Trigger Bot

14 Dec 2023, 05:09

shockzy wrote:
13 Dec 2023, 04:45
Hi all, I'm looking for a trigger bot for a game in which your crosshair turns red when it's placed over somebody. There would ideally need to be a tolerance for the exact shade of red, because this crosshair is also slightly transparent. I'm not good at coding and any sort of trigger bots I've come across all function based on what's under your cursor, not on the colour of the cursor itself! A key to toggle the triggerbot on/off would also be very useful. Thank you in advance to anybody who is able to help.
Hey! Crafting a trigger bot with color tolerance sounds interesting. While I can't assist directly with that, consider checking out forums dedicated to game modifications or coding communities. They might have resources or enthusiasts who can guide you through creating a customized trigger bot. Good luck with your project! 🔍🎮 #CodingCommunity #GameMods
shockzy
Posts: 7
Joined: 13 Dec 2023, 04:38

Re: Trigger Bot

15 Dec 2023, 00:24

geldingminibus wrote:
14 Dec 2023, 05:09
shockzy wrote:
13 Dec 2023, 04:45
Hi all, I'm looking for a trigger bot for a game in which your crosshair turns red when it's placed over somebody. There would ideally need to be a tolerance for the exact shade of red, because this crosshair is also slightly transparent. I'm not good at coding and any sort of trigger bots I've come across all function based on what's under your cursor, not on the colour of the cursor itself! A key to toggle the triggerbot on/off would also be very useful. Thank you in advance to anybody who is able to help.
Hey! Crafting a trigger bot with color tolerance sounds interesting. While I can't assist directly with that, consider checking out forums dedicated to game modifications or coding communities. They might have resources or enthusiasts who can guide you through creating a customized trigger bot. Good luck with your project! 🔍🎮 #CodingCommunity #GameMods
Thank you both of you for responding!
intensivelordpro
Posts: 3
Joined: 24 Jan 2024, 11:36

Re: Trigger Bot

24 Jan 2024, 11:40

shockzy wrote:
15 Dec 2023, 00:24
geldingminibus wrote:
14 Dec 2023, 05:09
shockzy wrote:
13 Dec 2023, 04:45
Hi all, I'm looking for a trigger bot for a game in which your crosshair turns red when it's placed over somebody. There would ideally need to be a tolerance for the exact shade of red, because this crosshair is also slightly transparent. I'm not good at coding and any sort of trigger bots I've come across all function based on what's under your cursor, not on the colour of the cursor itself! A key to toggle the triggerbot on/off would also be very useful. Thank you in advance to anybody who is able to help.
Hey! Crafting a trigger bot with color tolerance sounds interesting. While I can't assist directly with that, consider checking out forums dedicated to game modifications or coding communities. They might have resources or enthusiasts who can guide you through creating a customized trigger bot. Good luck with your project! 🔍🎮 #CodingCommunity #GameMods
Thank you both of you for responding!
Hey, I was wondering if you had any luck finding/creating a trigger bot script. I’m looking for a trigger bot script for this exact scenario. I would appreciate it if you could share any info you found!

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: kiv and 34 guests