-2

I'm trying to build an app that synchronizes a FileDialog to a specific path. I'm not opening the FileDialog myself, I need access to "all the currently opened FileDialogs", get a reference to the one I need and then change the currentworkingdirectory. Is there an API to get all opened filedialogs in Windows?

If you need a better explanation, here's a video of the feature I'm trying to implement: https://www.youtube.com/watch?v=9T9-OtRVeUw

Thanks!

valeriodidonato
  • 129
  • 1
  • 1
  • 9
  • 1
    You can easily do that with UI Automation. The OpenFileDialogs have class name `#32770` (all Dialogs, actually), the Explorer window has class name `CabinetWClass` and the Address bar (ClassName `ToolbarWindow32`) is child of a `pane` (`Automation.ControlType.Pane`) that has ClassName `Breadcrumb Parent`. The Address bar `AutomationElement.Name` is the currently shown path. See [here](https://stackoverflow.com/a/58233065/7444103) and [here](https://stackoverflow.com/a/55028688/7444103), for example, how to detect when a Window of those classes is opened. There are many forms of Interaction. – Jimi Mar 04 '20 at 11:44
  • 1
    @jim: Why would you want to fiddle with implementation details? [A big little program: Monitoring Internet Explorer and Explorer windows, part 3: Tracking creation and destruction](https://devblogs.microsoft.com/oldnewthing/20130614-00/?p=4083). – IInspectable Mar 04 '20 at 15:09
  • 1
    @IInspectable Thanks for that, I've missed that blog post completely. Anyway, the UI Automation methods are pretty simple to use. But, ShellWindows events, I don't think I've ever used these. That's a shame, I'll give it go. – Jimi Mar 04 '20 at 15:35

1 Answers1

0

“Is there an API to get all opened filedialogs in Windows?” No, because there is not just one in-box file dialog, and many applications use custom implementations (e.g.: Java, qt, Office 2016+).

The video you posted looks like they are hooking or subclassing the most common dialog and (probably) using automation (either COM or window messages) to set the folder.

Separately, I don’t quite understand the desired function. If you have the explorer window open, drag or copy/paste the desired file into the app or file dialog. No need for nonstandard hacks.

Mitch
  • 21,223
  • 6
  • 63
  • 86