Open 2 File Explorer windows side by side

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
w_i_k_i_d
Posts: 11
Joined: 17 Apr 2024, 16:28

Open 2 File Explorer windows side by side

Post by w_i_k_i_d » 27 Apr 2024, 21:52

Hello Ahk 2.0 forum,

Trying to open two file explorer windows in the upper right corner of the screen, side by side, in roughly the location seen in the image.
Please see attached image.
SNAG-0041.jpg
SNAG-0041.jpg (48.12 KiB) Viewed 435 times

Code: Select all

<!w:: 	;; LAlt + w
{
Soundbeep 1500
run "explorer.exe C:\Users\xxx\Documents"
Sleep 300          
run "explorer.exe C:\Users\xxx\Downloads"
return
}
Two issues with this code:-
1. I cannot hear the beep.
2. If anything is open like Chrome or other windows, at least one File explorer windows hides under and I have to dig it out.

If possible can both of the windows appear on top of every other opened window.

Thank you kindly 

------
Win 10 Pro

User avatar
mikeyww
Posts: 27128
Joined: 09 Sep 2014, 18:38

Re: Open 2 File Explorer windows side by side

Post by mikeyww » 28 Apr 2024, 11:35

Code: Select all

#Requires AutoHotkey v2.0
dir := [A_MyDocuments, StrReplace(A_MyDocuments, 'Documents', 'Downloads')]
MonitorGetWorkArea(, &monLeft, &monTop, &monRight, &monBottom)
monWidth  := monRight  - monLeft + 1
monHeight := monBottom - monTop  + 1
winWidth  := monWidth  * 1 / 3
winHeight := monHeight * 2 / 3
winTitle  := 'ahk_class CabinetWClass'

<!w:: {
 e := WinGetList(winTitle)
 While e.Length < 2 {              ; The target number of windows
  before := e.Length               ; Number of windows before the next instance
  Run 'explorer.exe ' dir[A_Index] ; Open a new instance
  Loop {
   Sleep 30
   e := WinGetList(winTitle)       ; Get new number of Explorer windows
  } Until e.Length > before        ; Check until the number has been incremented
 }                                 ; e[1] and e[2] are HWND values (unique ID) for the windows
 For n, hWnd in e                  ; Restore & activate each window
  If WinExist(hWnd) {
   WinRestore(), WinActivate()
   WinMove monLeft + n * winWidth, monTop, winWidth, winHeight
   WinSetAlwaysOnTop True
  }
}

w_i_k_i_d
Posts: 11
Joined: 17 Apr 2024, 16:28

Re: Open 2 File Explorer windows side by side

Post by w_i_k_i_d » 28 Apr 2024, 18:06

I love how the script is working.
I made minor changes to adjust the size of the window and I like these settings below :-

Code: Select all

winWidth  := monWidth  * 1 / 4
winHeight := monHeight * 1 / 2
Can I please request to place the windows to roughly where the yellow squares are in the new screenshot.

Also the windows are Always On Top.
Can they be On Top only when first opened.

Thank you so much
SNAG-0002.jpg
SNAG-0002.jpg (20.88 KiB) Viewed 325 times

User avatar
boiler
Posts: 17120
Joined: 21 Dec 2014, 02:44

Re: Open 2 File Explorer windows side by side

Post by boiler » 28 Apr 2024, 20:19

@w_i_k_i_d — Apparently you haven’t been seeing or have been ignoring the several emails notifying you of disapproved posts because you keep posting duplicates. Posts by new members must be approved before they appear. Please be patient and don’t post the same content again! Thank you!

User avatar
mikeyww
Posts: 27128
Joined: 09 Sep 2014, 18:38

Re: Open 2 File Explorer windows side by side

Post by mikeyww » 28 Apr 2024, 20:20

You can adjust the WinMove function call so that the position matches your preference.

Code: Select all

WinMove monLeft + n * winWidth - 250, monTop, winWidth, winHeight
The call to WinSetAlwaysOnTop can be deleted.

w_i_k_i_d
Posts: 11
Joined: 17 Apr 2024, 16:28

Re: Open 2 File Explorer windows side by side

Post by w_i_k_i_d » 03 May 2024, 09:38

Boiler @ I didn't know. Checking all the mails now.
Sometimes I felt my post didn't get submitted, so I kept posting it again or trying with a different browser but I get it, it will take some time to post. I will keep that in mind :)

Thanks Mr Mikeyww

Code: Select all

WinMove monLeft + n * winWidth +320, monTop, winWidth, winHeight
worked perfectly for me. So happy. :bravo:

Post Reply

Return to “Ask for Help (v2)”