WordPress headers with AUTOHOTKEYs
I’m starting to use more blocks in WordPress and am finding that there are not that many Keyboard Shortcuts within WordPress to use and the process of setting up blocks is quite slow.
Shortcodes too slow in writing code
So I wrote an aText snippet to allow for a fill in box for the title and tried to use it. Unfortunately the writing of the snippet in WordPress is slow, like send keys in AutoHotKey, and when it writes it that slowly it comes in as code string, not the header. So it needs to be pasted in from Clipboard.
I then tried doing a couple of things in aText to get it to send the snippet to clipboard and then paste from clipboard but I couldn’t get that to work. I was trying to call one snippet from another and wasn’t sure how I could get a variable to transfer across snippets.
Using AutoHotKey instead
So I added it to my main AutoHotKey script to do that instead, just putting all the HTML on one line and it works fine.
The original code for a header is:
<!-- wp:heading {"level":3} -->
<h3 id="using-autohotkey-instead">Using AutoHotKey instead</h3>
<!-- /wp:heading -->
Which has an id= some stuff in lower case with no spaces but dash instead. It works with this as id=”” (blank) and that is what I’m using in AutoHotKey script below with the extra background colour.
:X:h3::
InputBox, H3Title , H3 Header, Text for Title
clipboard =<!-- wp:heading {"level":3,"backgroundColor":"luminous-vivid-amber"} --><h3 class="has-luminous-vivid-amber-background-color has-background" id="">%H3Title%</h3><!-- /wp:heading -->
Send, ^v
return
This has the background colour to the title added, maybe a bit too loud, so I may have one with colour background and one without. The Keyboard Shortcuts for ones with colour could be h22, h33 or h44 to reduce reach on typing Keyboard Shortcuts
End Comments
I’m pleased with this shortcut edition for Headers to add to my list of shortcodes. It definitely makes writing blogs a bit quicker.
I’ll have to find a few more to add to my list, maybe some of the cosmic Blocks which are pretty sophisticated.
Just a shame that images are so awkward.