I’m using chromium embedded in my application. Using it, I would like to load the web-version of Visual Studio Code ( https://vscode.dev/ ), and then automatically open a specific directory on the device, without the user having to do it manually.
I’m sure this is possible using JavaScript (even if not officially supported), but I’m not sure how to find out which commands are responsible for opening a folder. When you press "Open Folder…" in VS Code, it opens a file dialog window where you can select the target directory. If I could break when a folder has actually been selected (and confirmed), I could probably narrow it down, but I couldn’t find a listener even that would work for such a case.
Is there a simple way to do this without having to take a deep dive into the entire source code?
2
Answers
To automate the process of opening a specific directory in Visual Studio Code (VS Code) when using the web version (https://vscode.dev/) embedded in your application, you’ll need to interact with the VS Code web API. Unfortunately, there is no official API or documented way to achieve this specific functionality.
Alternatively, if your goal is to automate the opening of a specific directory within an embedded browser, you could consider using other solutions or technologies specifically designed for automating browser interactions, such as Selenium WebDriver (https://www.selenium.dev/) or Puppeteer (https://pptr.dev/). These tools provide APIs to control browser instances, navigate web pages, and interact with elements, which might be helpful in automating the process within the VS Code web version.
In a standard web context, JavaScript doesn’t have the ability to automatically open a directory on a user’s machine due to the same security and privacy restrictions. For example, the File System Access API requires user gestures to grant read or write permissions to files and directories.
Moreover, the Visual Studio Code web-based editor
vscode.dev
is a relatively new service and may not support all the features of the desktop version. The functionality you are looking for might not be available in the web version.