Jump to content

How to open a folder in current explorer window ?


Recommended Posts

Hi all,

I am trying to open a specific path in my pc with this command

ShellExecute("D:\MyFolderPath")

But this will open the folder in a new explorer window. I just want the folder to open in the current explorer window. How to do it ? Please help. Thanks in advance. 

Side note : Actually, i am using QTTabbar in my Windows Explorer so it has a tabbed feature.  If the folder opened in current window, it will displayed in a new tab. But now, it is opening in a new explorer window.

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

Hi.

Use the Autoit Window Info Tool to catch the control-ID you need to put your path information in.

 

AFAIK shellexecute() will always open an additional Windows Explorer window.

 

CU Rudi.

 

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Hey

i actually don't know how QTTabbar works. but in a normal explorer u could set ur old window as parent to a new instance and set the pos/size to the old... like

#include <WinAPI.au3>
    #include <WinAPISysWin.au3>
    $newpath = @ScriptDir
    Global $hMigration, $hExplHolder, $hExplorer, $sStartDir = "C:\"
    
If WinExists ( "[CLASS:CabinetWClass]","" ) Then
    $hExplHolder = WinGetHandle ( "[CLASS:CabinetWClass]","" )
    Local $pos = WinGetPos ( $hExplHolder,"" )
    _createexp($hExplHolder,$newpath,$pos[2],$pos[3])
Else
    MsgBox ( 48,"error","no window exist" )
EndIf

Func _createexp ($hwnd,$newpath,$w,$h)
$sStartDir = $newpath
Run('C:\Windows\explorer.exe /n, "' & $sStartDir & '"',"",@SW_HIDE)
WinWaitActive("[CLASS:CabinetWClass]")
$hExplorer2 = WinGetHandle("[CLASS:CabinetWClass]")
WinSetState($hExplorer2, "", @SW_HIDE)
WinMove($hExplorer2, "", -8, -30, $W, $H)
_WinAPI_SetParent($hExplorer2, $hExplHolder)
WinSetState($hExplorer2, "", @SW_SHOW)
EndFunc

you just have to care when you want to resize it (btw i think there is an option to force size of parent) or if you have more then 1 instances of it because always the last is selected... but you could write the handle down.

was just first idea - maybe i get another soon :) 

 

tried to install QTTabbar but i have to read something about it first i guess :frantics:

 

else u could try it with controlsend or something

 

there is no way to do this without a new instance i guess, but im not sure :P

 

Edited by Aelc

why do i get garbage when i buy garbage bags? <_<

Link to comment
Share on other sites

  • 5 years later...
14 hours ago, robertocm said:

Just to add this reference that seems to work:

;Xenobiologist, Oct 21, 2020
;https://stackoverflow.com/questions/64417468/object-shell-application-open-folder-in-same-explorer-window
SendKeepActive($handle)
Send('{F4}')
Send('^a')
Send(@AppDataCommonDir & "{ENTER}")


.........
SendKeepActive($handle)
if @OSVersion="WIN_11" then Send('^t') ; new tab win 11
if @OSVersion="WIN_11" or @OSVersion="WIN_10" then
    Send('^l') ; focus on the address bar (win 10&11)
else
    Send('{F4}')
    Send('^a')
endif
Send(@AppDataCommonDir & "{ENTER}")

 

To community goes all my regards and thanks

Link to comment
Share on other sites

16 hours ago, robertocm said:

Just to add this reference that seems to work:

;Xenobiologist, Oct 21, 2020
;https://stackoverflow.com/questions/64417468/object-shell-application-open-folder-in-same-explorer-window

The Function _WinGetHandleByPID does not work with explorer.exe

returning 0 as the handle:

$pid = ShellExecute("explorer.exe ", @DesktopDir)
If Not ProcessExists($pid) Then ConsoleWrite("no matching process" & @CRLF)

 

Explained here:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...