Using VBA to search with Everything

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
vip_shadow
Posts: 23
Joined: Fri May 07, 2010 1:28 am

Using VBA to search with Everything

Post by vip_shadow »

From Microsoft Access VBA, I use the following line to search a file name :

Code: Select all

Shell "C:\Program Files\Everything\Everything.exe -s test.txt"
The file is searched successfully, but everything window remains minimized (or behind Excel/Access)
I have to select Everything's icon in taskbar to see the results.
Is there any way to bring Everything to front after each search?


thank you.
void
Developer
Posts: 16678
Joined: Fri Oct 16, 2009 11:31 pm

Re: Using VBA to search with Everything

Post by void »

Sounds like Everything is denied SetForegroundWindow privileges.

Is the program calling
Shell "C:\Program Files\Everything\Everything.exe -s test.txt"
in the foreground?

Try running:
Shell "C:\Program Files\Everything\Everything.exe -debug -s test.txt"

And look for the following in the debug console:
SetForegroundWindow failed xxxxxxxx
SetActiveWindow failed xxxxxxxx
SetForegroundWindow2 failed xxxxxxxx

What is the error code?



For a hack to force Everything into the foreground (not recommended):
  • In Everything, type in the following search and press ENTER:
    /set_foreground_window_attach_thread_input=1
  • If successful, set_foreground_window_attach_thread_input=1 is shown in the statusbar for a few seconds.
This will allow Everything to set itself as the foreground window, even when SetForegroundWindow privileges are denied.
vip_shadow
Posts: 23
Joined: Fri May 07, 2010 1:28 am

Re: Using VBA to search with Everything

Post by vip_shadow »

Thanks for the quick reply.
void wrote: Fri Nov 05, 2021 7:06 am Is the program calling
Shell "C:\Program Files\Everything\Everything.exe -s test.txt"
in the foreground?
Yes, It is.

void wrote: Fri Nov 05, 2021 7:06 am Try running:
Shell "C:\Program Files\Everything\Everything.exe -debug -s test.txt"

And look for the following in the debug console:
SetForegroundWindow failed xxxxxxxx
SetActiveWindow failed xxxxxxxx
SetForegroundWindow2 failed xxxxxxxx

What is the error code?
Followed your instruction. But I couldn't find any mention of any keywords listed above. This is what I received.
2021-11-05_16-23-51.jpg
2021-11-05_16-23-51.jpg (119.55 KiB) Viewed 5678 times
void wrote: Fri Nov 05, 2021 7:06 am For a hack to force Everything into the foreground (not recommended):
  • In Everything, type in the following search and press ENTER:
    /set_foreground_window_attach_thread_input=1
  • If successful, set_foreground_window_attach_thread_input=1 is shown in the statusbar for a few seconds.
Since this is not recommended, I leave it as the last solution.

Any further assist is much appreciated.
vip_shadow
Posts: 23
Joined: Fri May 07, 2010 1:28 am

Re: Using VBA to search with Everything

Post by vip_shadow »

I just tested the same procedure on 3 other PCs, running on Win 10 and Win 11.
All has the same results.
Everything stays in the background though the file is searched and the result is OK.
vip_shadow
Posts: 23
Joined: Fri May 07, 2010 1:28 am

Re: Using VBA to search with Everything

Post by vip_shadow »

void wrote: Fri Nov 05, 2021 7:06 am
For a hack to force Everything into the foreground (not recommended):
  • In Everything, type in the following search and press ENTER:
    /set_foreground_window_attach_thread_input=1
  • If successful, set_foreground_window_attach_thread_input=1 is shown in the statusbar for a few seconds.
I just tested this on a machine that I don't use so often.
Copied and pasted the above (including /) into Everything.
Nothing appeared in the status bar.
This was a Win 10 machine.
vip_shadow
Posts: 23
Joined: Fri May 07, 2010 1:28 am

Re: Using VBA to search with Everything

Post by vip_shadow »

Any further insight on this please?
void
Developer
Posts: 16678
Joined: Fri Oct 16, 2009 11:31 pm

Re: Using VBA to search with Everything

Post by void »

From the shell function documentation, please try calling:

Code: Select all

Shell "C:\Program Files\Everything\Everything.exe -s test.txt" 1
I'm not sure why the default is to run minimized.
vip_shadow
Posts: 23
Joined: Fri May 07, 2010 1:28 am

Re: Using VBA to search with Everything

Post by vip_shadow »

Million thanks.
Problem solved.
Post Reply