maphew

A lozenge for Pollen

2015-July-31

I was going through the quick tour for Pollen, and ran into the road block of not being able to enter the special command character "◊" on any of my computers because they don't have a numeric keypad.  My evening's goal of learning Pollen turned into several hours of extending my Auto Hot Key skills and learning about some vagaries of character encoding interpretation.  The story of my life: forever fixing the car in order to change a light bulb!

Technical lessons learned:

  • Use Send {U+hex} in preference to Send {ASC nnnn} . The codes/characters can be different depending on the receiving program, notepad++ might see "◊ ╩ Ê " while MS Office sees "◊ ◊ ◊".  (thank you @Lexicos)
     

  • Utf8 icons seems to be a good site for looking up unicode numbers (and html entities and others): http://www.utf8icons.com/search?q=9674

b:\apps\ahk_scripts\tick-tick-lozenge.ahk, now included in Pollen :)

; Double-tap backtick sends Pollen command character (◊)
; For some reason I needed to use Unicode 'U+25CA' 
; instead of the standard alt-code '9674'
;
; Adapted from http://ahkscript.org/docs/commands/SetTimer.htm
;
#EscapeChar \
$`::
if winc_presses > 0 ; SetTimer already started, so we log the keypress instead.
{
    winc_presses += 1
    return
}
; Otherwise, this is the first press of a new series. Set count to 1 and start
; the timer:
winc_presses = 1
SetTimer, KeyWinC, 400 ; Wait for more presses within a 400 millisecond window.
return
KeyWinC:
SetTimer, KeyWinC, off
if winc_presses = 1 ; The key was pressed once.
{
    Send `
}
else if winc_presses = 2 ; The key was pressed twice.
{
    Send {U+25CA}
}
else if winc_presses > 2
{
    MsgBox, Three or more backticks detected.
}
; Regardless of which action above was triggered, reset the count to
; prepare for the next series of presses:
winc_presses = 0
return

Tags: Racket, AHK, code