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

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
WKen
Posts: 183
Joined: 21 Feb 2023, 00:01

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

07 May 2023, 07:20

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?
User avatar
mikeyww
Posts: 26973
Joined: 09 Sep 2014, 18:38

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

07 May 2023, 07:25

What information are you trying to get?
WKen
Posts: 183
Joined: 21 Feb 2023, 00:01

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

07 May 2023, 07:52

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]
User avatar
mikeyww
Posts: 26973
Joined: 09 Sep 2014, 18:38

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

07 May 2023, 08:37

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'
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

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

07 May 2023, 09:01

if u want speed, use the dll or WM_COPYDATA

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: alawsareps, aleksbor, reborn, vmech and 131 guests