Populating the clipboard

Discussion related to "Everything" 1.5 Alpha.
Post Reply
Bamsen
Posts: 24
Joined: Thu Dec 09, 2021 9:16 am

Populating the clipboard

Post by Bamsen »

In a previous case I learned that I can use clipboard: to search for whatever is on the clipboard.
Is it possible to set the clipboard?

I know I can assign f.x. File Copy to a key, but I would like to be able to set the clipboard to the value of any column or columns.
Also I would like to populate the clipboard at any change of selected row in Everything.

My use case would be:
First window of Everything with some search that populates custom column column-0: with some value
Second window of Everything that uses clipboard: to do a new search.
When I now select or use arrow keys in the first window, the second window will automatically update.

This is f.x. a more flexible solution to the siblings problem.
void
Developer
Posts: 16670
Joined: Fri Oct 16, 2009 11:31 pm

Re: Populating the clipboard

Post by void »

I don't have an easy way to do this with Everything.

You would have to set one window to clipboard: then from the other window right click the cell and click Copy <property-name>



I'll look into adding commands to make this easier.
Bamsen
Posts: 24
Joined: Thu Dec 09, 2021 9:16 am

Re: Populating the clipboard

Post by Bamsen »

Maybe some form of direct communication to not disturb the clipboard...
https://learn.microsoft.com/en-us/windo ... unications
void
Developer
Posts: 16670
Joined: Fri Oct 16, 2009 11:31 pm

Re: Populating the clipboard

Post by void »

The result list in Everything is an emulated SysListView32.

There's third party tools to pull data from a SysListView32 and perform actions.
Autohotkey comes to mind.
Bamsen
Posts: 24
Joined: Thu Dec 09, 2021 9:16 am

Re: Populating the clipboard

Post by Bamsen »

I am using AutoHotkey a lot! :D It is the second most useful app I have. (After Everything of cause)
But I have not used it to pull data from SysListView32 before. I will test....
horst.epp
Posts: 1443
Joined: Fri Apr 04, 2014 3:24 pm

Re: Populating the clipboard

Post by horst.epp »

Here is an example how to pull data from the SysListView32.
We use it to generate a text file which can be loaded into Total Commander and other 3rd party file managers.

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
}

Bamsen
Posts: 24
Joined: Thu Dec 09, 2021 9:16 am

Re: Populating the clipboard

Post by Bamsen »

From AutoHotkey I can call DLLs and use Windows SendMessage.
Is there a way to use this functionality to set the search criteria of a Everything window?
Today I have to move the cursor to the search bar and paste (type) my criteria.
void
Developer
Posts: 16670
Joined: Fri Oct 16, 2009 11:31 pm

Re: Populating the clipboard

Post by void »

All UI commands are listed in the Everything SDK.

With these commands you can setup the window state, like match case, match regex etc...
After setting up the search state, just set the search box window text to your search.

All controls in Everything have a well defined ID.
The Everything Window has a class called "EVERYTHING"
The search box has a UI ID of: 10007



/copy is another option you might find useful for pulling data out of Everything 1.5.
Setup a bookmark to call:
/copy $fullpath:,$size:,$dm:
Customize the properties and formatting as needed.
Add a shortcut key and have your script send this key to Everything.



Copying as TSV is another option:
  • In Everything 1.5, from the Tools menu, click Options.
  • Click the Keyboard tab on the left.
  • To the right of Show commands containing, search for:
    tsv
  • Select Result List | Copy as TSV.
    (there's also Copy as CSV)
  • Click Add....
  • Press a new keyboard shortcut and click OK.
  • Click OK.
Bamsen
Posts: 24
Joined: Thu Dec 09, 2021 9:16 am

Re: Populating the clipboard

Post by Bamsen »

Hmmm....
I am trying the following AHK script:

Code: Select all

#Requires AutoHotkey v2.0+
#SingleInstance force
SetTitleMatchMode(2)

; Start GUI and get handle
Run('"C:\Program Files\Everything 1.5a\Everything64.exe" -newwindow -x 200 -y 150 -width ' A_ScreenWidth - 400 ' -height ' A_ScreenHeight - 600, , , &MainHwnd)
KeyWait("LButton", "D T5")
KeyWait("LButton")
MainHwnd := WinExist("A")


EverythingDll := "C:\Program Files\Everything 1.5a\Everything64.dll"
EverythingMod := DllCall("LoadLibrary", "Str", EverythingDll, "Ptr")
Build := DllCall(EverythingDll . "\Everything_GetBuildNumber", "Double")
DllCall(EverythingDll . "\Everything_SetReplyWindow", "Ptr", MainHwnd)
DllCall(EverythingDll . "\Everything_SetSearch", "Str", "morten")
DllCall(EverythingDll . "\Everything_Query", "Int", false)
Num :=  DllCall(EverythingDll . "\Everything_GetNumResults", "UInt")
; Show the results
MsgBox "Hwnd: " . MainHwnd . " Mod: " . EverythingMod . " Build: " . Build . " Result: " Num
DllCall("FreeLibrary", "Ptr", EverythingMod)
The message box shows: Hwnd: 2102228 Mod: 6442450944 Build: 0.0 Result: 0

Since I am not even getting a build number I am clearly missing something obvious...
Tips please?

I am running latest version Everything 1.5.0.1354a(x64)
(I am just trying to get "morten" to be the search text in my GUI)
void
Developer
Posts: 16670
Joined: Fri Oct 16, 2009 11:31 pm

Re: Populating the clipboard

Post by void »

The Everything SDK DLL should not be used to set the search in an Everything Search Window.

The Everything SDK DLL is designed to search your Everything index without the UI.
void
Developer
Posts: 16670
Joined: Fri Oct 16, 2009 11:31 pm

Re: Populating the clipboard

Post by void »

Set search text on Ctrl + Shift + Z:

Code: Select all

#Ifwinactive ahk_class EVERYTHING
	^+z::
	{
		ControlSetText, Edit1, "my search"
		return
	}
#Ifwinactive
Bamsen
Posts: 24
Joined: Thu Dec 09, 2021 9:16 am

Re: Populating the clipboard

Post by Bamsen »

That was exactly what I needed!! :D
AutoHotkey (like Everything) has an extreme amount of possibilities and even if I have used it for a long time, I did not know I could directly put text in other applications controls other then with key presses.

Now my duplicates finding mission is back on track and my three Everything GUI windows are working in perfect unison.

Thank you for your excellent help and immense patience! You (and your product) are the best! :D
Post Reply