Faster opening a set of folders (or disks / partitions)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
loek6000
Posts: 164
Joined: 14 Aug 2019, 17:46

Faster opening a set of folders (or disks / partitions)

Post by loek6000 » 31 May 2023, 13:16

I did make a script which opens 3 explorer folders of my drives / partitions

Is there a faster way to open up these explorer windows? Now it relatively slow because of the sleeps.

Code: Select all

runwait C:\
 WinWaitActive, C:\
 WinMove, C:\,, 50, 50, 1700, 2033
 sleep 50

 runwait D:\
 WinWaitActive, D:\
 WinMove, D:\,, 1740, 50, 1700, 2033
 sleep 200

 runwait W:\
 sleep 500
 WinWaitActive, W:\
 WinMove, W:\,, 3430, 50, 1700, 2033

 return

RussF
Posts: 1280
Joined: 05 Aug 2021, 06:36

Re: Faster opening a set of folders (or disks / partitions)

Post by RussF » 31 May 2023, 13:38

This worked for me:

Code: Select all

Run C:\
WinWaitActive, Local Disk (C:)
WinMove, Local Disk (C:),, 50, 50, 500, 500

Run D:\
WinWaitActive, DATA (D:)
WinMove, DATA (D:),, 75, 75, 500, 500
Adjust the WinTitles and coordinates to suit you. Wintitles are case sensitive - see WinTitle.

Russ

colt
Posts: 291
Joined: 04 Aug 2014, 23:12
Location: Portland Oregon

Re: Faster opening a set of folders (or disks / partitions)

Post by colt » 31 May 2023, 14:51

This is as fast as i could get it. It only takes 400ms if the windows already exist. It will just move them to the proper position

Code: Select all

#NoEnv
#SingleInstance Force
SetBatchLines -1

start := a_tickCOunt
winData := []

;spawn all windows at same time to take advantage of parallel processing
Run,  C:\
winData.push({title:"C:\",pos:{x:50,y:50,w:1700,h:2033}})

Run, D:\ 
winData.push({title:"D:\",pos:{x:1740,y:50,w:1700,h:2033}})

Run,  W:\ 
winData.push({title:"W:\",pos:{x:3430,y:50,w:1700,h:2033}})

;wait for windows here
scanCount := 0
hitCount := 0
targetCount := winData.count()

loop
{
	scanCount++	
	for index,data In winData
	{
		if(data) ;still need to place
		{
			;msgbox % winExist(data.title)
			if(winExist("ahk_exe explorer.exe",data.title) != "0x0") ;will ensure only explorer windows are snagged
			{	
				hitCount++
				winMove % data.title ,, % data.pos.x, % data.pos.y, % data.pos.w, % data.pos.h					
				winData[index] := "" ;clear pos data this window has been placed
			}	
		}
	}	
	if(hitCount == targetCount) ;everything placed so exit
	{
		break
	}
	sleep 18 ;tune speed here. this was sweet spot for me. got under 1s launch time, not having sleep was 1300ms
}

msgbox % "all windows placed scanned " . scanCount . " times.`nTicks elapsed : " . a_tickCOunt - start

loek6000
Posts: 164
Joined: 14 Aug 2019, 17:46

Re: Faster opening a set of folders (or disks / partitions)

Post by loek6000 » 01 Jun 2023, 00:54

Thanx both :)

I used @colt script

this was exactly what i wanted :) :)

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

Re: Faster opening a set of folders (or disks / partitions)

Post by mikeyww » 01 Jun 2023, 08:31

Just a clarification: while some parts of WinTitle may not be case-sensitive, the window title is case-sensitive (without the "i)" option for RegEx).

Post Reply

Return to “Ask for Help (v1)”