Windows: Key Sequences and Macros

Windows: Key Sequences and Macros

Remap Keys One-To-One

This is no longer relevant because Windows has this almost built in thanks to the PowerToys “Keyboard Manager”.

The previous solution was randyrants/sharpkeys which managed a Registry keys to remap one key to any other key. There is also the Microsoft Keyboard Layout Creator (MSKLC) where you could create a completely new layout file.

But all of that is now unnecessary and you can just use the Keyboard Manager from PowerToys.

Key Sequences

remap key sequences, text expander, text substitution tool, text snippet tool, remap multi-key sequences to individual keys

I think key sequences can be done with any automation tool, but there are also tools that are just for this purpose and aren’t as bulky as macro tools. These tools are also often used for entering accents in “weird” alphabets.

Espanso

Espanso is cross-platform and open-source and it’s written in Rust. Installing it is super easy with scoop install espanso. There are tons of Espanso add-ons available on Espanso Hub. It supports a lot of things, like app-specific configurations and Synchronization is properly documented.

I ran espansod env-path register to add espanso to the PATH, but it didn’t work, even after opening a new terminal. Later, I realized that espanso was never in the path when I opened the terminal as an Administrator, but it was there from the start when I opened it as a user.

You’ll find that the file espanso.cmd is just a wrapper that calls espansod.exe without any changes. Since espansod was already in my path, I’ll keep using it. You can use the command espansod path to get the important folders, for example a path to the configuration file.

So far Espanso was working great everywhere, except in applications with elevated privileges. To solve that, use:

$App = """$(scoop prefix espanso)\espansod.exe"""
$Name = "Espanso SVKO Task Elevated"
$Action = New-ScheduledTaskAction -Execute "$App" -Argument "launcher"

$Trigger = New-ScheduledTaskTrigger -AtLogon
$Principal = New-ScheduledTaskPrincipal -UserID "$env:USERDOMAIN\$env:USERNAME" -LogonType ServiceAccount -RunLevel Highest
$Settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -DontStopOnIdleEnd
$Task = New-ScheduledTask -Action $Action -Trigger $Trigger -Settings $Settings -Principal $Principal
Register-ScheduledTask -TaskName "$Name" -InputObject $Task -Force

Other Utilities

Windows Automation Tools

scripting utility, macro recording

AutoHotkey | AutoHotkey/AutoHotkey is an open-source legend and is used for all kinds of things on your computer. Think of it as an ultimate macro-creation and automation-oriented scripting utility for Windows.

  • AutoIt scripting language is a serious competitor to AutoHotkey, though still less popular

  • TinyTask is one of the alternatives that, even if it’s better, has a hard time competing against the already established and free players.

Tools to Learn and Practice App Shortcuts

I’m assuming there are plenty of these, but I haven’t explored this topic much.

  • KeyCombiner is a great online tool for organizing and practicung shortcuts and it’s mostly free.There’s a desktop app too, but there’s no need for it for the most part.

Developers have a real problem with QUERTZ Layout in German or Serbian.

The current official layout for Serbian is QWERTZ and there’s a layout image in that article. However, when it’s used in developer tools, the same problem exists with Germany and any other country that use the QWERTZ layout.

Everyone should definitely check out Why Keyboard Shortcuts don’t work on non-US Layouts and the comments on Hacker News.

The Keyboard Event Viewer which is mentioned in above sources is really useful as it is neat little online tool that shows which button presses produce which event properties.

Some sensible solutions have been proposed here: Can I make Ctrl+Alt NOT act like AltGr on Windows? and one of them is to press LCtrl+LAlt to activate English layout just temporarily thus avoiding part of the problem. That I read in this discussion: Option to disable Ctrl+Alt = AltGr.

Particularly, this comment suggested using the tool BladeMight/Mahou which in turn is all in proper Russian and terrible English and which apparently serves for some instant alphabet transliteration or something similar?

Either way, this user hints at the option to open Mahou’s “Layouts” tab and in the “Temporary change layout on LCtrl+LAlt combination” field enter value 67699721 as that’s the English US code, and then click on the “Apply” button.

I tried that and didn’t get much out of it!

Let’s Invent a New Layout

None of the solutions is ideal. A radical approach would be to use a completely new keyboard layout, something like the Dvorak layout for the US layout, and that’s what the following authors are doing for the EU or German layouts:

  • EurKEY aka “The European Keyboard Layout” is a custom remap layout that covers all European languages

  • Neo is an ergonomically optimized new German layout, but it’s all the same idea as others

  • bradrn/Conkey is also a new keyboard layout and the author says it’s for “conlangers”. I don’t know what that means, but I think it’s for languages with accent letters

  • Even our neighbors have some of their own solutions that theoretically I can also use ivancuric/mac-hr-sane-layout, but somehow it didn’t feel proper

  • Keyman is a free and open source keyboarding platform to define layouts, but it seems too bulky and corporate for me, so forget about it


Windows Automation

Autohotkey / Automation

Autohotkey / Automation

Interesting ideas

Snow SMS alert http://thenewhobbyist.com/2011/01/automated-snow-sms-alert/ :: Automated snow SMS alert « The New Hobbyist

Copy-Paste without formatting

AHK to simulate Copy-Paste, but without formatting: $^v:: ClipSaved := ClipboardAll ;save original clipboard contents clipboard = %clipboard% ;remove formatting Send ^v ;send the Ctrl+V command Clipboard := ClipSaved ;restore the original clipboard contents ClipSaved = ;clear the variable Return $^+v:: Send ^v ;just send the regular paste command Return Source: http://cache.gawker.com/assets/images/lifehacker/2009/10/BetterPaste_01.ahk http://lifehacker.com/5388814/better-paste-takes-the-annoyance-out-of-pasting-formatted-text :: Better Paste Takes the Annoyance

AHK Scripts with Evernote

http://www.mysimplecuriosity.com/getting-things-done-with-evernoteprojects-part-1-note-templates-for-windows/ :: Getting Things Done http://ori0nx.wordpress.com/2011/05/27/quick-autohotkey-hack-to-format-text-in-evernote/ :: Quick AutoHotKey hack to format text http://ori0nx.wordpress.com/2012/01/01/quick-evernote-search-with-autohotkey-and-your-favorite-launcher-2/ :: Quick Evernote search

Applied scripts on my system

Copy Evernote Note URL Link http://www.thoughtasylum.com/blog/2012/7/31/quick-copy-evernote-note-links.html :: Quick Copy Evernote Note Links - Home Reload current script on Ctrl-Alt-R and include it with every other script http://www.thoughtasylum.com/blog/2012/3/3/reloading-autohotkey-scripts.html :: Reloading AutoHotKey Scripts http://www.thoughtasylum.com/blog/2012/2/29/managing-autohotkey-scripts.html :: Managing AutoHotKey Scripts - Home - Thought Asylum

Belevedere Script

http://lifehacker.com/341950/belvedere-automates-your-self+cleaning-pc :: Belvedere Automates Your Self-Cleaning PC

https://github.com/mshorts/belvedere#readme :: mshorts/belvedere · GitHub


Search & replace clipboard for passwords

I made a small Autohotkey script to do exactly that. Replacements are stored in a file in the same directory as AHK script.

Machine: Linux user: / Root user: root / Database: , , /


Espanso Tips

  • Promenio sam default shortcut za Espanso koji je bio Alt+Space i koji mi treba za tool SmartSystemMenu, Win+Space služi za keyboard language switch, pa je jedino preostalo da promenim na Alt+Shift+Space.
cd "$(espanso path config)" # ne radi!

To sam uradio tako što sam u fajl `"$(espanso path config)/config/default.yml"` dodao `search_shortcut: ALT+SHIFT+SPACE`
  • Espanso has the ability to use specific configurations for certain applications.

  • To set the cursor location after an expansion is complete, use $|$ in the replacement text.

  • Use force_clipboard: true in the trigger when you want to have “soft-returns” instead of activating a hard Enter in the application. I use it for matches I use in Viber.

  • You can manipulate the clipboard and “paste clipboard as text” function is often useful. It is explained in the section on clipboard in Espanso.

  • Extensions can be found on the Espanso Package Hub, but there isn’t anything particularly monumental available.

-Espanso also supports forms, which I use for my shortcut :me.


Replacing clipboard contents with GPT3 : espanso GitHub - rohitna/chatgpt-script: A python script to interact with chatGPT via clipboard


New competitors to Autohotkey:

LGUG2Z/whkd is a simple hotkey daemon for Windows, like [koekeishiya/skhd(https://github.com/koekeishiya/skhd) for macOS and baskerville/sxhkd for Linux

Library used is amazing dnlmlr/windows-hotkeys: A lightweight and ergonomic rust crate to handle system-wide hotkeys on windows

News: whkd: A simple hotkey daemon for Windows : rust


Definitivno sam pokušao da pokrećem sa whkd.exe, ali sve mi to nekako kilavo. Fajl je tu, “.config\whkdrc” ali niti ima autorun, niti mi se sve to sviđa nekakoo.


Window Inspector by Binary Fortress Software može biti koristan možda.

date 31. Jan 2023 | modified 29. Dec 2023
filename: Windows » Remap Keys, Text Expanders, Macro Automation