Skip to content

Superscript and Subscript keyboard shortcut with Autohotkey script

July 14, 2009

Currently there are many scripts to be posted but as some of you would probably benefit here I start posting some of my Autohotkey scripts for supermemo.

If you don’t currently use Autohotkey I’lll post some explanation of how to load it. But for starters is pretty easy, just copy the following text in a text file with the extension ahk after installing autohotkey and the keyboard shortcuts ctrl+win+p= superscript, and ctrl+win+b=subscript will be available.

;****************************
;.[#^p] #SuperScript: Change current selectec text to superscript
;*****************************
#^p::
Send, ^c
clipboard = <SUP>%clipboard%</SUP>
Send, {AppsKey}xp
return

;****************************
;.[#^p] #SubScript: Change current selectec text to subscript
;*****************************
#^b::
Send, ^c
clipboard = <SUB>%clipboard%</SUB>
Send, {AppsKey}xp
return

Thanks for the idea yahoo group. I’m planning on using this sort of scripts for highligthing in different colours (some thing I think is missing in SuperMemo).

Advertisements
14 Comments leave one →
  1. Marcin Rybacki permalink
    July 15, 2009 08:21

    VERY cool, thanks :))… Autohotkey never stops to amaze me :)… I’ll transform it to add text coloring which I’m doing heavily recently 🙂

    • gersapa permalink*
      July 15, 2009 08:30

      Text coloring looks a great way to enhance incremental reading. I’ll probably go only far as changing background. But a sample of your font options would be great, creativity grows on knowledge.

      • Marcin Rybacki permalink
        July 17, 2009 11:16

        You’re absolutely right!! For me this is a great way to enhance incremental reading. I make the font more colorful and bigger for the more significant fragments of text. I try to use different colors for the text which provides different meaning and the same color for the text which conveys similar or related meaning. Thanks to this when revising I can easily grasp within a single glimpse which fragments of a text are the most important (saves time!) and IF I can’t understand the colored text alone I can always read the uncolored text to understand the context!

        Here’s the scren from my knowledge base http://twitpic.com/anjzq

        Coloring script would look something like this
        #1::
        Send, ^c
        clipboard = %clipboard%
        Send, {AppsKey}xp
        return

  2. Dan permalink
    May 14, 2011 10:51

    I would love to get a hotkey for subscripting…but this didn’t work for me…
    When I press the hotkey of ctrl+win+b all I get is the right click menu shows up with paste highlighted and then the error ‘ding’ noise…

    I tried editing the script to this:
    #^b::
    Send, ^c
    clipboard = %clipboard%
    Send, ^v
    return

    Now I don’t get the menu or the ding but instead the text is replaced by
    %clipboard%

    Where %clipboard% is whatever I had highlighted, but the and show up as text, which is obviously not the desired result.

    For Example, trying to subscript the 2 in B2 gives me:
    B2

    I’m running vista if that sheds any light on this

    Anyone know what’s going on and how to fix it?
    Thanks in advance if you do,
    -Dan

  3. Dan permalink
    May 14, 2011 10:58

    So for some reason when I type a reply, like the last one, text with < doesn't show up which greatly confuses my last comment. I'm going to try reposting with this stipulation: ignore quotations.

    I would love to get a hotkey for subscripting…but this didn’t work for me…
    When I press the hotkey of ctrl+win+b all I get is the right click menu shows up with paste highlighted and then the error ‘ding’ noise…

    I tried editing the script to this:
    #^b::
    Send, ^c
    clipboard = "”%clipboard%””
    Send, ^v
    return

    Now I don’t get the menu or the ding but instead the text is replaced by
    “”%clipboard%””

    Where %clipboard% is whatever I had highlighted, but the and show up as text, which is obviously not the desired result.

    For Example, trying to subscript the 2 in B2 gives me:
    B””2″”

    I’m running vista if that sheds any light on this

    Anyone know what’s going on and how to fix it?
    Thanks in advance if you do,
    -Dan

    • Dan permalink
      May 14, 2011 11:02

      Nevermind…that didn’t work either. Let’s try again: I’ll use ? instead of
      I would love to get a hotkey for subscripting…but this didn’t work for me…
      When I press the hotkey of ctrl+win+b all I get is the right click menu shows up with paste highlighted and then the error ‘ding’ noise…

      I tried editing the script to this:
      #^b::
      Send, ^c
      clipboard = “”%clipboard%””
      Send, ^v
      return

      Now I don’t get the menu or the ding but instead the text is replaced by
      ?SUB??%clipboard%?/SUB??

      Where %clipboard% is whatever I had highlighted, but the and show up as text, which is obviously not the desired result.

      For Example, trying to subscript the 2 in B2 gives me:
      B?SUB??2?/SUB??

      I’m running vista if that sheds any light on this

      Anyone know what’s going on and how to fix it?
      Thanks in advance if you do,
      -Dan

      • Dan permalink
        May 14, 2011 11:03

        Absolute last try:
        Using ? instead of less than symbol, and ??instead of greater than symbol:

        I would love to get a hotkey for subscripting…but this didn’t work for me…
        When I press the hotkey of ctrl+win+b all I get is the right click menu shows up with paste highlighted and then the error ‘ding’ noise…

        I tried editing the script to this:
        #^b::
        Send, ^c
        clipboard = ?SUB??%clipboard%?/SUB??
        Send, ^v
        return

        Now I don’t get the menu or the ding but instead the text is replaced by
        ?SUB??%clipboard%?/SUB??

        Where %clipboard% is whatever I had highlighted, but the and show up as text, which is obviously not the desired result.

        For Example, trying to subscript the 2 in B2 gives me:
        B?SUB??2?/SUB??

        I’m running vista if that sheds any light on this

        Anyone know what’s going on and how to fix it?
        Thanks in advance if you do,
        -Dan

        • Daniel permalink
          July 22, 2011 17:54

          Dan. {Appskey} represents a right-click as you know. It brings up a right-click menu. Usually menu items have a shortcut key, for example if you right-click inside a supermemo question and press x you will get to ‘Text’ on the right-click menu. If you press a key that doesn’t correspond to anything on the right-click menu then it will go ‘ding’. I suppose that is what is happening with you. The script says send {appskey}xp which means press the right-click key then x then p. For me that selects Paste HTML. I don’t know why it isn’t selecting for you. You have the select some text in a Supermemo question (inside supermemo) and then press #^b. Are you definitely doing that? It won’t work in notepad. Sorry if this all is obvious.

        • Daniel permalink
          July 31, 2011 00:33

          ; [] < <

  4. Daniel permalink
    July 22, 2011 13:40

    Thanks so much for this – i’ve been going through the mill trying to work out how to *quickly* change the font in certain places for 9 thousand SM questions. I just replaced %Clipboard% with %Clipboard%

    Works like a dream. Fantastic – thank you!

    • Daniel permalink
      July 22, 2011 13:41

      I mean: sup>%Clipboard% /sup> with span style=”font-family:Courier new”>%Clipboard% /span>

  5. Daniel permalink
    July 31, 2011 00:48

    Your script *is* excellent,.Thank you again. But it can be improved with Clipwait and Stringreplace. The biggest problem is that it messes around with spaces. This works better:

    #^p::
    Send, ^c
    clipwait
    stringreplace, clipboard, clipboard, <, & lt;, all
    stringreplace, clipboard, clipboard, %a_Space%, XXX, all
    clipboard = %clipboard%
    stringreplace, clipboard, clipboard, XXX, %a_Space%, all
    Send, {AppsKey}xp
    return

    Hopefully this will appear ok. Please remove the space between the ampersand and the letters lt semi-colon.

    • Daniel permalink
      July 31, 2011 00:57

      ah sorry the server clobbered one of the lines there. clipboard = %clipboard% is wrong – it should have some HTML around it like in your script.

      In my script I use (lets see if this will work): clipboard = <span style=”font-size:10pt; font-family:Times New Roman; color:black”>%clipboard%</span>

Trackbacks

  1. A really simple AutoHotkey scripter tutorial « The SuperMemo Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: