user3712978
user3712978

Reputation: 167

Autohotkey: Open windows explorer and wait till active window before proceeding

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

}

Upvotes: 3

Views: 4013

Answers (2)

Raf431
Raf431

Reputation: 21

how about this?:

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

Upvotes: 2

savanto
savanto

Reputation: 4550

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.

Upvotes: 0

Related Questions