Locate a photo in the game Mu Online

Ask gaming related questions (AHK v1.1 and older)
Jorge
Posts: 34
Joined: 11 Apr 2023, 09:01

Locate a photo in the game Mu Online

11 May 2023, 06:30

Good Morning

I want some help, I'm trying to identify an image on the screen, using imageSearch.

I'm trying on a photo, I have the whole photo, and the clipping of what I want him to find in it, but he doesn't find the image, I don't know if I'm implementing something wrong, follow the images and my script.

Main Image:
Image

Find Image:
Image

Script:

Code: Select all

#SingleInstance Force
#InstallKeybdHook
#InstallMouseHook
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
#WinActivateForce
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, 30, 30
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, 50

F5::
  CoordMode, Pixel, Screen

  ; captura uma imagem da tela inteira
  ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, bp.jpg

  ; verifica se a imagem foi encontrada
  if ErrorLevel = 0
  {
    MsgBox Imagem encontrada!
  }
  else{
  MsgBox Imagem nao encontrada na tela!
  }
Return
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Locate a photo in the game Mu Online

11 May 2023, 06:47

dont save ur needle images in lossy formats(eg jpg)
Jorge
Posts: 34
Joined: 11 Apr 2023, 09:01

Re: Locate a photo in the game Mu Online

11 May 2023, 09:09

@swagfag

I already tested using png too and the same thing happens
User avatar
boiler
Posts: 17120
Joined: 21 Dec 2014, 02:44

Re: Locate a photo in the game Mu Online

11 May 2023, 15:05

Your reference image isn't even the same size as where it appears in your main image. And that's viewing each image at full scale, not as scaled down as displayed on this page.
Jorge
Posts: 34
Joined: 11 Apr 2023, 09:01

Re: Locate a photo in the game Mu Online

12 May 2023, 06:16

@boiler


And how can I do? Because all I did was take the print of the screen, and cut the part I want it to look for the script.
User avatar
boiler
Posts: 17120
Joined: 21 Dec 2014, 02:44

Re: Locate a photo in the game Mu Online

12 May 2023, 06:28

You must not have done it correctly. Maybe you took a screen shot from the the main image when viewed at a different scale. Paste the main image in MS Paint, then use the crop tool to crop that specific section.
Jorge
Posts: 34
Joined: 11 Apr 2023, 09:01

Re: Locate a photo in the game Mu Online

12 May 2023, 08:23

@boiler

That's exactly what I did, I took the print, pasted it in Paint and cut just the piece I wanted to look for. The result is what is there.
User avatar
boiler
Posts: 17120
Joined: 21 Dec 2014, 02:44

Re: Locate a photo in the game Mu Online

12 May 2023, 10:29

OK. Sorry. When I took another look, I was wrong about the sizes being different. But looking at it closely, it's clear that you did not just take a crop of the original unless you did something like save if first as a jpg and then just converted that jpg to a png. It's too late then. The image already has the loss built in to it. You need to save the cropped part as a png directly.

See the comparison below of the original main image on the left and your reference image on the right. Compare what's in the red boxes. The one on the left has more definition between pixels. The one on the right has those colors blended across multiple pixels.

comparison.png
comparison.png (8.72 KiB) Viewed 1063 times

You can't find an image if you can't take a representative sample of the original.
Jorge
Posts: 34
Joined: 11 Apr 2023, 09:01

Re: Locate a photo in the game Mu Online

12 May 2023, 16:40

@boiler

Got it, well my idea is to do the following.

In a game there is a fusion where I place an item and if it works, another one comes out, the idea is to analyze if the other one came out, if so, click on it if not, just exit the fusion.

I started with just the print to analyze, because this print came from the game, which by default when I press the print screen button, it takes it as a jpg, which they already said is not ideal.

And being PNG, should I get more success? In the game the item is static, it only moves and changes with the mouse over it, otherwise a print will do. If I take the print of this item that comes out in the fusion saving in PNG, can it theoretically be found in the game?

Any idea how I can print what I need in png, maybe use a print program?
User avatar
boiler
Posts: 17120
Joined: 21 Dec 2014, 02:44

Re: Locate a photo in the game Mu Online

12 May 2023, 17:37

Yes, you have almost no chance on it working using a jpg and it shouldn't be a problem if you capture the image correctly using png. It already looks like you can capture the image correctly. The original main image has a lot more definition than your small sample image. You made some mistake in capturing and saving the smaller image. If you just cropped the main image you've already taken, it should be fine.

If not, see if you can use Alt+PrintScreen, which puts a copy of the active window on the clipboard. Then you can paste it into MS Paint, crop it, and save it as a png.
Jorge
Posts: 34
Joined: 11 Apr 2023, 09:01

Re: Locate a photo in the game Mu Online

12 May 2023, 21:30

@boiler

I just did the test as you said, I used alt+print, saved the photo in png in paint and cropped it in paint and also saved it in png.

I put the script to run and it does not find the same image.

I'll send below the code, the main image and what I'm looking for in it.

Main Image:
Image

Find Image:
Image

Script:

Code: Select all

#NoEnv
#SingleInstance Force
#InstallKeybdHook
#InstallMouseHook
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
#WinActivateForce
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, 30, 30
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, 50

F5::
  ; captura uma imagem da tela inteira
  CoordMode, Pixel, Screen

  ; captura uma imagem da tela inteira
  ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, testesd.png

  ; verifica se a imagem foi encontrada
  
  if ErrorLevel = 2
  {
    MsgBox Could not conduct the search.
  }
  else if ErrorLevel = 1
  {
    MsgBox Image could not be found on the screen.
  }
  else
  {
    ; move o mouse para a posição da imagem
    MouseMove, foundX, foundY, 0

    ; adiciona um pequeno atraso antes de clicar
    Sleep, 700

    ; clica na posição da imagem
    ;ControlClick, %foundX%, %foundY%, , , , Left, 1, D
	
    MsgBox The icon was found at %foundX%x%foundY%.
  }
Return
User avatar
boiler
Posts: 17120
Joined: 21 Dec 2014, 02:44

Re: Locate a photo in the game Mu Online

12 May 2023, 23:58

I find it here no problem. Why does your script say the image is name testesd.png but that's not the name of the file you attached. Are you sure it's named that? Is it in the script's directory? Which message does it show?
Are you sure you're displaying the main image at 100% scaling? What app are you displaying it with? Still with Paint or some photo viewer?
Jorge
Posts: 34
Joined: 11 Apr 2023, 09:01

Re: Locate a photo in the game Mu Online

13 May 2023, 07:48

@boiler

I just got it, it was really the scale, with the windows viewer, it doesn't come at the maximum, then I put full screen and found it.

And in the game I managed to find it too, perfect, thank you very much!

But I did one more test. Explaining to you, it's an item fusion, where according to the print, the pot comes out randomly in some slot of the chaos machine, how can I make it find the pot regardless of the position it comes out? because I did the test using the same files, and did not find the photo.

Chaos Machine with pot:

https://i.imgur.com/KzhSrdH.png
Last edited by Jorge on 13 May 2023, 08:05, edited 1 time in total.
User avatar
boiler
Posts: 17120
Joined: 21 Dec 2014, 02:44

Re: Locate a photo in the game Mu Online

13 May 2023, 07:58

Don’t use Windows Photo Viewer. It blends pixels. It it not a pixel-for-pixel accurate representation of the image.

I made it work by running a regular ImageSearch command, and I viewed it as the actual image using MS Paint. Never use Photo Viewer.
Jorge
Posts: 34
Joined: 11 Apr 2023, 09:01

Re: Locate a photo in the game Mu Online

13 May 2023, 08:05

I just got it, it was really the scale, with the windows viewer, it doesn't come at the maximum, then I put full screen and found it.

And in the game I managed to find it too, perfect, thank you very much!

But I did one more test. Explaining to you, it's an item fusion, where according to the print, the pot comes out randomly in some slot of the chaos machine, how can I make it find the pot regardless of the position it comes out? because I did the test using the same files, and did not find the photo.

Chaos Machine with pot:

https://i.imgur.com/KzhSrdH.png
User avatar
boiler
Posts: 17120
Joined: 21 Dec 2014, 02:44

Re: Locate a photo in the game Mu Online

13 May 2023, 08:38

If it is rendered differently by the game when it appears in a different place, which might not be able to discern by the naked eye but only when you zoom in on it and compare it at a pixel level, then you probably won’t be able to find it using the same reference image no matter how much variation you allow.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Locate a photo in the game Mu Online

13 May 2023, 08:50

pixelsearch for one of the dark grey background pixels instead
Jorge
Posts: 34
Joined: 11 Apr 2023, 09:01

Re: Locate a photo in the game Mu Online

13 May 2023, 10:31

@boiler

And how can I achieve this? Take a print of the result in each possible position and search among all the prints?
Is it possible to send imagesearch to fetch multiple images? Or does it have to be one at a time?

@swagfag


I tried to do it but I wasn't very successful, could you give me an example of how to do it?
User avatar
boiler
Posts: 17120
Joined: 21 Dec 2014, 02:44

Re: Locate a photo in the game Mu Online

13 May 2023, 13:13

Jorge wrote: And how can I achieve this? Take a print of the result in each possible position and search among all the prints?
Is it possible to send imagesearch to fetch multiple images? Or does it have to be one at a time?
You would have to run ImageSearch for each image. You could put it in a loop to run through all the images, It would be slower than what swagfag suggested.
Jorge
Posts: 34
Joined: 11 Apr 2023, 09:01

Re: Locate a photo in the game Mu Online

13 May 2023, 16:17

@boiler


can you give me an example of what this loop would look like? the bad thing is that it's slow, I tried to do it per pixel, but I couldn't identify a code that gets it right, it gets other places inside the chaos machine window.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 28 guests