Sign in to follow this  
Followers 0
Robbles

Unable to get right handle with WinWaitActive

5 posts in this topic

Hello folks, I have this simple script:

$dialog = WinWaitActive("[CLASS:#32770]", "") ; Notepad Ctrl-O "Open" dialog
ConsoleWrite('Handle: ' & $dialog & @crlf)

I switch over to Notepad.exe and click Ctrl-O. My script immediately returns handle "0x00010220" every single time, which is not the right handle according to Au3Info.exe

Using "Open" instead of "[CLASS:#32770]" works, and returns the proper handle. Anyone know what's going on? I'm a newbie but I'm pretty sure I'm doing everything by the book. I'm _completely_ stumped.

WinXP SP3, AutoIt3 v3.3.6.0

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Welcome Robbles.

$hWnd = _WinWaitOwner('Open', '', 'Untitled - Notepad')
If $hWnd Then
    WinMove($hWnd, '', 10, 10)
EndIf

Func _WinWaitOwner($sTitle, $sText = '', $sOwner = 0, $iTimeOut = 0)

    Local $hWnd, $List, $Ret, $Timer = TimerInit()

    $iTimeOut = Round($iTimeOut * 1000)

    While 1
        $List = WinList($sTitle, $sText)
        If $List[0][0] Then
            If Not $sOwner Then
                $hWnd = $List[1][1]
                ExitLoop
            Else
                $hWnd = WinGetHandle($sOwner)
                If IsHWnd($hWnd) Then
                    For $i = 1 To $List[0][0]
                        $Ret = DllCall('user32.dll', 'hwnd', 'GetWindow', 'hwnd', $List[$i][1], 'uint', 4)
                        If (Not @error) And ($Ret[0] = $hWnd) Then
                            $hWnd = $List[$i][1]
                            ExitLoop 2
                        EndIf
                    Next
                EndIf
            EndIf
        EndIf
        If ($iTimeOut) And (TimerDiff($Timer) > $iTimeOut) Then
            Return 0
        EndIf
        Sleep(10)
    WEnd
    Sleep(Opt('WinWaitDelay'))
    Return $hWnd
EndFunc   ;==>_WinWaitOwner
Edited by Yashied

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I'm sorry, but I have no idea what the purpose of your script is (I'm a newb.)

I am running a little freeware program called Pitaschio that is causing this problem. If I kill the Pitaschio.exe process, AutoIt3 can get Window handles from Class names again.

Is there any way to call a Windows DLL directly to get a window handle based on a Class name? Maybe that will work.

Edited by Robbles

Share this post


Link to post
Share on other sites

Yes. In my sig there is a link ' Control Handle under mouse' which has the functions to do this.

If you have any issues with it, let me know.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks for the reply. I will dig into your code and see if I can make heads or tails of it.

Edited by Robbles

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