Page 1 of 2

Maths Calculations With AutoHotKey

Posted: 28 Nov 2017, 12:55
by Guest
....

Re: Maths Calculations With AutoHotKey

Posted: 28 Nov 2017, 13:30
by BoBo

Code: Select all

!c::  ; press Alt + c to "google" using the content of your clipboard
   Send, ^c
   Run, % "https://goosh.org/#calculate " . ClipBoard
   Return
... now you need to parse the content of the response

Another toy: https://code.google.com/archive/p/cli4g/

Probably you can use the "="-character to create an AHK hotstring that triggers the calculation ?!

Re: Maths Calculations With AutoHotKey

Posted: 28 Nov 2017, 13:41
by Guest
BoBo wrote:

Code: Select all

!c::  ; press Alt + c to "google" using the content of your clipboard
   Send, ^c
   Run, % "https://goosh.org/#calculate " . ClipBoard
   Return
... now you need to parse the content of the response

Another toy: https://code.google.com/archive/p/cli4g/

Probably you can use the "="-character to create an AHK hotstring that triggers the calculation ?!


This wasn't what I was looking for. I don't want another tab to open up. I just want to type a calculation into any text box and the answer will appear. Please refer to this thread as it is similar to what I'm looking for but on that one it only works for notepad. https://autohotkey.com/boards/viewtopic.php?f=5&t=2394

Re: Maths Calculations With AutoHotKey

Posted: 28 Nov 2017, 13:44
by BoBo
So you want to use it for a game as well?!

Re: Maths Calculations With AutoHotKey

Posted: 28 Nov 2017, 13:46
by Guest
BoBo wrote:So you want to use it for a game as well?!
Yes preferably an in-client virtual game.

Re: Maths Calculations With AutoHotKey

Posted: 28 Nov 2017, 14:29
by Rohwedder
Hallo,
try:

Code: Select all

InputBox, Calc, Calculation, type your Calculation e.g.`n 3*(1+2)
FileDelete, A.ahk
FileAppend , ClipBoard := %Calc%, A.ahk
RunWait, A.ahk
MsgBox,, Result, Result = %ClipBoard%

Re: Maths Calculations With AutoHotKey

Posted: 28 Nov 2017, 14:41
by Guest
Rohwedder wrote:Hallo,
try:

Code: Select all

InputBox, Calc, Calculation, type your Calculation
FileDelete, A.ahk
FileAppend , ClipBoard := %Calc%, A.ahk
RunWait, A.ahk
MsgBox,, Result, Result = %ClipBoard%
How do I run this under normal notepad autohotkey script.

Re: Maths Calculations With AutoHotKey

Posted: 28 Nov 2017, 14:44
by Rohwedder
Hallo,
do not use "="
simple e.g.
3*(1+2)

Re: Maths Calculations With AutoHotKey

Posted: 28 Nov 2017, 14:51
by Exaskryz
Have you done the tutorial Manlikezab? Rohwedder's code works as is. If you save this into its own AHK script and launch it, it will do the calculation for you. Do note that it won't correctly do something like 3^2=9, because AHK does not recognize the ^ operator as the exponent operator. You would need to enter into the InputBox 3**2.

The way Roh's script is working is by creating a new AHK script called A.ahk. The command is for it to do ClipBoard := ____ where ___ is the equation you typed into the InputBox. This works because of the nature of the Clipboard variable being shared across scripts (and the entire system). The := is the assign operator which evaluates any equations, like 2+2 to result in 4, putting 4 on the clipboard.

You would be able to replace the MsgBox line with a Send ^v to paste it if you'd like.


It's going to take more work to figure out how to trigger it natively in Chrome. You'd need to be able to identify what the equation is. I personally suggest using a hotkey like Ctrl+= ^=:: when you start to type your equation. Have it use the Input command. And wait for the = operator as the ending character; you may use the V (visible) parameter. If you use the V parameter, you will want to send as many {BackSpace}s as there are characters in your equation. Easily done by using the StrLen() function to check the length of the variable you captured in the Input command.

Re: Maths Calculations With AutoHotKey

Posted: 28 Nov 2017, 15:06
by Guest
Exaskryz wrote:Have you done the tutorial Manlikezab? Rohwedder's code works as is. If you save this into its own AHK script and launch it, it will do the calculation for you. Do note that it won't correctly do something like 3^2=9, because AHK does not recognize the ^ operator as the exponent operator. You would need to enter into the InputBox 3**2.

The way Roh's script is working is by creating a new AHK script called A.ahk. The command is for it to do ClipBoard := ____ where ___ is the equation you typed into the InputBox. This works because of the nature of the Clipboard variable being shared across scripts (and the entire system). The := is the assign operator which evaluates any equations, like 2+2 to result in 4, putting 4 on the clipboard.

You would be able to replace the MsgBox line with a Send ^v to paste it if you'd like.


It's going to take more work to figure out how to trigger it natively in Chrome. You'd need to be able to identify what the equation is. I personally suggest using a hotkey like Ctrl+= ^=:: when you start to type your equation. Have it use the Input command. And wait for the = operator as the ending character; you may use the V (visible) parameter. If you use the V parameter, you will want to send as many {BackSpace}s as there are characters in your equation. Easily done by using the StrLen() function to check the length of the variable you captured in the Input command.
Thank you so much, I was concerned about the Msgbox appearing before I then paste and press enter. Whereas your replacement of Msgbox to Send ^v automatically drops it into my textbox and then I press enter.

Re: Maths Calculations With AutoHotKey

Posted: 29 Nov 2017, 11:43
by Guest
Exaskryz wrote:Have you done the tutorial Manlikezab? Rohwedder's code works as is. If you save this into its own AHK script and launch it, it will do the calculation for you. Do note that it won't correctly do something like 3^2=9, because AHK does not recognize the ^ operator as the exponent operator. You would need to enter into the InputBox 3**2.

The way Roh's script is working is by creating a new AHK script called A.ahk. The command is for it to do ClipBoard := ____ where ___ is the equation you typed into the InputBox. This works because of the nature of the Clipboard variable being shared across scripts (and the entire system). The := is the assign operator which evaluates any equations, like 2+2 to result in 4, putting 4 on the clipboard.

You would be able to replace the MsgBox line with a Send ^v to paste it if you'd like.


It's going to take more work to figure out how to trigger it natively in Chrome. You'd need to be able to identify what the equation is. I personally suggest using a hotkey like Ctrl+= ^=:: when you start to type your equation. Have it use the Input command. And wait for the = operator as the ending character; you may use the V (visible) parameter. If you use the V parameter, you will want to send as many {BackSpace}s as there are characters in your equation. Easily done by using the StrLen() function to check the length of the variable you captured in the Input command.

I am experiencing some delay with the input of calculation, would you know why?
Like if I type a calculation in the textbox and then immediately after I do another one it doesn't paste the answer.

Re: Maths Calculations With AutoHotKey

Posted: 29 Nov 2017, 11:53
by Nightwolf85
Have you tried using this?
https://github.com/davebrny/in-line-calculator/releases
from here:
https://autohotkey.com/boards/viewtopic.php?t=27431

Edit:
To have it do what you requested just open the settings.ini file and set the trigger key to nothing.

Re: Maths Calculations With AutoHotKey

Posted: 29 Nov 2017, 12:22
by Guest
Nightwolf85 wrote:Have you tried using this?
https://github.com/davebrny/in-line-calculator/releases
from here:
https://autohotkey.com/boards/viewtopic.php?t=27431

Edit:
To have it do what you requested just open the settings.ini file and set the trigger key to nothing.
Image

What is going on? I double clicked the script icon and it's not functioning

Re: Maths Calculations With AutoHotKey

Posted: 29 Nov 2017, 12:25
by Nightwolf85
Manlikezab12 wrote:...
You are running it when it is still compressed, this doesn't allow it to access the lib folder and it contains required functions.

unzip it first.

Re: Maths Calculations With AutoHotKey

Posted: 29 Nov 2017, 12:28
by Guest
Nightwolf85 wrote:
Manlikezab12 wrote:...
You are running it when it is still compressed, this doesn't allow it to access the lib folder and it contains required functions.

unzip it first.
So after I unzip how does it work? I type 2*2 it will come up as 4? or do I have to modify something as you said.

Re: Maths Calculations With AutoHotKey

Posted: 29 Nov 2017, 12:39
by Nightwolf85
Manlikezab12 wrote:So after I unzip how does it work? I type 2*2 it will come up as 4? or do I have to modify something as you said.
Open the settings file and make the trigger key equal nothing
i.e.

Code: Select all

[settings]
enable_hotstrings = yes
trigger_key       = (DELETE what was here)
result_endkey     = =
equation_endkey   = #

result_hotkey   = !=
equation_hotkey = !#
history_hotkey  = ^!=
history_max     = 15

enable_number_row  = yes
enable_number_pad  = yes
numpadEnter_endKey = no
timeout            = T60
then you just type out 4+4= and it will auto erase and put 8

by default I think you would need to type =4+4=, so to do what I think you described you need to make that modification in the settings.

Re: Maths Calculations With AutoHotKey

Posted: 29 Nov 2017, 12:45
by Exaskryz
Manlikezab12 wrote:
Exaskryz wrote:Have you done the tutorial Manlikezab? Rohwedder's code works as is. If you save this into its own AHK script and launch it, it will do the calculation for you. Do note that it won't correctly do something like 3^2=9, because AHK does not recognize the ^ operator as the exponent operator. You would need to enter into the InputBox 3**2.

The way Roh's script is working is by creating a new AHK script called A.ahk. The command is for it to do ClipBoard := ____ where ___ is the equation you typed into the InputBox. This works because of the nature of the Clipboard variable being shared across scripts (and the entire system). The := is the assign operator which evaluates any equations, like 2+2 to result in 4, putting 4 on the clipboard.

You would be able to replace the MsgBox line with a Send ^v to paste it if you'd like.


It's going to take more work to figure out how to trigger it natively in Chrome. You'd need to be able to identify what the equation is. I personally suggest using a hotkey like Ctrl+= ^=:: when you start to type your equation. Have it use the Input command. And wait for the = operator as the ending character; you may use the V (visible) parameter. If you use the V parameter, you will want to send as many {BackSpace}s as there are characters in your equation. Easily done by using the StrLen() function to check the length of the variable you captured in the Input command.

I am experiencing some delay with the input of calculation, would you know why?
Like if I type a calculation in the textbox and then immediately after I do another one it doesn't paste the answer.
It would depend on what code you ended up running.

Re: Maths Calculations With AutoHotKey

Posted: 29 Nov 2017, 12:48
by Guest
Exaskryz wrote:
Manlikezab12 wrote:
Exaskryz wrote:Have you done the tutorial Manlikezab? Rohwedder's code works as is. If you save this into its own AHK script and launch it, it will do the calculation for you. Do note that it won't correctly do something like 3^2=9, because AHK does not recognize the ^ operator as the exponent operator. You would need to enter into the InputBox 3**2.

The way Roh's script is working is by creating a new AHK script called A.ahk. The command is for it to do ClipBoard := ____ where ___ is the equation you typed into the InputBox. This works because of the nature of the Clipboard variable being shared across scripts (and the entire system). The := is the assign operator which evaluates any equations, like 2+2 to result in 4, putting 4 on the clipboard.

You would be able to replace the MsgBox line with a Send ^v to paste it if you'd like.


It's going to take more work to figure out how to trigger it natively in Chrome. You'd need to be able to identify what the equation is. I personally suggest using a hotkey like Ctrl+= ^=:: when you start to type your equation. Have it use the Input command. And wait for the = operator as the ending character; you may use the V (visible) parameter. If you use the V parameter, you will want to send as many {BackSpace}s as there are characters in your equation. Easily done by using the StrLen() function to check the length of the variable you captured in the Input command.

I am experiencing some delay with the input of calculation, would you know why?
Like if I type a calculation in the textbox and then immediately after I do another one it doesn't paste the answer.
It would depend on what code you ended up running.
I did the Roh's script where I changed Msgbox to Send ^v

Re: Maths Calculations With AutoHotKey

Posted: 29 Nov 2017, 12:51
by Guest
Nightwolf85 wrote:
Manlikezab12 wrote:So after I unzip how does it work? I type 2*2 it will come up as 4? or do I have to modify something as you said.
Open the settings file and make the trigger key equal nothing
i.e.

Code: Select all

[settings]
enable_hotstrings = yes
trigger_key       = (DELETE what was here)
result_endkey     = =
equation_endkey   = #

result_hotkey   = !=
equation_hotkey = !#
history_hotkey  = ^!=
history_max     = 15

enable_number_row  = yes
enable_number_pad  = yes
numpadEnter_endKey = no
timeout            = T60
then you just type out 4+4= and it will auto erase and put 8

by default I think you would need to type =4+4=, so to do what I think you described you need to make that modification in the settings.

Yeah that's the problem, I don't want to type = button before it will give me answer. I want to type it plain without = and then it gives answer.
Is there a trigger key such as enter key? Like It triggers when you press enter key? I'm not too sure if that would work. I'm new to this so I'm struggling.

Re: Maths Calculations With AutoHotKey

Posted: 29 Nov 2017, 12:54
by Nightwolf85
Manlikezab12 wrote:Yeah that's the problem, I don't want to type = button before it will give me answer. I want to type it plain without = and then it gives answer.
Is there a trigger key such as enter key? Like It triggers when you press enter key? I'm not too sure if that would work. I'm new to this so I'm struggling.
Sorry in your OP you listed out equations ending in an equal sign.

Just change the result_endkey to enter

Code: Select all

[settings]
enable_hotstrings = yes
trigger_key       =
result_endkey     = enter
equation_endkey   = #

result_hotkey   = !=
equation_hotkey = !#
history_hotkey  = ^!=
history_max     = 15

enable_number_row  = yes
enable_number_pad  = yes
numpadEnter_endKey = no
timeout            = T60