Jump to content

Recommended Posts

Posted (edited)

From Autoit Help file:

"GUIGetCursorInfo ( [winhandle] )

..

$array[4] = ID of the control that the cursor is hovering over (or 0 if none)

..

The mouse cursor position is successfull only on an active window created by a GUICreate."

Autoit info tool can retrive any control ID of Control Under Mouse..

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Size: X: 0 Y: 90 W: 760 H: 362

Control ID: 11

ClassNameNN: SysListView321

Text:

Style: 0x54A00249

ExStyle: 0x00000200

My prog cannot.Can anyone helps me? To do the same thing without Using the Autoit Info tool?

(retrieve the ControlID of the control Under Mouse)

Edited by Amen
  • 4 weeks later...
Posted

I really wanted to know it too. I think it's something with the WinAPI functions:

GetCursorPos

WindowFromPoint

ChildWindowFromPoint

While 1
$p = DllStructCreate("int;int")
$pet = DllCall("user32.dll", "int", "GetCursorPos", "ptr", DllStructGetPtr($p))
$set = DllCall("user32.dll", "int", "WindowFromPoint", "int", DllStructGetData($p,1),"int",DllStructGetData($p,1))
;$set = DllCall("user32.dll", "int", "ChildWindowFromPoint", "hwnd", $WinNow, "int", DllStructGetData($p,1),"int",DllStructGetData($p,1))
TrayTip("", $set[0], 5, 16)

Sleep(1)
WEnd

Hope you will find it out :)

Posted

From Autoit Help file:

"GUIGetCursorInfo ( [winhandle] )

..

$array[4] = ID of the control that the cursor is hovering over (or 0 if none)

..

The mouse cursor position is successfull only on an active window created by a GUICreate."

Autoit info tool can retrive any control ID of Control Under Mouse..

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Size: X: 0 Y: 90 W: 760 H: 362

Control ID: 11

ClassNameNN: SysListView321

Text:

Style: 0x54A00249

ExStyle: 0x00000200

My prog cannot.Can anyone helps me? To do the same thing without Using the Autoit Info tool?

(retrieve the ControlID of the control Under Mouse)

Truthfully, I don't know what you are asking, but maybe this will help.

FindClasses by Text

Posted (edited)

$prevhwnd = 0
$hwnd = WindowFromPoint()
While 1
    If $prevhwnd <> $hwnd And $hwnd <> 0 Then
        $WinNow = WinGetHandle(WinGetTitle(""))
        DllCall("user32.dll","int","InvalidateRect","hwnd",$WinNow,"int",0,"int",1)
        OutlineControl($hwnd,$WinNow)
        $prevhwnd = $hwnd
    EndIf
    Sleep(1)
    $hwnd = WindowFromPoint()
WEnd

Func WindowFromPoint()
    $p = DllStructCreate("int;int")
    DllCall("user32.dll", "int", "GetCursorPos", "ptr", DllStructGetPtr($p))
    Local $point1 = DllStructGetData($p,1), $point2 = DllStructGetData($p,2)
    $hwnd = DLLCall("user32.dll", "hwnd", "WindowFromPoint", "int", $point1, "int", $point2)
    If $hwnd[0] <> 0 Then
        $pos = WinGetPos($hwnd[0])
        If @error Then Return 0
        $size = WinGetClientSize($hwnd[0])
        If @error Then Return 0
        $pos[0] += (($pos[2] - $size[0]) / 2)
        $pos[1] += (($pos[3] - $size[1]) - (($pos[2] - $size[0]) / 2))
        $cHwnd = DLLCall("user32.dll","hwnd","ChildWindowFromPoint","hwnd",$hwnd[0], _
                    "int",$point1 - $pos[0],"int",$point2 - $pos[1])
        If $cHwnd[0] <> 0 Then $hwnd[0] = $cHwnd[0]
    EndIf
    Return $hwnd[0]
EndFunc

Func OutlineControl($l_hWnd,$l_hWndDad)
  $l_rect = ControlGetPos("","",$l_hWnd)
  $l_hdc = DLLCall("user32.dll","int","GetDC","hwnd",$l_hWndDad)
  DLLCall("gdi32.dll","int","MoveToEx","int",$l_hdc[0],"int",$l_rect[0],"int",$l_rect[1],"int",0)
  DLLCall("gdi32.dll","int","LineTo","int",$l_hdc[0],"int",$l_rect[0] + $l_rect[2],"int",$l_rect[1])
  DLLCall("gdi32.dll","int","LineTo","int",$l_hdc[0],"int",$l_rect[0] + $l_rect[2],"int",$l_rect[1]+$l_rect[3])
  DLLCall("gdi32.dll","int","LineTo","int",$l_hdc[0],"int",$l_rect[0],"int",$l_rect[1]+$l_rect[3])
  DLLCall("gdi32.dll","int","LineTo","int",$l_hdc[0],"int",$l_rect[0],"int",$l_rect[1])
  $l_hdc = DLLCall("user32.dll","int","ReleaseDC","hwnd",$l_hWndDad,"int",$l_hdc[0])
EndFunc

It works now quite nice, only sometimes highlights strange things...

Edited by rysiora
  • 4 years later...

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
  • Recently Browsing   0 members

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