Sign in to follow this  
Followers 0
Helomotorola

How does get Windows Infomation underneath the mouse pointer?

12 posts in this topic

#1 ·  Posted (edited)

"Autoit windows Info" Programme can get many windows Info, I don't know how it does?

Please help me get windows Title, Instance Control, Style, ExStyle info

Thank!

Edited by Helomotorola

Share this post


Link to post
Share on other sites



I know WIN* functions, but I want get info underneath the mouse pointer?

In "Autoit windows Info" Programme get Instance Control. Ex: button1, button2.

Share this post


Link to post
Share on other sites

I know WIN* functions, but I want get info underneath the mouse pointer?

In "Autoit windows Info" Programme get Instance Control. Ex: button1, button2.

Not sure this is what you want but search for childwindowfrompoint


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Thanks, you can help me get get info underneath the mouse pointer.

button1, button2.. not "buton"

Windows Title ==> Windows underneath the mouse pointer

Thank you!

Share this post


Link to post
Share on other sites

Thanks, you can help me get get info underneath the mouse pointer.

button1, button2.. not "buton"

Windows Title ==> Windows underneath the mouse pointer

Thank you!

Given that the window under the mouse pointer might not be top of the Z-order (active), you have a couple options:

1. Search the forum for a couple of function posted by SmOke_N that give window and control info under the mouse pointer.

2. Code something yourself that runs WinList() then loops through the list checking each window for coordinates and size containing the mouse location.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thank

Share this post


Link to post
Share on other sites

Given that the window under the mouse pointer might not be top of the Z-order (active), you have a couple options:

1. Search the forum for a couple of function posted by SmOke_N that give window and control info under the mouse pointer.

2. Code something yourself that runs WinList() then loops through the list checking each window for coordinates and size containing the mouse location.

:)

I have been searching for a solution of the same (or similar) problem.

ad 1) I searched and found some functions that only give that information

of an active window but not of a window under mouse (non active).

One function gives the info from the active window regardless the mouse

pointer position.

Another one (with tooltips) retrieves "blanc" outside an active window

ad 2) It's not possible to base it on window position and size on the screen because

they may be two or more wins overlayed (for ex: explorer)

I need it for (drag and) dropping an item (file) on a window explorer window

(or another exporer)

The Window Info Tools gives the info from any window on the screen (active and

non active)

Thanks

Share this post


Link to post
Share on other sites

I have been searching for a solution of the same (or similar) problem.

ad 1) I searched and found some functions that only give that information

of an active window but not of a window under mouse (non active).

One function gives the info from the active window regardless the mouse

pointer position.

Another one (with tooltips) retrieves "blanc" outside an active window

ad 2) It's not possible to base it on window position and size on the screen because

they may be two or more wins overlayed (for ex: explorer)

I need it for (drag and) dropping an item (file) on a window explorer window

(or another exporer)

The Window Info Tools gives the info from any window on the screen (active and

non active)

Thanks

MouseGetPos

Then

http://msdn2.microsoft.com/en-us/library/ms633558.aspx

Then

http://msdn2.microsoft.com/en-us/library/ms632676.aspx

Should do what you are looking for.


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.

Share this post


Link to post
Share on other sites

Thank you SmOke_N for your suggestion

I read msdn and I see now that a non active window

is considered a child window

Ok I will try it out

Share this post


Link to post
Share on other sites

Have It! :)

The only obstacle was not to remember that WinList() retreaves the windows

"in order" (visibles: first the active window, then the win "under" it, .........)

PsaltyDS, you were right, naturely

This script gets a control of a window in the screen (also inactive) - like AutoIt Windows Info Tool does

It contains _MouseGetCtrlInfo() ----- slightly adapted function made by: SmOke_N ?

ClientToScreen($hWnd) ---- made by smashly

#include <misc.au3>
#include <Array.au3>
HotKeySet('{ESC}', '_Exit')

Global $WinText, $OldMouse[2], $NewMouse[2], $Windows, $x, $MyWin, $MyCoords

While 1
    $NewMouse = MouseGetPos()
    If $NewMouse[0] <> $OldMouse[0] Or $NewMouse[1] <> $OldMouse[1] Then ToolTip(_GetWin())
    Sleep(100)
WEnd

Func _GetWin()
    Local $Coords
    ToolTip("")
    $Mouse = MouseGetPos()
    $OldMouse = $Mouse
    $Windows = _WinList()
    ;_ArrayDisplay($Windows, "")
    For $x = 1 To UBound($Windows)-1
        $Coords = WinGetPos($Windows[$x][0], "")
        If $Coords = -4 Then ExitLoop
        If IsArray($Coords) Then
            If $Mouse[0] >= $Coords[0] And $Mouse[0] <= ($Coords[0]+$Coords[2]) And $Mouse[1] >= $Coords[1] And $Mouse[1] <= ($Coords[1]+$Coords[3]) Then ExitLoop
        EndIf   
    Next
    If $x = UBound($Windows) Then $x -= 1
    $MyWin =  $Windows[$x][0]
    $Control = _MouseGetCtrlInfo()
    $Return = $Windows[$x][0] & @CRLF & $Control 
    Return $Return
EndFunc 

Func _WinList()
    Local $WinListArray[1][2]
    $var = WinList()
    For $i = 1 to $var[0][0]
        If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
            Redim $WinListArray[UBound($WinListArray) + 1][2]
            $WinListArray[UBound($WinListArray)-1][0] = $var[$i][0]
            $WinListArray[UBound($WinListArray)-1][1] = $var[$i][1]
        EndIf
    Next
    Return $WinListArray
EndFunc

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf
EndFunc

Func _Exit()
    Exit
EndFunc 

Func _MouseGetCtrlInfo()  ; get ID, Classe and Text of a control
    Global $hWin = WinGetHandle($MyWin)
    Global $sClassList = WinGetClassList($hWin)
    Local $sSplitClass = StringSplit(StringTrimRight($sClassList, 1), @LF)
    Local $aMPos = MouseGetPos()
    ;_ArrayDisplay($sSplitClass, "")
    $MyCoords = ClientToScreen($hWin)
    For $iCount = UBound($sSplitClass) - 1 To 1 Step - 1
        Local $nCount = 0
        If $sSplitClass[$iCount] = "WorkerW" Then ContinueLoop
        While 1
            $nCount += 1
            $aCPos = ControlGetPos($hWin, '', $sSplitClass[$iCount] & $nCount)
            If @error Then ExitLoop
            $hCtrlWnd = ControlGetHandle ($hWin, "", $sSplitClass[$iCount] & $nCount)
            If IsArray($aCPos) Then
                If $aMPos[0] >= ($MyCoords[0]+$aCPos[0]) And $aMPos[0] <= ($MyCoords[0]+$aCPos[0] + $aCPos[2]) _
                    And $aMPos[1] >= ($MyCoords[1]+$aCPos[1]) And $aMPos[1] <= ($MyCoords[1]+$aCPos[1] + $aCPos[3]) Then
                    $aReturn = DllCall('User32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hCtrlWnd)
                    If @error Then Return "Err"
                    $Text = ControlGetText($hWin, '', $sSplitClass[$iCount] & $nCount)
                    If StringInStr($Text, @LF) Then $Text = "demasiado largo"
                    If IsArray($aReturn) Then Return 'ControlID: ' & $aReturn[0] & @CRLF & 'ClassNameNN: ' & $sSplitClass[$iCount] & $nCount &  @CRLF & "Text: " & $Text
                EndIf       
            EndIf
        WEnd
    Next
    ;_ArrayDisplay($sSplitClass, "")
    Return "No Ctrl"
EndFunc

Func ClientToScreen($hWnd)    ; get client area of a win relative to the screan
    Local $Point, $aRes[2]
    Local $cX, $cY
    $Point = DllStructCreate("int;int")
    DllStructSetData($Point, 1, $cX)
    DllStructSetData($Point, 1, $cY)
    DllCall("User32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($Point))
    $aRes[0] = DllStructGetData($Point, 1)
    $aRes[1] = DllStructGetData($Point, 2)
    Return $aRes
EndFunc

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