ImageSearchList Count

Post gaming related scripts
Bontoft
Posts: 4
Joined: 16 Feb 2019, 04:57

ImageSearchList Count

04 May 2019, 08:33

I'm currently wanting to count the amount of a certain item are in my inventory by using the ImageSearchList (https://github.com/MasterFocus/AutoHotkey/tree/master/Functions/outdated_ImageSearchList).

However, it seems to be counting the amount of that item in my inventory but it is always 1 more than what there is.

This is what I have at the moment:

Code: Select all

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors. 
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. 
CoordMode, Mouse, Window
SetTitleMatchMode, 1

#IfWinActive, RuneLite

IfNotExist, Counter
file := FileOpen(Counter, "w") 
file.write(increment) 
file.close()

increment := 0 
Counter := "C:\Users\Callum\Documents\AHK\Counters\Counter.txt" ; put your path here


F12::
  glob_List := ImageSearchList("C:\Users\Callum\Documents\AHK\AHK Images\Item.png",557,235,737,490,",","`n","f_MyDebug")
  ToolTip
  Loop, Parse, glob_List, `n
  {
    increment += 1 
    file:= FileOpen(Counter, "w") 
    file.write(increment) 
    file.close()
  }
Return




ImageSearchList(p_ImgStr,p_StartX=0,p_StartY=0,p_EndX=0,p_EndY=0,p_CDelim=",",p_LDelim="`n",p_DebugFunc="")
{
  l_Debug := IsFunc(p_DebugFunc) , l_StX := p_StartX , l_List := ""
  p_EndX := ( !p_EndX ? A_ScreenWidth : p_EndX ) , p_EndY := ( !p_EndY ? A_ScreenHeight : p_EndY )
  Loop
  {
    ImageSearch, l_OutX, l_OutY, %l_StX%, %p_StartY%, %p_EndX%, %p_EndY%, %p_ImgStr%
    If l_Debug
      %p_DebugFunc%(A_Index,l_OutX,l_OutY,l_StX,p_StartY,p_EndX,p_EndY,p_ImgStr,l_List)
    If InStr( l_List , l_OutX p_CDelim l_OutY p_LDelim )
    {
      l_StX := l_OutX+1
      Continue
    }   
    If ( l_OutX="" || l_OutY="" )
      If ( l_StX <> p_StartX )
      {
        l_StX := p_StartX , p_StartY++
        Continue
      }
      Else
        Break
    l_List .= l_OutX p_CDelim ( p_StartY := l_OutY ) p_LDelim
  }
  Return l_List
}
_3D_
Posts: 211
Joined: 29 Jan 2014, 14:40

Re: ImageSearchList Count

05 May 2019, 00:23

Code: Select all

increment:= 0
;your function add delimiter after each found item
glob_List:= "1`n2`n"	;it mean 1 2 and ""
						;when N delimiters then N+1 items

Loop Parse glob_List, "`n"
	;if(A_LoopField) ;if increment (skip "")
{
	increment += 1
	;increment += (A_LoopField != "") ;alternative if increment
	MsgBox(A_LoopField " | " increment)
}
AHKv2.0 use the future now.

Return to “Gaming”

Who is online

Users browsing this forum: Google [Bot] and 5 guests