Working with dual VS Code and Atom

I have learned recently that I have to use VS Code as a dependency for experimenting with IBM blockchain development. There is a VS Code extension - IBM Blockchain Platform not available in Atom.

Recently i started to settle into using Atom environment, learning its quirks, and I am now pondering how to use both environments (Atom+VS Code) for ongoing development. It is not easy to switch between both environments.

I have started an experiment where I now use automation scripts (sited in Atom) to drive separate running session of VS Code GUI. This allows me to use Atom as my main environment but, through scripts, drawing on features of VS Code as an engine. So far this approach seems feasible and avoids issues of different packages/extensions.

Has anyone tried this odd approach? It seems that a library of GUI automation scripts could be built. Or the alternative way is to just accept learning both environments. i could drop using Atom but it has some features not found in VS Code.

Mind sharing the documentation you’ve found on how to manipulate VS Code from another program?

I explain the approach I am using but this is work in progress.
The basic principle is to use an intermediary application which “drives” the target application in “autopilot mode” through a combination of targetting windows, images or key sequences. The user is out of the interaction.

In some situations the user might be prompted to take a decision.

The choice of automation tool depends on the host OS. Some tools work only in Windows, others only in Linux, and some work across platforms. The scripts written will depend on syntax of the OS (e.g. Windows file paths vs. Linux file paths).

I have dual boot Windows and Ubuntu where Ubuntu 16.04 is my OS of choice.

The tools I have looked at are:

AutoHotKey is a Windows only tool not of use to me as a Ubuntu user but I see that there is now IronAHK which is cross platform.

https://autohotkey.com/board/topic/50354-ironahk-alpha-cross-platform-net-rewrite-of-autohotkey/

I pursued, only today as I write this, the alpha release of

https://www.mono-project.com/download/stable/

Note that this is a 389 Mb installation and you might choose to defer this route and try Actiona first.

I installed Mono today as part of my experiment in Atom < -- > VS Code and then tried the Mono hello world example.

https://www.mono-project.com/docs/getting-started/mono-basics/

This creates hello.exe which I could run in Ubuntu by the command …

mono hello.exe

That is as far as I have got with the AutoHotKey/Mono route.

This blog suggests that this route (in Linux) is experimental

http://maul-esel.github.io/ahkbook/en/What-Version-To-Choose.html

Returning to my main preferred tool Actiona I compiled a script to run hello world in VS Code from Atom.

Actiona has one distinct advantage when running in Atom.
The Action embedded scripts can be written in javascript.

Actiona compiled scripts have extension *.ascr which in fact is XML format and can be viewed in Atom and even edited from within Atom if tweaks in script dialogue embedded text are required.

Assuming that we have dual windows (sessions) of Atom and VS Code running the script runs through these actions.

From Atom run script by the command …

actexec yourautomationscript.ascr

The script is run using a command in process-palette.

Within yourautomationscript.ascr are these actions …

command > code -n args

This launches a new session of VS Code open at the file defined in args.

Start by launching Actiona GUI.
If Docky is installed GUI icon is seen alongside Atom and VS Code sessions.

The first action we will create in GUI is Command.
Input parameters are:
Command: code

… note: do not add any args to this command line

Parameters: -n /path/to/your/file/README.md

… note: the file path is your choice from your Atom files directory

Next we might add a Pause action of a few seconds to allow VS Code session to be initiated.

When this script is tested by clicking in Actiona GUI we see a new session of VSCode being launched and the contents of file README.md is seen in VSCode window.

We might add to the script a Message Box to explain to the user the next steps. This can be useful when we are using Actiona to walk the user step-by-step through a workflow (instead of the common practice of using animated gifs or video tutorials).

Another action might be a Multi data input combo box. The GUI has a rich set of widgets to choose from and embedded scripts within each action can be written in javascript.

Let us now try to automate the launched VS Code window.

The most effective way of automating the target window is through key sessions.

The action to use in the script is Device > Key where multiple key sequences can be defined.

One obstacle is the use of external applications such as Nautilus. For example in opening folders and files we must use Nautilus. Added note: I now see a way around this.

If a key sequence is not available for a particular VS Code action we can create a target image (such as a button or icon) to search for. For this we use the Window action which can target attributes such as window name.

Tips

  • Ensure that VS Code window is maximised otherwise some icons leaking out of background windows (such as Atom) might confuse the actionscript operating on VS Code window, particularly if images are targetted.

  • Leverage VS Code command line options https://code.visualstudio.com/docs/editor/command-line which are easier to automate than targetting images.

After creating the Actiona script it can be run from within Atom by using the command

actexec yourautomationscript.ascr

Such commands can be launched through Atom process-palette or script. That is, the Actiona GUI is only used when creating and testing the automation script.

This is a very basic example or Atom to VSCode communication. Much more advanced interactions can be created.

I am creating a library of such actionscripts. Indeed some scripts might be applied to Atom.

1 Like

Impressive. :slight_smile:

1 Like