Sign in to follow this  
Followers 0
Andreik

_WinAPI_PtInRect

6 posts in this topic

I don't see anything wrong in this code but the result is not what I expect. I am doing something wrong?

#include <WinAPI.au3>

Global $GUI = GUICreate("Example")
GUISetState(@SW_SHOW,$GUI)

While True
    If GUIGetMsg() = -3 Then Exit
    Check()
    Sleep(10)
WEnd

Func Check()
    Local $rect = _WinAPI_GetWindowRect($GUI)
    Local $point = DllStructCreate($tagPOINT)
    DllStructSetData($point,"X",MouseGetPos(0))
    DllStructSetData($point,"Y",MouseGetPos(1))
    $result = _WinAPI_PtInRect($rect,$point)
    TrayTip("","Mouse over GUI: " & $result,1)
EndFunc

When the words fail... music speaks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You are not doing anything wrong. This is bug on our side.

This is one of the reasons "struct" data type is introduced to the language. Will be fixed.

Use this in the meantime (and one of latest betas):

Func _WinAPI_PtInRect(ByRef $tRect, ByRef $tPoint)
    Local $aResult = DllCall("user32.dll", "bool", "PtInRect", "struct*", $tRect, "struct", $tPoint)
    If @error Then Return SetError(1, 0, False)
    Return $aResult[0]
EndFunc
Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thank you! Actually I`m not interested in use of this code but I start writing an AutoIt tutorial in romanian language and I tried to make an example using this function.

EDIT:

btw I never noticed "struct" as data type for DllCall, I got @error=1 if I change this with "ptr" I don't get any error but the result is all time false.

Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites

EDIT:

btw I never noticed "struct" as data type for DllCall, I got @error=1 if I change this with "ptr" I don't get any error but the result is all time false.

She told you to use the beta for a reason. "struct" type was added in 3.3.7.20

Share this post


Link to post
Share on other sites

You could also modify trancexx's function above to this for the current production version (added 1 more underscore to name):

Func __WinAPI_PtInRect(ByRef $tRect, ByRef $tPoint)
    Local $iPt = DllStructGetData(DllStructCreate('uint64',DllStructGetPtr($tPoint)),1)
    Local $aResult = DllCall("user32.dll", "bool", "PtInRect", "ptr", DllStructGetPtr($tRect), "uint64", $iPt)
    If @error Then Return SetError(1, 0, False)
    Return $aResult[0]
EndFunc

Share this post


Link to post
Share on other sites

Sorry I have just 3.3.7.19, I go for update now. :D


When the words fail... music speaks

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