Jump to content

Recommended Posts

Posted

My first post, please forgive any transgressions

Trying to reference windows using the window handle, I think I have the syntax right, and the handle returned matches the spy value, I would be grateful for any advice

    Dim oAuto As Object
    Set oAuto = New AutoItX3
    With oAuto
        While Title = ""
            Hndl = .WinGetHandle(ThisWorkbook.Name)
            Title = .WinGetTitle(Hndl)
            MsgBox (Title)
            MsgBox (.WinGetTitle(ThisWorkbook.Name) & " " & Hndl)
            x = x + 1
        Wend
    End With
End Sub

Posted

Hello. AutoIt COM Object seems to be  partially written so dont expect it works exactly as AutoIt normal Scripts. There are may COM functions that will not work. You would need to do something like this to solve your issue.

Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Function WinGetTitle(ByVal hwnd As String) As String
    Dim MyStr As String
    MyStr = String$(260, vbNullChar)
    GetWindowText CLng("&H" & Mid(hwnd, 3)), MyStr, 260
    MyStr = Left$(MyStr, InStr(MyStr, Chr$(0)) - 1)
    WinGetTitle = MyStr
End Function

Sub Test()
Dim oAuto As Object
    Set oAuto = New AutoItX3
    With oAuto
    'While Title = ""
            Hndl = .WinGetHandle(ThisWorkbook.Name)
            MsgBox (WinGetTitle(Hndl))
    ' Wend
    End With
End Sub

Saludos

Posted

Thank you Danyfirex,

For a while I thought the Internet was ignoring me.

This worked well and I shall restart my efforts to run Autoit from Excel!

 

 

 

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
  • Recently Browsing   0 members

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