Need Help

Ask gaming related questions
TankWantBeCoder
Posts: 4
Joined: 04 Feb 2018, 11:59

Need Help

04 Feb 2018, 12:12

Hello ,

how to do this : mouse or cursor detects color, for example (color id: 060606) and shoots (LMouse)
Sorry for my bad Text: D
User avatar
eventhorizon
Posts: 158
Joined: 27 Oct 2016, 14:22

Re: Need Help

04 Feb 2018, 14:51

Here is an example of what it seems you might be looking for. Adapt this as needed..

Code: Select all

#SingleInstance, Force
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
CoordMode, Tooltip, Screen
DetectHiddenWindows, On
return

esc:: ;<- use the esc key to end the script
	suspend permit
	MsgBox, 0x1000, Line%A_LineNumber%, End of script, 3
	exitapp	
	
	
	
^!s:: ;<- use control-alt-s to check the color
	suspend on
	someX := 0 ;x location on screen where you want to check
	somey := 0 ;y location on screen where you want to check
	someOtherColor = 0x000000 ;the color you're looking for in RGB format

	pixelGetColor, somecolor, %someX%, %someY%, RGB ;check the color on the screen
	sleep 200
	isMatch := someColor = someOtherColor ? "matches" : "does not match"
	MsgBox,0x1000, Line%A_LineNumber%, The color at %someX%`,%someY% is %someColor%,`n%someColor% %isMatch% %someOtherColor%
	if (somecolor = someOtherColor) ;see if the colors match
	{	click, %someX%, %someY% ;if they do then click the left mouse button
		sleep 100
	}
	suspend off
	return ;end the routing

A computer lets you make more mistakes faster than any invention in human history – with the possible exceptions of handguns and tequila.
TankWantBeCoder
Posts: 4
Joined: 04 Feb 2018, 11:59

Re: Need Help

05 Feb 2018, 01:25

Thank you , but i have 2 questions.
1:how it is work? I Think its work =: if mouse find color = click (LMouse) ?
2:Will it work in game ?
Again sorry fo my stupid text :D
User avatar
eventhorizon
Posts: 158
Joined: 27 Oct 2016, 14:22

Re: Need Help

05 Feb 2018, 11:31

things i don't know:
1. i don't know what color you're looking for.
2. I don't know where you are looking on your screen.
3. I don't know what game you're actually playing.
4. I don't know if your game is in full screen or windowed mode.
5. I don't if the game you're playing uses some anticheat software.

Things you need to know and do...
1. what are the xy coordinates of the place on the screen you're looking for the color. that information you have to put into someX and someY
2. What is the color you're searching for. That information you have to put into the someOtherColor variable.
3, If your screen (which i can't see) isn't in windowed mode you need to put your game into windowed mode.
4. If your game is using some form of anticheat software that will prevent AutoHotkey from working.

You see this isn't something i can fix. It's something you have to fix. I can only give you what help i can based on what i know. I can't see you playing your game or how it's responding on your screen.
A computer lets you make more mistakes faster than any invention in human history – with the possible exceptions of handguns and tequila.
TankWantBeCoder
Posts: 4
Joined: 04 Feb 2018, 11:59

Re: Need Help

07 Feb 2018, 14:14

Sorry
1: color id: 343D44 (Red=34 Green=3D Blue=44)
2: in middle of full screen in csgo (cursor)
3:CSGO
4:Windowed fullscreen
5:VAC is not good anticheat
User avatar
eventhorizon
Posts: 158
Joined: 27 Oct 2016, 14:22

Re: Need Help

08 Feb 2018, 21:48

Ok here's how it reads out. The first part of the script is the header information the rest of the scripts uses to set things up. the Esc key hotkey ends the script when you're ready to stop. the Alt-m hotkey places the mouse in the center of the screen after figuring out what screen it is and what size it is on your computer. the Shift-Alt-u routine grabs the color on the screen from where the mouse currently is placed and writes it to a script-generated ini file to save it. the shift-alt-c routine retrieves the color data from the file and checks the screen to see if the screen has the color you saved at that location. the other routines support all that. If you have trouble with it just read the help file on the commands in the script to find out what they do. basically all you have to do is hit alt-m to place the mouse. shift-alt-u to grab the color and save it and when you want to check the color hit Shift-Alt-C. I know it seems like a lot of code but this gives you the ability to check individual colors anywhere you want on your screen whenever you want. Test it on your background windows before you try it on your game just to be sure in your own mind that it works and how to read it out. If your game doesn't block AutoHotkey then you should be golden.

Code: Select all

#SingleInstance, Force
SendMode, Event
settitlematchmode,2 ;<- so you don't need the whole nopad window title
detecthiddenwindows On ;<- so the script can detect the target window even if hidden
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen

SplitPath, A_ScriptFullPath, ofname, ofdir, ofext, ofnamene, odrv
SetWorkingDir, %ofdir%
inifile = %ofnamene%.ini

;; uses windows notepad for testing
;tstwin := "Untitled"
;ifwinnotexist, %tstwin%
;{	run, Notepad.exe
;}
;WinActivate, %tstwin%

return

esc::
	suspend permit
	MsgBox, 0x1000, Line%A_LineNumber%, End of script, 3
	exitapp	


!m:: ;Center mouse in active window
; note this does not work on text windows because they
; essentially have no "center" until full of text
CenterMouse: ;<- center the mouse in the active window
Suspend Permit
	WinGet, vWinID, ID, A
	rawID := vWinID
	vwinid = ahk_id %vWinID%
	WinGetActiveStats, vWinTitle, vWinWidth, vWinHeight, vWinX, vWinY
	mx := (vWinX + (vWinWidth // 2))
	my := (vWinY + (vwinHeight // 2))
	MouseMove, %mx%, %my%
	sleep 200
	return
	
 ;-----------------------------------------------
 
 ;Mouse Color Setup Routine
;	prompt user to place mouse where they want a color check
;	once user hits the ok button. grab the location and color
;	write the location and color to an ini file
;	build a routine to read the color and location from the ini file
;	build a routine that will check the location for the desired color and
;		tell the user if it's there or not
;
+!u:: ;retrieve color from screen at mouse position and save
	retval := fntkColorGrab()
	;msgBox, 0x1000, Line%A_LineNumber%, retval = %retval%
	stringsplit, colordat, retval, " "
	gosub, writeini
	run, %inifile%
	return


+!c:: ;retrieve static color from file and check
	gosub, readini
	found := fnCheckColorAt(xloc,yloc,searchcolor)
	foundstring := found ? "was found" : "was not found"
	msgbox, Color %searchcolor% %foundstring% at %xloc%`,%yloc% on screen
	return
		
	
fntkColorGrab()
{	MouseGetPos, fgmx, fgmy
	pixelGetColor, fgColor, %fgmx%, %fgmy%, Alt Slow RGB
	retval = %fgmx% %fgmy% %fgcolor%
	;msgBox, 0x1000, Line%A_LineNumber%, coords=%fgmx%`,%fgmy% color=%fgcolor%
	return (retval)
}
	
writeini:
	iniWrite,%retval%, %inifile%, Setup, ColorString
	IniWrite,%colordat1%, %inifile%, Setup, LocX
	iniwrite,%colordat2%, %inifile%, Setup, LocY
	iniWrite,%colordat3%, %inifile%, Setup, colorcheck
	return


readini:
	iniRead,colorstring, %inifile%, Setup, colorstring, none
	iniRead,xloc, %inifile%, Setup, LocX, none
	iniread,yloc, %inifile%, Setup, LocY, none
	iniRead,searchcolor, %inifile%, Setup, colorcheck, none
	return


fnCheckColorAt(x,y,tstcolor)
{	PixelGetColor, somecolor, %x%, %y%, RGB
	if (somecolor = tstcolor)
		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.
TankWantBeCoder
Posts: 4
Joined: 04 Feb 2018, 11:59

Re: Need Help

13 Feb 2018, 13:19

Ok thank you and will it LButton click if it find the color?
User avatar
eventhorizon
Posts: 158
Joined: 27 Oct 2016, 14:22

Re: Need Help

13 Feb 2018, 13:32

no, it gives you a message box to tell you the color was found you can replace the msg box with a click command in place of that if you want it to do the action once the color is found. But that assumes you want to click at the color and not somewhere else. the command you would want to put there would be Click Left, %xloc%, %yloc%
A computer lets you make more mistakes faster than any invention in human history – with the possible exceptions of handguns and tequila.
GreatGazoo
Posts: 69
Joined: 28 Dec 2017, 02:53

Re: Need Help

24 Feb 2018, 18:29

seems like this will be shooting dead bodies as well :D

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 23 guests