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: 6449
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Open Everything GUI results with TC LOADLIST

Post by *Horst.Epp »

I have cleaned up the code for an illegal destination file definition
and updated the first post with this version.
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
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 »

2Horst.Epp
Great!
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
For the test at that time, I used this column arrangement:

Code: Select all

Name|Path|Extension|Size|Date Modified|Date Created|Date Accessed|Title|Subject|Tags|Comment|Authors	--> 12 columns
After I repeated the test based on your note, I was completely perplexed,
because this time the files with comments were present in the search result in TC.
But maybe your script sometimes needs a PC restart before execution. :wink: :)

I have done tests with the files that did not arrive in TC before, with these versions:
- 2021-10-16_1324_Ovg.exe
- 2021-10-17_1804_First-Post.exe
and also changed the order of the comment column (behind: Date Accessed) several times.

I therefore consider the issue of comments to be closed.

(If, contrary to expectations, an error message regarding comments still appears, I will change the comment,
i.e. paste it into a text editor and format it so that the comment is only on a single line
and then copy/paste it into the file properties).

I'm sorry to have bothered you with this topic again. :(

For further tests, I use these scripts (with further comments added) for the sole purpose,
to choose whether the window in Everything stays open or closes.

At least one more Everything instance is required for this purpose (total: 2 Everything instances), e.g.
- Everything 1.5.0.1280a (x64) ................. (C:\Tools\Everything\Everything64.exe)
- Everything 1.5.0.1280a (x64) - (PRIVATE) ... (C:\Tools\Everything\Everything_PRIVATE\Everything64.exe -instance "PRIVATE" -startup)
and 2 AHK-scripts are required.

Here are the 2 AHK scripts:
2021-10-17_1804_First-Post.AHK ---------------> Everthing (I call it the "main instance")

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
;The contents of lines which are underlined with '*'-asterisk are to be adjusted if necessary, e.g. path and parameter adjustments.
;
; 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]
        ; 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
        ;****************************

	;====================================================================================================
	;https://ghisler.ch/board/viewtopic.php?p=406266#p406266 ... Description of PARAMETERS and how to change the AHK-INI FILE
	;https://www.ghisler.ch/board/viewtopic.php?p=406296#p406296 ADDENDSLASH=; Everything: FOLDER_APPEND_PATH_SEPARATOR=
	;====================================================================================================

    )"
    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")) {
    Msgbox, 16, Fatal error, Destination file does not exist!
    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]:")
            {
              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 "C:\Tools\Everything\Everything64.exe" -instance "PRIVATE" -close
	;   ***********************************************************************************************************************************************************

	; Quick Access Popup (QAP) - Hotkeys: https://www.ghisler.ch/board/viewtopic.php?p=406233#p406233 | https://www.quickaccesspopup.com/tag/shortcuts/
	;==============================================================================================================================================================

    }
    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
}
2021-10-17_1804_First-Post_instance.AHK ---> Everything - Instance "PRIVATE" (1 further instance)

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
;The contents of lines which are underlined with '*'-asterisk are to be adjusted if necessary, e.g. path and parameter adjustments.
;
; 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]
        ; 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
        ;****************************

	;====================================================================================================
	;https://ghisler.ch/board/viewtopic.php?p=406266#p406266 ... Description of PARAMETERS and how to change the AHK-INI FILE
	;https://www.ghisler.ch/board/viewtopic.php?p=406296#p406296 ADDENDSLASH=; Everything: FOLDER_APPEND_PATH_SEPARATOR=
	;====================================================================================================

    )"
    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")) {
    Msgbox, 16, Fatal error, Destination file does not exist!
    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]:")
            {
              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 "C:\Tools\Everything\Everything64.exe" -close
	;   ***********************************************************************************************************************************************************

	; Quick Access Popup (QAP) - Hotkeys: https://www.ghisler.ch/board/viewtopic.php?p=406233#p406233 | https://www.quickaccesspopup.com/tag/shortcuts/
	;==============================================================================================================================================================

    }
    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
}
If you should change the script again and I should test it,
I would prefer the variant Everything - Instance "PRIVATE".
(because there I have set that the window in Everything remains open).

Thanks!


Windows 10 Pro (x64) Version 21H1 (OS build 19043.1288)
TC 10.00 x64/x86 | 'Everything' 1.5.0.1280a (x64)
Last edited by tuska on 2021-10-17, 22:01 UTC, edited 1 time in total.
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 »

In this context ("EV-Results.txt") and for further tests, I would like to find the following in a text file (e.g. EmEditor [RegEx]):
  1. Lines where N: is present at the beginning
  2. Lines that do NOT have N: at the beginning
  3. Lines that have a backslash at the end
  4. Lines that do NOT have a backslash at the end
With effort, I could get at least part of what I want,
but a search query would make this activity much easier.

Please support.
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 »

tuska wrote: 2021-10-17, 21:07 UTC 2Ovg

I'm sorry to have bothered you with this topic again. :(

For further tests, I use these scripts (with further comments added) for the sole purpose,
to choose whether the window in Everything stays open or closes.

At least one more Everything instance is required for this purpose (total: 2 Everything instances), e.g.
- Everything 1.5.0.1280a (x64) ................. (C:\Tools\Everything\Everything64.exe)
- Everything 1.5.0.1280a (x64) - (PRIVATE) ... (C:\Tools\Everything\Everything_PRIVATE\Everything64.exe -instance "PRIVATE" -startup)
and 2 AHK-scripts are required.....
Sorry, due to my poor English I don't understood what you want. could you please to explain once more with more details. And probably I need exact
titles of your EV windows: https://disk.yandex.com/i/K-5fcSqkxjoDxw
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

Your regexp's

1. Lines where N: is present at the beginning

Code: Select all

(?i)^N:.*$
2. Lines that do NOT have N: at the beginning

Code: Select all

(?i)^[^N]:.*$
3. Lines that have a backslash at the end

Code: Select all

^.*\\$
4. Lines that do NOT have a backslash at the end

Code: Select all

^.*[^\\]$
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
Ovg wrote: 2021-10-18, 03:08 UTC ... I don't understood what you want. could you please to explain once more with more details.
And probably I need exact titles of your EV windows: ...
I meant I would have liked to have the script with spoiler title:
2021-10-17_1804_First-Post_instance.AHK ---> Everything - Instance "PRIVATE" (1 further instance)

You could of course also take the script with the following spoiler title:
2021-10-17_1804_First-Post.AHK ---------------> Everthing (I call it the "main instance")

... because the scripts only differ in 1 line:

Main instance - title: Everything 1.5.0.1280a (x64)

Code: Select all

run "C:\Tools\Everything\Everything64.exe" -instance "PRIVATE" -close
The Everything window remains OPEN.

Further instance - title: Everything 1.5.0.1280a (x64) - (PRIVATE)
(I use another instance mainly because I don't want to have to switch constantly between English and the home language).

Code: Select all

run "C:\Tools\Everything\Everything64.exe" -close
The Everything window is CLOSED.

During the tests, I noticed that the
- Everything window was closed
- The Everything window of the instance (PRIVATE) remained open.
and have therefore swapped the above parameters.
(In practice, I see no other possibility at the moment).

[If you only use Everything without instance, this line must be used:

Code: Select all

run "C:\Tools\Everything\Everything64.exe" -close
This then corresponds to the script in the first post]

I am glad that you asked again, because I have added a few more comment lines to the script,
namely your RegEx parameters -> thank you very much ... and TC commands!
Btw, bookmarks, e.g. in EmEditor, make it much easier to find the lines to be edited.

I therefore ask you to use the following script:
2021-10-17_1804_Script

Code: Select all

;https://www.ghisler.ch/board/viewtopic.php?t=75439 ...... Open Everything GUI results with TC LOADLIST (Thanks to Horst.Epp & Ovg!)
;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
;
;The contents of lines which are underlined with '*'-asterisk are to be adjusted if necessary, e.g. path and parameter adjustments.
;**********************************************************************************************************************************
;TC: cm_SwitchHidSys -> Everything shows hidden files automatically, in TC hidden files must first be shown with this command.
;TC: cm_SwitchIgnoreList -> TC's ignore list is NOT OBSERVED by the AHK script (this can lead to unexpected search results in TC).
;
;EV-Results.txt - RegEx queries (thanks to Ovg!)
;1. Lines where N: is present at the beginning, e.g. ..... (?i)^N:.*$
;2. Lines that do NOT have N: at the beginning, e.g. ..... (?i)^[^N]:.*$
;3. Lines that have a backslash at the end ............... ^.*\\$
;4. Lines that do NOT have a backslash at the end ........ ^.*[^\\]$
;- Notepad++ | EV-Results.txt -> Edit with Notepad++ ...
;  Search -> Find... Ctrl+F -> Find what : (e.g.) -> (?i)^N:.*$ -> ◉ Regular expression -> Count -> Search result in status bar
;- EmEditor  | Field: Filter | [✓] Use Regular Expressions | Incremental Search | Ctrl+A in Search result: result in status bar
;
;==================================================================================================================================
; 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]
        ; 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
        ;****************************

	;====================================================================================================
	;https://ghisler.ch/board/viewtopic.php?p=406266#p406266 ... Description of PARAMETERS and how to change the AHK-INI FILE
	;https://www.ghisler.ch/board/viewtopic.php?p=406296#p406296 ADDENDSLASH=; Everything: FOLDER_APPEND_PATH_SEPARATOR=
	;====================================================================================================

    )"
    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")) {
    Msgbox, 16, Fatal error, Destination file does not exist!
    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]:")
            {
              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 "C:\Tools\Everything\Everything64.exe" -instance "PRIVATE" -close
	;   ***********************************************************************************************************************************************************

	; Quick Access Popup (QAP) - Hotkeys: https://www.ghisler.ch/board/viewtopic.php?p=406233#p406233 | https://www.quickaccesspopup.com/tag/shortcuts/
	;==============================================================================================================================================================

    }
    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!
Last edited by tuska on 2021-10-18, 10:20 UTC, edited 1 time in total.
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

Well.

Script should use private instance of EV and close private instance upon completion?

Script shouldn't use "main" instance of EV and should leave it intact upon completion?

Am I right?

PS. does regexps work for 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
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 »

2Horst.Epp
2tuska
I want to add to ini file path to EV and path to TC. What do you think?
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-18, 10:06 UTC 2tuska
Script should use private instance of EV and close private instance upon completion?
Script shouldn't use "main" instance of EV and should leave it intact upon completion?
Am I right?

PS. does regexps work for you?
For me, everything fits as it is.
- If only Everything is used (no further instance), the window closes.
- With 2 instances, I have the choice of closing Everything window or leaving it open.

Regex works fine.
Thanks again!
Ovg wrote: 2021-10-18, 10:13 UTC 2tuska
I want to add to ini file path to EV and path to TC. What do you think?
I don't see a problem with that, but for me it would be a step forward,
because in case of doubt (e.g. for forum enquiries) it would be enough to post the .ini file (and not the whole script).

I am unsure whether this parameter should also be added to the .ini file:

Code: Select all

% A_Temp "\~EV-Results.txt"
... it certainly couldn't do any harm...

PS: I have made minimal changes to the previously announced script.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6449
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Open Everything GUI results with TC LOADLIST

Post by *Horst.Epp »

Ovg wrote: 2021-10-18, 10:13 UTC 2Horst.Epp
2tuska
I want to add to ini file path to EV and path to TC. What do you think?
Good idea
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
Horst.Epp
Power Member
Power Member
Posts: 6449
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Open Everything GUI results with TC LOADLIST

Post by *Horst.Epp »

tuska wrote: 2021-10-18, 10:32 UTC
I am unsure whether this parameter should also be added to the .ini file:

Code: Select all

% A_Temp "\~EV-Results.txt"
... it certainly couldn't do any harm...
No for me.
I have removed the replacement code for missing or illegal destination file.
Look into the first post, it displays an error message and terminates in this case.
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 »

Horst.Epp wrote: 2021-10-18, 10:56 UTC
tuska wrote: 2021-10-18, 10:32 UTC
I am unsure whether this parameter should also be added to the .ini file:

Code: Select all

% A_Temp "\~EV-Results.txt"
... it certainly couldn't do any harm...
No for me.
I have removed the replacement code for missing or illegal destination file.
Look into the first post, it displays an error message and terminates in this case.
I don't know what you just changed in the code.
A_Temp "\~EV-Results.txt" ... is still in the code. :roll:
Zuletzt geändert von Horst.Epp am 18.10.2021 12:58, insgesamt 9-mal geändert.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6449
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Open Everything GUI results with TC LOADLIST

Post by *Horst.Epp »

tuska wrote: 2021-10-18, 11:11 UTC I don't know what you just changed in the code.
A_Temp "\~EV-Results.txt" ... is still in the code. :roll:
You are right :(
I missed to change the default string, its now fixed.
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
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 »

New Version, paths to EV and TC was added to ini file

Code: Select all

;https://www.ghisler.ch/board/viewtopic.php?t=75439 ...... Open Everything GUI results with TC LOADLIST (Thanks to Horst.Epp & Ovg!)
;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
;
;The contents of lines which are underlined with '*'-asterisk are to be adjusted if necessary, e.g. path and parameter adjustments.
;**********************************************************************************************************************************
;TC: cm_SwitchHidSys -> Everything shows hidden files automatically, in TC hidden files must first be shown with this command.
;TC: cm_SwitchIgnoreList -> TC's ignore list is NOT OBSERVED by the AHK script (this can lead to unexpected search results in TC).
;
;EV-Results.txt - RegEx queries (thanks to Ovg!)
;1. Lines where N: is present at the beginning, e.g. ..... (?i)^N:.*$
;2. Lines that do NOT have N: at the beginning, e.g. ..... (?i)^[^N]:.*$
;3. Lines that have a backslash at the end ............... ^.*\\$
;4. Lines that do NOT have a backslash at the end ........ ^.*[^\\]$
;- Notepad++ | EV-Results.txt -> Edit with Notepad++ ...
;  Search -> Find... Ctrl+F -> Find what : (e.g.) -> (?i)^N:.*$ -> ? Regular expression -> Count -> Search result in status bar
;- EmEditor  | Field: Filter | [?] Use Regular Expressions | Incremental Search | Ctrl+A in Search result: result in status bar
;
;==================================================================================================================================
; 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]
        ; 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
        Everything = C:\Tools\Everything\Everything64.exe
        TotalCmd = D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\TOTALCMD64.EXE
        ;****************************

	;====================================================================================================
	;https://ghisler.ch/board/viewtopic.php?p=406266#p406266 ... Description of PARAMETERS and how to change the AHK-INI FILE
	;https://www.ghisler.ch/board/viewtopic.php?p=406296#p406296 ADDENDSLASH=; Everything: FOLDER_APPEND_PATH_SEPARATOR=
	;====================================================================================================

    )"
    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
IniRead, Everything, % iniFile, General, Everything, "C:\Tools\Everything\Everything64.exe"
IniRead, TotalCmd, % iniFile, General, TotalCmd,"D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\TOTALCMD64.EXE"
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")) {
    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]:")
            {
              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 %DestinationDir%



;	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 "C:\Tools\Everything\Everything64.exe" -instance "PRIVATE" -close
run %everything% -instance "PRIVATE" -close
	;   ***********************************************************************************************************************************************************

	; Quick Access Popup (QAP) - Hotkeys: https://www.ghisler.ch/board/viewtopic.php?p=406233#p406233 | https://www.quickaccesspopup.com/tag/shortcuts/
	;==============================================================================================================================================================

    }
    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
}
2Horst.Epp
Please change names and paths to your own
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