Maths Calculations With AutoHotKey Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Guest

Maths Calculations With AutoHotKey

Post by Guest » 28 Nov 2017, 12:55

....
Last edited by Guest on 17 Mar 2023, 22:27, edited 2 times in total.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Maths Calculations With AutoHotKey

Post by BoBo » 28 Nov 2017, 13:30

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 ?!

Guest

Re: Maths Calculations With AutoHotKey

Post by Guest » 28 Nov 2017, 13:41

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

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Maths Calculations With AutoHotKey  Topic is solved

Post by BoBo » 28 Nov 2017, 13:44

So you want to use it for a game as well?!

Guest

Re: Maths Calculations With AutoHotKey

Post by Guest » 28 Nov 2017, 13:46

BoBo wrote:So you want to use it for a game as well?!
Yes preferably an in-client virtual game.
Last edited by Guest on 07 Jul 2018, 08:42, edited 1 time in total.

Rohwedder
Posts: 7719
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Maths Calculations With AutoHotKey

Post by Rohwedder » 28 Nov 2017, 14:29

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%
Last edited by Rohwedder on 28 Nov 2017, 14:43, edited 1 time in total.

Guest

Re: Maths Calculations With AutoHotKey

Post by Guest » 28 Nov 2017, 14:41

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.

Rohwedder
Posts: 7719
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Maths Calculations With AutoHotKey

Post by Rohwedder » 28 Nov 2017, 14:44

Hallo,
do not use "="
simple e.g.
3*(1+2)

User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Maths Calculations With AutoHotKey

Post by Exaskryz » 28 Nov 2017, 14:51

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.

Guest

Re: Maths Calculations With AutoHotKey

Post by Guest » 28 Nov 2017, 15:06

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.

Guest

Re: Maths Calculations With AutoHotKey

Post by Guest » 29 Nov 2017, 11:43

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.

Nightwolf85
Posts: 302
Joined: 05 Feb 2017, 00:03

Re: Maths Calculations With AutoHotKey

Post by Nightwolf85 » 29 Nov 2017, 11:53

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.

Guest

Re: Maths Calculations With AutoHotKey

Post by Guest » 29 Nov 2017, 12:22

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

Nightwolf85
Posts: 302
Joined: 05 Feb 2017, 00:03

Re: Maths Calculations With AutoHotKey

Post by Nightwolf85 » 29 Nov 2017, 12:25

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.

Guest

Re: Maths Calculations With AutoHotKey

Post by Guest » 29 Nov 2017, 12:28

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.

Nightwolf85
Posts: 302
Joined: 05 Feb 2017, 00:03

Re: Maths Calculations With AutoHotKey

Post by Nightwolf85 » 29 Nov 2017, 12:39

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.

User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Maths Calculations With AutoHotKey

Post by Exaskryz » 29 Nov 2017, 12:45

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.

Guest

Re: Maths Calculations With AutoHotKey

Post by Guest » 29 Nov 2017, 12:48

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
Attachments
lol.ahk
(146 Bytes) Downloaded 71 times
Last edited by Guest on 29 Nov 2017, 12:52, edited 1 time in total.

Guest

Re: Maths Calculations With AutoHotKey

Post by Guest » 29 Nov 2017, 12:51

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.

Nightwolf85
Posts: 302
Joined: 05 Feb 2017, 00:03

Re: Maths Calculations With AutoHotKey

Post by Nightwolf85 » 29 Nov 2017, 12:54

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

Post Reply

Return to “Ask for Help (v1)”