How to calculate a variable that contains digits

Get help with using AutoHotkey and its commands and hotkeys
vsub
Posts: 476
Joined: 29 Sep 2015, 03:39

How to calculate a variable that contains digits

If I set the number into a variable or a message box,then AHk calculates them but if I copy the numbers and use the clipboard as variable,AHk will display them rather than calculate them

Var = 5+5
Msgbox,% var ; displays 5+5

var := 5+5
msgbox,% var ; displays 10

var := Clipboard ; the clipboard contains 5+5
msgbox,% var ; displays 5+5

Var1 = 5+5
var2 := var1
msgbox,% var2 ; displays 5+5
YoucefHam
Posts: 344
Joined: 24 Aug 2015, 12:56
Facebook: https://fb.me/YoucefHamDz
Google: [email protected]
GitHub: YoucefHam
Location: Algeria
Contact:

Re: How to calculate a variable that contains digits

There is always more than one way to solve a problem.
vsub
Posts: 476
Joined: 29 Sep 2015, 03:39

Re: How to calculate a variable that contains digits

Yes I know that but why AHK can calculate variable with digits with no extra functions but need that code if the calculation is in a variable

Can calculate
Msgbox,% 5+5

Can't calculate and need that extra code to do the calculation
var = 5+5
msgbox,% var
YoucefHam
Posts: 344
Joined: 24 Aug 2015, 12:56
Facebook: https://fb.me/YoucefHamDz
Google: [email protected]
GitHub: YoucefHam
Location: Algeria
Contact:

Re: How to calculate a variable that contains digits

There is always more than one way to solve a problem.
YoucefHam
Posts: 344
Joined: 24 Aug 2015, 12:56
Facebook: https://fb.me/YoucefHamDz
Google: [email protected]
GitHub: YoucefHam
Location: Algeria
Contact:

Re: How to calculate a variable that contains digits

https://www.autohotkey.com/docs/Variables.htm#Intro

Code: Select all

``````;var = TEXT
var = 5 + 5

MsgBox, % var

;var = % Experssion
var = % 5 + 5

MsgBox, % var

;var := "TEXT"
var := "5 + 5"

MsgBox, % var

;var := Experssion
var := 5 + 5

MsgBox, % var
``````
There is always more than one way to solve a problem.

Return to “Ask For Help”

Who is online

Users browsing this forum: austin4149, mikeyww and 32 guests