Sign in to follow this  
Followers 0
MyEarth

FindWindowByCaption?

5 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yes, really. No MsgBox

Local $aList = WinList("[CLASS:NativeHWNDHost]")
    For $i = 1 To $aList[0][0]
        MsgBox(0, "", "Title: " & $aList[$i][0] & @CRLF & "Handle: " & $aList[$i][1])
    Next
Edited by MyEarth

Share this post


Link to post
Share on other sites

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 ;)

Share this post


Link to post
Share on other sites

FYI, you need to use the "[CLASS...]" syntax for native autoit funcs, that's not the case of _WinAPI_FindWindow.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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