Jump to content

Cool Calculator v1.0


z0mgItsJohn
 Share

Recommended Posts

Just A Calculator I Made ^^ Its Smexy :)

Source : Cool Calculator v1.0 :P

#Include <GUIConstants.Au3>
Opt ('GUIOnEventMode','1')

Global $Button_Row['5']['4'], $Display_String = '', $Real_String = ''

GUICreate ('    Cool Calculator v1.0','151','166','-1','-1','-1','144')
GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit')
GUISetBkColor ('0x0000FF')
$Display = GUICtrlCreateInput ('','11','15','129','20','1')
GUICtrlSetState ($Display, $GUI_DISABLE)
GUICtrlSetFont ($Display, '10','','','New Times Roman')
_Create_Buttons ()
_Set_Text ()
GUISetState (@SW_SHOW)

While ('1')
Sleep ('750')
_Random_Color ()
WEnd

Func _Create_Buttons ()
Local $Top = ('0')
For $Array_1 = '1' To '4'
For $Array_2 = '0' To '3'
$Button_Row[$Array_1][$Array_2] = GUICtrlCreateButton ('','30' * $Array_2 + '18', '50' + $Top, '25','23')
GUICtrlSetFont ('-1', '10','','','Arial')
Next
$Top = $Top + '26'
Next
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Random_Color ()
$Random = Random ('0x000000','0xFFFFFF')
GUISetBkColor ($Random)
$Random = Random ('10','20')
Sleep ($Random)
EndFunc

Func _Set_Text ()
GUICtrlSetData ($Button_Row['1']['0'], '7')
GUICtrlSetOnEvent ($Button_Row['1']['0'], '_Set_7')
GUICtrlSetData ($Button_Row['1']['1'], '8')
GUICtrlSetOnEvent ($Button_Row['1']['1'], '_Set_8')
GUICtrlSetData ($Button_Row['1']['2'], '9')
GUICtrlSetOnEvent ($Button_Row['1']['2'], '_Set_9')
GUICtrlSetData ($Button_Row['1']['3'], '÷')
GUICtrlSetOnEvent ($Button_Row['1']['3'], '_Divide')
GUICtrlSetData ($Button_Row['2']['0'], '4')
GUICtrlSetOnEvent ($Button_Row['2']['0'], '_Set_4')
GUICtrlSetData ($Button_Row['2']['1'], '5')
GUICtrlSetOnEvent ($Button_Row['2']['1'], '_Set_5')
GUICtrlSetData ($Button_Row['2']['2'], '6')
GUICtrlSetOnEvent ($Button_Row['2']['2'], '_Set_6')
GUICtrlSetData ($Button_Row['2']['3'], '×')
GUICtrlSetOnEvent ($Button_Row['2']['3'], '_Multiply')
GUICtrlSetData ($Button_Row['3']['0'], '1')
GUICtrlSetOnEvent ($Button_Row['3']['0'], '_Set_1')
GUICtrlSetData ($Button_Row['3']['1'], '2')
GUICtrlSetOnEvent ($Button_Row['3']['1'], '_Set_2')
GUICtrlSetData ($Button_Row['3']['2'], '3')
GUICtrlSetOnEvent ($Button_Row['3']['2'], '_Set_3')
GUICtrlSetData ($Button_Row['3']['3'], '-')
GUICtrlSetOnEvent ($Button_Row['3']['3'], '_Subtract')
GUICtrlSetData ($Button_Row['4']['0'], '0')
GUICtrlSetOnEvent ($Button_Row['4']['0'], '_Set_0')
GUICtrlSetData ($Button_Row['4']['1'], 'C')
GUICtrlSetOnEvent ($Button_Row['4']['1'], '_Clear')
GUICtrlSetData ($Button_Row['4']['2'], '=')
GUICtrlSetOnEvent ($Button_Row['4']['2'], '_Equal')
GUICtrlSetData ($Button_Row['4']['3'], '+')
GUICtrlSetOnEvent ($Button_Row['4']['3'], '_Add')
EndFunc

Func _Set_0 ()
_Set_Number ('0')
EndFunc

Func _Set_1 ()
_Set_Number ('1')
EndFunc

Func _Set_2 ()
_Set_Number ('2')
EndFunc

Func _Set_3 ()
_Set_Number ('3')
EndFunc

Func _Set_4 ()
_Set_Number ('4')
EndFunc

Func _Set_5 ()
_Set_Number ('5')
EndFunc

Func _Set_6 ()
_Set_Number ('6')
EndFunc

Func _Set_7 ()
_Set_Number ('7')
EndFunc

Func _Set_8 ()
_Set_Number ('8')
EndFunc

Func _Set_9 ()
_Set_Number ('9')
EndFunc

Func _Clear ()
GUICtrlSetData ($Display, '')
$String = ''
EndFunc

Func _Divide ()
$Display_String = ($Display_String & ' ÷ ')
$Real_String = ($Real_String & ' / ')
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Multiply ()
$Display_String = ($Display_String & ' × ')
$Real_String = ($Real_String & ' * ')
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Subtract ()
$Display_String = ($Display_String & ' - ')
$Real_String = ($Real_String & ' - ')
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Add ()
$Display_String = ($Display_String & ' + ')
$Real_String = ($Real_String & ' + ')
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Equal ()
$Equal = Execute ($Real_String)
GUICtrlSetData ($Display, $Equal)
$Display_String = ($Equal)
$Real_String = ($Equal)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Set_Number ($Number)
$Display_String = ($Display_String & $Number)
$Real_String = ($Real_String & $Number)
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Exit ()
Exit
EndFunc

Please Feel Free To Comment ( You Better Comment :P ) :D Etc.....

Enjoy ~~

Latest Projects :- New & Improved TCP Chat

Link to comment
Share on other sites

Just one quick thing, replace your current _Clear() function with this ...

Func _Clear()
    GUICtrlSetData($Display, '')
    $Real_String = ''
    $Display_String = ''
EndFunc   ;==>_Clear

Reason: You were resetting the wrong variables :)

My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game :)My website

Link to comment
Share on other sites

  • 1 year later...

Is it just more or is this topic a year old?

Onto vat, All you need to do is read the control, times it by vat + 1 (117.5% = 1.175) so 20 = 20 * 1.175, and then set the result to the control again.

Holy.... Didn't check the date :D Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

Thanks for the replies guys, here is the code i modded a bit to my liking and now has a working +vat button, also changed the gui.

#Include <GUIConstants.Au3>
Opt ('GUIOnEventMode','1')

Global $Display_String = '', $Real_String = ''

GUICreate("VAT Calculator v2.0", 317, 400, 278, 166)
GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit')
$Display = GUICtrlCreateInput("", 24, 32, 265, 35)
GUICtrlSetState ($Display, $GUI_DISABLE)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")

_Set_Text ()
GUISetState (@SW_SHOW)

While ('1')
Sleep ('750')
WEnd

Func _Set_Text ()

$Button1 = GUICtrlCreateButton("1", 32, 104, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button1, '_Set_1')

$Button2 = GUICtrlCreateButton("2", 92, 104, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button2, '_Set_2')

$Button3 = GUICtrlCreateButton("3", 152, 104, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button3, '_Set_3')

$Button4 = GUICtrlCreateButton("4", 32, 164, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button4, '_Set_4')

$Button5 = GUICtrlCreateButton("5", 92, 164, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button5, '_Set_5')

$Button6 = GUICtrlCreateButton("6", 152, 164, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button6, '_Set_6')

$Button7 = GUICtrlCreateButton("7", 32, 223, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button7, '_Set_7')

$Button8 = GUICtrlCreateButton("8", 92, 223, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button8, '_Set_8')

$Button9 = GUICtrlCreateButton("9", 152, 223, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button9, '_Set_9')

$Button0 = GUICtrlCreateButton("0", 92, 282, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button0, '_Set_0')

$ButtonADD = GUICtrlCreateButton("+", 231, 104, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($ButtonADD, '_Add')

$ButtonMINUS = GUICtrlCreateButton("-", 231, 164, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($ButtonMINUS, '_Minus')

$ButtonDIVIDE = GUICtrlCreateButton("÷", 231, 282, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($ButtonDIVIDE, '_Divide')

$ButtonTIMES = GUICtrlCreateButton("x", 231, 223, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($ButtonTIMES, '_Times')

$ButtonEqual = GUICtrlCreateButton("=", 231, 341, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($ButtonEqual, '_Equal')

$ButtonDecimal = GUICtrlCreateButton(".", 152, 282, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($ButtonDecimal, '_Decimal')

$ButtonVAT = GUICtrlCreateButton("+VAT", 32, 282, 49, 49)
GUICtrlSetFont(-1, 8, 800, 0, "Arial")
GUICtrlSetOnEvent ($ButtonVAT, '_VAT')

$ClearButton = GUICtrlCreateButton("Clear", 2, 2, 43, 25)
GUICtrlSetOnEvent ($ClearButton, '_Clear')
EndFunc

Func _Set_0 ()
_Set_Number ('0')
EndFunc

Func _Set_1 ()
_Set_Number ('1')
EndFunc

Func _Set_2 ()
_Set_Number ('2')
EndFunc

Func _Set_3 ()
_Set_Number ('3')
EndFunc

Func _Set_4 ()
_Set_Number ('4')
EndFunc

Func _Set_5 ()
_Set_Number ('5')
EndFunc

Func _Set_6 ()
_Set_Number ('6')
EndFunc

Func _Set_7 ()
_Set_Number ('7')
EndFunc

Func _Set_8 ()
_Set_Number ('8')
EndFunc

Func _Set_9 ()
_Set_Number ('9')
EndFunc

Func _Clear()
    GUICtrlSetData($Display, '')
    $Real_String = ''
    $Display_String = ''
EndFunc

Func _Divide ()
$Display_String = ($Display_String & ' ÷ ')
$Real_String = ($Real_String & ' / ')
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Times ()
$Display_String = ($Display_String & ' × ')
$Real_String = ($Real_String & ' * ')
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Minus ()
$Display_String = ($Display_String & ' - ')
$Real_String = ($Real_String & ' - ')
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Add ()
$Display_String = ($Display_String & ' + ')
$Real_String = ($Real_String & ' + ')
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _VAT ()
$Display_String = ($Display_String & ' +VAT ')
$Real_String = ($Real_String & ' * 1.175')
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Equal ()
$Equal = Execute ($Real_String)
GUICtrlSetData ($Display, $Equal)
$Display_String = ($Equal)
$Real_String = ($Equal)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Decimal ()
$Display_String = ($Display_String & ' . ')
$Real_String = ($Real_String & ' ????? ')
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Set_Number ($Number)
$Display_String = ($Display_String & $Number)
$Real_String = ($Real_String & $Number)
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Exit ()
Exit
EndFunc

I have just 1 problem, I tried adding a decimal button but im not really getting anywhere. please does anyone have any ideas?

youll notice i just put ??? in the post btw :D

thanks.

and here is a screen shot for your pleasure

post-49753-12638472432846_thumb.png

Edited by am632
Link to comment
Share on other sites

I'll let you off this time, as it had just been bumped by am632, but next time :D

Glad to know that the vat is now sorted though am632.

Mat

:huggles:

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

  • 2 weeks later...

Thanks for the replies guys, here is the code i modded a bit to my liking and now has a working +vat button, also changed the gui.

#Include <GUIConstants.Au3>
Opt ('GUIOnEventMode','1')

Global $Display_String = '', $Real_String = ''

GUICreate("VAT Calculator v2.0", 317, 400, 278, 166)
GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit')
$Display = GUICtrlCreateInput("", 24, 32, 265, 35)
GUICtrlSetState ($Display, $GUI_DISABLE)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")

_Set_Text ()
GUISetState (@SW_SHOW)

While ('1')
Sleep ('750')
WEnd

Func _Set_Text ()

$Button1 = GUICtrlCreateButton("1", 32, 104, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button1, '_Set_1')

$Button2 = GUICtrlCreateButton("2", 92, 104, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button2, '_Set_2')

$Button3 = GUICtrlCreateButton("3", 152, 104, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button3, '_Set_3')

$Button4 = GUICtrlCreateButton("4", 32, 164, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button4, '_Set_4')

$Button5 = GUICtrlCreateButton("5", 92, 164, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button5, '_Set_5')

$Button6 = GUICtrlCreateButton("6", 152, 164, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button6, '_Set_6')

$Button7 = GUICtrlCreateButton("7", 32, 223, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button7, '_Set_7')

$Button8 = GUICtrlCreateButton("8", 92, 223, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button8, '_Set_8')

$Button9 = GUICtrlCreateButton("9", 152, 223, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button9, '_Set_9')

$Button0 = GUICtrlCreateButton("0", 92, 282, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($Button0, '_Set_0')

$ButtonADD = GUICtrlCreateButton("+", 231, 104, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($ButtonADD, '_Add')

$ButtonMINUS = GUICtrlCreateButton("-", 231, 164, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($ButtonMINUS, '_Minus')

$ButtonDIVIDE = GUICtrlCreateButton("÷", 231, 282, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($ButtonDIVIDE, '_Divide')

$ButtonTIMES = GUICtrlCreateButton("x", 231, 223, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($ButtonTIMES, '_Times')

$ButtonEqual = GUICtrlCreateButton("=", 231, 341, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($ButtonEqual, '_Equal')

$ButtonDecimal = GUICtrlCreateButton(".", 152, 282, 49, 49)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetOnEvent ($ButtonDecimal, '_Decimal')

$ButtonVAT = GUICtrlCreateButton("+VAT", 32, 282, 49, 49)
GUICtrlSetFont(-1, 8, 800, 0, "Arial")
GUICtrlSetOnEvent ($ButtonVAT, '_VAT')

$ClearButton = GUICtrlCreateButton("Clear", 2, 2, 43, 25)
GUICtrlSetOnEvent ($ClearButton, '_Clear')
EndFunc

Func _Set_0 ()
_Set_Number ('0')
EndFunc

Func _Set_1 ()
_Set_Number ('1')
EndFunc

Func _Set_2 ()
_Set_Number ('2')
EndFunc

Func _Set_3 ()
_Set_Number ('3')
EndFunc

Func _Set_4 ()
_Set_Number ('4')
EndFunc

Func _Set_5 ()
_Set_Number ('5')
EndFunc

Func _Set_6 ()
_Set_Number ('6')
EndFunc

Func _Set_7 ()
_Set_Number ('7')
EndFunc

Func _Set_8 ()
_Set_Number ('8')
EndFunc

Func _Set_9 ()
_Set_Number ('9')
EndFunc

Func _Clear()
    GUICtrlSetData($Display, '')
    $Real_String = ''
    $Display_String = ''
EndFunc

Func _Divide ()
$Display_String = ($Display_String & ' ÷ ')
$Real_String = ($Real_String & ' / ')
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Times ()
$Display_String = ($Display_String & ' × ')
$Real_String = ($Real_String & ' * ')
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Minus ()
$Display_String = ($Display_String & ' - ')
$Real_String = ($Real_String & ' - ')
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Add ()
$Display_String = ($Display_String & ' + ')
$Real_String = ($Real_String & ' + ')
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _VAT ()
$Display_String = ($Display_String & ' +VAT ')
$Real_String = ($Real_String & ' * 1.175')
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Equal ()
$Equal = Execute ($Real_String)
GUICtrlSetData ($Display, $Equal)
$Display_String = ($Equal)
$Real_String = ($Equal)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Decimal ()
$Display_String = ($Display_String & ' . ')
$Real_String = ($Real_String & ' ????? ')
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Set_Number ($Number)
$Display_String = ($Display_String & $Number)
$Real_String = ($Real_String & $Number)
GUICtrlSetData ($Display, $Display_String)
GUICtrlSetState ($Display, $GUI_FOCUS)
EndFunc

Func _Exit ()
Exit
EndFunc

I have just 1 problem, I tried adding a decimal button but im not really getting anywhere. please does anyone have any ideas?

youll notice i just put ??? in the post btw :D

thanks.

and here is a screen shot for your pleasure

post-49753-12638472432846_thumb.png

In your function _Decimal () you have a space before and after the decimal point.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...