kjpolker Posted August 30, 2019 Posted August 30, 2019 (edited) I am having the hardest time getting a window to activate. When I troubleshoot I get the right title but there appears to be no active window immediately following the WinActivate. WinActivate($hWnd) Send(1) MsgBox(0, "", $hWnd) ;Used to immediately pass on the title to ensure it is correct Using this line I am getting the correct Title as if it were copy and pasted. However the window will not activate, so I used WinGetTitle to check the active window and it is blank as if nothing is active. I am obtaining the Title via: Func checkproc() $winproc = WinGetProcess("[CLASS:Chrome_WidgetWin_1]") Global $hWnd = _GetWinTitleFromProcName($winproc) MsgBox(1, "", "Process ID is: " & $winproc & @CRLF & "Window Title is: " & $hWnd) If $hWnd = "" Then If @Compiled = 1 Then Run( FileGetShortName(@ScriptFullPath)) Else Run( FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) EndIf DllClose($dll) Exit Else Sleep(10) EndIf EndFunc Func _GetWinTitleFromProcName($s_ProcName) $pid = ProcessExists($s_ProcName) $a_list = WinList() For $i = 1 To $a_list[0][0] If $a_list[$i][0] <> "" Then $pid2 = WinGetProcess($a_list[$i][0]) If $pid = $pid2 Then Return $a_list[$i][0] EndIf Next EndFunc ;==>_GetWinTitleFromProcName I'm guessing this can't really even be solved because to my understanding there is no issues with the syntax... I have never had an issue with this. The only clue I can pass on is that WinGetTitle returns a blank value. Edited August 30, 2019 by kjpolker typo
KaFu Posted August 30, 2019 Posted August 30, 2019 The handle you get is most likely the handle of a child window and not the main window. Try to find the parent window with _WinAPI_GetAncestor() and activate that. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
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