Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Smart quotation marks and em dashes in BlogJet


  • Please log in to reply
3 replies to this topic
twwilliams
  • Members
  • 23 posts
  • Last active: May 07 2010 09:01 PM
  • Joined: 24 May 2004
I've recently started using BlogJet to post to my blog, but it has one limitation: it doesn't have any way to enter "smart" quotation marks and other typographically-correct symbols (such as em dashes).

So I wrote this script that makes it behave like Microsoft Word with its autoformat as you type capabilities:

#SingleInstance
SetBatchLines,  10ms
SetKeyDelay,   -1

enabled             = 1
blogJetAndEnabled   = 0
inQuotedString      = 0

#F12::
If enabled = 1
{
    ToolTip, Typography disabled
    SetTimer, RemoveToolTip, 1000
    enabled = 0
}
else
{
    ToolTip, Typography enabled
    SetTimer, RemoveToolTip, 1000
    enabled = 1
}
return

~'::
Gosub, CheckForBlogJet
If blogJetAndEnabled = 1
    Send, {backspace}{ASC 0146}
return

~"::
Gosub, CheckForBlogJet
If blogJetAndEnabled = 1
{
    If inQuotedString = 0
    {
        ;not in a quoted string
        Send, {backspace}{ASC 0147}
        inQuotedString = 1
    }
    else
    {
        ;in a quoted string
        Send, {backspace}{ASC 0148}
        inQuotedString = 0
    }
}
return

~-::
Gosub, CheckForBlogJet
If blogJetAndEnabled = 1
{
    MatchChar = -
    Input, UserInput, VT2L1, {esc}{tab}, -
    if UserInput = -
        Send, {backspace 2}{ASC 0151}
}
return

CheckForBlogJet:
IfWinActive, Tommy Blogs - BlogJet
    blogJetAndEnabled = 1
else
    blogJetAndEnabled = 0
If enabled = 0
    blogJetAndEnabled = 0
return

RemoveToolTip:
SetTimer, RemoveToolTip, Off
ToolTip
return

Tommy

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Looks interesting. It's great that someone's used the Input command for something other than auto-replace (abbreviation expansion).

twwilliams
  • Members
  • 23 posts
  • Last active: May 07 2010 09:01 PM
  • Joined: 24 May 2004
Well, even my use of the Input command is just a variation on auto-replace, since I'm turning -- into an em dash.

But I could imagine turning Input into something like ActiveWords (http://www.activewords.com/) where you can type a word anywhere, and it can become an autoreplace value, or a trigger to launch another process.
Tommy

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
ActiveWords sounds interesting. I hope to make auto-replace a more intrinsic feature of AHK in future versions: Something that supports a set of configurable end-word punctation marks , while being easier to script than Input (Input will still have its uses because it is very flexible). With the ideas that others have shared with me, I'm starting visualize auto-replace as a subset of Rajat's "hot strings", which are basically abbreviations that trigger some type of action, whether it be auto-replace or launching a program.