Ask gaming related questions
Posts: 6
Joined: 18 Mar 2018, 08:37


21 Apr 2018, 19:49

I want to make a script that scans one pixel, and when a slightest change happens inside that pixel is does a left click. (triggerbot) I have found a scirpt that i tried to adjust to my needs but i failed. Need help :oops:

Code: Select all

#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
SendMode Input

	if ErrorLevel = 1
		Click Left Down
		Click Left Up

User avatar
Posts: 158
Joined: 27 Oct 2016, 14:22

Re: TriggerBot

22 Apr 2018, 18:34

1, first you need the xy address of the pixel on the screen
2 save that in an ini file or in your program as a variable so you can always find it again
3 then you need to read the color there and save it
4 on a hotkey command you can do a loop to read the color and compare it with the saved color to find out if it's different
you can use PixelGetColor for this or you cn use PixelSearch both will work
save the color you find as the new base color
then click on the desired screen location
you can then either go loop back with some way to break the loop when you want it to stop
or you can just exit the click routine and use the hotkey to restart it when you want to.
Here are a couple of routines that will help you locate and save the color you're looking for.
It's always better to go as simple as possible first then add complexity as your knowledge of the
problem grows. The header stuff is there to make sure you're in the proper screen mode to grab
the color. Being in True full screen will cause the mouse and pixel reads to fail. make sure your game
is in window mode or window full screen mode. you can tell the difference because window mode has
a title bar at the top of the screen. If you don't see that you're in the wrong video mode.

Code: Select all

#SingleInstance, Force
#MaxThreads, 100
#MaxThreadsPerHotkey, 2
SetBatchLines, -1
DetectHiddenWindows, On
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen
SetTitleMatchMode, 2
SetTitleMatchMode, slow
SetKeyDelay, 100,100
SetMouseDelay 10
SetDefaultMouseSpeed, 0
SendMode Event
#UseHook, On

; this version puts the values in a variable and splits it off
; into the retval array. This allows you to grab color and location
; and use them directly in a script or routine.
;retvalary1 is the x location. retvalary2 is the y location and 
;retvalary3 is the color found there.
+!u:: ;<- returns retval string and retval array
	suspend permit
	retval := fntkFastGrab()
	;msgBox, 0x1000, Line%A_LineNumber%, retval = %retval%
	stringsplit, retvalary, retval, `,
; create a space separated retval loc & color string	
{	MouseGetPos, fgmx, fgmy
	pixelGetColor, fgColor, %fgmx%, %fgmy%, Alt Slow RGB
	retval = %fgmx%`,%fgmy%`,%fgcolor% ;space separated values
	;msgBox, 0x1000, Line%A_LineNumber%, coords=%fgmx%`,%fgmy% color=%fgcolor%
	return (retval)

{	pixelGetColor,thiscolor,%x%,%y%,alt slow,RGB
	return (thiscolor)

{	thiscolor := tkfnGetColorAtXY(x,y)
	if (thiscolor = c)
		return 1
	return 0

A computer lets you make more mistakes faster than any invention in human history – with the possible exceptions of handguns and tequila.

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 8 guests