Sign in to follow this  
Followers 0
Apocalypse

WinGetClientSize Question

5 posts in this topic

I wrote a program in C++ (with AutoItX) that intelligently finds a Minesweeper window, reads it, then takes control of the mouse (with AutoIt's MouseMove and MouseClick) and solves the game. While the program works really well on my computer, it doesn't work on almost any other because all the coordinates and dimensions are relative to the whole window, not just to the client. So, I am trying to rewrite the program to work relative to the window's client area. AutoItX has WinGetClientSizeWidth() and WinGetClientSizeHeight(), but not WinGetClientPosX() and not WinGetClientPosY().

How can I find the X and Y coordinates of the client window?

Share this post


Link to post
Share on other sites



I wrote a program in C++ (with AutoItX) that intelligently finds a Minesweeper window, reads it, then takes control of the mouse (with AutoIt's MouseMove and MouseClick) and solves the game. While the program works really well on my computer, it doesn't work on almost any other because all the coordinates and dimensions are relative to the whole window, not just to the client. So, I am trying to rewrite the program to work relative to the window's client area. AutoItX has WinGetClientSizeWidth() and WinGetClientSizeHeight(), but not WinGetClientPosX() and not WinGetClientPosY().

How can I find the X and Y coordinates of the client window?

Does it have... AutoItSetOption('MouseCoordMode', 2)? (Not real familiar with the dll.) ... If it does, all you need are the client coords, and your done by setting that option ahead of time.

Also, there was a memory hack for that game done by w0uter I believe in the example scripts forum.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Does it have... AutoItSetOption('MouseCoordMode', 2)? (Not real familiar with the dll.) ... If it does, all you need are the client coords, and your done by setting that option ahead of time.

Also, there was a memory hack for that game done by w0uter I believe in the example scripts forum.

There is an AutoItSetOption('MouseCoordMode', 2), but I still have to read in the pixels. AutoItSetOption('PixelCoordMode', 2) doesn't help because I use C++ to read pixels, not AutoIt (C++ is MUCH faster). So, I still need the X and Y of the window's client area.

PS: The goal of the program was to force me to think of algorithms to solve a problem efficiently and to better understand recursion. I could use a memory hack, but that would defeat the purpose.

Share this post


Link to post
Share on other sites

There is an AutoItSetOption('MouseCoordMode', 2), but I still have to read in the pixels. AutoItSetOption('PixelCoordMode', 2) doesn't help because I use C++ to read pixels, not AutoIt (C++ is MUCH faster). So, I still need the X and Y of the window's client area.

PS: The goal of the program was to force me to think of algorithms to solve a problem efficiently and to better understand recursion. I could use a memory hack, but that would defeat the purpose.

So pass the Hwnd to your GetDC function? I am not really understanding the difficulty here I suppose, or maybe you are making it way harder than it needs to be?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

So pass the Hwnd to your GetDC function? I am not really understanding the difficulty here I suppose, or maybe you are making it way harder than it needs to be?

Your right, the GetDC function retrieves a handle to a display device context for the client area of the window. In my original program I got the X and Y position in terms of the window and did everything in terms of absolute screen coordinates.

Share this post


Link to post
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
Sign in to follow this  
Followers 0