Author Topic: Get screen position of a control handle returned by RoboScripter  (Read 124 times)

cssyphus

  • Newbie
  • *
  • Posts: 30
Get screen position of a control handle returned by RoboScripter
« 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:

Code: [Select]
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

td

  • Tech Support
  • *****
  • Posts: 3210
    • WinBatch
Re: Get screen position of a control handle returned by RoboScripter
« Reply #1 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
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

snowsnowsnow

  • Sr. Member
  • ****
  • Posts: 302
Re: Get screen position of a control handle returned by RoboScripter
« Reply #2 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...)

td

  • Tech Support
  • *****
  • Posts: 3210
    • WinBatch
Re: Get screen position of a control handle returned by RoboScripter
« Reply #3 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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

cssyphus

  • Newbie
  • *
  • Posts: 30
Re: Get screen position of a control handle returned by RoboScripter
« Reply #4 on: February 05, 2020, 09:03:33 am »
Many thanks