; https://www.autoitscript.com/forum/topic/154916-locate-file-in-windows-explorer/ #include #include ;#Include <_DBUG.au3> ; Used for debugging script #AutoIt3Wrapper_Change2CUI=y ; taken from https://www.autoitscript.com/forum/topic/31607-make-consolewrite-write-to-the-console/ _LocateFileInCatalog(@SystemDir & "\format.com") Func _LocateFileInCatalog($path) Local $fileName = $path Local $folderName = @SystemDir ConsoleWrite("Filename/foldername: " & $filename & " " & $folderName & @CRLF) Sleep(500) Local $hPid = Run(@WindowsDir & "\explorer.exe /e, /select, " & $fileName) Sleep(500) ;Local $hExplorerHndl1 = WinWaitActive($folderName, "", 8) Local $hExplorerHndl = WinWaitActive("C:\Windows\SysWOW64", "", 10) Sleep(500) $hMenuHndl = _GUICtrlMenu_GetSystemMenu($hExplorerHndl, False) If $hMenuHndl <> 0 Then ; $hMenuHndl contains the handle to a copy of the window menu Else ConsoleWrite("hMenuHndl not found-exit!!!" & $hMenuHndl & @CRLF) Return EndIf Local $hSubMenuHndl = ControlGetHandle($hExplorerHndl, "", "[CLASS:DirectUIHWND; INSTANCE:3]") ;Local $hSubMenuHndl = ControlGetHandle($hExplorerHndl, $folderName, "[CLASS:SysListView32;INSTANCE:1]") Sleep(500) ;Local $iIndex = _GUICtrlListView_FindText($hSubMenuHndl, $fileName) Local $iIndex = _GUICtrlListView_FindText($hSubMenuHndl, "format.com") Local $iArray = _GUICtrlListView_GetItemText($hSubMenuHndl, $iIndex) Sleep(500) _GUICtrlListView_EnsureVisible($hSubMenuHndl, $iIndex) Sleep(500) $true ="true" _GUICtrlListView_SetItemSelected($hSubMenuHndl, $iIndex, $true, $true) Sleep(500) ConsoleWrite("hPid: " & $hPid & @CRLF) ConsoleWrite("hMenuHndl: " & $hMenuHndl & @CRLF) ConsoleWrite("hExplorerHndl: " & $hExplorerHndl & @CRLF) ConsoleWrite("hSubMenuHndl: " & $hSubMenuHndl & @CRLF) ConsoleWrite("iIndex: " & $iIndex & @CRLF) EndFunc ;; Use ControlGetHandle() + _GUICtrlListView_GetItemText() - suggestion from autoit forum