Jump to content

Recommended Posts

Posted

Hello,

I got some troubles using ControlDisable and ControlEnable.

I found a script on the Internet to determine the Windows and Control Handle which is located under your mouse cursor. I modified the Function "enable" to initially disable all the Controls in the dialog whether to save or not save the changes done to a text document which works fine for me. I changed the function ControlDisable to ControlEnable and ran the script again to manually re-enable the initially disabled controls... but nothing happens at all! The Control Handle changed from 0x0033079A to 0x0020040C in the process when i check it in the tray tip but the autoit window info tool still shows the correct Control Handle which was originally used to disable the control. I can also use the manually entered (old) Control Handle to re-enable the control so the script detecting the Control Handle seems to be broken :(

Could you please tell me where the bug is hidden so I can make it run as intended?

#include <WinAPI.au3>
#include <Misc.au3>
 hotkeyset("{F1}", "enable")

Func _WindowFromPoint($iX,$iY)
    Local $stInt64,$aRet,$stPoint=DllStructCreate("long;long")
    DllStructSetData($stPoint,1,$iX)
    DllStructSetData($stPoint,2,$iY)
    $stInt64=DllStructCreate("int64",DllStructGetPtr($stPoint))
    $aRet=DllCall("user32.dll","hwnd","WindowFromPoint","int64",DllStructGetData($stInt64,1))
    If @error Then Return SetError(2,@error,0)
    If $aRet[0]=0 Then Return SetError(3,0,0)
    Return $aRet[0]
EndFunc

Local $hControl, $hWin, $hOldWin, $aMousePos
$hOldWin = ""
While sleep(100)
WEnd

func enable()
    $aMousePos = MouseGetPos()
    $hControl=_WindowFromPoint($aMousePos[0],$aMousePos[1])
    ; Since _WindowFromPoint() can return 'sub' windows, or control handles, we should seek the owner window
    $hWin=_WinAPI_GetAncestor($hControl,2)
    Controlenable($hWin, "", $hControl)
    traytip("", $hWin&@crlf&$hControl, 1)


EndFunc 

Many Thanks in Advance!

Posted

You can't with WindowFromPoint function:

 

The WindowFromPoint function does not retrieve a handle to a hidden or disabled window, even if the point is within the window. An application should use the ChildWindowFromPoint function for a nonrestrictive search.

Maybe there are other ways like "AutoIt Window Info" does but i dunno

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

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
×
×
  • Create New...