Coordinates relative to an inactive window Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Meow
Posts: 24
Joined: 21 Feb 2016, 22:48

Coordinates relative to an inactive window

31 Mar 2017, 12:09

Hi,

So what I need is to be able to do a PixelSearch on an inactive window (I check with a loop every few seconds if one specific item has disappeared from my inventory (for a game)) but I can't figure out how I could get the coordinates to be relative to an inactive window.
So when I use

Code: Select all

PixelSearch, , , X1, Y1, X2, Y2,...
I can't make the coordinate params which make my search region be anything that would help me.

I looked at CoordMode, but it won't do it (unless I misunderstood the way that command functions).
A_AhkUser
Posts: 1076
Joined: 06 Mar 2017, 16:18
GitHub: AAhkUser
Location: France

Re: Coordinates relative to an inactive window  Topic is solved

31 Mar 2017, 12:28

First retrieves the position of the inactive window by means of WinGetPos command and
make the inactive window upper-left corner coordinates function as reference from wich start your pixel research.

Code: Select all

CoordMode, Pixel, Screen
YourRectangle := {"width": 400, "height": 300} ; for exemple
WinGetPos, XStart, YStart,,, TitleOfYourInactiveWindow
PixelSearch, X, Y, % XStart, % YStart, % (XStart + YourRectangle.width), % (YStart + YourRectangle.height), YourColorID
MsgBox % X . "," . Y
EDIT: and if you want, besides to be able to do a PixelSearch on an inactive window, retrieves relatives coordinates:
change:

Code: Select all

MsgBox % X . "," . Y
by:

Code: Select all

MsgBox % (X-XStart) . "," . (Y-YStart)
User avatar
Meow
Posts: 24
Joined: 21 Feb 2016, 22:48

Re: Coordinates relative to an inactive window

31 Mar 2017, 12:54

A_AhkUser wrote:First retrieves the position of the inactive window by means of WinGetPos command and
make the inactive window upper-left corner coordinates function as reference from wich start your pixel research.

Code: Select all

CoordMode, Pixel, Screen
YourRectangle := {"width": 400, "height": 300} ; for exemple
WinGetPos, XStart, YStart,,, TitleOfYourInactiveWindow
PixelSearch, X, Y, % XStart, % YStart, % (XStart + YourRectangle.width), % (YStart + YourRectangle.height), YourColorID
MsgBox % X . "," . Y
EDIT: and if you want, besides to be able to do a PixelSearch on an inactive window, retrieves relatives coordinates:
change:

Code: Select all

MsgBox % X . "," . Y
by:

Code: Select all

MsgBox % (X-XStart) . "," . (Y-YStart)
With this, search area rectangle's upper left corner would always be the inactive window's upper left corner, correct?
I only need to (/have to) search a smaller area from somewhere near the middle of the window, but I think I know how I'll achieve that easily.
I'll just add however many pixels I need to to the XStart variable you. Should do it, ye?

Thanks!

EDIT: Yup, got it all working now, thanks!
Tobor D
Posts: 10
Joined: 07 Apr 2017, 20:35

Re: Coordinates relative to an inactive window

07 Apr 2017, 21:07

Hi. I spending about 4 days to find something that whould help me to get coordinates from PixelSearch on inactive window.
I tried this GDI+ http://www.autohotkey.net/~tic/Gdip.ahk but there nothing about searching for specific pixels coords.
Also there is one Display.ahk https://autohotkey.com/board/topic/2267 ... ure/page-2 with function Display_PixelSearch but it return not a coords of a pixel but "Returns true if the specified color/variation is found within the given area, false otherwise."
And i tried this
A_AhkUser wrote:

Code: Select all

CoordMode, Pixel, Screen
YourRectangle := {"width": 400, "height": 300} ; for exemple
WinGetPos, XStart, YStart,,, TitleOfYourInactiveWindow
PixelSearch, X, Y, % XStart, % YStart, % (XStart + YourRectangle.width), % (YStart + YourRectangle.height), YourColorID
MsgBox % X . "," . Y
I cant imagine how this may supose to work on inactive window. It defenently dosen`t work for me. :(

Return to “Ask For Help”

Who is online

Users browsing this forum: No registered users and 114 guests