Magic Online v4 - Image Search

Ask gaming related questions (AHK v1.1 and older)
SteB
Posts: 4
Joined: 30 Apr 2017, 05:33

Magic Online v4 - Image Search

30 Apr 2017, 06:01

Hello

i was fiddling around with the imageSearch function today. As mentioned in the title i want to use it with Magic Online v4 by Wizards of the Coast.

At first i wrote some simple scripts and tried to match some images on a few random websites to get familiar with the functionality, which worked without any issues. So i moved on to my actual task.
I screencapped the attached image, which shows the gameplay screen. (note: this is jpg image to reduce the file size, for the script i worked with png images)

I tried to match several interface elements, controls and card images but non of that worked.
Something strange happend to which at first made it to appear as if the script is working. I got positiv hits from the script, but not from the position where the images appear in the game screen. The script matched the preview thumbnails in the directory where i stored the imageFiles and the script. After i realized that i noticed that this even works when the magic online gamewindow overlaps or even covers the windows explorer window entierely. In that case the script still matches the preview thumbnails in the explorer window behind the game window.
So it appears that ahk seems to ignore the magic online window for some reason when using image search.

I ried if the game window is able to recive clicks and that seems to work without issues.

here is my script:
(the area i try to match is just the entire area shown by my 2 monitors)

Code: Select all

F6::searchImg()

searchImg(){
    ; ImageSearch, FoundX, FoundY, 40,40, 300, 300, C:\My Images\test.bmp
    ; CoordMode Pixel  ; Interprets the coordinates below as relative to the screen rather than the active window.
    
    ImageSearch, FoundX, FoundY, 0, 0, 3120, 1050, symbol.png
    
    if ErrorLevel = 2
        MsgBox Could not conduct the search.
    else if ErrorLevel = 1
        MsgBox Icon could not be found on the screen.
    else
        MsgBox The icon was found at %FoundX%x%FoundY%.

    MouseMove FoundX, FoundY 
}
I already tried:
*) running the script in admin mode
*) compling the script and running the exe
*) running the exe in admin mode

Does anybody now what else I could try here?
Attachments
mtgoImageSearch.jpg
mtgoImageSearch.jpg (440.04 KiB) Viewed 2300 times
User avatar
SnowFlake
Posts: 368
Joined: 28 Apr 2015, 05:41
Contact:

Re: Magic Online v4 - Image Search

30 Apr 2017, 16:14

i made some chnages try now,press X to loopit/toggle the loop on and off

Code: Select all

IF NOT A_IsAdmin
{
   Run *RunAs "%A_ScriptFullPath%"
   ExitApp
}

#MaxThreadsPerHotkey 2
#SingleInstance Force
#Persistent

toggle = 0
CoordMode, Mouse, Client
CoordMode, Pixel, Client
CoordMode, ToolTip, Client

X::
SoundBeep
    Toggle := !Toggle
     While Toggle{
    ; ImageSearch, FoundX, FoundY, 40,40, 300, 300, C:\My Images\test.bmp
    ; CoordMode Pixel  ; Interprets the coordinates below as relative to the screen rather than the active window.
    
    ImageSearch, FoundX, FoundY, 0, 0, 3120, 1050, symbol.png
    
    if ErrorLevel = 2
        MsgBox Could not conduct the search.
    else if ErrorLevel = 1
        MsgBox Icon could not be found on the screen.
    else
        MsgBox The icon was found at %FoundX%x%FoundY%.

    MouseMove FoundX, FoundY 
}
return

^Esc::
ExitApp
return
:yawn:
User avatar
SnowFlake
Posts: 368
Joined: 28 Apr 2015, 05:41
Contact:

Re: Magic Online v4 - Image Search

30 Apr 2017, 16:14

i made some chnages try now,press X to loopit/toggle the loop on and off

Code: Select all

IF NOT A_IsAdmin
{
   Run *RunAs "%A_ScriptFullPath%"
   ExitApp
}

#MaxThreadsPerHotkey 2
#SingleInstance Force
#Persistent

toggle = 0
CoordMode, Mouse, Client
CoordMode, Pixel, Client
CoordMode, ToolTip, Client

X::
SoundBeep
    Toggle := !Toggle
     While Toggle{
    ; ImageSearch, FoundX, FoundY, 40,40, 300, 300, C:\My Images\test.bmp
    ; CoordMode Pixel  ; Interprets the coordinates below as relative to the screen rather than the active window.
    
    ImageSearch, FoundX, FoundY, 0, 0, 3120, 1050, symbol.png
    
    if ErrorLevel = 2
        MsgBox Could not conduct the search.
    else if ErrorLevel = 1
        MsgBox Icon could not be found on the screen.
    else
        MsgBox The icon was found at %FoundX%x%FoundY%.

    MouseMove FoundX, FoundY 
}
return

^Esc::
ExitApp
return
:yawn:
SteB
Posts: 4
Joined: 30 Apr 2017, 05:33

Re: Magic Online v4 - Image Search

01 May 2017, 07:00

thanks for the effort

i just tried your updated script, and unfortunately it doesn't solve the problem. It still has the same issues as before that it seems to "ignore" (for the lack of a better term) the game window.

//edit:
additional information:
afaik mtgo is programmed in c# and runs on the unity game engine.

Are there any known issues with those kind of applications?

//edit2:
just tried something else

Code: Select all

q::  ; Control+Alt+Z hotkey.
MouseGetPos, MouseX, MouseY
PixelGetColor, color, %MouseX%, %MouseY%
MsgBox The color at the current cursor position is %color%.
return
i used this script to determine if i'm able to grab the pixelcolor of the mtgo window. The answer is i can't this script will give back whatever color happens to be on the pixel at the mouse position behind the mtgo window. So just like 'imageSearch', 'PixelGetColor' ignores the game window.
User avatar
FanaticGuru
Posts: 1908
Joined: 30 Sep 2013, 22:25

Re: Magic Online v4 - Image Search

01 May 2017, 11:05

Just for the record. Your code works fine for me at least when I am in the Collection tab with what ever version I am running.

I opened my collection. Did a screen clip of one card. Saved that to a file as a png. Changed the file in script to the correct path and file name. Started script and pushed F6. It found the card every time with no problem. Completely as I would expect.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
SteB
Posts: 4
Joined: 30 Apr 2017, 05:33

Re: Magic Online v4 - Image Search

03 May 2017, 14:30

Hmm that is strange.

I tried it on a different computer and i had the same problems there.
Both where running with Windows 7.
The first one used Autohotkey v1.1.23.01 the other one version v1.1.25.01

I'll try on at least one more i guess.
User avatar
FanaticGuru
Posts: 1908
Joined: 30 Sep 2013, 22:25

Re: Magic Online v4 - Image Search

03 May 2017, 15:19

SteB wrote:Hmm that is strange.

I tried it on a different computer and i had the same problems there.
Both where running with Windows 7.
The first one used Autohotkey v1.1.23.01 the other one version v1.1.25.01

I'll try on at least one more i guess.
I don't think the Autohotkey version would matter. The Window version could maybe, especially with various transparency and theme settings. I tested on Windows 10.

Since you got it to work with websites I assume you have the clipping and prepping the image process figured out in a way that does not convert or change the images in some way.

So I don't really have a great suggestion to solve your problem.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
SteB
Posts: 4
Joined: 30 Apr 2017, 05:33

Re: Magic Online v4 - Image Search

06 May 2017, 04:51

I put some more time into this problem yesterday.

In order to determine if windows might be the issue i tried if the imageCapture function of IrfanView works. The answer is it doesn't. Indeed it the same issue that it doesn't screencap the mtgo window but whatever lies behind it. I haven't tried other applications beyond that yet.
I know that windows own snipping tool works, tough i haven't yet investigated why that is.

It's kinda hard to google for solutions to this problem as the goolge search just yields 234619283 results of stupid tutorials on how to take a simple screenshot :/
User avatar
FanaticGuru
Posts: 1908
Joined: 30 Sep 2013, 22:25

Re: Magic Online v4 - Image Search

08 May 2017, 10:24

SteB wrote:I put some more time into this problem yesterday.

In order to determine if windows might be the issue i tried if the imageCapture function of IrfanView works. The answer is it doesn't. Indeed it the same issue that it doesn't screencap the mtgo window but whatever lies behind it. I haven't tried other applications beyond that yet.
I know that windows own snipping tool works, tough i haven't yet investigated why that is.

It's kinda hard to google for solutions to this problem as the goolge search just yields 234619283 results of stupid tutorials on how to take a simple screenshot :/
I used IrfanView 64 to clip the image of a card from my Magic Online collection with no problems.

Before I used a AHK script (which uses the Gdip library) to do the clipping to get the image to search for with no problems.

Basically I experience no weirdness with Magic Online.

Not any solutions but at least you know it is possible to interact with Magic Online normally.

I tried googling it a different way. How would I screen clip and ignore a certain window and I got results talking about Desktop Window Manager (DWM) composition which changed in versions of Windows after 7 which is why I am probably not have a problem with Windows 10. There was info on skinned windows being ignored which the Magic Online window does look like a skinned window that is having its basic look modified. If you must do this on Windows 7 I would look at tinkering with all the graphic settings options that Windows 7 might have especially stuff like Aero.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
User avatar
SnowFlake
Posts: 368
Joined: 28 Apr 2015, 05:41
Contact:

Re: Magic Online v4 - Image Search

10 May 2017, 11:16

have you gotten this working yet?
:yawn:

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 96 guests