Sign in to follow this  
Followers 0
Helomotorola

WindowFromPoint no active

6 posts in this topic

#1 ·  Posted (edited)

While 1
    Sleep (1)
    $hwnd = WindowFromPoint(Point())
    ToolTip($hwnd, 0, 0)
WEnd

Func Point()
    $pos = MouseGetPos()
    $str        = "int var1;ubyte var2;uint var3;char var4[128]"
    $a        = DllStructCreate($str)
    if @error Then
        MsgBox(0,"","Error in DllStructCreate " & @error);
        exit
    endif
    DllStructSetData($a,"X",$pos[0])
    DllStructSetData($a,"Y",$pos[1])
EndFunc

Func WindowFromPoint($tPoint)
  Local $iX, $iY, $aResult
  $iX     = DllStructGetData($tPoint, "X")
  $iY     = DllStructGetData($tPoint, "Y")
  $aResult = DllCall("User32.dll", "hwnd", "WindowFromPoint", "int", $iX, "int", $iY)
  Return $aResult[0]
EndFunc

Thank

Edited by Helomotorola

Share this post


Link to post
Share on other sites



I am very unclear about what your question is?

Share this post


Link to post
Share on other sites

We've been here before...

Why are you putting the X/Y values in a struct, when you don't use it for the call to WindowFromPoint?

Drop the struct if you aren't going to use it:

HotKeySet("{ESC}", "_Quit")

While 1
    Sleep(100)
    ToolTip("")
    $hwnd = WindowFromPoint(MouseGetPos())
    ToolTip($hwnd)
WEnd

Func WindowFromPoint($aPoint)
    $aResult = DllCall("User32.dll", "hwnd", "WindowFromPoint", "int", $aPoint[0], "int", $aPoint[1])
    Return $aResult[0]
EndFunc   ;==>WindowFromPoint

Func _Quit()
    Exit
EndFunc   ;==>_Quit

:)


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

Hix, i want use "DllStructSetData". Please help me

Share this post


Link to post
Share on other sites

Hix, i want use "DllStructSetData". Please help me

What are you even doing with the struct (from your example) that you need one?

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

Hix, i want use "DllStructSetData". Please help me

OK, if it's just an exercise, this works:

HotKeySet("{ESC}", "_Quit")
Global $Struct = DllStructCreate("int x;int y")

While 1
    Sleep(100)
    ToolTip("")
    Pos()
    $hwnd = WindowFromPoint()
    ToolTip($hwnd)
WEnd

Func Pos()
    DllStructSetData($Struct, "x", MouseGetPos(0))
    DllStructSetData($Struct, "y", MouseGetPos(1))
EndFunc   ;==>Pos

Func WindowFromPoint()
    Local $x = DllStructGetData($Struct, "X")
    Local $y = DllStructGetData($Struct, "Y")
    Local $aResult = DllCall("User32.dll", "hwnd", "WindowFromPoint", "int", $x, "int", $y)
    Return $aResult[0]
EndFunc   ;==>WindowFromPoint

Func _Quit()
    Exit
EndFunc   ;==>_Quit

In your original struct (copied from an unrelated help file script I suspect), you variables were named var1, var2, etc., which is why they don't work when you call them by "X" and "Y".

:)


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

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