Highlight a Folder (by Name or Path) in the active Windows 10 Explorer window Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jwinfl
Posts: 89
Joined: 16 Aug 2017, 12:37

Highlight a Folder (by Name or Path) in the active Windows 10 Explorer window

17 Apr 2019, 11:21

How do I Highlight an existing Folder (using it's Name or Path) in the active Windows 10 Explorer window?
User avatar
Tigerlily
Posts: 377
Joined: 04 Oct 2018, 22:31

Re: Highlight a Folder (by Name or Path) in the active Windows 10 Explorer window

17 Apr 2019, 13:26

jwinfl wrote:
17 Apr 2019, 11:21
How do I Highlight an existing Folder (using it's Name or Path) in the active Windows 10 Explorer window?

try this:

Code: Select all

filepath := "C:\Users\User\Desktop\YourFile.txt"
Run, % "explorer /select, " filepath

:arrow: Explorer docs for more info
-TL
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Highlight a Folder (by Name or Path) in the active Windows 10 Explorer window

17 Apr 2019, 19:03

- Some ideas (set the focus/selection):
Explorer window interaction (folder windows/Desktop, file/folder enumeration/selection/navigation/creation) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=35041
- Nice link Tigerlily. Cheers.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
jwinfl
Posts: 89
Joined: 16 Aug 2017, 12:37

Re: Highlight a Folder (by Name or Path) in the active Windows 10 Explorer window

18 Apr 2019, 09:36

Tigerlily,
Thanks for the response.
I wanted to highlight the folder (filepath) in the ACTIVE (already existing) Explorer window, if possible.
Run, % "explorer /select, " filepath ... opens a NEW Explorer window (does NOT use the existing window).
If you know how to select the file in the existing Explorer window (I have the title & wHandle), I would appreciate it.
Thank You
Jack
Klarion
Posts: 176
Joined: 26 Mar 2019, 10:02

Re: Highlight a Folder (by Name or Path) in the active Windows 10 Explorer window

18 Apr 2019, 10:53

easy

First, get the information
Now, close it
Lastly, open it with the information you have as above mentioned tips

right ?
jwinfl
Posts: 89
Joined: 16 Aug 2017, 12:37

Re: Highlight a Folder (by Name or Path) in the active Windows 10 Explorer window

19 Apr 2019, 08:36

Klarion,
Thank you, but I already knew how to make Tigerlily's code work, unfortunately, I want to use the active window not a new one.
There are many reasons, including, the active windows set up, screen location, etc. which are being controlled by other programs.
Yes, all of these can be redone to the new window but I would prefer not to reinvent the wheel here.
If there is a simple way to highlight the folder name specified in the active explorer window, great, if not, it is not worth the time and effort to change my code to work with a the new window.
Thank You
Jack
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: Highlight a Folder (by Name or Path) in the active Windows 10 Explorer window  Topic is solved

19 Apr 2019, 09:03

In the link posted by jeeswg you can find the Function which set the focus in the current Explorer window.
Usage:
press q to hilight the requested file or folder.
press esc to exit.

Code: Select all

;~ From : ;~ https://www.autohotkey.com/boards/viewtopic.php?f=6&t=35041
#SingleInstance, force
#Persistent

~q::
JEE_ExpWinSetFoc(0, "NameOfyourFileOrFolder")
return 

ExitApp

JEE_ExpWinSetFoc(hWnd, vName, vByPos:=0, vFlags:=0x1D)
{
	local oItems, oWin, oWindows, vWinClass
	DetectHiddenWindows, On
	(!hWnd) && hWnd := WinExist("A")
	WinGetClass, vWinClass, % "ahk_id " hWnd
	if (vWinClass = "CabinetWClass") || (vWinClass = "ExploreWClass")
	{
		for oWin in ComObjCreate("Shell.Application").Windows
			if (oWin.HWND = hWnd)
				break
	}
	else if (vWinClass = "Progman") || (vWinClass = "WorkerW")
	{
		oWindows := ComObjCreate("Shell.Application").Windows
		VarSetCapacity(hWnd, 4, 0)
		;SWC_DESKTOP := 0x8 ;VT_BYREF := 0x4000 ;VT_I4 := 0x3 ;SWFO_NEEDDISPATCH := 0x1
		oWin := oWindows.FindWindowSW(0, "", 8, ComObject(0x4003, &hWnd), 1)
	}
	else
		return

	oItems := oWin.Document.Folder.Items
	;SVSI_FOCUSED = 0x10 ;SVSI_ENSUREVISIBLE := 0x8
	;SVSI_DESELECTOTHERS := 0x4 ;SVSI_EDIT := 0x3
	;SVSI_SELECT := 0x1 ;SVSI_DESELECT := 0x0
	if !vByPos
		oWin.Document.SelectItem(oItems.Item(vName), vFlags)
	else
		oWin.Document.SelectItem(oItems.Item(vName-1), vFlags)
	oWindows := oWin := oItems := ""
}
esc::
    ExitApp
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
jwinfl
Posts: 89
Joined: 16 Aug 2017, 12:37

Re: Highlight a Folder (by Name or Path) in the active Windows 10 Explorer window

20 Apr 2019, 07:36

Odlanir,
Thank you for the code.
I added; JEE_ExpWinSetFoc(0, "NameOfyourFileOrFolder") to my code (no hotkey)
and the function; JEE_ExpWinSetFoc(hWnd, vName, vByPos:=0, vFlags:=0x1D)
It works exactly as I had hoped.
Thanks again.
Jack
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: Highlight a Folder (by Name or Path) in the active Windows 10 Explorer window

20 Apr 2019, 07:46

Nice, but you should tank jeeswg who is the author.
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Decar, doodles333, Google [Bot], mikeyww and 222 guests