RataVa Posted August 12, 2017 Share Posted August 12, 2017 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 Link to comment Share on other sites More sharing options...
RataVa Posted August 12, 2017 Author Share Posted August 12, 2017 Oh dear, first post and I didn't really say what was wrong! The line Title = .WinGetTitle(Hndl) Never returns a value Link to comment Share on other sites More sharing options...
Danyfirex Posted August 14, 2017 Share Posted August 14, 2017 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 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
RataVa Posted August 15, 2017 Author Share Posted August 15, 2017 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! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now