Skip to content

A C# console application that looks for open windows of a target application by Process Name and shows the window if one is open already or launches a new window if there are no open windows.

License

tronfacex/Dock-Companion

Repository files navigation

Dock-Companion

About

Dock Companion is a C# console application that checks if a target application is already running, and if it finds an open window (including minimized) it shows the window. If the target application is determined to not be running it launches a new window.

This application was made for use alongside popular Rainmeter Docks. Using it alongside Rainmeter docks like Silmeria Dock, Docker and Circle Launcher basically adds taskbar-style functionality to the targeted applications.

For example, when targeted at Chrome or Firefox those applications will find and surface any already open windows instead of opening a brand new window each time they are clicked from the dock.

See Dock Companion in action with Silmeria Dock on Youtube.

Instructions for initial setup including how to use it with the most popular Rainmeter docks are below.

This project is published with a GNU General Public License v3.0.

Table of Contents

Initial Setup

  1. Download latest release .zip file.
  2. Ensure that you have .Net Framework 4.8 runtime installed. Click here to download official Microsoft installer.
  3. Unzip the zip file in your preferred file location on your machine.
  4. Run DockCompanion.exe.
  5. On initial launch the application will open a window that helps you create a Config.txt file.
  6. Click the "Browse..." button and navigate to the target application's exe file and click "OK". For instance, Mozilla Firefox usually has a default filepath of C:\Program Files\Mozilla Firefox\firefox.exe.
  7. Click "Save".
  8. Now use this instance of DockCompanion.exe to launch the target application instead of the target application .exe file.

How to Use Alongside Silmeria Dock

  1. Navigate to Silmeria Dock's Settings.ini file. The default location is Rainmeter\Skins\Silmeria Dock\@Resources\Settings.ini.
  2. Find the reference to the application you would like to use Dock Companion with, find the field "Icon1Action", and replace the filepath for the target application .exe with the filepath for DockCompanion.exe. For Instance, the Mozilla Firefox reference should read Icon1Action=["C:Path\To\DockCompanion.exe"]
  3. Save and close Settings.ini.
  4. Load or refresh the Silmeria Dock skin for the application in Rainmeter by right-clicking the skin and selecting Refresh Skin.

If you would like to setup a second application for use with DockCompanion:

  1. Create a second instance of the Dock Companion application by copy and pasting the entire Dock Companion folder.
  2. Delete Config.txt and go through initial setup by opening DockCompanion.exe. Each instance of Dock Companion requires a Config.txt file to exist in the same folder as DockCompanion.exe
    1. Alternatively, you can edit the txt file directly. Line 1 should be the target application process name, and line 2 should be the filepath to the target application's exe file.
  3. Set the reference to DockCompanion.exe in Silmeria Dock's Settings.ini file.
  4. Load or refresh the Silmeria Dock skin for the application in Rainmeter.

How To Use Alongside Circle Launcher

  1. Navigate to Circle Launcher's Variables.inc file. The default location is Rainmeter\Skins\Circle Launcher\@Resources\Variables.inc.
  2. Find the reference to the application you would like to use Dock Companion with, and replace the filepath for the target application .exe with the filepath for DockCompanion.exe. For Instance, the Mozilla Firefox reference should read MozillaFirefox=["C:Path\To\DockCompanion.exe"]
  3. Save and close Variables.inc.
  4. Load or refresh the Circle Launcher skin for the application in Rainmeter by right-clicking the skin and selecting Refresh Skin.

If you would like to setup a second application for use with DockCompanion:

  1. Create a second instance of the Dock Companion application by copy and pasting the entire Dock Companion folder.
  2. Delete Config.txt and go through initial setup by opening DockCompanion.exe. Each instance of Dock Companion requires a Config.txt file to exist in the same folder as DockCompanion.exe
    1. Alternatively, you can edit the txt file directly. Line 1 should be the target application process name, and line 2 should be the filepath to the target application's exe file.
  3. Set the reference to DockCompanion.exe in Circle Launcher's Variables.inc file.
  4. Load or refresh the Circle Launcher skin for the application in Rainmeter.

How to Use Alongside Docker

  1. Navigate to Docker's Settings.ini file. The default location is Rainmeter\Skins\Docker\@Resources\Basic.ini for the Basic Dock and Rainmeter\Skins\Docker\@Resources\Advanced.ini for the Advanced Dock.
  2. Find the reference to the application you would like to use Dock Companion with, find the field "LeftMouseUpAction", and replace the filepath for the target application .exe with the filepath for DockCompanion.exe. For Instance, the Mozilla Firefox reference should read LeftMouseUpAction=["C:Path\To\DockCompanion.exe"]
  3. Save and close Settings.inc.
  4. Load or refresh the Silmeria Dock skin for the application in Rainmeter by right-clicking the skin and selecting Refresh Skin.

If you would like to setup a second application for use with DockCompanion:

  1. Create a second instance of the Dock Companion application by copy and pasting the entire Dock Companion folder.
  2. Delete Config.txt and go through initial setup by opening DockCompanion.exe. Each instance of Dock Companion requires a Config.txt file to exist in the same folder as DockCompanion.exe
    1. Alternatively, you can edit the txt file directly. Line 1 should be the target application process name, and line 2 should be the filepath to the target application's exe file.
  3. Set the reference to DockCompanion.exe in Docker's Basic.ini/Advanced.ini file.
  4. Load or refresh the Docker skin for the application in Rainmeter.

Debugging Issues

There are two primary reasons why Dock Companion fails: a mismatched Process Name or an invalid filepath in the Config.txt file. Both issues can be solved using the Debug tool.

Mismatched Process Name

Dock Companion assumes an application's Process Name based on the program's exe filename. There are some cases where the Process Name does not match the exe filename. In those cases Dock Companion will fail to find open windows of the target application. Solve this issue by using the Debug tool to find the true Process Name for a given window and override the original Config.txt file.

Follow these instructions to Debug the Config.txt:

  1. Navigate to the Dock Companion folder and open DockCompanionConfigSetup.exe.
  2. Click "Debug" at the bottom of the window. The debug window will open.
  3. Open an instance of the target application.
  4. Return to the debug window and click "Find Windows".
  5. Look through the list of open windows and double click the entry for the target application. This will add the true Process Name to the Process Name field.
  6. Click "Browse..." and navigate to the target application exe file.
  7. Click "Save"

Invalid Target Application Filepath

If no target application windows are launched when DockCompanion.exe is run without any open windows it indicates that the target application filepath doesn't exist. Delete Config.txt and run the initial setup again.

Alternatively, open Config.txt and examine the filepath on line 2 to ensure it is a valid.

The Debug Tool can also be used to reset the filepath and set an alternative Process Name.

Follow these instructions to Debug the Config.txt via the Debug Tool:

  1. Navigate to the Dock Companion folder and open DockCompanionConfigSetup.exe.
  2. Click "Debug" at the bottom of the window. The debug window will open.
  3. Open an instance of the target application.
  4. Return to the debug window and click "Find Windows".
  5. Look through the list of open windows and double click the entry for the target application. This will add the true Process Name to the Process Name field.
  6. Click "Browse..." and navigate to the target application exe file.
  7. Click "Save"

Notes

Dock Companion was created by adapting two blocks of code found on StackOverflow, and a conversation with OpenAI's ChatGPT.

The StackOverflow threads that form the starting point of this project can be found in the ATTRIBUTIONS file.

The full transcript of my conversation with ChatGPT can be found here.

This project is published with a GNU General Public License v3.0.

About

A C# console application that looks for open windows of a target application by Process Name and shows the window if one is open already or launches a new window if there are no open windows.

Resources

License

Stars

Watchers

Forks

Languages