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: Hacker, petermad, Stefan2, white

Post Reply
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6950
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, Version 24H2 (OS Build 26100.3915)
TC 11.51 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64
User avatar
tuska
Power Member
Power Member
Posts: 4046
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!!
User avatar
tuska
Power Member
Power Member
Posts: 4046
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

In Everything 1.5.0.1384a+ - 28.11.2024, there have been changes regarding the 'Status Bar Format'.

As a result, the codes given here under points 1.a and 1.b change as follows
"Optional (recommended): Everything 1.5 – 1. statusbar/footer - 2. window_title_format, 3. dialog_title_format":

1.a. is as follows from Everything 1.5.0.1384a+ onwards -> statusbar_format - used when there's no selection
Example: 1 133 460 items (820 782 files, 312 678 folders)

Code: Select all

<IF:$result-count:==1,"1 item",<TEXT:$result-count:,"#,###"> items> (<TEXT:$file-result-count:,"#,###"> files, <TEXT:$folder-result-count:,"#,###"> folders)
1.b. is as follows from Everything 1.5.0.1384a+ onwards -> statusbar_selection_format - used when there's multiple items selected
Example: Selected 3 of 1 133 461 items (0 of 820 783 files, 3 of 312 678 folders) | Size: 46,31 KiB of 703,44 GiB

Code: Select all

Selected <IF:$selection-count:==$result-count:,"all",<TEXT:$selection-count:,"#,###"> of> <TEXT:$result-count:,"#,###"> items (<IF:$file-result-count:,<IF:$file-selection-count:==$file-result-count:,"all",<TEXT:$file-selection-count:,"#,###"> of> <TEXT:$file-result-count:,"#,###">,no> files, <IF:$folder-result-count:,<if:$folder-selection-count:==$folder-result-count:,"all",<TEXT:$folder-selection-count:,"#,###"> of> <TEXT:$folder-result-count:,"#,###">,no> 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.c. NEW (not covered by the above post)) -> statusbar_selected_item_format - used when there's a single item selected
Example:
1 item (1 of 312 678 folders) | Size:15,43 KiB | Date Modified: 29.11.2024 12:22 | Date Created: 29.11.2024 12:22 | Date Accessed: 29.11.2024 12:22 | Path: C:\totalcmd\Migration\_Forumsanfragen\'Everything' by default on 'Find files'

Code: Select all

1 item (1 of [if:$folder-selection-count:,[text:$folder-result-count:,"#,###"] folders,[text:$file-result-count:,"#,###"] files])[if:$file-selection-count:," | Extension: "$extension:] | Size:$s | Date Modified: $m | Date Created: $c | Date Accessed: $a | Path: $f
In the current version, Everything 1.5.0.1385a (x64), these codes can be entered as follows:
Menu "Tools" > Options... > Advanced > Show settings containing: >
statusbar_format ... - OR - ... statusbar_selection_format ... - OR - statusbar_selection_format -> ...
PASTE THE CODE FROM ABOVE into the appropriate field:
- Value for statusbar_format
- Value for statusbar_selection_format
- Value for statusbar_selected_item_format

Confirm the codes with “OK”.

An Everything restart is NOT required.
In the footer, you should immediately see e.g. the format from point 1.a. (statusbar_format): ### items (### files, ### folders).


Reference: Status Bar Format

void (Author) - 01.12.2024 wrote:I will consider renaming:
statusbar_selected_item_format => statusbar_single_selection_format
statusbar_selection_format =>     statusbar_multiple_selection_format
mihail_ms
Junior Member
Junior Member
Posts: 24
Joined: 2024-06-01, 00:00 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *mihail_ms »

If the search bar is empty, the script freezes and does not close the ahk icon near the clock...

Если строка поиска пустая скрипт зависает и не закрывает значок ahk возле часов..
User avatar
tuska
Power Member
Power Member
Posts: 4046
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

mihail_ms wrote: 2024-12-12, 22:16 UTC If the search bar is empty, the script freezes and does not close the ahk icon near the clock...

Если строка поиска пустая скрипт зависает и не закрывает значок ahk возле часов..
Nice find.
But the script was actually made to transfer search results from 'Everything' to Total Commander.

I'm curious to see what the AHK expert has to say about it.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6950
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Open Everything GUI results with TC LOADLIST

Post by *Horst.Epp »

mihail_ms wrote: 2024-12-12, 22:16 UTC If the search bar is empty, the script freezes and does not close the ahk icon near the clock...

Если строка поиска пустая скрипт зависает и не закрывает значок ahk возле часов..
Not confirmed
If the search bar is empty and the script runs with its assigned hotkey
it produces an error message:

Code: Select all

---------------------------
ExportEverythingWindow.exe
---------------------------
Search result is Empty, Nothing to do ...
---------------------------
OK   
---------------------------
Windows 11 Home, Version 24H2 (OS Build 26100.3915)
TC 11.51 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64
User avatar
tuska
Power Member
Power Member
Posts: 4046
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

2Horst.Epp

When I call a button with command (search bar is empty!):

Code: Select all

%COMMANDER_PATH%\Tools\AutoHotkey\Skripte\EV_SearchResults_to_TC-panel\SEND_EV-RESULTS_to_TC-panel_(A)_CloseEverything-0_TAB-Search_result_(A).exe
the AHK icon is displayed in the systray until I close it by right-clicking on the icon and clicking on “Exit”.

In this case, I will NOT receive an error message.

EDIT:
I get this
error message: wrote: Error: Memory limit reached (see #MaxMem in the help file).

Line#
---> 124: fullContent .= full "
"

The current thread will exit.
... and the icon was removed from the systray.
Windows 11 Pro (x64) Version 24H2 (OS Build 26100.2605) - Latest revision date: 2024-12-10
https://aka.ms/Windows11/ReleaseInfo
; https://learn.microsoft.com/en-us/windows/release-health/windows11-release-information

Code: Select all

Sources	 		msinfo32.exe (System Information), Windows logo key + Pause key (System > About), Search: winver[.exe]
.
OS Name			Microsoft Windows 11 Pro
Version			10.0.26100 Build 26100
Processor		Intel(R) Core(TM) i5-12600K 12th Gen, 3.70 GHz, 10 Cores, 16 Logical Processors
Installed RAM		32.0 GB (22.6 GB usable)
System type		64-bit operating system, x64-based processor

Edition			Windows 11 Pro
Version			24H2
Installed on		22/11/2024
OS Build		26100.2605
Experience		Windows Feature Experience Pack 1000.26100.36.0
User avatar
tuska
Power Member
Power Member
Posts: 4046
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

Just out of interest, I typed the following into the 'Everything' search box:

Code: Select all

c:\Windows
This is what appeared in the status bar of 'Everything' (immediately, i.e. real-time!):
237 954 items (192 478 files, 45 476 folders)

The transfer using the button in TC
FROM: 'Everything' 1.5.0.1388a (x64)
TO    : Total Commander 11.50RC2 (x64)
took about 2 minutes and 10 seconds (no cache!).
Tab “Search result:” was automatically created in Total Commander.

Code: Select all

Name/Ext	Size		Date/Time		Attr.	Path
EV-Results.txt	58 784 578	13.12.2024 11:51	-a--	C:\totalcmd\EV-Results\
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6950
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Open Everything GUI results with TC LOADLIST

Post by *Horst.Epp »

2Tuska
As I said, no such problem here.
Maybe you run another version of the script or any non-standard settings of Everything itself ?

The AHK script does not need any parameters !
It starts with a hotkey (from QAP in my case)
and has no problem to terminate when nothing is entered into the search bar
and terminates with the error shown above.

The script I use is the compiled version of this

Code: Select all

; Transfer Everything GUI results to TC
; Authors: Horst.Epp & Ovg (based on a script from user Highend in XYplorer forum)
; Last modified: 04.10.2022 (Changed regex by Ovg)
 
; 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:\Tools\Wincmd\Scripts\Results\Everything.txt
        EverythingColumnPositions=2,1
        AddEndSlash = 1
        CloseEverything = 1
        UseInstance =
        Everything = C:\Tools\Everything\Everything64.exe
        TotalCmd = C:\Tools\Wincmd\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:\Tools\Everything\Everything64.exe"
IniRead, TotalCmd, % iniFile, General, TotalCmd, "C:\Tools\Wincmd\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
}
The ini file it reads looks like this

Code: Select all

[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
; UseInstace (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:\Tools\Wincmd\Scripts\Results\Everything.txt
EverythingColumnPositions=2,1
AddEndSlash =0
CloseEverything =1
UseInstance =
Everything = C:\Tools\Everything\Everything64.exe
TotalCmd = C:\Tools\Wincmd\totalcmd64.exe
;********************************************************************************************************
Windows 11 Home, Version 24H2 (OS Build 26100.3915)
TC 11.51 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64
User avatar
tuska
Power Member
Power Member
Posts: 4046
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

Horst.Epp wrote: 2024-12-13, 16:46 UTC 2Tuska
Maybe you run another version of the script or any non-standard settings of Everything itself ?
No, certainly not - the AHK script is also from October 4, 2022.

Incidentally, my script is the same (with my settings!) as the script you announced in the first post:
"Zuletzt geändert von Horst.Epp am 15.10.2022 15:30, insgesamt 45-mal geändert."

Your script no longer matches this script 100%:
The second and third (commented out) lines are different from the script given in the first post.

The .ahk file is basically (paths) identical except for: CloseEverything =0 (on my PC)

I set
AddEndSlash =1
CloseEverything =0

in the .ini file

The error message indicates this:
error message wrote: Error: Memory limit reached (see #MaxMem in the help file).
Line#
---> 124: fullContent .= full "
"

The current thread will exit.
I don't have such an entry in line 124, but line 154 contains the following:
fullContent .= full "`n"

I am not interested in the AHK messages mentioned so far,
because when there is a search query in the search box,
I have never received an error message.
mihail_ms
Junior Member
Junior Member
Posts: 24
Joined: 2024-06-01, 00:00 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *mihail_ms »

я пользую скрипт идентичный из сообщения *Хорста.Эппа » 2024-12-13, 19:46 UTC

Возможно у меня не вывозит мой компютер
я запускаю через контекстное меню
open_file_command=$exec("%ahk1%" "%COMMANDER_PATH%\Plugins\Everything\1.ahk")
где %ahk1% - путь к %COMMANDER_PATH%\Scripts\ahk\ahk.exe

кстати ini увы не понимает %COMMANDER_PATH%
_____________________________________________________
I'm using a script identical to the one from Horst's message.Eppa " 2024-12-13, 19:46 UTC

Maybe my computer is not taking out
I run it through the context menu
open_file_command=$exec("%ahk1%" "%COMMANDER_PATH%\Plugins\Everything\1.ahk")
where %ahk1% is the path to %COMMANDER_PATH%\Scripts\ahk\ahk.exe

by the way, alas, ini does not understand %COMMANDER_PATH%
User avatar
tuska
Power Member
Power Member
Posts: 4046
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

The 'Everything' context menu does not understand the Total Commander(!) environment variable %COMMANDER_PATH%.
This means that the absolute path, e.g. C:\totalcmd\Plugins\..., must be specified in Everything.
mihail_ms
Junior Member
Junior Member
Posts: 24
Joined: 2024-06-01, 00:00 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *mihail_ms »

т.к. у меня всегда запущен тотал, то все работает

because I always have total running, then everything works

open_file_command=$exec("%ahk1%" "%COMMANDER_PATH%\Plugins\Everything\1.ahk")
Post Reply