WinCalcHelper improves the Windows Calculator
September 10, 2014
We use the Windows Calculator a great deal, but wanted to make it more efficient. AutoHotkey was happy to oblige. This script adds the following features:
- Pressing your keyboard's Calculator key turns Num Lock on if it is off.
- Pressing your keyboard's Calculator key recalls the most recently used Calculator, or opens a new one if a Calculator is currently active.
- Holding your keyboard's Calculator key closes the active Calculator.
- Using the Windows + Arrow keys allows you to position the calculator.
- The Num Lock key can be used to clear the calculator.
; WinCalcHelper - by Mango - http://www.toao.net/
#NoTrayIcon
#SingleInstance force
; If the Calculator key is pressed...
Launch_App2::
; Wait until the user releases the key, or time out after a short time.
KeyWait, Launch_App2, T.3 L
; Turn Num Lock on.
SetNumLockState, On
; If we held the key down, and Calculator is active, close Calculator.
if (ErrorLevel == 1 and WinActive("Calculator")) {
Send !{F4}
} else if (WinActive("Calculator") or !WinExist("Calculator")) {
; Open a new calculator if there isn't one open, or if there is one active.
Run, calc.exe
} else {
; If there is an inactive calculator, activate it.
WinActivate Calculator
}
return
#IfWinActive Calculator
; Move the Calculator to various positions, using Windows + arrow keys.
RWin & up::
LWin & up::
WinGetPos, X, Y
WinMove, X, (Y-250)
return
RWin & right::
LWin & right::
WinGetPos, X, Y
WinMove, (X+250), Y
return
RWin & down::
LWin & down::
WinGetPos, X, Y
WinMove, X, (Y+250)
return
RWin & left::
LWin & left::
WinGetPos, X, Y
WinMove, (X-250), Y
return
; Clear the calculator if Num Lock is pressed.
NumLock::
if (GetKeyState("NumLock", "T")) {
; Clear the calculator, since NumLock was already on.
Send {Esc}
} else {
; NumLock got accidentally turned off; turn it on.
SetNumLockState, On
}
return
#IfWinActive
; As a side effect of remapping the NumLock key to Esc, NumLock may not work the first time in other applications. The following code fixes that.
#IfWinNotActive Calculator
NumLock::
if (GetKeyState("NumLock", "T")) {
SetNumLockState, Off
} else {
SetNumLockState, On
}
return
#IfWinNotActive
To run or compile this script, here's a free download of AutoHotkey.