retieve size of files selected in everything Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
enrica
Posts: 32
Joined: 21 Aug 2019, 08:40

retieve size of files selected in everything

13 Jun 2021, 21:35

Hi Friends! I.m tryng to retrieve the total size of files selected in "everything" or explorer or xplorer2.
im able to retrieve only one per time, but i like to know the total size when i select one by one.
thank you for any help!
bye!

Code: Select all

SetTimer, SetTimer45, 666
Return

SetTimer45:
totalSize = 
WinActivate, ahk_class EVERYTHING
WinMove, ahk_class EVERYTHING,,-4,-4,666,776 
Sleep, 111
Sendinput, ^c
clipwait, 1

;gosub, fileopen
;FileOpen:
 ;   FileSelectFile, thisfile, 3,startdirectory, Select Files, Any File (*.*; *.gabc)
thisfile = %Clipboard%
    
        filegetsize, thisfilesize, %thisfile%
  tooltip, %thisfilesize%
    

  ;files := %Clipboard%
   Loop, parse, Clipboard, `n
   {
      b := InStr(FileExist(A_LoopField), "D")
      Loop, Files, % A_LoopField . (b ? "\*" : ""), FR
         totalSize += A_LoopFileSize
   }

totalSize += %totalSize% 

Gui, 28: Destroy
Gui, 28: -SysMenu +AlwaysOnTop -Caption +ToolWindow
Gui, 28: color, B5FF6C ; 
Gui, 28: Font, s26
Gui, 28: Add, Text, x20 y-2,
(
totalSize = %totalSize%
%D%
size = %OutputVar%
  tooltip %thisfilesize%
Clipboard  %Clipboard%
)
Gui, 28: Show, noactivate   x650 y110 ; h42 ; w150
SetTimer, SetTimer45, off
return


Last edited by enrica on 14 Jun 2021, 07:18, edited 1 time in total.
User avatar
mikeyww
Posts: 26931
Joined: 09 Sep 2014, 18:38

Re: retieve size of files selected in everything

14 Jun 2021, 07:13

I am adding a note because no one else has replied. You have the right idea, but I find that Everything is tricky because it seems to manage the keyboard in its own way-- not very easy to use with AHK, in my own experience. There may still be a way.

At least on my version, the keyboard shortcut to copy file paths is ^+c, though I did not get it to work so well via an AHK script.

My other comment is that setting the Clipboard inside a timed loop like this can be inefficient and sometimes problematic, because the Clipboard is fairly slow.

Your goal is readily accomplished in Windows File Explorer, but I realize that this probably does not help you.
enrica
Posts: 32
Joined: 21 Aug 2019, 08:40

Re: retieve size of files selected in everything

14 Jun 2021, 07:23

Hi.
in my everything the keys are customizable so i can choice the best for me.
i can do this in a very complicated way using fileappend fileread filegetsize etc
but i.m searching a more elegant and logic way
but is too complicated for my capacity
thank you anyway!
User avatar
mikeyww
Posts: 26931
Joined: 09 Sep 2014, 18:38

Re: retieve size of files selected in everything

14 Jun 2021, 07:29

You could do this semi-manually, by using OnClipboardChange(). You select your files, and press Ctrl+C. Your function would then run your routine as a function, to compute the total file size.

Code: Select all

#SingleInstance Force
Loop {
 WinWaitActive, ahk_exe Everything.exe
 OnClipboardChange("ClipChanged")
 SoundBeep, 1500
 WinWaitNotActive
 OnClipboardChange("ClipChanged", 0)
 SoundBeep, 1000
}

ClipChanged(Type) {
 If (Type != 1)
  Return
 MsgBox, 64, Done, Replace this MsgBox with your computation routine.`n`n%Clipboard%
}
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: retieve size of files selected in everything

14 Jun 2021, 09:47

Code: Select all

DetectHiddenWindows On
ControlGet, currentEverythingSelection, List, Selected, SysListView321, ahk_class EVERYTHING
MsgBox % currentEverythingSelection

totalSize := 0
for each, Line in StrSplit(currentEverythingSelection, "`n", "`r")
{
	size := StrSplit(line, "`t")[3] ; size is in the 3rd tab-delimited column
	size := StrReplace(size, ",") ; remove decimal commas
	size := StrReplace(size, " KB") ; remove ' KB' suffix
	size := Round(size) ; cast to int, or 0 if empty string
	totalSize += size
}
MsgBox % totalSize " KB"
User avatar
mikeyww
Posts: 26931
Joined: 09 Sep 2014, 18:38

Re: retieve size of files selected in everything

14 Jun 2021, 09:56

That did not work at my end, but it might be how I have set up Everything.
User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: retieve size of files selected in everything

14 Jun 2021, 10:59

It works here if you use size := StrSplit(line, "`t")[2]
14.3 & 1.3.7
Eureka
Posts: 65
Joined: 03 Apr 2018, 13:31

Re: retieve size of files selected in everything

14 Jun 2021, 18:22

Everything reports the total size of the selected files in the status bar when Show size in status bar is enabled (Options > View )

You can even configure the format in which that is displayed through the statusbar_size_format setting:

In the search bar type - for example - /statusbar_size_format=1 and press ENTER.


Or use Everything's command-line tool ES.exe (example: ES.exe c:\windows -get-total-size)
Instant result ..


Or use the SDK APIs (no personal experience).
enrica
Posts: 32
Joined: 21 Aug 2019, 08:40

Re: retieve size of files selected in everything  Topic is solved

14 Jun 2021, 21:20

Thank you very much everybody!
really appreciate!
:dance: :dance: :dance:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ht55cd3, OrangeCat, Panaku, Rohwedder and 317 guests