WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: cssyphus on February 04, 2020, 08:06:12 AM

Title: Get screen position of a control handle returned by RoboScripter
Post by: cssyphus on February 04, 2020, 08:06:12 AM
I used RoboScripter to get a handle to a window control (a button on an IrfanView dialog).  I wish to somehow get the coords of the button so that I can know how close the mouse is to the button at any given moment.

I've looked at the various cWnd functions and nothing leaps out at me as to how to accomplish this. Anyone have a suggestion or idea?

My code to get the button:


if winExist(`Browse Subfolders~`)
_winIrfanBrowseSubs = cWndByWndSpec(`#32770`,`i_view32`,8,3129,1,2,65535,65535,3131,65535,3064)
_btnIrfanUseFolder = cWndByID(_winIrfanBrowseSubs, 1)
;;;_btnCoords = HOW_DO_I_DO_THIS?
endif

Title: Re: Get screen position of a control handle returned by RoboScripter
Post by: td on February 04, 2020, 01:04:34 PM
Search on the term "getwindowrect" in the Tech Database.  "GetWindowRect" is a Win32 API function the returns the window rectangle and there are numerous examples.  The results are in screen Pixels so you may need to convert them into virtual coordinates depending on your intended purpose.


But one example:
https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Window~Manipulation+Active~Window~Height~and~Width~in~Pixels.txt (https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Window~Manipulation+Active~Window~Height~and~Width~in~Pixels.txt)
Title: Re: Get screen position of a control handle returned by RoboScripter
Post by: snowsnowsnow on February 05, 2020, 02:33:50 AM
This looks a lot like this thread that I started a while back:

https://forum.winbatch.com/index.php?topic=2273.msg11869#msg11869

"td" gave a nice solution in that thread that worked very well for me (even though he said it was just a rough first draft...)
Title: Re: Get screen position of a control handle returned by RoboScripter
Post by: td on February 05, 2020, 07:11:59 AM
Forgot all about that one... Probably need to add that bit of script to the Tech Database.
Title: Re: Get screen position of a control handle returned by RoboScripter
Post by: cssyphus on February 05, 2020, 09:03:33 AM
Many thanks