|
; This file must be saved with UTF-8-BOM encoding to work correctly. |
|
|
|
; Custom icon from http://www.famfamfam.com/lab/icons/silk/preview.php |
|
; Converted from PNG to ICO |
|
Menu, Tray, Icon, application-x-qalculate.ico |
|
|
|
#NoEnv ; For security |
|
; Avoids checking empty variables to see if they are environment variables (recommended for all new scripts). |
|
|
|
#SingleInstance force |
|
|
|
#q:: |
|
Clipboard= ; this line must be after the Win+Q or it won't get executed and the ClipWait has no effect |
|
Send ^c |
|
ClipWait, 1 ; put a timeout so it doesn't get stuck if invoked with empty clipboard |
|
if ErrorLevel ; if timeout |
|
return |
|
Myclip := Clipboard |
|
Myclip := StrReplace(Myclip, Chr(0x2126), "ohm") ; Replace ohm sign (U+2126, Ω) with ohm |
|
Myclip := StrReplace(Myclip, Chr(0x03A9), "ohm") ; Replace uppercase omega character (U+03A9, Ω) with ohm |
|
; Replace superscript numbers with regular exponent notation |
|
Myclip := StrReplace(Myclip, "⁰", "^0") |
|
Myclip := StrReplace(Myclip, "¹", "^1") |
|
Myclip := StrReplace(Myclip, "²", "^2") |
|
Myclip := StrReplace(Myclip, "³", "^3") |
|
Myclip := StrReplace(Myclip, "⁴", "^4") |
|
Myclip := StrReplace(Myclip, "⁵", "^5") |
|
Myclip := StrReplace(Myclip, "⁶", "^6") |
|
Myclip := StrReplace(Myclip, "⁷", "^7") |
|
Myclip := StrReplace(Myclip, "⁸", "^8") |
|
Myclip := StrReplace(Myclip, "⁹", "^9") |
|
RunWait, cmd.exe /c qalc "%Myclip%" | clip,,hide |
|
Clipboard := RegExReplace(Clipboard, "\R", "") ; Remove newline characters from the result |
|
SendRaw % Myclip " = " Clipboard |
|
Sleep, 500 ; must wait to give time to paste before clearing clipboard |
|
Clipboard= |
|
return ; really should have this, especially if other code follows |
Put together a version of this which is compatible with AHK v2, with some tweaks to preserve clipboard content: