The early script did work for me, but the alt esc does not recognize the incremental order if windows are selected out of order from their placement on the taskbar.
For the second script I placed the debug lines on the bottom of the script, but it did not make an error message come out.