Open Everything GUI results with TC LOADLIST

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *Ovg »

Now I'm writing version that will work with CR/LF in a right way.
A'm I right - now all works right to you?
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
User avatar
tuska
Power Member
Power Member
Posts: 3740
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

Ovg wrote: 2021-10-15, 15:49 UTC Now I'm writing version that will work with CR/LF in a right way.
A'm I right - now all works right to you?
Yes, thank you, everything is fine for me now.
I always find it so difficult to enter my values in the script, because until now I have always had doubts.
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *Ovg »

:thumbsup:
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *Ovg »

2tuska

Version that working with CR/LF in columns in a right way.
Your path and programs are preserved, check it, but it seems that all ok (I tested with your paths )

Try and enjoy! :D
Spoiler

Code: Select all

;https://www.ghisler.ch/board/viewtopic.php?t=75439 Open Everything GUI results with TC LOADLIST
;https://www.ghisler.ch/board/viewtopic.php?t=75417 LOADLIST command and UTF8 file lists
;https://www.voidtools.com/forum/viewtopic.php?f=4&t=10594 Send ResultsList to Total Commander
;
; Build AutoHotkey_L
; Build x64
; Build Kill=true
; Build Zip=false
; Build Run=true

#NoEnv
;#Persistent
#SingleInstance Force
SetBatchLines, -1



;#x::
; Create / read .ini file settings
SetTitleMatchMode, RegEx
iniFile := RegExReplace(A_ScriptFullPath, "(ahk|exe)$", "ini")

if not (FileExist(iniFile)) {
    iniContent :="
    ( LTrim
        [General]
        ; Where to save the output (full path)
        DestinationFile=D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\EV-Results\EV-Results.txt

        ; The columns 'Name' and 'Path' must be visible in the Everything
        ; window. The first value is the position of the 'Path', the second
        ; value is the position of the 'Name' column
        ; Default: 2,1
        EverythingColumnPositions=2,1
        AddEndSlash=1
    )"
    FileAppend, % iniContent, % iniFile, UTF-16
}

IniRead, DestinationFile,           % iniFile, General, DestinationFile,           % A_Temp "\~EV-Results.txt"
IniRead, EverythingColumnPositions, % iniFile, General, EverythingColumnPositions, 2`,1
IniRead, AddEndSlash, % iniFile, General, AddEndSlash, 1

DestinationFile           := ResolveEnvVars(DestinationFile)
EverythingColumnPositions := StrReplace(EverythingColumnPositions, " ")

; Force default value if none is given (or path doesn't exist)
SplitPath, DestinationFile, , dstPath
if (DestinationFile = "" || !InStr(FileExist(dstPath), "D")) {
    DestinationFile := "D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\EV-Results\EV-Results.txt"
;   DestinationFile := A_Temp "~EV-Results.txt" ... in an earlier script! ... analogous to line 40 in the current script (modified).
;   DestinationFile := A_Temp "~EV-Results.txt" ... in einem fruheren Skript! ... analog zu Zeile 40 im aktuellen Skript (modifiziert).
}
if (EverythingColumnPositions = "" || !InStr(EverythingColumnPositions, ",")) {
    EverythingColumnPositions := "2,1"
}
;OutputDebug, % "DestinationFile: " DestinationFile

columnArray := StrSplit(EverythingColumnPositions, ",")


;hWnd := WinExist("im).*?Everything ahk_class EVERYTHING")
hWnd := WinExist("ahk_exe Everything(?:\d\d)*\.exe")

if hWnd
{
  ControlGet, winContent, List, , SysListView321, % "ahk_id" hWnd

  if (winContent)
  {
    fullContent := ""
;   Loop over row(s)
    Loop, Parse, winContent, `n
    {
      rowID := A_Index
      path  := ""
      name  := ""
      full  := ""
      Bad := 2
;     Loop over column(s)
      Loop, Parse, A_LoopField, % A_Tab
      {
        colID   := A_Index
        content := A_LoopField
        If (colID > columnArray[1] And colID > columnArray[2])
        {
          Break
        }
        Else
        {
          If (colID = columnArray[1])
          {
            If !RegExMatch(content,"i)^[a-z]:")
            {
              Break
            }
            path := content
            Bad -= 1
            If !RegExMatch(path,"\\$")
            {
              path := path . "\"
            }
          }
          Else if (colID = columnArray[2])
          {
            If !content
            {
              Break
            }
            name := content
            Bad -= 1
          }
        }
      }
      If (Bad == 0)
      {
        full        := path . name
        If InStr(FileExist(full), "D")
        {
          if (AddEndSlash == 1)
          {
            if !RegExMatch(full,"\\$")
            {
              full := full . "\"
            }
          }
          Else
          {
            If RegExMatch(full,"\\$")
            {
              full := SubStr(full,1,StrLen(full)-1)
            }
          }
        }
        fullContent .= full "`n"
      }
    }
    fullContent := RegExReplace(fullContent,"\R$","")
    If (FileExist(DestinationFile))
      FileDelete, % DestinationFile

        FileAppend, % fullContent, % DestinationFile, UTF-16
	run "D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\TOTALCMD64.EXE" /O /T /S D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\EV-Results\
;       run "D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\TOTALCMD64.EXE" /O /R=D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\EV-Results\
;       run "C:\Program Files\Total Commander\TotalCmd64.exe" /O /R=g:\System\Temp

        run "C:\Tools\Everything\Everything64.exe" -instance "PRIVATE" -close
;	run "C:\Tools\Everything\Everything64.exe" -close    	--> see also line 151!
    }
    Else
;   Empty search result
    {
      Msgbox, 16,, Search result is Empty, Nothing to do ...
    }
; No Everything window visible
} Else {
    Msgbox, 16, Fatal error, Everything window does not exist!
}
;run "C:\Tools\Everything\Everything64.exe" -close		--> see also line 140!
SetTitleMatchMode, 1
return

; ==================================
; = GOTO: FUNCTIONS - ResolveEnvVars
; ==================================
; http://www.autohotkey.com/board/topic/40115-func-envvars-replace-environment-variables-in-text/#entry310601
ResolveEnvVars(str) {
    if sz := DllCall("ExpandEnvironmentStrings", "uint", &str, "uint", 0, "uint", 0)
    {
        VarSetCapacity(dst, A_IsUnicode ? sz * 2 : sz)
        if DllCall("ExpandEnvironmentStrings", "uint", &str, "str", dst, "uint", sz)
            return dst
    }
    return str
}
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
User avatar
tuska
Power Member
Power Member
Posts: 3740
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

2Ovg

Super! Thanks a lot! :D
This script works without error message and takes line breaks in the comments to Word documents into account!
(I had several such files).

Thanks also for keeping my paths!!
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *Ovg »

Great! :D
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
User avatar
tuska
Power Member
Power Member
Posts: 3740
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

2Ovg
Can you please check the last script again.
In TC, the folders are suddenly no longer displayed. :shock:
They are also no longer listed in the EV-Results.txt (only files are listed).

I only noticed that now.
Previously I only did a short test with the script and it ran through without errors.
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *Ovg »

Ok, Can you give me the names of absent dirs?
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
User avatar
tuska
Power Member
Power Member
Posts: 3740
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

Sorry, please wait, now I have to check again.
First (a few hours ago) the folders were not there from different directories, now they are suddenly there again!?
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *Ovg »

I found that dir with names like "0", "00" and so on are absent. check this please. I have corrected this already. I'll upload new version today morning.
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
User avatar
tuska
Power Member
Power Member
Posts: 3740
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

Ahh, thanks for the info!
Will test the new script...


I am very sorry to have bothered you again.
The script basically works!

(I have unexpected search results in extremely rare cases
- where I have to repeat the search query several times -,
but that this has to happen now, especially with this topic, annoys me).
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *Ovg »

2tuska

Your new version. Your paths and filenames are preserved.

I have tested with 36500 files (some files has comments) and dirs. Should work now. :D
Spoiler

Code: Select all

;https://www.ghisler.ch/board/viewtopic.php?t=75439 Open Everything GUI results with TC LOADLIST
;https://www.ghisler.ch/board/viewtopic.php?t=75417 LOADLIST command and UTF8 file lists
;https://www.voidtools.com/forum/viewtopic.php?f=4&t=10594 Send ResultsList to Total Commander
;
; Build AutoHotkey_L
; Build x64
; Build Kill=true
; Build Zip=false
; Build Run=true

#NoEnv
;#Persistent
#SingleInstance Force
SetBatchLines, -1



;#x::
; Create / read .ini file settings
SetTitleMatchMode, RegEx
iniFile := RegExReplace(A_ScriptFullPath, "(ahk|exe)$", "ini")

if not (FileExist(iniFile)) {
    iniContent :="
    ( LTrim
        [General]
        ; Where to save the output (full path)
        DestinationFile=D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\EV-Results\EV-Results.txt

        ; The columns 'Name' and 'Path' must be visible in the Everything
        ; window. The first value is the position of the 'Path', the second
        ; value is the position of the 'Name' column
        ; Default: 2,1
        EverythingColumnPositions=2,1
        AddEndSlash=1
    )"
    FileAppend, % iniContent, % iniFile, UTF-16
}

IniRead, DestinationFile,           % iniFile, General, DestinationFile,           % A_Temp "\~EV-Results.txt"
IniRead, EverythingColumnPositions, % iniFile, General, EverythingColumnPositions, 2`,1
IniRead, AddEndSlash, % iniFile, General, AddEndSlash, 1

DestinationFile           := ResolveEnvVars(DestinationFile)
EverythingColumnPositions := StrReplace(EverythingColumnPositions, " ")

; Force default value if none is given (or path doesn't exist)
SplitPath, DestinationFile, , dstPath
if (DestinationFile = "" || !InStr(FileExist(dstPath), "D")) {
    DestinationFile := "D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\EV-Results\EV-Results.txt"
;   DestinationFile := A_Temp "~EV-Results.txt" ... in an earlier script! ... analogous to line 40 in the current script (modified).
;   DestinationFile := A_Temp "~EV-Results.txt" ... in einem fruheren Skript! ... analog zu Zeile 40 im aktuellen Skript (modifiziert).
}
if (EverythingColumnPositions = "" || !InStr(EverythingColumnPositions, ",")) {
    EverythingColumnPositions := "2,1"
}
;OutputDebug, % "DestinationFile: " DestinationFile

columnArray := StrSplit(EverythingColumnPositions, ",")


;hWnd := WinExist("im).*?Everything ahk_class EVERYTHING")
hWnd := WinExist("ahk_exe Everything(?:\d\d)*\.exe")

if hWnd
{
  ControlGet, winContent, List, , SysListView321, % "ahk_id" hWnd

  if (winContent)
  {
    fullContent := ""
;   Loop over row(s)
    Loop, Parse, winContent, `n
    {
      rowID := A_Index
      path  := ""
      name  := ""
      full  := ""
      Bad := 2
;     Loop over column(s)
      Loop, Parse, A_LoopField, % A_Tab
      {
        colID   := A_Index
        content := A_LoopField
        If (colID > columnArray[1] And colID > columnArray[2])
        {
          Break
        }
        Else
        {
          If (colID == columnArray[1])
          {
            If !RegExMatch(content,"i)^[a-z]:")
            {
              Break
            }
            path := content
            Bad -= 1
            If !RegExMatch(path,"\\$")
            {
              path := path . "\"
            }
          }
          Else if (colID == columnArray[2])
          {
            If content is Space
            {
              Break
            }
            name := content
            Bad -= 1
          }
        }
      }
      If (Bad == 0)
      {
        full        := path . name
        If InStr(FileExist(full), "D")
        {
          if (AddEndSlash == 1)
          {
            if !RegExMatch(full,"\\$")
            {
              full := full . "\"
            }
          }
          Else
          {
            If RegExMatch(full,"\\$")
            {
              full := SubStr(full,1,StrLen(full)-1)
            }
          }
        }
        fullContent .= full "`n"
      }
    }
    fullContent := RegExReplace(fullContent,"\R$","")
    If (FileExist(DestinationFile))
      FileDelete, % DestinationFile

        FileAppend, % fullContent, % DestinationFile, UTF-16
	run "D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\TOTALCMD64.EXE" /O /T /S D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\EV-Results\
;       run "D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\TOTALCMD64.EXE" /O /R=D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\EV-Results\
;       run "C:\Program Files\Total Commander\TotalCmd64.exe" /O /R=g:\System\Temp

        run "C:\Tools\Everything\Everything64.exe" -instance "PRIVATE" -close
;	run "C:\Tools\Everything\Everything64.exe" -close    	--> see also line 151!
    }
    Else
;   Empty search result
    {
      Msgbox, 16,, Search result is Empty, Nothing to do ...
    }
; No Everything window visible
} Else {
    Msgbox, 16, Fatal error, Everything window does not exist!
}
;run "C:\Tools\Everything\Everything64.exe" -close		--> see also line 140!
SetTitleMatchMode, 1
return

; ==================================
; = GOTO: FUNCTIONS - ResolveEnvVars
; ==================================
; http://www.autohotkey.com/board/topic/40115-func-envvars-replace-environment-variables-in-text/#entry310601
ResolveEnvVars(str) {
    if sz := DllCall("ExpandEnvironmentStrings", "uint", &str, "uint", 0, "uint", 0)
    {
        VarSetCapacity(dst, A_IsUnicode ? sz * 2 : sz)
        if DllCall("ExpandEnvironmentStrings", "uint", &str, "str", dst, "uint", sz)
            return dst
    }
    return str
}      
Last edited by Ovg on 2021-10-16, 08:24 UTC, edited 1 time in total.
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
User avatar
tuska
Power Member
Power Member
Posts: 3740
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

2Ovg

Fits me perfectly :) with 44 470 objects (23061 file, 3585 directories) and further tests (e.g. folders with zeros, comments)!
(Unfortunately I always forget to show the hidden files before the search query - cm_SwitchHidSys).

Can you please use this script in the future?
I have marked for myself where I have to make changes to personal settings in the script if necessary.
Script - 2021-10-16_0905.AHK

Code: Select all

;https://www.ghisler.ch/board/viewtopic.php?t=75439 Open Everything GUI results with TC LOADLIST
;https://www.ghisler.ch/board/viewtopic.php?t=75417 LOADLIST command and UTF8 file lists
;https://www.voidtools.com/forum/viewtopic.php?f=4&t=10594 Send ResultsList to Total Commander
;
; Build AutoHotkey_L
; Build x64
; Build Kill=true
; Build Zip=false
; Build Run=true

#NoEnv
;#Persistent
#SingleInstance Force
SetBatchLines, -1



;#x::
; Create / read .ini file settings
SetTitleMatchMode, RegEx
iniFile := RegExReplace(A_ScriptFullPath, "(ahk|exe)$", "ini")

if not (FileExist(iniFile)) {
    iniContent :="
    ( LTrim
        [General]
        ; **************************************************************************************************
        ; Where to save the output (full path)
        DestinationFile=D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\EV-Results\EV-Results.txt
        ; **************************************************************************************************

        ; The columns 'Name' and 'Path' must be visible in the Everything
        ; window. The first value is the position of the 'Path', the second
        ; value is the position of the 'Name' column
        ; Default: 2,1
;       *****************************
        EverythingColumnPositions=2,1
        AddEndSlash=1
;       *****************************
    )"
    FileAppend, % iniContent, % iniFile, UTF-16
}
;                                                                                             ***************
IniRead, DestinationFile,           % iniFile, General, DestinationFile,           % A_Temp "\~EV-Results.txt"
;                                                                                             ***************
IniRead, EverythingColumnPositions, % iniFile, General, EverythingColumnPositions, 2`,1
IniRead, AddEndSlash, % iniFile, General, AddEndSlash, 1

DestinationFile           := ResolveEnvVars(DestinationFile)
EverythingColumnPositions := StrReplace(EverythingColumnPositions, " ")

; Force default value if none is given (or path doesn't exist)
SplitPath, DestinationFile, , dstPath
if (DestinationFile = "" || !InStr(FileExist(dstPath), "D")) {
;                       ************************************************************************************
    DestinationFile := "D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\EV-Results\EV-Results.txt"
;                       ************************************************************************************
}
if (EverythingColumnPositions = "" || !InStr(EverythingColumnPositions, ",")) {
    EverythingColumnPositions := "2,1"
}
;OutputDebug, % "DestinationFile: " DestinationFile

columnArray := StrSplit(EverythingColumnPositions, ",")


;hWnd := WinExist("im).*?Everything ahk_class EVERYTHING")
hWnd := WinExist("ahk_exe Everything(?:\d\d)*\.exe")

if hWnd
{
  ControlGet, winContent, List, , SysListView321, % "ahk_id" hWnd

  if (winContent)
  {
    fullContent := ""
;   Loop over row(s)
    Loop, Parse, winContent, `n
    {
      rowID := A_Index
      path  := ""
      name  := ""
      full  := ""
      Bad := 2
;     Loop over column(s)
      Loop, Parse, A_LoopField, % A_Tab
      {
        colID   := A_Index
        content := A_LoopField
        If (colID > columnArray[1] And colID > columnArray[2])
        {
          Break
        }
        Else
        {
          If (colID == columnArray[1])
          {
            If !RegExMatch(content,"i)^[a-z]:")
            {
              Break
            }
            path := content
            Bad -= 1
            If !RegExMatch(path,"\\$")
            {
              path := path . "\"
            }
          }
          Else if (colID == columnArray[2])
          {
            If content is Space
            {
              Break
            }
            name := content
            Bad -= 1
          }
        }
      }
      If (Bad == 0)
      {
        full        := path . name
        If InStr(FileExist(full), "D")
        {
          if (AddEndSlash == 1)
          {
            if !RegExMatch(full,"\\$")
            {
              full := full . "\"
            }
          }
          Else
          {
            If RegExMatch(full,"\\$")
            {
              full := SubStr(full,1,StrLen(full)-1)
            }
          }
        }
        fullContent .= full "`n"
      }
    }
    fullContent := RegExReplace(fullContent,"\R$","")
    If (FileExist(DestinationFile))
      FileDelete, % DestinationFile

        FileAppend, % fullContent, % DestinationFile, UTF-16
;            **********************************************************************************************************************************************************
	run "D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\TOTALCMD64.EXE" /O /T /S D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\EV-Results\
;            **********************************************************************************************************************************************************
;       run "D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\TOTALCMD64.EXE" /O /R=D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\EV-Results\
;       run "C:\Program Files\Total Commander\TotalCmd64.exe" /O /R=g:\System\Temp

;           *****************************************************************
        run "C:\Tools\Everything\Everything64.exe" -instance "PRIVATE" -close
;           *****************************************************************
;	run "C:\Tools\Everything\Everything64.exe" -close
    }
    Else
;   Empty search result
    {
      Msgbox, 16,, Search result is Empty, Nothing to do ...
    }
; No Everything window visible
} Else {
    Msgbox, 16, Fatal error, Everything window does not exist!
}
SetTitleMatchMode, 1
return

; ==================================
; = GOTO: FUNCTIONS - ResolveEnvVars
; ==================================
; http://www.autohotkey.com/board/topic/40115-func-envvars-replace-environment-variables-in-text/#entry310601
ResolveEnvVars(str) {
    if sz := DllCall("ExpandEnvironmentStrings", "uint", &str, "uint", 0, "uint", 0)
    {
        VarSetCapacity(dst, A_IsUnicode ? sz * 2 : sz)
        if DllCall("ExpandEnvironmentStrings", "uint", &str, "str", dst, "uint", sz)
            return dst
    }
    return str
}
Thank you very much!

PS:
I also tested yesterday's search queries.
Today there were no more unexpected results.
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *Ovg »

Ок, got it!
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *Ovg »

2tuska

One note: Now script ignores the root directory of any drive (c:\, d:\, e:\ and so on), they will not be listed, I'll correct this later.
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
Post Reply