GUI Custom Calculator with Checkboxs

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Forthwith
Posts: 2
Joined: 26 Sep 2017, 02:45

GUI Custom Calculator with Checkboxs

26 Sep 2017, 02:57

I am trying to create a calculator for a customized equation. The user will enter the total wealth at the top, which will be multiplied by 0.15

They will select which type of car or cars they have with checkboxes, depending on the ones they select it will be a different value. These checkboxes will be added to the first value*0.15 Then they will enter the value of any properties they have, which will be multiplied by 0.10. Everything will be added together and give a final Total.

I am so new to AHK, All I have so far is this:

Code: Select all

Gui, Show, w479 h602, Untitled GUI
Gui, Add, Text, x42 y269 w100 h30 , Propert 1 Value
Gui, Add, Text, x42 y309 w100 h30 , Propert 2 Value
Gui, Add, Text, x42 y349 w100 h30 , Propert 3 Value
Gui, Add, Text, x42 y389 w100 h30 , Propert 4 Value
Gui, Add, Text, x42 y429 w100 h30 , Propert 5 Value
Gui, Add, Text, x42 y469 w100 h30 , Propert 6 Value
Gui, Add, Text, x42 y509 w100 h30 , Propert 7 Value
Gui, Add, Text, x42 y89 w100 h30 , Total Wealth
Gui, Add, CheckBox, x52 y179 w100 h30 , Car 1
Gui, Add, CheckBox, x152 y179 w100 h30 , Car 3
Gui, Add, CheckBox, x252 y179 w100 h30 , Car 5
Gui, Add, CheckBox, x352 y179 w100 h30 , Car 7
Gui, Add, CheckBox, x352 y209 w100 h30 , Car 8
Gui, Add, CheckBox, x252 y209 w100 h30 , Car 6
Gui, Add, CheckBox, x152 y209 w100 h30 , Car 4
Gui, Add, CheckBox, x52 y209 w100 h30 , Car 2
Gui, Add, Edit, x142 y89 w250 h30 vwealth +number, 0
Gui, Add, Edit, x142 y269 w250 h30 , 0
Gui, Add, Edit, x142 y309 w250 h30 , 0
Gui, Add, Edit, x142 y349 w250 h30 , 0
Gui, Add, Edit, x142 y389 w250 h30 , 0
Gui, Add, Edit, x142 y429 w250 h30 , 0
Gui, Add, Edit, x142 y469 w250 h30 , 0
Gui, Add, Edit, x142 y509 w250 h30 , 0
Gui, Add, Button, x172 y549 w100 h30 gMath, MATH!
return	

Math:
	Gui, Submit, Nohide
	c := Wealth *= 0.15
	msgbox, Total: %c%
	return
	
	
I have the layout for the GUI:

Image

But just don't know how to make a checkbox = a certain value or how to make all the different edit fields add together with multiplication for each field.
Forthwith
Posts: 2
Joined: 26 Sep 2017, 02:45

Re: GUI Custom Calculator with Checkboxs

26 Sep 2017, 14:17

So far I have figured out how to add the different groups together in a msgbox, but I am not sure how to assign a certain value to a checkbox and add it into my math:

Code: Select all

Gui, Add, Edit, x142 y89 w250 h30 vwealth +number, 0
Gui, Add, Edit, x142 y269 w250 h30 vprop1, 0
Gui, Add, Edit, x142 y309 w250 h30 vprop2, 0
Gui, Add, Edit, x142 y349 w250 h30 vprop3, 0
Gui, Add, Edit, x142 y389 w250 h30 vprop4, 0
Gui, Add, Edit, x142 y429 w250 h30 vprop5, 0
Gui, Add, Edit, x142 y469 w250 h30 vprop6, 0
Gui, Add, Edit, x142 y509 w250 h30 vprop7, 0
Gui, Add, Button, x172 y549 w100 h30 gMath, MATH!
return	

Math:
	Gui, Submit, Nohide
	c := wealth *= 0.15
	d := prop1 *= 0.10
	e := prop2 *= 0.10
	f := prop3 *= 0.10
	g := prop4 *= 0.10
	h := prop5 *= 0.10
	i := prop6 *= 0.10
	j := prop7 *= 0.10
	k := c+d+e+f+g+h+i+j
	msgbox, Total: %k%
	return
User avatar
boiler
Posts: 16963
Joined: 21 Dec 2014, 02:44

Re: GUI Custom Calculator with Checkboxs

26 Sep 2017, 16:49

Read about Gui output variables and see how they apply specifically to checkboxes. The checkbox would return a value of 1 to its associated variable if checked and 0 if unchecked, so you can do your math based on that.

It looks like you've incorporated that concept into your edit controls in your second post. So you would just add the same "v" option to checkbox controls.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ShatterCoder, Xaucy and 173 guests