Auto Hot Key script POC to manage windows on a screen
I was asked to develop a Proof-of-Concept (POC) for controlling multiple apps within a single visual context
The requirements were expressed as: 2 apps occupying a screen tiled in a specific fashion Simple controls to start and stop the apps No interaction between apps is required The initial apps were Render, an installed app, and Bible Well which is a Progressive Web App (PWA) MS Windows only environment as Render is windows only Complete POC in 2 weeks
My initial thinking was to place multiple apps into browser iframes to manage their relative positions. I have had substantial success using iframes on previous projects.
I constructed browser searches like browser control of installed app windows app in iframe
I came up with an initial list of candidate frameworks in order of discovery
- Remote Desktop to connect to Windows app
- guacamole-apache server to connect to Windows app
- Asynchronous Pluggable Protocol (URI Scheme) to connect to Windows app
- Recompile app into LLVM bytecode using emscripten to run in browser
- 0data.fr service to connect to Windows app
- spawn apps service to connect to Windows app
- boxedwine to emulate windows to connect to Windows app
- vscode to integrate bible well and render
Since time was of the essence I ordered these according to how I would attempt to use them based on what I considered to be the difficulty of integration.
- Asynchronous Pluggable Protocol (URI Scheme) to connect to Windows app After research, this seemed too complicated to be portable. Uses "magic" registry entries.
- Remote Desktop to connect to Windows app Researched this till I found that I have little control over remote desktop window.
- spawn apps service to connect to Windows app - spawnapps2.wordpress.com Reviews indicated that this service is difficult to configure
- 0data.fr service to connect to Windows app - at 0data.fr 20 euros/mo At first this seemed like the fastest to implement candidate, however, This service seems to have disappeared. Could not make contact with anyone or sign up for service. Google maps shows their Houston office available for lease
- boxedwine to emulate windows to connect to Windows app Could not build from source. Installable image was suited only for very old games Star Trek 1992 works great.
- guacamole-apache server to connect to Windows app Open source RDP/VNC equivalent that would take too long to configure
- Recompile app into LLVM bytecode using emscripten to run in browser - Requires access to source. Code not available
- vscode to integrate bible well and render Recent projects told me this would not be a small effort
If managing windows in a browser is not going to work then how do I control the apps independently?
Searching for strings like controlling windows applications
I stumbled onto AutoHotKey (AHK). This is an old product but is used to control apps in a way similar to selenium. It has deep contol of starting, controlling, stopping and positioning windows with a javascript like scripting language using traditional hotkeys (window control) and hotstrings (string replacement).
AHK scripts can be compiled and dropped on a desktop as a single icon to enable hotkeys to control a collection of apps The current POC uses 3 keys to: start, cycle, and stop 3 different apps.
The 3 apps are Render, Notepad and Bible Well
- Could control the installation of bible well as PWA but could not locate handle to reposition it. So this code is commented out
- Added ugly control at top right corner of display as illustration of how one might create control interface for AHK.
- Render will currently not respond to window control except to start and stop.
- The script is sensitive to the installed location of Render. My installation is not portable.
- AHK is an elegant way to manage window automation.
- It can read and write .ini files to manage its configuration
- An experienced AHK script writer can employ tools to simplify the access to an app's embedded controls.
- The project was a success in an elapsed time of 2 weeks.
- To work with Render, Render will have to be "somewhat" responsive to resize events
- Any number of app could be controlled by extending the current POC, however, making the apps configurable would allow a great interim solution for multiple apps interesting to a workflow.
To install this POC, drop the Render.exe file onto desktop
To run the script,
- Double click on "H" icon
- Click one of:
- WIN-A to start the 3 referenced apps
- WIN-S to switch among the 3 in round robbin order
- WIN-S to stop all three
- Alternatively there is a prototype menu at the top right hand corner of the screen to accomplish the same tasks
- This script uses the 32bit autohotkey version 2. It is incompatible with any pre 2.0 versions. Download from: https://www.autohotkey.com/download/
- The "Render_3.7.3.0_Installer.msi" version of Render is installed from their website
The Render.ahk file can be directly edited by your favorite editor but should be stored in UTF-8 with BOM format To recompile it;
- download release "AutoHotkey_2.0.15_setup.exe" or greater from autohotkey.com
- Double click on it to install
- click on its installed Icon which looks like a Green Capital H.
- Select compile
- Enter or select path to source .ahk file
- Enter or select path to exe file to be produced
- Press Convert