FindImagePos not staying within the WINDOW given

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
madcyborg
Newbie
Posts: 12
Joined: Sun Oct 20, 2019 3:22 pm

FindImagePos not staying within the WINDOW given

Post by madcyborg » Wed Jun 10, 2020 2:01 pm

[snippet=]
GetWindowHandle>SM-G955U,nHandle
Let>WIN_USEHANDLE=1
GetWindowPos>nHandle,nXPos,nYPos

FindImagePos>C:\Users\MyUser\Documents\Macro Scheduler 14\FGLair Powerful (blast heat)\image_5.bmp,WINDOW:SM-G995U,0.4,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif
[/snippet]

I have a computer that I use just for smart home stuff. And one of the things that it does is it navigates an android application that controls a mini split heater.

In the example above, in the first three lines, I just wanted to prove that I could find the window handle for the android. That works correctly. And in the last few lines, it's supposed to find some image within that android window. But what ends up happening is, it recognizes the image within a chrome browser window instead.

I thought that supplying a WINDOW:title argument would constrain the image match to just the window, but it's not doing that. Can you tell me what I'm doing wrong? Would it be possible to supply a handle instead?

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: FindImagePos not staying within the WINDOW given

Post by Dorian (MJT support) » Thu Jun 11, 2020 5:19 pm

If it doesn't find the window it searches the entire screen.

I'm wondering if it could be one of these :

1: The window is not visible, cannot be captured and so you're getting a false positive. Try setting focus.
2: The window you're getting a false positive in is on top of the one you want.
3: The window title is changing or is incorrect.

I would add a SetFocus before your code and increase your tolerance to 0.7.
Yes, we have a Custom Scripting Service. Message me or go here

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts