Jump to content

FindWindowByCaption?


Go to solution Solved by MyEarth,

Recommended Posts

I have found a script ( probably C++ ) that use this function and i want to convert that to autoit

Well, i can't recreate it, Windows 8 version.

I have try:

WinExist

WinGetHandle

_WinAPI_FindWindow

WinGetTitle

WinList

Nothing, nothing work but the original C++ yes. I can't get the handle. If i use Autoti Spy tool i have the Title, the Class etc. but nothing seems work, WinList don't report that window...

Class:  NativeHWNDHost
Position:   50, 580
Size:   432, 140
Style:  0x96000000
ExStyle:    0x00200088
Handle: 0x00000000000100FC

>>>> Control <<<<
Class:  DirectUIHWND
Instance:   0
ClassnameNN:    DirectUIHWND0
Name:   
Advanced (Class):   [CLASS:DirectUIHWND; INSTANCE:0]
ID: 
Text:   
Position:   0, 0
Size:   432, 140
ControlClick Coords:    317, 71
Style:  0x56000000
ExStyle:    0x00000000
Handle: 0x00000000000100FE

Suggestion?

An example in C++

[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);

IntPtr hWnd = FindWindowByCaption(IntPtr.Zero, "Title Here");
Edited by MyEarth
Link to comment
Share on other sites

Really?

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Retrieve a list of window handles.
    Local $aList = WinList("[CLASS:NativeHWNDHost]")

    ; Loop through the array displaying only visable windows with a title.
    For $i = 1 To $aList[0][0]
        If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then
            MsgBox($MB_SYSTEMMODAL, "", "Title: " & $aList[$i][0] & @CRLF & "Handle: " & $aList[$i][1])
            WinClose($aList[$i][1])
        EndIf
    Next
EndFunc   ;==>Example

Br, FireFox.

Link to comment
Share on other sites

  • Solution

I have resolved with _WinAPI_FindWindow + WinGetTitle in the same line. A note, for the class in FindWindow you don't need to write [CLASS:ETC] but directly the class, that was my error.

Thank you firefox for your help ;)

Link to comment
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
 Share

  • Recently Browsing   0 members

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