Jump to content

Having a hard ol' time


jebus495
 Share

Recommended Posts

Here's my problem.

ControlGetPos()

Returns an array containing the size and the control's position relative to it's client window

_WinAPI_ClientToScreen()

It then replaces the screen coordinates with the client coordinates.

_WinAPI_ScreenToClient()

It replaces the screen coordinates with the client coordinates.

WinGetPos()

Returns screen coords.

My problem is that I need to position a control so that is universally centered regardless of the computer. (Or at least in the same position.) I can't for the life of me figure out how to (with the functions above) do it.

#include <ie.au3>

$oIE = _IECreate()
_IENavigate($oIE, "http://www.addictinggames.com/kittencannon.html")
_IELoadWait($oIE)
Sleep(1000)
Do
    $oObj = _IEGetObjById($oIE, "FlashContent")
    Sleep(500)
Until IsObj($oObj)

;Need some positioning magic here. Or at least a point to the direction I should be heading. Thank you.

While 1
    Sleep(200)
WEnd

Is there an easy way I haven't been able to think of for positioning the control (the game)?

How would I got about moving the top left corner of the control to the top left of the screen?

Edited by jebus495
Link to comment
Share on other sites

If you embed it in a GUI window then yes and it's easy because you know the control position and size. If it's by automating the Internet Explorer browser you need to check the window is not maximized, resize the window as you see fits and then calculate the window position by x = @DesktopWidth/2-$IEWidth/2, same for the height. The embedded flash object is another story, you need to scroll the IE window by the document size to the flash object's position. Probably each element in the page has client position properties relative to the document window, you can use them. DHTML Objects

Link to comment
Share on other sites

If you embed it in a GUI window then yes and it's easy because you know the control position and size. If it's by automating the Internet Explorer browser you need to check the window is not maximized, resize the window as you see fits and then calculate the window position by x = @DesktopWidth/2-$IEWidth/2, same for the height. The embedded flash object is another story, you need to scroll the IE window by the document size to the flash object's position. Probably each element in the page has client position properties relative to the document window, you can use them. DHTML Objects

Now I remember the last problem I had. The real reason for posting this thread. PixelGetColor only accepts screen coords and I need to read the color of a pixel on a control on the exact same spot on multiple computers.

I've gotten around this before with an extremely clunky workaround involving using a separate script to align and position a browser saving the offsets for further use. That method is pretty ugly and prone to error which is why I'm looking to eliminate the need for such crazyness. I can use ControlSend and ControlClick for most of it but I still need to use PixelGetColor, PixelSearch and PixelCheckSum which require screen coordinates.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...