Jon Aquino's Mental Garden

Engineering beautiful software jon aquino labs | personal blog

Saturday, August 08, 2009

Adding up all the numbers in the clipboard

Wouldn’t it be nifty to have a hotkey that will add up all the numbers in the clipboard? You could select a table on a webpage and instantly add up the values. Or if you wanted to add up a bunch of numbers, just type out the numbers, copy them to the clipboard, then hit the hotkey.

Scripting/automation tools make this pretty easy to do. Here’s such a script for AutoHotKey for Windows:

Sum := 0
String := Clipboard
FoundPosition := 1
FoundPosition := RegExMatch(String, "[0-9.]+", Match, FoundPosition)
If FoundPosition = 0
Sum := Sum + Match
FoundPosition := FoundPosition + StrLen(Match)
Send %Sum%

Typing sum [Tab] will output the sum of any numbers found in the clipboard.


  • Hi Jon,

    I found this on the web, and I think it is exactly what I need as I frequently need to do a quick sum of cells returned from SQL Server while debugging code.

    However I cannot get this to work in AutoHotKey at all. I can't seem to get your script to run against an assigned key. Any suggestions as to what I'm doing wrong?

    Thanks in advance,


    By Anonymous Richard Rose, at 7/29/2011 1:16 a.m.  

  • Hi Richard,

    Alas, I now use a Mac, so I don't readily have a copy of AutoHotKey to try this again on.


    By Blogger Jonathan, at 7/29/2011 5:33 p.m.  

Post a Comment

<< Home