Pixel Coordinates on a scrollable page

Windows specific forum
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Pixel Coordinates on a scrollable page

Post by IdeasVacuum »

Desktop coordinates are easy with PB:

Code: Select all

        If OpenWindow(0,0,0,90,0,"", #PB_Window_SystemMenu | #PB_Window_Tool)

                 StickyWindow(0, #True)

                 Define iEvent.i

                 Repeat
                        iEvent = WaitWindowEvent(1)

                            SetWindowTitle(0, "X" + Str(DesktopMouseX()) + ", Y" + Str(DesktopMouseY()))

                 Until iEvent = #PB_Event_CloseWindow
        EndIf
End
Alternatively, Windows API GetCursorPos_() is good (just found that PB does not 'know' GetPhysicalCursorPos(), surprising).

However, what I'm looking to do is the seemly impossible. Let's say we want to know the pixel position of an image displayed in MS Word for example. If the Word Doc fits within the screen at scale 100%, all is well, but if the page has to be scrolled......?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Julian
Enthusiast
Enthusiast
Posts: 276
Joined: Tue May 24, 2011 1:36 pm

Re: Pixel Coordinates on a scrollable page

Post by Julian »

There's so many factors to take into consideration here I'd think it would be almost impossible to get it 100% right.

My first though would be to check the scroll position of the scrollbar on the word window then offset that verses the mouse position, but you'd need to take into account so many factors like window size, size of MDI inside the window and even what viewing mode the document was in that it would be very rare that you'd get the correct answer.

Personally I'd think this was bordering on impossible unless there's some script access internally for word that provides these coordinates that you could somehow hook into.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Pixel Coordinates on a scrollable page

Post by IdeasVacuum »

Yeah, and it's not specifically Word either - could be any similar application. I have found that in some you can verify the gadget that is a 'page' and then you can verify the size of that gadget, but if a full-size page requires scrolling, you need to know what the scroll value is and that's not easy.

Rashad has some handy code that can take a snapshot of the whole page, auto-scrolling in the process. That seems the way to go, because the image can be loaded and then of course all variables are known.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply