focus after close

Get help with using AutoHotkey and its commands and hotkeys
matiaan
Posts: 2
Joined: 20 Jun 2018, 10:03

focus after close

20 Jun 2018, 10:23

Often after closing a window focus goes to the taskbar
I'd like to create a script that
1) will close the current window
2) if focus went to the taskbar, move it to the currently top window
3) if there are only minimized windows left, restore one of them and move the focus to that one

my problem is with #2.
a) how do you get if focus is on the taskbar (or desktop)?
b) how can you get the currently top window (esp if it does not have focus)?

if somebody can please guide me in the right direction
Qysh
Posts: 143
Joined: 24 Apr 2018, 09:16

Re: focus after close

20 Jun 2018, 12:39

I'm not sure if this works but try : IfWinActive, ahk_class Shell_TrayWnd
matiaan
Posts: 2
Joined: 20 Jun 2018, 10:03

Re: focus after close

21 Jun 2018, 09:54

Hey that worked, thanks.
I realized I can press alt+tab to move focus to the top window when the taskbar is active
my final script (took a bit of hacking to get the timing right for alt+tab):

Code: Select all

CapsLock & W::
  send !{F4}
  sleep 100
  IfWinActive, ahk_class Shell_TrayWnd
  {
    send !{tab down}
    sleep 100
    send {tab up}
  }
  return

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], return and 39 guests