Page 1 of 1

Pass the command line to the program and get the return value

Posted: 07 May 2023, 07:20
by WKen
viewtopic.php?p=516462#p516462
The code in the link works but is slow and doesn't hide the window, is there a fast way to get the value returned by the Everything tool?

Re: Pass the command line to the program and get the return value

Posted: 07 May 2023, 07:25
by mikeyww
What information are you trying to get?

Re: Pass the command line to the program and get the return value

Posted: 07 May 2023, 07:52
by WKen
For example

Code: Select all

#Requires AutoHotkey v2.0.2 

 es := "C:\Program Files\Everything\es.exe"
 folder := "H:\Folders\Pics\"
 rand := Random(1, 9)
 arg := folder . " !.txt " . rand

 RunWait es " " arg " -export-txt " A_Temp "\esOutput.txt", , "Hide"

 FileEncoding "UTF-8"
 esOutput := FileRead(A_Temp "\esOutput.txt")
 if !esOutput
    return

 myArray := StrSplit(esOutput, "`r`n")
 randLine := Random(1, myArray.Length)
 msgbox MyArray[randLine]

Re: Pass the command line to the program and get the return value

Posted: 07 May 2023, 08:37
by mikeyww
This took 100-150 ms and showed no command window. It is essentially the same as your script. Nonetheless, if you are looking for text within files, Everything is not designed to do it. By this, I simply mean that the program would need to search within every file, and this process is not fast. Other programs (e.g., dtSearch) are available that index all words in all files and would provide faster output for this type of search.

Code: Select all

#Requires AutoHotkey v2.0
start    := A_TickCount
es       := A_ProgramFiles '\Everything\es.exe'
es       := 'd:\Q\everything\es.exe'
folder   := 'H:\Folders\Pics\'
folder   := A_ScriptDir
arg      := folder ' !.txt ' Random(1, 9)
out      := A_Temp '\esOutput.txt'
Try FileRecycle out
RunWait es ' ' arg ' -export-txt ' out,, 'Hide'
; FileEncoding 'UTF-8'
If !esOutput := FileRead(out)
 Return
line     := StrSplit(esOutput, '`r`n')
randLine := Random(1, line.Length)
MsgBox line[randLine] '`n`nTime elapsed: ' A_TickCount - start ' ms'

Re: Pass the command line to the program and get the return value

Posted: 07 May 2023, 09:01
by swagfag
if u want speed, use the dll or WM_COPYDATA

Re: Pass the command line to the program and get the return value

Posted: 07 May 2023, 09:43
by mikeyww