Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subtracting Variables with Autohotkey

I am building a macro in Autohotkey which requires me to subtract a number from a variable, as shown below:

screenWidth = 1280
MsgBox, screenWidth - 150

For some reason, whenever the dialog box appears with the message, all I get is screenWidth - 150, instead of 1130. I get one step closer with this approach:

screenWidth = 1280
MsgBox, %screenWidth% - 150

For the above code, I get 1280 - 150, but still no the mathematical result.

According to the documentation, code as simple as Price * (1 - Discount/100) should work, assuming that "Price" and "Discount" are both defined.

Could someone direct me as to what I am doing wrong?

like image 556
Oliver Spryn Avatar asked Dec 04 '25 14:12

Oliver Spryn


1 Answers

My mistake, in the documentation of the MsgBox method, I am told that adding a percent sign to the end of MsgBox causes it to see the input as an expression. So MsgBox % screenWidth - 150 is now computed correctly.

like image 92
Oliver Spryn Avatar answered Dec 08 '25 06:12

Oliver Spryn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!