help with more then one PixelSearch!

Ask gaming related questions (AHK v1.1 and older)
Kcolb
Posts: 2
Joined: 22 Apr 2017, 16:02

help with more then one PixelSearch!

22 Apr 2017, 16:26

So have tried everything I know (no that much) in AHK. But cant solve my problem

First, what i want the script to do, I want the script to check 2 things on 8 spots in a game called Dark age of camelot on a free server
1, Want it to check if groupmates have my buff, if not I want it to target groupmember (f1-f8) cast the buff (key q) or play a sound(what ever)
2, Want it to check teammates healt if its below 60% I want to to Send, {enter} Send, "/g !! HEAL HEAL !!"


Have no problem doing one task with loop so it keep cheking the
Spoiler
but it fucks up when I try to add more then one pixelsearch.


have tried things like:
Spoiler
But as soon as I put another pixelsearch in the loop it fucks up, tried with settimers, loop in the loop, and diffrent pixelsearch n Im out of options thats why im asking u guys!

hope u can help me out!
User avatar
PipeDreams
Posts: 165
Joined: 19 Dec 2015, 00:20

Re: help with more then one PixelSearch!

23 Apr 2017, 23:00

I don’t think pixel search can be used in that manner, you would need a script that can read memory to accomplish what you’re asking. However, I pose an alternative, what about a timer? Something along the lines of: I’ve pressed “3” which cast Spell XYZ. Timer rings in say 30 seconds and lets you know it is time to rebuff.

Code: Select all

#Persistent
~3:: ;Set to desired key.
Sleep, 2000 ;1000 = 1 second 
SoundBeep, 700, 100
Return
grant
Posts: 323
Joined: 14 Oct 2015, 17:27

Re: help with more then one PixelSearch!

24 Apr 2017, 02:27

I would rather use pixelgetcolor as it looks at a specific pixel (unless it moves around). If there are small shadows, there are some functions that take an area and return an average color value for the window that you might be able to use. But your way can also work.

Untested code:

Code: Select all

f1::
Loop
{
buffcheck()
healteam()
}
Return 

f2::
reload

f12::
exitapp

;-------------------------------------------
;functions start here

;-------------------------------------------
buffcheck()
{
Sleep, 50

CoordMode, Pixel, Window
PixelSearch, FoundX, FoundY, 1027, 730, 1039, 746, 0x95940F, 30, Fast RGB

If ErrorLevel = 0
	{
	Sleep, 50
	Send, {q down}
	Sleep, 90
	Send, {q up}
	return
	}

if Errorlevel = 1
	;msgbox, your party should be buffed - you are looking for the color that indicates that you are not buffed so that you can buff.
	return
	
if Errorlevel = 2
	{
	msgbox, Pixelsearch could not run.... exiting app.
	exit
	}
}


;-------------------------------------------
healteam()
{
				;your code, similar to the buffcheck() function can go here
return
}
What I have done is added some error checks to your working code, **Always do this** it makes your life more simple when something silly happens so that you know what went wrong immediately. I turned it into a function that you can call from anywhere. Functions are in my mind one of the most valuable tools you can use.

Then in your main program (triggered by F1) we call the function buffcheck() once that is done, the loop continues and calls the healteam() function. When that is done, the loop starts all over again.

F2 reloads the script if it bugs out and F12 will exit the entire thing.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Google [Bot], ReyAHK and 44 guests