Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Count numbers of same pictures found


  • Please log in to reply
3 replies to this topic
SnowFlake_FlowSnake
  • Members
  • 845 posts
  • Last active: Jan 24 2016 05:24 PM
  • Joined: 08 Oct 2012

Hello

 

So i want to make a script that searches for a picture and keeps doing it until all the pictures of that kind have been found and then shows the number of how many pictures of that kind there is.

 

the runes/stones in the picture are the ones that i need to count how man there are of them in my inventory/bag and show the result in a msgbox but i dont know a good way of doing it and i would like some advice.

 

 

likes this,

screenshot_336.png IF this picture is found then make Stone1 = 1 and if it finds another one like that but not one the same place like this

screenshot_336.png screenshot_336.png then it should make Stone1 = 2 and so one for every stone/rune, so it doesnt count the stones on the same location over and over again.

 

The game is Diablo 2 Lord of destruction

 

Inventory with the runes/stones:

screenshot_335.png


  • Download link of my scripts on Autohotkey.com 2/10/2015 [DOWNLAND]
  • Contact Info:  https://github.com/floowsnaake //  FloowSnaake(A)gmail.com
  • IF you need Help send me a PM,Email or Post on Github

  • Quote by tank  Posted 29 September 2015 - 06:14 PM

  • "Eventually i will find a way to convert the DB back to PHPBB3. but i dont have the bandwidth right now. No one that has tried has had success. It is the Only way i can keep this open is if i could successfully convert it."

Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

Are stones always in the same row (left panel) and same column (right panel), or is that just how you have it set up?

 

Because that's feasibly the best way to go here. If you make an image match, you can repeat a search with the found coordinates, but shift the search area just a few pixels over.

 

Say for example the first stone's top left edge is found at coordinate (50, 100). If you know other stones are going to be to the right of it, you would start searching from (52, 100) to (A_ScreenWidth, 100+ImageHeight). The first image you found is now cutoff in the second search and so it won't be matched.

 

It becomes a problem if they can be in any order in your screen. The next best bet is to do this:

 

Search every single slot in your inventory for one particular stone. If it matches, increase the count for that stone by one. In that screenshot, it looks like you'd have to search 108 times using this approach.

 

But if the inventory is not in an exact location at all times (slot expansions or moving panels or something),then it gets so tricky I don't even know if I have it right. What I would do is find your first match, then search progressively toward the right of that. When you get no more matches, you go back to the first match and search progressively toward the bottom of that.  It becomes tricky because you might repeat some, so what you'd want to do is record all of your matched coordinates and if they repeat, not to count that stone as a find again. I am not sure if this approach will skip any stones.



Grant
  • Members
  • 14 posts
  • Last active: Nov 13 2015 10:03 AM
  • Joined: 03 Feb 2010

I was bored..... and need to practice creating functions.

 

Oops, I reread your original post and see you only wanted advice, my appologies.  Do feel free not to use my code, or use it....

~::


number := count_rune(2)
msgbox, %number% runes


return

	;A nice function for you. Send it the rune number and it will return how many there are.

count_rune(type)								
{
		;variables that we need in the function	
		;they are the counting of the runes "number"
		;and the start location for each following search cycle.
	number := 0
	searchx := 1
	searchy := 1

loop
	{
		;change the path as needed
		;The *20 variation may need to be fiddeled with a bit depending on all your runes
	ImageSearch, foundX, foundY, searchx, searchy, A_ScreenWidth, A_ScreenHeight, *20 c:\scripting\diablo2\rune%type%.png		
	
		;error catching.  if you get a -1 result there is an error and it will pop up an error message
	if ErrorLevel = 2
		{
		MsgBox Could not conduct the search, your file does not egsist. Also check the path in the seach command
		return, -1
		}
	
		;this is the part that returns the number found once we no longer find the rune being searched for.
	else if ErrorLevel = 1
		{
;MsgBox No further runes could not be found on the screen.
		return, number
		}
    
		;if a rune is found, we will
		;increase the number found by 1
		;set the start for the next search cycle a bit past where we found the last one.
		;and start the loop again.
	number := number + 1
	searchx := foundx + 5
	searchy := foundy

	}
}


Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
Others
http://autohotkey.co...in-flash-games/
http://autohotkey.co...more/]Findclick
http://autohotkey.co...ck-2nd-edition/

and there are more for sure...
Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About