an interfaceless calculator that can be used almost anywhere in windows where you can enter text
- activate the calculator by pressing the = key, type an equation and then press the = key to delete the equation and paste the result, or end with the # key to leave the equation text where it is and paste the result after it
- you can also select equation text and use the hotkeys alt + = or alt + # to calculate it
- if youre using a keyboard that doesnt have a number pad then you can use the letter keys p m x d instead of + - * / which makes this easier to type since you dont have to use the shift key
see the github page for more details
latest release: v2.4.2 (10th october 2017)
https://github.com/davebrny/in-line-calculator/releases
in-line calculator
in-line calculator
Last edited by davebrny on 10 Oct 2017, 03:33, edited 3 times in total.
Re: in-line calculator
Good idea
I will test this.
I will test this.
-
- Posts: 26
- Joined: 15 May 2016, 07:49
Re: in-line calculator
nice one - very handy
This can greatly improve productivity !
This can greatly improve productivity !
Re: in-line calculator
ive think ironed out all the bugs at this stage (on my system anyway) but if you find some more then be sure to give me a roasting here or on githubHelgef wrote:Good idea
I will test this.
yes, the less going back and forth between the windows calculator and some other program the betterSpecialGuest wrote:nice one - very handy
This can greatly improve productivity !
thanks!guest3456 wrote:vnice
seems like the same sort of idea yea. i made this nearly a year and a half ago now so that was the last time i checked to see if there was anything similar around. i didnt come across that script by Laszlo though so i must look around for that. do a bit of light pillaging on it maybe...
Re: in-line calculator
ive changed how this works slightly.
https://github.com/davebrny/in-line-calculator/releases
instead of the calculator becoming active when you first press one of the number keys, you now have to press the grave/backtick key and then type an equation.
there were a few situations where you could be typing something like a date (12-01-2017) and then one of the end keys (= or #) after it which would mean the date would be calculated by accident... so this should cut down the chances of things like that happening
https://github.com/davebrny/in-line-calculator/releases
instead of the calculator becoming active when you first press one of the number keys, you now have to press the grave/backtick key and then type an equation.
there were a few situations where you could be typing something like a date (12-01-2017) and then one of the end keys (= or #) after it which would mean the date would be calculated by accident... so this should cut down the chances of things like that happening
-
- Posts: 175
- Joined: 24 Dec 2016, 13:16
- Location: Antarctica
Re: in-line calculator
HERE's A FAR SIMPLER ALTERNATIVE: in just 70lines,
valid inputs are: "x=4+12 OUTPUT: 'x=16' " OR "4+12 OUTPUT: '16' "
Just select the expression you want to calculate & press Ctrl+Shift+C,the answer as in the examples will replace selected expression. CHEERS.
valid inputs are: "x=4+12 OUTPUT: 'x=16' " OR "4+12 OUTPUT: '16' "
Just select the expression you want to calculate & press Ctrl+Shift+C,the answer as in the examples will replace selected expression. CHEERS.
Code: Select all
#SingleInstance, force
#NoTrayIcon
/*
Copy selected input which must be an expression,then execute it as a separate script that pastes the value of the expression inplace of the selected input:
Examples: ;select the string to evaluate as an expression
x=4+12 OUTPUT: 'x=16'
OR
4+12 OUTPUT: '16'
*/
^+c:: ;calculate select text as an expression
GetExecExpression()
Return
GetExecExpression(){
Send ^c
; MsgBox, DEBUG1 = %clipboard%
if clipboard contains `= ;if expression is sth like x=123+4524, then the value of x is output as 'x'='value'
{
Loop, Parse, clipboard, `= ;split the equation
{
if (A_Index=1)
varOutName:=A_LoopField
else
expression.=A_LoopField
}
execExp=
(
%varOutName%:=%expression%
%varOutName%:=Round(%varOutName%, 3)
Clipboard:=%varOutName%
)
ExecScript(execExp, true)
clipBuffer:=Clipboard
Clipboard:= varOutName . "=" . clipBuffer
; MsgBox, DEBUG2 = %clipboard%
if clipBuffer is number
Send ^v ;once expression is calculated & a valid number in the clipboard paste output value
else
MsgBox, 0x40010, %A_ScriptName%, Selected Input was not an expression!
}
else ;if expression is sth like 2(123+123)/4, then the value of the expression is output as 'value'
{
execExp=
(
x:=%clipboard%
x:=Round(x, 3)
Clipboard:=x
)
ExecScript(execExp, true)
clipBuffer:=Clipboard
; MsgBox, DEBUG3 = %clipboard%
if clipBuffer is number
Send ^v ;once expression is calculated & a valid number in the clipboard paste output value
else
MsgBox, 0x40010, %A_ScriptName%, Selected Input was not an expression!
}
}
; ExecScript: Executes the given code as a new AutoHotkey process.
ExecScript(Script, Wait:=true)
{
shell := ComObjCreate("WScript.Shell")
exec := shell.Exec("AutoHotkey.exe /ErrorStdOut *")
exec.StdIn.Write(script)
exec.StdIn.Close()
if Wait
return exec.StdOut.ReadAll()
}
Outsourcing Clicks & Presses Since 2004.
Re: in-line calculator
@davebrny
I remember I had some problems with this script too, it might be for the same reasons Pinkfloydd describes. I ended up doing something similar to brutus_skywalker, I use it all the time, so thank you very much for the idea.
I remember I had some problems with this script too, it might be for the same reasons Pinkfloydd describes. I ended up doing something similar to brutus_skywalker, I use it all the time, so thank you very much for the idea.
Re: in-line calculator
This script nor Brutus script works with either Unix Exceed or Windows version of Emacs. Brutus script doesn't replace the highlighted text but it sometimes copies the answer to the clipboard but not for the windows version of Emacs. Davebrny's script doesn't work at all for Exceed or Emacs.
-
- Posts: 33
- Joined: 09 Apr 2016, 22:14
Re: in-line calculator
Nice, thanks... Check out also this one by derRaphael, which may contain some useful code:
https://autohotkey.com/board/topic/5908 ... -brackets/
https://autohotkey.com/board/topic/5908 ... -brackets/
Re: in-line calculator
Just so people new to this thread don't get the wrong impression about davebrny's script: I've been using his original script (without the back tick key to initiate) with a US keyboard, and I really like it. It's usage is simple, which is what matters to the user rather than the number of lines in the code (it's nowhere close to being a resource hog). It also has more features and is more flexible than the simpler code.
Re: in-line calculator
i have made a few changes to this script:
- the equals key is now the default trigger that starts the calculator instead of the grave/backtick key
- the default key can now be changed to another key such as #, [ or the backtick
- if "trigger_key" is left blank then the calculator will start when any of the number keys are pressed (like in the original version)
- the number pad enter key can be used to send both the trigger key and endkey
- - this works best when the trigger key is left blank as the enter key will still send 'enter' when the calculator is off
https://github.com/davebrny/in-line-calculator/releases v2.4.2
- the equals key is now the default trigger that starts the calculator instead of the grave/backtick key
- the default key can now be changed to another key such as #, [ or the backtick
- if "trigger_key" is left blank then the calculator will start when any of the number keys are pressed (like in the original version)
- the number pad enter key can be used to send both the trigger key and endkey
- - this works best when the trigger key is left blank as the enter key will still send 'enter' when the calculator is off
https://github.com/davebrny/in-line-calculator/releases v2.4.2
ive gone back to triggering it with the number keys. even after a few months of trying to use the backtick, i still couldnt get rid of the muscle memory that i had built up with the original scriptboiler wrote:I've been using his original script (without the back tick key to initiate)
Re: in-line calculator
What a nice, handy tool! Unfortunately only the exe works for me, but not the script itself, any idea why?
-
- Posts: 4
- Joined: 25 Aug 2014, 15:09
- Location: USA
Re: in-line calculator
Put this code into a file, compiled it and tried to start the executable, but got stopped by Windows:brutus_skywalker wrote: ↑15 Jun 2017, 10:05HERE's A FAR SIMPLER ALTERNATIVE: in just 70lines,
valid inputs are: "x=4+12 OUTPUT: 'x=16' " OR "4+12 OUTPUT: '16' "
Just select the expression you want to calculate & press Ctrl+Shift+C,the answer as in the examples will replace selected expression. CHEERS.
{code removed}
"Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item."
Windows 10 Enterprise, limited account.
Older executables built with AHK don't see to have the same problem.
Anyone else see this error or know of a work-around?
Regards,
PJ
Re: in-line calculator
Hello
I have exactly the same problem.
With the exe running, =5p5= is replaced by 10; With the AHK running it just remains.
I would love to have the tool's functionality. I tried to find the problem in the code, but I couldn't figure it out. In fact, I did not even find where the „=“ triggers the script.
Davebrny - do you have any idea why user silence and I have this problem?
Kind regards, Hauke
PS 1 230321-210739: UPDATE
In standard INI file, both trigger_key and result_endkey are set to „=“.
When I change the result_endkey to something else, it works as expected.
-
- Posts: 3
- Joined: 07 Dec 2017, 15:08
Re: in-line calculator
Just discovered this script also does "to the power of" calculations (exponentiation). Just use ** (or bb, tt, xx).
Three squared...
=3xx2= --> 9
Four to the power of four...
=4xx4= --> 256
Square root of sixteen...
=16xx0.5= --> 4
Three squared...
=3xx2= --> 9
Four to the power of four...
=4xx4= --> 256
Square root of sixteen...
=16xx0.5= --> 4
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: wilkster and 46 guests