Jump to content

Dynamically Display Window Info?


 Share

Recommended Posts

This seems like it would be a real popular tool for automation but a search (and the FAQ) didn't reveal anything (or I used the wrong search terms).

I'm looking for a scriptlet that will run (on top) and display window information for the active window. My initial need is to map cursor x,y positions but it seems that a lot of good information could be returned relatively quickly.

I know it can be done because I'm working with those functions now, but I thought if someone had one made already it would save me some time.

Link to comment
Share on other sites

This seems like it would be a real popular tool for automation but a search (and the FAQ) didn't reveal anything (or I used the wrong search terms).

I'm looking for a scriptlet that will run (on top) and display window information for the active window. My initial need is to map cursor x,y positions but it seems that a lot of good information could be returned relatively quickly.

I know it can be done because I'm working with those functions now, but I thought if someone had one made already it would save me some time.

wouldn't it be alot easyer to use the autoitinfo?

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Link to comment
Share on other sites

#include <GUIConstants.au3>

GUICreate("", 100, 50)
GUISetState ()

GuiCtrlCreateLabel("Mouse X - ", 5, 5)
GuiCtrlCreateLabel("Mouse Y - ", 5, 20)
$x = GuiCtrlCreateLabel(MouseGetPos(0), 55, 5, 50, 15)
$y = GuiCtrlCreateLabel(MouseGetPos(1), 55, 20, 50, 15)

$x_pos1 = MouseGetPos(0)
$y_pos1 = MouseGetPos(1)

While 1
    $msg = GUIGetMsg()
Global $x
Global $y
Global $x_pos1
Global $x_pos2
$x_pos = MouseGetPos(0)
$y_pos = MouseGetPos(1)

    If $x_pos <> $x_pos1 Then
    GuiCtrlSetData($x, MouseGetPos(0))
    $x_pos1 = MouseGetPos(0)
    EndIf

    If $y_pos <> $y_pos1 Then
    GuiCtrlSetData($y, MouseGetPos(1))
    $y_pos1 = MouseGetPos(1)
    EndIf

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Tested! :)

Link to comment
Share on other sites

wouldn't it be alot easyer to use the autoitinfo?

Why yes it would. Now if it gave me the x,y of the inside of the window (working area as opposed to referenced from the frame perimeter) it would be perfect. I didn't even know what that was, thanks for pointing it out.

Tested! :)

Pretty close Dido ... that's only returning the x,y of the screen position though, not of the active window. Thanks for the code though, seeing how someone else does things is always time well spent. There's more than a few ways to skin a cat. :-)
Link to comment
Share on other sites

Now if it gave me the x,y of the inside of the window (working area as opposed to referenced from the frame perimeter) it would be perfect.

It can.

Options > Coord Mode > Screen/Window/Client

"be smart, drink your wine"

Link to comment
Share on other sites

Okay I got the immediate info that I needed from the "AutoIt Window Info" applet so I'm past that part. it gave me an idea to incorporate some feedback/setup in my script along the lines of what Didonet posted. That script reported the position on the screen however what I needed was the position relative to the active window, and I also needed it to stay on top.

I changed the second line from "GUICreate("", 100, 50)" to "GUICreate("", 100, 50, -1, -1, -1, $WS_EX_TOPMOST)" which does exactly what I want it to as far as staying on top. What I'm lacking is the ability to return the x,y of the active window instead of the screen. I thought switching the calls to "MouseGetPos()" to "GUIGetCursorInfo()" but I think I'm doing something wrong.

Any tips?

EDIT: I thought a new thread might be more noticeable so I re-posted in this thread.

Edited by Lee Bussy
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...