TriggerBot

Ask gaming related questions (AHK v1.1 and older)
zarioftw
Posts: 6
Joined: 18 Mar 2018, 08:37

TriggerBot

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

#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process,Priority,,A
SetBatchLines,-1
SetKeyDelay,-1,-1
SetMouseDelay,-1
SetDefaultMouseSpeed,0
SetWinDelay,-1
SetControlDelay,-1
SendMode Input


LShift::
{
	DllCall("Sleep",UInt,1) 
	PixelGetColor,colorz,954,547,Slow 
	PixelSearch,,,954,547,954,547,%colorz%,4,Fast 
	if ErrorLevel = 1
	{
		Click Left Down
		DllCall("Sleep",UInt,20)
		Click Left Up
		DllCall("Sleep",UInt,20)
	}
}
return

$*ins::
Suspend
Pause,,1
return
User avatar
eventhorizon
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

#NoEnv
#SingleInstance, Force
#MaxThreads, 100
#MaxThreadsPerHotkey, 2
#Persistent
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
#InstallKeybdHook
#InstallMouseHook
#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
tkFastGrab:
	retval := fntkFastGrab()
	;msgBox, 0x1000, Line%A_LineNumber%, retval = %retval%
	stringsplit, retvalary, retval, `,
	return
	
; create a space separated retval loc & color string	
fntkFastGrab()
{	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)
}

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

tkfnCompareColorAtXY(x,y,c)
{	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 Help (v1)”

Who is online

Users browsing this forum: No registered users and 86 guests