3
votes

Really struggling with this.

I need to simply open a windows explorer window at a specified domain, wait until it is active then proceed. This is what I have so far:

#::
{
  WinGet, old_active, ID, A
  Run, explore C:\Users\Nathan\Documents\Test FDA

  loop{
    WinGet, new_active, ID, A
    if(ahk_id %new_active% != ahk_id %old_active%)
    {
      WinMaximize, A
      break
    }
  }
  return
}

EDIT SOLVED ?>>>

DIDNT KNOW WINDOW SPY EXISTED CAME WITH IT :(((

Long time wasted, this simply works.

[::

{

Run explore C:\Users\Nathan\Documents\Test FDA

WinWaitActive Test FDA

WinMaximize A

return

}
2
Just a note, You might want to use WinWait then WinActivate instead. What I found is that if you have something open that demands the foreground, like cmd.exe then the window will never be active by itself.Pykler

2 Answers

2
votes

how about this?:

" F12:: WINDOWEXPLORER: WinWaitActive, Windows Explorer,, 0.01 if ErrorLevel { Goto WINDOWEXPLORER } else { ; SoundBeep 4500, 30 Return } "

0
votes

I think you are looking for the WinWaitActive function. From the documentation:

Waits until the specified window is active

Put it after the line with Run...:

WinWaitActive, WinTitle

You will need to replace WinTitle with the title of the window that comes up after the Run command. There are other options available, such as duration to wait, titles to exclude, etc.

See the documentation for more details.