therks Posted December 10, 2019 Share Posted December 10, 2019 WinWait('Task Manager') ConsoleWrite(WinGetTitle('[last]')) WinWaitClose('[last]') Run this, open task manager, close task manager. The ConsoleWrite will print, but the script never closes. But if you change the WinWaitClose to a real title, or a handle it works fine. I don't see this listed in the bug tracker, so I thought I'd ask here if anyone has similar issues before submitting it. Tested with stable (3.3.14.5) and beta (3.3.15.0), Windows 10 v1909. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Musashi Posted December 10, 2019 Share Posted December 10, 2019 1 hour ago, therks said: I don't see this listed in the bug tracker, so I thought I'd ask here if anyone has similar issues before submitting it. Same behavior with Windows 7 and AutoIt 3.3.14.0. WinWaitClose does not accept [Last] (as you wrote), not even [Active] . This works (as you know) : WinWait('Windows Task-Manager') ; my title in german ConsoleWrite("1. WinGetTitle = " & WinGetTitle("[Last]") & @CRLF) WinWaitClose(WinGetTitle("[Last]")) ConsoleWrite("2. CLOSED" & @CRLF) But I don't think that should be considered as a bug. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
therks Posted December 10, 2019 Author Share Posted December 10, 2019 1 hour ago, Musashi said: But I don't think that should be considered as a bug. Why not? It's inconsistent behaviour. If it doesn't get fixed then the next person wondering why it doesn't work will come here wondering why as well. Considering the lack of updates I'm not expecting it to get fixed any time soon, but it should be recorded at least. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Musashi Posted December 10, 2019 Share Posted December 10, 2019 (edited) 4 hours ago, therks said: Why not? It's inconsistent behaviour. [...] Considering the lack of updates I'm not expecting it to get fixed any time soon, but it should be recorded at least. After reconsideration, I have come to the conclusion that you are right. E.g. WinExists reports true even if the window has already been closed. Here is a little script to play around with : expandcollapse popupHotKeySet("{ESC}", "_Terminate") Local $iCount = 0 WinWait('Windows Task-Manager') ; title in german (==> use titel in your language instead, e.g. 'Task Manager') ConsoleWrite("> >>>> WinGetTitle = " & WinGetTitle("[LAST]") & @CRLF) ; just a check : "[LAST]" with WinExists If WinExists("[LAST]") Then ConsoleWrite("> >>>> WinExists = TRUE" & @CRLF) Else ConsoleWrite("! >>>> WinExists = FALSE" & @CRLF) EndIf ; just a check : "[LAST]" with WinActive If WinActive("[LAST]") Then ConsoleWrite("> >>>> WinActive = TRUE" & @CRLF) Else ConsoleWrite("! >>>> WinActive = FALSE" & @CRLF) EndIf ; =========================================================== ; Remove the comment for the desired area : ; =========================================================== ; Variation 1 : WinWaitClose ;~ WinWaitClose("[LAST]") ; <=== waits endlessly ;~ WinWaitClose(WinGetTitle("[LAST]")) ; <=== works ; Variation 2 : WinClose <=== works ;~ Sleep(2000) ;~ WinClose("[LAST]") ; Variation 3 : While WinExists <=== runs endlessly While WinExists("[LAST]") ConsoleWrite("> >>>> While WinExists -> " & $iCount & @CRLF) $iCount += 1 Sleep(250) WEnd ; Final message : ConsoleWrite("> >>>> CLOSED" & @CRLF) Func _Terminate() ConsoleWrite("! >>>> TERMINATED by ESC" & @CRLF) Exit EndFunc ;==>_Terminate Edited December 10, 2019 by Musashi typo therks 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
therks Posted December 10, 2019 Author Share Posted December 10, 2019 Wow, yeah that is interesting. I wonder what the [LAST] keyword is doing internally. I assumed that when AutoIt did title matching it was just saving the handle from the most recent title match, and swapping that in whenever it encountered the [LAST] keyword, but I just tried this: $iCount = 0 HotKeySet('{ESC}', '_Exit') WinWait('[CLASS:TaskManagerWindow]') ; Let's use the classname so we don't have to translate each time ;) Do $iCount += 1 ConsoleWrite($iCount & ') =============================================' & @CRLF) ConsoleWrite('WinGetHandle: ' & WinGetHandle('[last]') & @CRLF) ; Always returns a valid handle ConsoleWrite('WinExists: ' & WinExists('[last]') & @CRLF) ; Always returns 1 ConsoleWrite('WinGetHandle(WinGetHandle): ' & WinGetHandle(WinGetHandle('[last]')) & @CRLF) ; Properly returns 0 ConsoleWrite('WinExists(WinGetHandle): ' & WinExists(WinGetHandle('[last]')) & @CRLF) ; Properly returns 0 Until WinWaitClose('[last]', '', 1) ;Until WinWaitClose(WinGetHandle('[last]'), '', 1) ; <- This line will detect properly Func _Exit() Exit EndFunc And as you'll see, WinGetHandle on [LAST] will give the same handle even after the window is closed, but WinGetHandle ON that handle, will return 0. So if it were a simple swap of [LAST] for an HWND, then the first WinGetHandle would also return 0. Maybe someone in the know can weigh in and explain what's happening with [LAST] behind the scenes. Musashi 1 My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Musashi Posted December 10, 2019 Share Posted December 10, 2019 18 minutes ago, therks said: So if it were a simple swap of [LAST] for an HWND, then the first WinGetHandle would also return 0. Maybe someone in the know can weigh in and explain what's happening with [LAST] behind the scenes. Yes, I can confirm the process flow that you described. I also expected [LAST] to be converted / swapped internally into a handle. We really need somebody who has a deeper insight into the processes in the background 😛. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
therks Posted December 10, 2019 Author Share Posted December 10, 2019 Bug report submitted: https://www.autoitscript.com/trac/autoit/ticket/3743#ticket My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Administrators Jon Posted May 13, 2020 Administrators Share Posted May 13, 2020 [last] does indeed store the handle of the last window. All the Win... functions setup the search the same way so can't see why this wouldn't be working. therks 1 Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
therks Posted May 25, 2020 Author Share Posted May 25, 2020 (edited) Hi Jon, just to confirm: You're saying it doesn't make sense that it would behave that way, but are you seeing the same results with our test scripts? Edited May 26, 2020 by therks Better wording My AutoIt Stuff | My Github 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