tariibaba / WinENFET

Make Win + E hotkey open a new File Explorer tab instead of a new window
GNU General Public License v3.0
77 stars 4 forks source link

Autohotkey v2 translation #6

Open shtirlitsDva opened 1 year ago

shtirlitsDva commented 1 year ago
The same but in AHKv2 syntax.

#e::FocusFileExplorer()

FocusFileExplorer() {
   ids := WinGetList("ahk_class CabinetWClass")
   if (ids.Length != 0) {
      for id in ids {
         WinActivate(id)
         win := WinWaitActive(id,, 2)
         if (win) {
            Send "^t"
            break
         }
      }
   }
   else {
      Run("explorer")
   }
}
tariibaba commented 1 year ago

Alright!

Please make a pull request so the changes can be merged easily into the codebase 😃

shtirlitsDva commented 1 year ago

Well, I posted this not to change your code, but rather for those who were looking for a v2 implementation of your script.

elpocoburrito commented 1 year ago

Man Ahk V2 is clean, I must look into converting my scripts and learning it, love the syntax being less VBA-like...

corvus2606 commented 1 year ago

couldn't this be simplified to:

#e:: OpenExplorer()

OpenExplorer() {
   if WinExist("ahk_class CabinetWClass")
      {
         WinActivate
         WinWaitActive "ahk_class CabinetWClass"
         send "^t"
      }
   else
      run "explorer.exe"
}