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
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Open Everything GUI results with TC LOADLIST

Post by *Horst.Epp »

2yanch
1. Show the content of the ini-File the script has created after the first run in your scripts dir.
2. For what reason do you need a .bat file ?

Btw. the current Everything 1.5 version is 1.5.0.1343a
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 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 »

2yanch

AutoHotkey script (.AHK)
Please check the lines: 41-47, 63, 64, 164 in the script and adjust the code if necessary, e.g. paths or TC command line parameters.
Example (.AHK) - lines 41-47, 63, 64, 164  –  The entire code for AHK script is a little further down...

Code: Select all

Line  41:       DestinationFile = C:\totalcmd\EV-Results\EV-Results.txt
Line  42:       EverythingColumnPositions=2,1
Line  43:       AddEndSlash = 1
Line  44:       CloseEverything = 0
Line  45:       UseInstance =
Line  46:       Everything = C:\Everything\Everything64.exe
Line  47:       TotalCmd = C:\totalcmd\TOTALCMD64.EXE

Line  63:	IniRead, Everything, % iniFile, General, Everything, "C:\Everything\Everything64.exe"
Line  64:	IniRead, TotalCmd, % iniFile, General, TotalCmd, "C:\totalcmd\TOTALCMD64.EXE"

Line 164:	Run %TotalCmd% /O /T /S LOADLIST:%DestinationFile%
Lines 41-47 are displayed in the .INI file in lines 15-21.

With this variant (line 164: LOADLIST), a View mode with Auto Switch Mode is NOT required.
However, a View mode with Auto Switch Mode can be created OPTIONALLY.

Option: Alternatively a BUTTON with these commands is also possible...
em_EV-results_TC-LOADLIST,CM_WAIT 750,cm_SrcCustomView37,cm_SrcSortByCol6,cm_ExchangeSelBoth
- Custom columns - Name: Path; Name, Ext, [=tc.size], [=tc.writedate], [=tc.attributestr], [=tc.path]
- cm_SrcSortByCol6 .......: Path [=tc.path]
Especially please check line 164 of the AHK script and then run this test:
Search the compiled* AHK script (= .EXE) in Everything and then double-click the .EXE file in Everything(!) ...
Example .EXE file name: "SEND_EV-RESULTS_to_TC-panel_(A)_CloseEverything-0_TAB-Search_result_(A).EXE".
---------------------------------------------------------------------------------------------------------------------------------------
Total Commander opens, tab "Search result:" is created and the search result is displayed in Total Commander.
The Everything window remains open (CloseEverything = 0).
---------------------------------------------------------------------------------------------------------------------------------------
* Compiled .AHK script  (the entire code for AHK script is a little further down...):
- Right click on the .AHK file, then click on "Compile Script" or "Compile Script (GUI)..." creates an .EXE file.
- Double click on the .EXE file and the search result is transferred from the opened Everything window to TC...
- In addition, the first time the .EXE file is called up, an .INI file of the same name is created - with essential
  but not all settings (only lines 41-47 are displayed in the .INI file in lines 15-21).
  After each execution of the .EXE file, the modification date and time of the .INI file is updated. This makes it
  possible to determine when the last transfer of search results from Everything to Total Commander was carried out.
 
Optional: Create a button in Total Commander for the transfer of multiple search results from Everything to TC.
Optional: Example BUTTON (additional entry in usercmd.ini required)

Code: Select all

TOTALCMD#BAR#DATA
em_EV-results_TC-LOADLIST,CM_WAIT 750,cm_ExchangeSelBoth

%COMMANDER_PATH%\Tools\AutoHotkey\AutoHotkey.exe,2
em_EV-results_TC-LOADLIST,CM_WAIT 750,cm_ExchangeSelBoth|AHK script 4.10.2022|Tab "Search result:" in TC|Everything window remains OPEN|Without EV: Mix Files and Folders

0
-1
The search result is highlighted automatically so that you can compare the number of files in the Total Commander footer
with the number of files in Everything. With the command cm_ExchangeSelBoth you can switch the marking manually on or off.
The command "CM_WAIT 750" is mandatory in this case [or at least highly recommended].
With this procedure I want to check whether all search results have arrived in Total Commander.
Note (in case of number differences): The Everything search result also includes hidden files, e.g. file "descript.ion" for TC file comments (Ctrl+Z).

If you don't want the automatic marking, just omit ',CM_WAIT 750,cm_ExchangeSelBoth' in the button.
In this case, the button and the em_command are no longer necessary, because it is then sufficient to double-click on the compiled AHK file -> .EXE.
Before executing the .EXE file, the Everything window with the search results must be open in Everything.
Optional: Make a BUTTON: Copy/paste button-CODE | Tooltip | FAQs
  • Click on "SELECT ALL" (next to CODE:), then press Ctrl+C (copy to clipboard).
  • Right-click on TC's button bar, then click on "Paste" (from clipboard)
    ⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺
  • Point to the button (slightly longer): 'Tooltip' is shown (= description to the button).
    A maximum of 259 characters is allowed for the tooltip. | = create line break, || = create | as separator character.
  • Button - "Tooltip" field: A single space deactivates the display of the tooltip.
    If the "Tooltip" field is empty, the content of the "Command" field is displayed.
  • See also: Tooltip configuration
    ⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺
  • FAQs: Button-code: How-to Copy Share Paste a button ('TOTALCMD#BAR#DATA')
Optional: em_command | Mandatory: Only required when the "Example BUTTON" is created - usercmd.ini
Create an em_command: Enter this CODE at the end in the file "usercmd.ini" - adjust the path and file name <.exe> (!):
If the file "usercmd.ini" does NOT exist, create it in the path %COMMANDER_PATH%.

usercmd.ini (File name)

Code: Select all

[em_EV-results_TC-LOADLIST]
button=
cmd=%COMMANDER_PATH%\Tools\AutoHotkey\Skripte\EV_SearchResults_to_TC-panel\SEND_EV-RESULTS_to_TC-panel_(A)_CloseEverything-0_TAB-Search_result_(A).exe

Mandatory: SEND_EV-RESULTS_to_TC-panel_(A)_CloseEverything-0_TAB-Search_result_(A).AHK
See also above: * Compiled .AHK script ... results in .EXE file:
"SEND_EV-RESULTS_to_TC-panel_(A)_CloseEverything-0_TAB-Search_result_(A).EXE"

Code: Select all

; Transfer Everything GUI results to TC
; Authors: Horst.Epp & Ovg
; Last modified: 04.10.2022 (Updated for TC 10.52 RC1)

; 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

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

if not (FileExist(iniFile)) {
    iniContent :="
    (( LTrim
        [General]
	; DestinationFile
        ;    Where to save the output (full path to DestinationFile.txt)
        ; EverythingColumnPositions (Default: 2,1)
	;    The columns 'Name' and 'Path' must be visible in the Everything GUI Window
        ;    The first value is the position of the 'Path' column
        ;    The second value is the position of the 'Name' column
	; CloseEverything (Default 1 for yes)
	;    Should Everything GUI window be closed after transfering to TC
	; UseInstance (Empty for default instance)
        ;    Name of the Everything instance to be used for closing the GUI

; The contents of the following lines must be adjusted if necessary, e.g. path and parameter adjustments.
;********************************************************************************************************
        DestinationFile = C:\totalcmd\EV-Results\EV-Results.txt
        EverythingColumnPositions=2,1
        AddEndSlash = 1
        CloseEverything = 0
        UseInstance =
        Everything = C:\Everything\Everything64.exe
        TotalCmd = C:\totalcmd\TOTALCMD64.EXE
;********************************************************************************************************

    )"
    FileAppend, % iniContent, % iniFile, UTF-16
}
IniRead, DestinationFile, % iniFile, General, DestinationFile, %A_Space%
IniRead, EverythingColumnPositions, % iniFile, General, EverythingColumnPositions, 2`,1

IniRead, AddEndSlash, % iniFile, General, AddEndSlash, 1
IniWrite, %AddEndSlash%, % iniFile, General, AddEndSlash
IniRead, CloseEverything, % iniFile, General, CloseEverything, 1
IniWrite, %CloseEverything%, % iniFile, General, CloseEverything
IniRead, UseInstance, % iniFile, General, UseInstance, %A_Space%
IniWrite, %UseInstance%, % iniFile, General, UseInstance

IniRead, Everything, % iniFile, General, Everything, "C:\Everything\Everything64.exe"
IniRead, TotalCmd, % iniFile, General, TotalCmd, "C:\totalcmd\TOTALCMD64.EXE"

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

; Force error if none is given (or path doesn't exist)
SplitPath, DestinationFile, , dstPath
if (DestinationFile = "" || !InStr(FileExist(dstPath), "D")) {
    Msgbox, 16, Fatal error, Destination file definition is missing or illegal named !
    Return
}
if (EverythingColumnPositions = "" || !InStr(EverythingColumnPositions, ",")) {
    EverythingColumnPositions := "2,1"
}

columnArray := StrSplit(EverythingColumnPositions, ",")

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]:|\\\.*?\\")
	    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

	DestinationDir := SubStr(DestinationFile,1,InStr(DestinationFile, "\",,-1))
	Run %TotalCmd% /O /T /S LOADLIST:%DestinationFile%
	If (CloseEverything) {
             run %Everything% -instance "%UseInstance%" -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
}
Optional (recommended): Everything 1.5 – 1. statusbar/footer - 2. window_title_format, 3. dialog_title_format
    1. Copy and paste the following CODE into your Everything search box and then press ENTER:
      If successful, statusbar_format... is shown in the status bar for a few seconds.

      Code: Select all

      /statusbar_format=#if:<#result-count:==1,1 object,#TEXT:<#result-count:,#,###> objects> (#TEXT:<#file-result-count:,#,###> files, #TEXT:<#folder-result-count:,#,###> folders)
    2. Copy and paste the following CODE into your Everything search box and then press ENTER:
      If successful, statusbar_selection_format... is shown in the status bar for a few seconds.

      Code: Select all

      /statusbar_selection_format=Selected #if:<$selection-count:==$result-count:,all,#TEXT:$selection-count:,"#,###" of> #TEXT:$result-count:,"#,###" #ifs:<$folder-result-count:==0,files.,$file-result-count:==0,folders.,1,objects. (#if:<$file-selection-count:==$file-result-count:,all,#TEXT:$file-selection-count:,"#,###" of> #TEXT:$file-result-count:,"#,###" files#comma: #if:<$folder-selection-count:==$folder-result-count:,all,#TEXT:$folder-selection-count:,"#,###" of> #TEXT:$folder-result-count:,"#,###" folders.)> Size: #if:<$total-selection-size:!=$total-result-size:,#FORMATSIZE:$total-selection-size:,0 of >#FORMATSIZE:<$total-result-size:,0>.#if:<$total-result-size:<=1024, (#if:<$total-selection-size:!=$total-result-size:,#TEXT:$total-selection-size:,"#,###" of >#TEXT:$total-result-size:,"#,###" bytes.)>
  1. Option (recommended): Copy and paste the following CODE into your Everything search box and then press ENTER:
    If successful, window_title_format... is shown in the status bar for a few seconds.

    Code: Select all

    /window_title_format=$t $v$i?{ - ($i)}#if:<#isadmin:, - [Administrator]>
  2. Option (recommended): Copy and paste the following CODE into your Everything search box and then press ENTER:
    If successful, dialog_title_format... is shown in the status bar for a few seconds.

    Code: Select all

    /dialog_title_format=$s?{$s - }$v$i?{ - ($i)}[if:isadmin:," - [Administrator]"]
See also:
- 16. Send 'Everything' search results to Total Commander | Indexed network-/drives supported by TC
- Everything - Context menu items


Windows 11 Pro (x64) Version 22H2 (OS build Build 22621.1555)
TC 10.52 x64/x86 | 'Everything' 1.5.0.1343a (x64) | Search queries: Total Commander <=> 'Everything'
Open Everything GUI results with TC LOADLIST - AutoHotkey (.AHK) SCRIPT and GUIDANCE, discussions
Transfer 'Everything' GUI results to Total Commander - STEP-BY-STEP GUIDE, summary | AutoHotkey v1.1.36.02
Quick Access Popup (QAP) v11.6.1.5 (2023-04-11) | QuickAccessPopup-Hotkeys_SETTINGS
wetware05
Junior Member
Junior Member
Posts: 64
Joined: 2023-05-15, 16:10 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *wetware05 »

Thanks, tuska .

Very good script!!
Post Reply