Help me, search image Topic is solved

Ask gaming related questions (AHK v1.1 and older)
tru
Posts: 4
Joined: 23 Aug 2021, 15:32
Contact:

Help me, search image

05 Sep 2021, 12:20

Hi everyone,
I have an animation in the game but can't find it. I have tried with Imagesearch, pixelsearch, Gdip_Imagesearch (Gdip_Imagesearch with form file is ok). Below is a picture (I also uploaded the video) I need to find the flickering yellow border and click on that image. The yellow border will change by day (receive login gift). Anyone have a method to guide me with.
sorry i'm not good at english.
Thanks everyone.

https://www.dropbox.com/s/vzxs4ryczz4lp2y/vhkn1.png?dl=0
User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Help me, search image

05 Sep 2021, 13:04

Gdip_ImageSearch should work because you would be searching a static, captured image. But it may take several samples before it finds it because the yellow border is faded out part of the time. You need to create the reference image wisely. Using a reference image made up of just a few pixels of the brightest yellow with no background pixels and an adequate level of allowable variation in the search options should work. Develop your script on a static screenshot where the bright border is captured before adapting it to using multiple samples with the live game animation.
Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Help me, search image

05 Sep 2021, 13:04

Hallo,
just an idea. Take a snapshot #1 of the area, invert all its color values and overlay with a later second non-inverted snapshot #2
Color value#3 = (Color values#1 + Color values#2) / 2
All static areas will disappear and time-varying areas will be easy to find.
tru
Posts: 4
Joined: 23 Aug 2021, 15:32
Contact:

Re: Help me, search image

06 Sep 2021, 03:45

boiler wrote:
05 Sep 2021, 13:04
Gdip_ImageSearch should work because you would be searching a static, captured image. But it may take several samples before it finds it because the yellow border is faded out part of the time. You need to create the reference image wisely. Using a reference image made up of just a few pixels of the brightest yellow with no background pixels and an adequate level of allowable variation in the search options should work. Develop your script on a static screenshot where the bright border is captured before adapting it to using multiple samples with the live game animation.
I have created many sample images but it is not working. Can you give specific instructions?
Image
Image
tru
Posts: 4
Joined: 23 Aug 2021, 15:32
Contact:

Re: Help me, search image

06 Sep 2021, 03:47

Rohwedder wrote:
05 Sep 2021, 13:04
Hallo,
just an idea. Take a snapshot #1 of the area, invert all its color values and overlay with a later second non-inverted snapshot #2
Color value#3 = (Color values#1 + Color values#2) / 2
All static areas will disappear and time-varying areas will be easy to find.
Can you give specific instructions? I just learned autohotkey.
User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Help me, search image

06 Sep 2021, 04:44

tru wrote: I have created many sample images but it is not working. Can you give specific instructions?
Image
Image
Yes. Even if you used something like a TransBlack option to ignore the black area in the middle of the images above, it would only find them if the border happened to be exactly that size and shape including the exact fuzziness of its edges. Very unlikely for a constantly changing animation.

Again, make the reference image just a few pixels of the brightest yellow. Nothing else. Crop a portion of the vertical part of the border that is only 3 pixels high and 1 pixel wide of the brightest yellow and nothing else. That’s the whole reference image.
Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Help me, search image  Topic is solved

16 Sep 2021, 04:21

Try: viewtopic.php?t=82812

Refer the following Global array elements to know the screen coordinates where the pixel change occurred:
Window X,Y : A_Args.ScrCmp.CX and A_Args.ScrCmp.CY
Screen X,Y : A_Args.ScrCmp.SX and A_Args.ScrCmp.SY
MrHue
Posts: 17
Joined: 01 Oct 2015, 02:51

Re: Help me, search image

17 Sep 2021, 07:58

Animations are very difficult to search for.
I would try not to search for that blinking shrinking yellow square if possible.
If you just want to click on the square with animation, then why not have the script click on all the squares?
Alternatively, if it's a daily event, have the script click on a square depending on which day it is?
Otherwise search for the green tick and click on the square next to the green tick?
tru
Posts: 4
Joined: 23 Aug 2021, 15:32
Contact:

Re: Help me, search image

18 Sep 2021, 09:21

Rohwedder wrote:
16 Sep 2021, 04:21
Try: viewtopic.php?t=82812

Refer the following Global array elements to know the screen coordinates where the pixel change occurred:
Window X,Y : A_Args.ScrCmp.CX and A_Args.ScrCmp.CY
Screen X,Y : A_Args.ScrCmp.SX and A_Args.ScrCmp.SY
i have researched but i don't understand . Can you help me ?
Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Help me, search image

18 Sep 2021, 12:41

This script found the time changing area of your video.
First select the area to be searched with hotkey #LButton::, the ticker must not be included! Then start the video and immediately afterwards the search with hotkey q::
Then a short beep should sound and the cursor goes to the upper left corner of the found area.

Code: Select all

#NoEnv
#SingleInstance, Force
SetBatchLines, -1
CoordMode, Mouse, Screen
;note: 'CoordMode, Mouse, Screen' must be used in the auto-execute section
#LButton::
InputRect(vX1, vY1, vX2, vY2)
vW := vX2-vX1, vH := vY2-vY1
if (vInputRectState = -1)
	return
Return
q::
ScrCmp(vX1, vY1, vW, vH)
SoundBeep, 4000, 20
MouseMove, A_Args.ScrCmp.SX, A_Args.ScrCmp.SY
Return
;==================================================
InputRect(ByRef vX1, ByRef vY1, ByRef vX2, ByRef vY2)
{
	global vInputRectState := 0
	DetectHiddenWindows, On
	Gui, 1: -Caption +ToolWindow +AlwaysOnTop +hWndhGuiSel
	Gui, 1: Color, Red
	WinSet, Transparent, 128, % "ahk_id " hGuiSel
	Hotkey, *LButton, InputRect_Return, On
	Hotkey, *RButton, InputRect_End, On
	Hotkey, Esc, InputRect_End, On
	KeyWait, LButton, D
	MouseGetPos, vX0, vY0
	SetTimer, InputRect_Update, 10
	KeyWait, LButton
	Hotkey, *LButton, Off
	Hotkey, Esc, InputRect_End, Off
	SetTimer, InputRect_Update, Off
	Gui, 1: Destroy
	return

	InputRect_Update:
	if !vInputRectState
	{
		MouseGetPos, vX, vY
		(vX < vX0) ? (vX1 := vX, vX2 := vX0) : (vX1 := vX0, vX2 := vX)
		(vY < vY0) ? (vY1 := vY, vY2 := vY0) : (vY1 := vY0, vY2 := vY)
		Gui, 1:Show, % "NA x" vX1 " y" vY1 " w" (vX2-vX1) " h" (vY2-vY1)
		return
	}
	vInputRectState := 1

	InputRect_End:
	if !vInputRectState
		vInputRectState := -1
	Hotkey, *LButton, Off
	Hotkey, *RButton, Off
	Hotkey, Esc, Off
	SetTimer, InputRect_Update, Off
	Gui, 1: Destroy

	InputRect_Return:
	return
}

;==================================================

ScrCmp( X, Y, W, H, Hwnd:=0x0, Sleep* )  {                                        ; v0.66 By SKAN on D3B3/D3B6 @ tiny.cc/scrcmp
Local
Global A_Args
  Sleep[1] := Sleep[1]="" ? 100 : Format("{:d}", Sleep[1])
  Sleep[2] := Sleep[2]="" ? 100 : Format("{:d}", Sleep[2])

  VarSetCapacity(BITMAPINFO, 40, 0)
  NumPut(32, NumPut(1, NumPut(0-H*2, NumPut(W, NumPut(40,BITMAPINFO,"Int"),"Int"),"Int"),"Short"),"Short")

  hBM := DllCall("Gdi32.dll\CreateDIBSection", "Ptr",0, "Ptr",&BITMAPINFO, "Int",0, "PtrP",pBits := 0, "Ptr",0, "Int",0, "Ptr")
  sDC := DllCall("User32.dll\GetDC", "Ptr",(Hwnd := WinExist("ahk_id" . Hwnd)), "Ptr")
  mDC := DllCall("Gdi32.dll\CreateCompatibleDC", "Ptr",sDC, "Ptr")
  DllCall("Gdi32.dll\SaveDC", "Ptr",mDC)
  DllCall("Gdi32.dll\SelectObject", "Ptr",mDC, "Ptr",hBM)
  DllCall("Gdi32.dll\BitBlt", "Ptr",mDC, "Int",0, "Int",H, "Int",W, "Int",H, "Ptr",sDC, "Int",X, "Int",Y, "Int",0x40CC0020)

  A_Args.ScrCmp := {"Wait": 1},   Bytes := W*H*4,  Count := 0
  hMod := DllCall("Kernel32.dll\LoadLibrary", "Str","ntdll.dll", "Ptr")
  While ( A_Args.ScrCmp.Wait && (Count<2) )
  {
      DllCall("Gdi32.dll\BitBlt", "Ptr",mDC, "Int",0, "Int",0, "Int",W, "Int",H, "Ptr",sDC, "Int",X, "Int",Y, "Int",0x40CC0020)
      Count := ( (Byte := DllCall("ntdll.dll\RtlCompareMemory", "Ptr",pBits, "Ptr",pBits+Bytes, "Ptr",Bytes) ) != Bytes )
               ? (Count + 1) : 0
      Sleep % (Count ? Sleep[2] : Sleep[1])
  }   Byte +=1
  DllCall("Kernel32.dll\FreeLibrary", "Ptr",hMod)

  SX := (CX := Mod((Byte-1)//4, W) + X),    SY := (CY := (Byte-1) // (W*4)   + Y)
  If (Hwnd)
    VarsetCapacity(POINT,8,0), NumPut(CX,POINT,"Int"), NumPut(CY,POINT,"Int")
  , DllCall("User32.dll\ClientToScreen", "Ptr",Hwnd, "Ptr",&POINT)
  , SX := NumGet(POINT,0,"Int"),  SY := NumGet(POINT,4,"Int")

  If (Wait := A_Args.ScrCmp.Wait)
      A_Args.ScrCmp := { "Wait":0, "CX":CX, "CY":CY, "SX":SX, "SY":SY }
  DllCall("Gdi32.dll\RestoreDC", "Ptr",mDC, "Int",-1)
  DllCall("Gdi32.dll\DeleteDC", "Ptr",mDC)
  DllCall("User32.dll\ReleaseDC", "Ptr",Hwnd, "Ptr",sDC)
  DllCall("Gdi32.dll\DeleteObject", "Ptr",hBM)
Return ( !!Wait )
}

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: KaylieBullock and 62 guests