Jump to content
Sign in to follow this  
LimeSeed

Amazing Calculator!

Recommended Posts

LimeSeed

Heres my second version of a calculator, this one has

Steam like visual style

No external images needed!

Is able to keep performing operations by clicking the equals button (on * or +)

Has an advanced menu item that expands the gui and adds sin cos tan and sqrt

has a copy and paste function

has a clear button (obviously)

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=32Calc.ico
#AutoIt3Wrapper_outfile=Calc.exe
#AutoIt3Wrapper_Res_Comment=Isaac Flaum
#AutoIt3Wrapper_Res_Description=Calculator: by Isaac Flaum
#AutoIt3Wrapper_Res_LegalCopyright=Isaac Flaum
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <guiconstants.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
;calculator created by isaac flaum
Opt("GUIResizeMode", $GUI_DOCKALL)
$calc = Guicreate("Calc", 105, 130)
guictrlsetresizing($calc, $GUI_DOCKMENUBAR)
winmove("Calc", "", Default, Default, 150, 220)
dim $i = 0
$menu = guictrlcreatemenu("Menu")
$copy = guictrlcreatemenuitem("Copy", $menu)
$paste = guictrlcreatemenuitem("Paste", $menu)
$exit = guictrlcreatemenuitem("Exit", $menu)
$about = guictrlcreatemenuitem("About", $menu)
$edit = guictrlcreatemenu("Edit")
$advanced = guictrlcreatemenuitem("Advanced", $edit)
$simple = guictrlcreatemenuitem("Simple", $edit)
$input = GUICtrlCreateInput("", 5, 5, 135, 20, $ES_READONLY)
$7 = guictrlcreatebutton("7", 5, 30, 30, 30, $BS_FLAT)
$8 = guictrlcreatebutton("8", 40, 30, 30, 30, $BS_FLAT)
$9 = guictrlcreatebutton("9", 75, 30, 30, 30, $BS_FLAT)
$4 = guictrlcreatebutton("4", 5, 65, 30, 30, $BS_FLAT)
$5 = guictrlcreatebutton("5", 40, 65, 30, 30, $BS_FLAT)
$6 = guictrlcreatebutton("6", 75, 65, 30, 30, $BS_FLAT)
$1 = guictrlcreatebutton("1", 5, 100, 30, 30, $BS_FLAT)
$2 = guictrlcreatebutton("2", 40, 100, 30, 30, $BS_FLAT)
$3 = guictrlcreatebutton("3", 75, 100, 30, 30, $BS_FLAT)
$equals = guictrlcreatebutton("=", 5, 135, 30, 30, $BS_FLAT)
$0 = guictrlcreatebutton("0", 40, 135, 30, 30, $BS_FLAT)
$clear = guictrlcreatebutton("C", 75, 135, 30, 30, $BS_FLAT)
$divide = guictrlcreatebutton("/", 110, 30, 30, 30, $BS_FLAT)
$multiply = guictrlcreatebutton("x", 110, 65, 30, 30, $BS_FLAT)
$plus = guictrlcreatebutton("+", 110, 100, 30, 30, $BS_FLAT)
$minus = guictrlcreatebutton("-", 110, 135, 30, 30, $BS_FLAT)
$operation = -1 ;0 = plus, 1 = minus, 2 = times, 3 = divide, 4 = nothing

;set the background button color!
guictrlsetbkcolor($input, 0xFFF8DC)
guictrlsetbkcolor($9, 0x5a6a50)
guictrlsetbkcolor($8, 0x5a6a50)
guictrlsetbkcolor($7, 0x5a6a50)
guictrlsetbkcolor($6, 0x5a6a50)
guictrlsetbkcolor($5, 0x5a6a50)
guictrlsetbkcolor($4, 0x5a6a50)
guictrlsetbkcolor($3, 0x5a6a50)
guictrlsetbkcolor($2, 0x5a6a50)
guictrlsetbkcolor($1, 0x5a6a50)
guictrlsetbkcolor($0, 0x5a6a50)
guictrlsetbkcolor($equals, 0x5a6a50)
guictrlsetbkcolor($clear, 0x5a6a50)
guictrlsetbkcolor($divide, 0x5a6a50)
guictrlsetbkcolor($multiply, 0x5a6a50)
guictrlsetbkcolor($plus, 0x5a6a50)
guictrlsetbkcolor($minus, 0x5a6a50)

;creating the advanced buttons

Global $sin = guictrlcreatebutton("sin", 145, 30, 30, 30)
Global $cos = guictrlcreatebutton("cos", 145, 65, 30, 30)
Global $tan = guictrlcreatebutton("tan", 145, 100, 30, 30)
Global $sqrt = guictrlcreatebutton("sqrt", 145, 135, 30, 30)

guictrlsetbkcolor($sin, 0x5a6a50)
guictrlsetbkcolor($cos, 0x5a6a50)
guictrlsetbkcolor($tan, 0x5a6a50)
guictrlsetbkcolor($sqrt, 0x5a6a50)
guictrlsetstate($sin, $GUI_HIDE)
guictrlsetstate($cos, $GUI_HIDE)
guictrlsetstate($tan, $GUI_HIDE)
guictrlsetstate($sqrt, $GUI_HIDE)


GUISetBkColor(0x494e48)

guisetstate(@SW_SHOW)
GUICtrlSetState($simple, $GUI_CHECKED)

Do
    $msg = guigetmsg()
    if($msg = -3) Then
        $i = 1
    EndIf
    Select
        Case($msg = $0)
            $pnum = guictrlread($input)
            guictrlsetdata($input, $pnum & "0")
        Case($msg = $copy)
            $pnum = guictrlread($input)
            clipput($pnum)
        Case($msg = $paste)
            $data = clipget()
            guictrlsetdata($input, $data)
        Case($msg = $1)
            $pnum = guictrlread($input)
            guictrlsetdata($input, $pnum & "1")
        Case($msg = $2)
            $pnum = guictrlread($input)
            guictrlsetdata($input, $pnum & "2")
        Case($msg = $3)
            $pnum = guictrlread($input)
            guictrlsetdata($input, $pnum & "3")
        Case($msg = $4)
            $pnum = guictrlread($input)
            guictrlsetdata($input, $pnum & "4")
        Case($msg = $5)
            $pnum = guictrlread($input)
            guictrlsetdata($input, $pnum & "5")
        Case($msg = $6)
            $pnum = guictrlread($input)
            guictrlsetdata($input, $pnum & "6")
        Case($msg = $7)
            $pnum = guictrlread($input)
            guictrlsetdata($input, $pnum & "7")
        Case($msg = $8)
            $pnum = guictrlread($input)
            guictrlsetdata($input, $pnum & "8")
        Case($msg = $9)
            $pnum = guictrlread($input)
            guictrlsetdata($input, $pnum & "9")
        Case($msg = $plus)
            $num1 = guictrlread($input)
            $operation = 0
            guictrlsetdata($input, "")
        Case($msg = $minus)
            $num1 = guictrlread($input)
            $operation = 1
            guictrlsetdata($input, "")
        Case($msg = $multiply)
            $num1 = guictrlread($input)
            $operation = 2
            guictrlsetdata($input, "")
        Case($msg = $divide)
            $num1 = guictrlread($input)
            $operation = 3
            guictrlsetdata($input, "")
        Case($msg = $equals)
            if $operation = 0 Then
                _add()
            Elseif $operation = 1 Then
                _subtract()
            Elseif $operation = 2 Then
                _multiply()
            Elseif $operation = 3 Then
                _divide()
            Else
                msgbox(0, "Error", "No Operation Was Selected", 5)
            EndIf
        Case($msg = $clear)
            $num1 = 0
            $num2 = 0
            guictrlsetdata($input, "")
        Case($msg = $exit)
            $i = 1
        Case($msg = $about)
            msgbox(0, "Calc", "This calculator was created by Isaac Flaum using Autoit as an efficent, good looking calculator.", 10)
        Case($msg = $advanced)
            GUICtrlSetState($advanced, $GUI_CHECKED)
            GUICtrlSetState($simple, $GUI_UNCHECKED)
            $num1 = guictrlread($input)
            guictrldelete($input)
            winmove("Calc", "", default, default, 185, 220)
            Dim $input = guictrlcreateinput($num1, 5, 5, 168, 20)
            guictrlsetstate($sin, $GUI_SHOW)
            guictrlsetstate($cos, $GUI_SHOW)
            guictrlsetstate($tan, $GUI_SHOW)
            guictrlsetstate($sqrt, $GUI_SHOW)
        Case($msg = $simple)
            GUICtrlSetState($simple, $GUI_CHECKED)
            GUICtrlSetState($advanced, $GUI_UNCHECKED)
            $num1 = guictrlread($input)
            winmove("Calc", "", Default, Default, 150, 220)
            guictrldelete($input)
            guictrlsetstate($sin, $GUI_HIDE)
            guictrlsetstate($cos, $GUI_HIDE)
            guictrlsetstate($tan, $GUI_HIDE)
            guictrlsetstate($sqrt, $GUI_HIDE)
            Dim $input = GUICtrlCreateInput($num1, 5, 5, 135, 20, $ES_READONLY)
        Case($msg = $sin)
            $num1 = guictrlread($input)
            _sine()
        Case($msg = $cos)
            $num1 = guictrlread($input)
            _cosine()
        Case($msg = $tan)
            $num1 = guictrlread($input)
            _tangent()
        Case($msg = $sqrt)
            $num1 = guictrlread($input)
            _sqrt()
    EndSelect

Until $i = 1

func _add()
    $num2 = guictrlread($input)
    $final = $num1 + $num2
    guictrlsetdata($input, $final)
EndFunc   ;==>_add

func _subtract()
    $num2 = guictrlread($input)
    $final = $num1 - $num2
    guictrlsetdata($input, $final)
EndFunc   ;==>_subtract

func _multiply()
    $num2 = guictrlread($input)
    $final = ($num1 * $num2)
    guictrlsetdata($input, $final)
EndFunc   ;==>_multiply

func _divide()
    $num2 = guictrlread($input)
    $final = ($num1 / $num2)
    guictrlsetdata($input, $final)
EndFunc   ;==>_divide

func _sine()
    $final = sin($num1)
    guictrlsetdata($input, $final)
EndFunc   ;==>_sine

Func _cosine()
    $final = cos($num1)
    guictrlsetdata($input, $final)
EndFunc   ;==>_cosine

Func _tangent()
    $final = tan($num1)
    guictrlsetdata($input, $final)
EndFunc   ;==>_tangent

Func _sqrt()
    $final = sqrt($num1)
    guictrlsetdata($input, $final)
EndFunc   ;==>_sqrt

global $warming = true

Share this post


Link to post
Share on other sites
gseller

Sweet!! I like the advanced expansion...

Share this post


Link to post
Share on other sites
monoceres

Looks good.

Some suggestions:

- Choose between radians/degrees for the trigonometric functions.

- ^ operator!

- Log10 and natural logarithm

- Switch between different number bases

;)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
LimeSeed

Looks good.

Some suggestions:

- Choose between radians/degrees for the trigonometric functions.

- ^ operator!

- Log10 and natural logarithm

- Switch between different number bases

;)

im 15 going into algebra trig 2, so i have no idea what the difference is between radians and degrees! but yea i could add the log, log10, and the exponent (^) buttons


global $warming = true

Share this post


Link to post
Share on other sites
Sanku1

nice one, it will help me to learn of creating my own :Cheers:

Share this post


Link to post
Share on other sites
LimeSeed

nice one, it will help me to learn of creating my own :Cheers:

woot woot! i remember when i saw someone elses calculator like 2 years ago and i was like woaaa how did they do that!


global $warming = true

Share this post


Link to post
Share on other sites
LimeSeed

#NoTrayIcon

;calculator = 35745 & 31639 & 26426

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=32Calc.ico
#AutoIt3Wrapper_Outfile=Calc.exe
#AutoIt3Wrapper_Res_Comment=Isaac Flaum
#AutoIt3Wrapper_Res_Description=Calculator: by Isaac Flaum
#AutoIt3Wrapper_Res_LegalCopyright=Isaac Flaum
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <guiconstants.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
;calculator created by isaac flaum

Opt("GUIResizeMode", $GUI_DOCKALL)
$calc = GUICreate("Calc", 105, 130)
GUICtrlSetResizing($calc, $GUI_DOCKMENUBAR)
WinMove("Calc", "", Default, Default, 150, 220)

Dim $i = 0
Dim $j = 0

$menu = GUICtrlCreateMenu("Menu")
$copy = GUICtrlCreateMenuItem("Copy", $menu)
$paste = GUICtrlCreateMenuItem("Paste", $menu)
$exit = GUICtrlCreateMenuItem("Exit", $menu)
$about = GUICtrlCreateMenuItem("About", $menu)
$edit = GUICtrlCreateMenu("Edit")
$advanced = GUICtrlCreateMenuItem("Advanced", $edit)
$simple = GUICtrlCreateMenuItem("Simple", $edit)
$language = GUICtrlCreateMenu("Language")
$english = GUICtrlCreateMenuItem("English", $language)
$mandarin = GUICtrlCreateMenuItem("Mandarin", $language)
$input = GUICtrlCreateInput("", 5, 5, 135, 20, $ES_READONLY)

Global $button[10]
$button[7] = GUICtrlCreateButton("7", 5, 30, 30, 30, $BS_FLAT)
$button[8] = GUICtrlCreateButton("8", 40, 30, 30, 30, $BS_FLAT)
$button[9] = GUICtrlCreateButton("9", 75, 30, 30, 30, $BS_FLAT)
$button[4] = GUICtrlCreateButton("4", 5, 65, 30, 30, $BS_FLAT)
$button[5] = GUICtrlCreateButton("5", 40, 65, 30, 30, $BS_FLAT)
$button[6] = GUICtrlCreateButton("6", 75, 65, 30, 30, $BS_FLAT)
$button[1] = GUICtrlCreateButton("1", 5, 100, 30, 30, $BS_FLAT)
$button[2] = GUICtrlCreateButton("2", 40, 100, 30, 30, $BS_FLAT)
$button[3] = GUICtrlCreateButton("3", 75, 100, 30, 30, $BS_FLAT)
$button[0] = GUICtrlCreateButton("0", 40, 135, 30, 30, $BS_FLAT)
$equals = GUICtrlCreateButton("=", 5, 135, 30, 30, $BS_FLAT)

$clear = GUICtrlCreateButton("C", 75, 135, 30, 30, $BS_FLAT)
$divide = GUICtrlCreateButton("/", 110, 30, 30, 30, $BS_FLAT)
$multiply = GUICtrlCreateButton("x", 110, 65, 30, 30, $BS_FLAT)
$plus = GUICtrlCreateButton("+", 110, 100, 30, 30, $BS_FLAT)
$minus = GUICtrlCreateButton("-", 110, 135, 30, 30, $BS_FLAT)
$operation = -1 ;0 = plus, 1 = minus, 2 = times, 3 = divide, 4 = nothing

;set the background button color!
GUICtrlSetBkColor($input, 0xFFF8DC)
GUICtrlSetBkColor($button[9], 0x5a6a50)
GUICtrlSetBkColor($button[8], 0x5a6a50)
GUICtrlSetBkColor($button[7], 0x5a6a50)
GUICtrlSetBkColor($button[6], 0x5a6a50)
GUICtrlSetBkColor($button[5], 0x5a6a50)
GUICtrlSetBkColor($button[4], 0x5a6a50)
GUICtrlSetBkColor($button[3], 0x5a6a50)
GUICtrlSetBkColor($button[2], 0x5a6a50)
GUICtrlSetBkColor($button[1], 0x5a6a50)
GUICtrlSetBkColor($button[0], 0x5a6a50)
GUICtrlSetBkColor($equals, 0x5a6a50)
GUICtrlSetBkColor($clear, 0x5a6a50)
GUICtrlSetBkColor($divide, 0x5a6a50)
GUICtrlSetBkColor($multiply, 0x5a6a50)
GUICtrlSetBkColor($plus, 0x5a6a50)
GUICtrlSetBkColor($minus, 0x5a6a50)


;creating the advanced buttons



GUICtrlSetBkColor($sin, 0x5a6a50)
GUICtrlSetBkColor($cos, 0x5a6a50)
GUICtrlSetBkColor($tan, 0x5a6a50)
GUICtrlSetBkColor($sqrt, 0x5a6a50)
GUICtrlSetState($sin, $GUI_HIDE)
GUICtrlSetState($cos, $GUI_HIDE)
GUICtrlSetState($tan, $GUI_HIDE)
GUICtrlSetState($sqrt, $GUI_HIDE)

GUISetBkColor(0x494e48)

GUISetState(@SW_SHOW)
GUICtrlSetState($simple, $GUI_CHECKED)
GUICtrlSetState($english, $GUI_CHECKED)

Do
    Local $msg = GUIGetMsg()
    If ($msg = -3) Then
        $i = 1
    EndIf
    Select
        Case ($msg = $button[0])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "0")
            $j = 0
        Case ($msg = $copy)
            $pnum = GUICtrlRead($input)
            ClipPut($pnum)
        Case ($msg = $paste)
            $data = ClipGet()
            GUICtrlSetData($input, $data)
        Case ($msg = $button[1])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "1")
            $j = 0
        Case ($msg = $button[2])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "2")
            $j = 0
        Case ($msg = $button[3])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "3")
            $j = 0
        Case ($msg = $button[4])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "4")
            $j = 0
        Case ($msg = $button[5])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "5")
            $j = 0
        Case ($msg = $button[6])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "6")
            $j = 0
        Case ($msg = $button[7])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "7")
            $j = 0
        Case ($msg = $button[8])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "8")
            $j = 0
        Case ($msg = $button[9])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "9")
            $j = 0
        Case ($msg = $plus)
            $num1 = GUICtrlRead($input)
            $operation = 0
            $j = 1
        Case ($msg = $minus)
            $num1 = GUICtrlRead($input)
            $operation = 1
            $j = 1
        Case ($msg = $multiply)
            $num1 = GUICtrlRead($input)
            $operation = 2
            $j = 1
        Case ($msg = $divide)
            $num1 = GUICtrlRead($input)
            $operation = 3
            $j = 1
        Case ($msg = $equals)
            $j = 0
            If $operation = 0 Then
                _add()
            ElseIf $operation = 1 Then
                _subtract()
            ElseIf $operation = 2 Then
                _multiply()
            ElseIf $operation = 3 Then
                _divide()
            Else
                MsgBox(0, "Error", "No Operation Was Selected", 5)
            EndIf
        Case ($msg = $clear)
            $num1 = 0
            $num2 = 0
            GUICtrlSetData($input, "")
        Case ($msg = $exit)
            $i = 1
        Case ($msg = $about)
            MsgBox(0, "Calc", "This calculator was created by Isaac Flaum using Autoit as an efficent, good looking calculator.", 10)
        Case ($msg = $advanced)
            GUICtrlSetState($advanced, $GUI_CHECKED)
            GUICtrlSetState($simple, $GUI_UNCHECKED)
            $num1 = GUICtrlRead($input)
            GUICtrlDelete($input)
            WinMove("Calc", "", Default, Default, 185, 220)
            Dim $input = GUICtrlCreateInput($num1, 5, 5, 168, 20)
            GUICtrlSetState($sin, $GUI_SHOW)
            GUICtrlSetState($cos, $GUI_SHOW)
            GUICtrlSetState($tan, $GUI_SHOW)
            GUICtrlSetState($sqrt, $GUI_SHOW)
        Case ($msg = $simple)
            GUICtrlSetState($simple, $GUI_CHECKED)
            GUICtrlSetState($advanced, $GUI_UNCHECKED)
            $num1 = GUICtrlRead($input)
            WinMove("Calc", "", Default, Default, 150, 220)
            GUICtrlDelete($input)
            GUICtrlSetState($sin, $GUI_HIDE)
            GUICtrlSetState($cos, $GUI_HIDE)
            GUICtrlSetState($tan, $GUI_HIDE)
            GUICtrlSetState($sqrt, $GUI_HIDE)
            Dim $input = GUICtrlCreateInput($num1, 5, 5, 135, 20, $ES_READONLY)
        Case ($msg = $mandarin)
            GUICtrlSetState($english, $GUI_UNCHECKED)
            GUICtrlSetState($mandarin, $GUI_CHECKED)
            GUICtrlSetData($button[0], ChrW(38646))
            GUICtrlSetData($button[1], ChrW(19968))
            GUICtrlSetData($button[2], ChrW(20108))
            GUICtrlSetData($button[3], ChrW(19977))
            GUICtrlSetData($button[4], ChrW(22235))
            GUICtrlSetData($button[5], ChrW(20116))
            GUICtrlSetData($button[6], ChrW(20845))
            GUICtrlSetData($button[7], ChrW(19971))
            GUICtrlSetData($button[8], ChrW(20843))
            GUICtrlSetData($button[9], ChrW(20061))
        Case ($msg = $english)
            GUICtrlSetState($english, $GUI_CHECKED)
            GUICtrlSetState($mandarin, $GUI_UNCHECKED)
            GUICtrlSetData($button[0], "0")
            GUICtrlSetData($button[1], "1")
            GUICtrlSetData($button[2], "2")
            GUICtrlSetData($button[3], "3")
            GUICtrlSetData($button[4], "4")
            GUICtrlSetData($button[5], "5")
            GUICtrlSetData($button[6], "6")
            GUICtrlSetData($button[7], "7")
            GUICtrlSetData($button[8], "8")
            GUICtrlSetData($button[9], "9")
        Case ($msg = $sin)
            $num1 = GUICtrlRead($input)
            _sine()
        Case ($msg = $cos)
            $num1 = GUICtrlRead($input)
            _cosine()
        Case ($msg = $tan)
            $num1 = GUICtrlRead($input)
            _tangent()
        Case ($msg = $sqrt)
            $num1 = GUICtrlRead($input)
            _sqrt()
    EndSelect

Until $i = 1

Func _add()
    $num2 = GUICtrlRead($input)
    $final = $num1 + $num2
    GUICtrlSetData($input, $final)
EndFunc   ;==>_add

Func _subtract()
    $num2 = GUICtrlRead($input)
    $final = $num1 - $num2
    GUICtrlSetData($input, $final)
EndFunc   ;==>_subtract

Func _multiply()
    $num2 = GUICtrlRead($input)
    $final = ($num1 * $num2)
    GUICtrlSetData($input, $final)
EndFunc   ;==>_multiply

Func _divide()
    $num2 = GUICtrlRead($input)
    $final = ($num1 / $num2)
    GUICtrlSetData($input, $final)
EndFunc   ;==>_divide

Func _sine()
    $final = Sin($num1)
    GUICtrlSetData($input, $final)
EndFunc   ;==>_sine

Func _cosine()
    $final = Cos($num1)
    GUICtrlSetData($input, $final)
EndFunc   ;==>_cosine

Func _tangent()
    $final = Tan($num1)
    GUICtrlSetData($input, $final)
EndFunc   ;==>_tangent

Func _sqrt()
    $final = Sqrt($num1)
    GUICtrlSetData($input, $final)
EndFunc   ;==>_sqrt

added arrays for the buttons, and support for mandarin chinese (i am taking it in school). they are simplified characters, and u need to have chinese language pack installed on ur computer. Enjoy!


global $warming = true

Share this post


Link to post
Share on other sites
Skrip

I do not know, but isn't radian working with 180degrees and...degrees 360?


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites
TomZ

I do not know, but isn't radian working with 180degrees and...degrees 360?

2*pi RAD = 360 DEG

Share this post


Link to post
Share on other sites
netman74501

calc.au3 (84) : ==> Variable used without being declared.:

GUICtrlSetBkColor($sin, 0x5a6a50)

GUICtrlSetBkColor(^ ERROR

Same for me...

Share this post


Link to post
Share on other sites
ludocus

its nice..

but it would be much easier and better if you use, Execute..

and it would make the script alot smaller + you could add many more functions like: (-3+9)*(-25*(35+46))=

Share this post


Link to post
Share on other sites
LimeSeed

Fixed the errors, much better now, for some reason i accidentally erased the sin cos tan and sqrt buttons. Works now!! i added the execute also

#NoTrayIcon

;calculator = 35745 & 31639 & 26426

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=32Calc.ico
#AutoIt3Wrapper_Outfile=Calc.exe
#AutoIt3Wrapper_Res_Comment=Isaac Flaum
#AutoIt3Wrapper_Res_Description=Calculator: by Isaac Flaum
#AutoIt3Wrapper_Res_LegalCopyright=Isaac Flaum
#AutoIt3Wrapper_Res_Language=1033
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#include <guiconstants.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
;calculator created by isaac flaum

Opt("GUIResizeMode", $GUI_DOCKALL)
$calc = GUICreate("Calc", 105, 130)
GUICtrlSetResizing($calc, $GUI_DOCKMENUBAR)
WinMove("Calc", "", Default, Default, 150, 220)

Dim $i = 0
Dim $j = 0

$menu = GUICtrlCreateMenu("Menu")
$copy = GUICtrlCreateMenuItem("Copy", $menu)
$paste = GUICtrlCreateMenuItem("Paste", $menu)
$exit = GUICtrlCreateMenuItem("Exit", $menu)
$about = GUICtrlCreateMenuItem("About", $menu)
$edit = GUICtrlCreateMenu("Edit")
$advanced = GUICtrlCreateMenuItem("Advanced", $edit)
$simple = GUICtrlCreateMenuItem("Simple", $edit)
$language = GUICtrlCreateMenu("Language")
$english = GUICtrlCreateMenuItem("English", $language)
$mandarin = GUICtrlCreateMenuItem("Mandarin", $language)
$input = GUICtrlCreateInput("", 5, 5, 135, 20, $ES_READONLY)

Global $button[10]
$button[7] = GUICtrlCreateButton("7", 5, 30, 30, 30, $BS_FLAT)
$button[8] = GUICtrlCreateButton("8", 40, 30, 30, 30, $BS_FLAT)
$button[9] = GUICtrlCreateButton("9", 75, 30, 30, 30, $BS_FLAT)
$button[4] = GUICtrlCreateButton("4", 5, 65, 30, 30, $BS_FLAT)
$button[5] = GUICtrlCreateButton("5", 40, 65, 30, 30, $BS_FLAT)
$button[6] = GUICtrlCreateButton("6", 75, 65, 30, 30, $BS_FLAT)
$button[1] = GUICtrlCreateButton("1", 5, 100, 30, 30, $BS_FLAT)
$button[2] = GUICtrlCreateButton("2", 40, 100, 30, 30, $BS_FLAT)
$button[3] = GUICtrlCreateButton("3", 75, 100, 30, 30, $BS_FLAT)
$button[0] = GUICtrlCreateButton("0", 40, 135, 30, 30, $BS_FLAT)
$equals = GUICtrlCreateButton("=", 5, 135, 30, 30, $BS_FLAT)

$clear = GUICtrlCreateButton("C", 75, 135, 30, 30, $BS_FLAT)
$divide = GUICtrlCreateButton("/", 110, 30, 30, 30, $BS_FLAT)
$multiply = GUICtrlCreateButton("x", 110, 65, 30, 30, $BS_FLAT)
$plus = GUICtrlCreateButton("+", 110, 100, 30, 30, $BS_FLAT)
$minus = GUICtrlCreateButton("-", 110, 135, 30, 30, $BS_FLAT)
$operation = -1;0 = plus, 1 = minus, 2 = times, 3 = divide, 4 = nothing

Global $sin = guictrlcreatebutton("sin", 145, 30, 30, 30)
Global $cos = guictrlcreatebutton("cos", 145, 65, 30, 30)
Global $tan = guictrlcreatebutton("tan", 145, 100, 30, 30)
Global $sqrt = guictrlcreatebutton("sqrt", 145, 135, 30, 30)

;set the background button color!
GUICtrlSetBkColor($input, 0xFFF8DC)
GUICtrlSetBkColor($button[9], 0x5a6a50)
GUICtrlSetBkColor($button[8], 0x5a6a50)
GUICtrlSetBkColor($button[7], 0x5a6a50)
GUICtrlSetBkColor($button[6], 0x5a6a50)
GUICtrlSetBkColor($button[5], 0x5a6a50)
GUICtrlSetBkColor($button[4], 0x5a6a50)
GUICtrlSetBkColor($button[3], 0x5a6a50)
GUICtrlSetBkColor($button[2], 0x5a6a50)
GUICtrlSetBkColor($button[1], 0x5a6a50)
GUICtrlSetBkColor($button[0], 0x5a6a50)
GUICtrlSetBkColor($equals, 0x5a6a50)
GUICtrlSetBkColor($clear, 0x5a6a50)
GUICtrlSetBkColor($divide, 0x5a6a50)
GUICtrlSetBkColor($multiply, 0x5a6a50)
GUICtrlSetBkColor($plus, 0x5a6a50)
GUICtrlSetBkColor($minus, 0x5a6a50)


;creating the advanced buttons



GUICtrlSetBkColor($sin, 0x5a6a50)
GUICtrlSetBkColor($cos, 0x5a6a50)
GUICtrlSetBkColor($tan, 0x5a6a50)
GUICtrlSetBkColor($sqrt, 0x5a6a50)
GUICtrlSetState($sin, $GUI_HIDE)
GUICtrlSetState($cos, $GUI_HIDE)
GUICtrlSetState($tan, $GUI_HIDE)
GUICtrlSetState($sqrt, $GUI_HIDE)

GUISetBkColor(0x494e48)

GUISetState(@SW_SHOW)
GUICtrlSetState($simple, $GUI_CHECKED)
GUICtrlSetState($english, $GUI_CHECKED)

Do
    Local $msg = GUIGetMsg()
    If ($msg = -3) Then
        $i = 1
    EndIf
    Select
        Case ($msg = $button[0])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "0")
            $j = 0
        Case ($msg = $copy)
            $pnum = GUICtrlRead($input)
            ClipPut($pnum)
        Case ($msg = $paste)
            $data = ClipGet()
            GUICtrlSetData($input, $data)
        Case ($msg = $button[1])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "1")
            $j = 0
        Case ($msg = $button[2])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "2")
            $j = 0
        Case ($msg = $button[3])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "3")
            $j = 0
        Case ($msg = $button[4])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "4")
            $j = 0
        Case ($msg = $button[5])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "5")
            $j = 0
        Case ($msg = $button[6])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "6")
            $j = 0
        Case ($msg = $button[7])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "7")
            $j = 0
        Case ($msg = $button[8])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "8")
            $j = 0
        Case ($msg = $button[9])
            If $j = 1 Then
                GUICtrlSetData($input, "")
            EndIf
            $pnum = GUICtrlRead($input)
            GUICtrlSetData($input, $pnum & "9")
            $j = 0
        Case ($msg = $plus)
            $num1 = GUICtrlRead($input)
            $operation = 0
            $j = 1
        Case ($msg = $minus)
            $num1 = GUICtrlRead($input)
            $operation = 1
            $j = 1
        Case ($msg = $multiply)
            $num1 = GUICtrlRead($input)
            $operation = 2
            $j = 1
        Case ($msg = $divide)
            $num1 = GUICtrlRead($input)
            $operation = 3
            $j = 1
        Case ($msg = $equals)
            $j = 0
            If $operation = 0 Then
                _add()
            ElseIf $operation = 1 Then
                _subtract()
            ElseIf $operation = 2 Then
                _multiply()
            ElseIf $operation = 3 Then
                _divide()
            Else
                MsgBox(0, "Error", "No Operation Was Selected", 5)
            EndIf
        Case ($msg = $clear)
            $num1 = 0
            $num2 = 0
            GUICtrlSetData($input, "")
        Case ($msg = $exit)
            $i = 1
        Case ($msg = $about)
            MsgBox(0, "Calc", "This calculator was created by Isaac Flaum using Autoit as an efficent, good looking calculator.", 10)
        Case ($msg = $advanced)
            GUICtrlSetState($advanced, $GUI_CHECKED)
            GUICtrlSetState($simple, $GUI_UNCHECKED)
            $num1 = GUICtrlRead($input)
            GUICtrlDelete($input)
            WinMove("Calc", "", Default, Default, 185, 220)
            Dim $input = GUICtrlCreateInput($num1, 5, 5, 168, 20)
            GUICtrlSetState($sin, $GUI_SHOW)
            GUICtrlSetState($cos, $GUI_SHOW)
            GUICtrlSetState($tan, $GUI_SHOW)
            GUICtrlSetState($sqrt, $GUI_SHOW)
        Case ($msg = $simple)
            GUICtrlSetState($simple, $GUI_CHECKED)
            GUICtrlSetState($advanced, $GUI_UNCHECKED)
            $num1 = GUICtrlRead($input)
            WinMove("Calc", "", Default, Default, 150, 220)
            GUICtrlDelete($input)
            GUICtrlSetState($sin, $GUI_HIDE)
            GUICtrlSetState($cos, $GUI_HIDE)
            GUICtrlSetState($tan, $GUI_HIDE)
            GUICtrlSetState($sqrt, $GUI_HIDE)
            Dim $input = GUICtrlCreateInput($num1, 5, 5, 135, 20, $ES_READONLY)
        Case ($msg = $mandarin)
            GUICtrlSetState($english, $GUI_UNCHECKED)
            GUICtrlSetState($mandarin, $GUI_CHECKED)
            GUICtrlSetData($button[0], ChrW(38646))
            GUICtrlSetData($button[1], ChrW(19968))
            GUICtrlSetData($button[2], ChrW(20108))
            GUICtrlSetData($button[3], ChrW(19977))
            GUICtrlSetData($button[4], ChrW(22235))
            GUICtrlSetData($button[5], ChrW(20116))
            GUICtrlSetData($button[6], ChrW(20845))
            GUICtrlSetData($button[7], ChrW(19971))
            GUICtrlSetData($button[8], ChrW(20843))
            GUICtrlSetData($button[9], ChrW(20061))
        Case ($msg = $english)
            GUICtrlSetState($english, $GUI_CHECKED)
            GUICtrlSetState($mandarin, $GUI_UNCHECKED)
            GUICtrlSetData($button[0], "0")
            GUICtrlSetData($button[1], "1")
            GUICtrlSetData($button[2], "2")
            GUICtrlSetData($button[3], "3")
            GUICtrlSetData($button[4], "4")
            GUICtrlSetData($button[5], "5")
            GUICtrlSetData($button[6], "6")
            GUICtrlSetData($button[7], "7")
            GUICtrlSetData($button[8], "8")
            GUICtrlSetData($button[9], "9")
        Case ($msg = $sin)
            $num1 = GUICtrlRead($input)
            _sine()
        Case ($msg = $cos)
            $num1 = GUICtrlRead($input)
            _cosine()
        Case ($msg = $tan)
            $num1 = GUICtrlRead($input)
            _tangent()
        Case ($msg = $sqrt)
            $num1 = GUICtrlRead($input)
            _sqrt()
    EndSelect

Until $i = 1

Func _add()
    $num2 = GUICtrlRead($input)
    $final = Execute($num1 + $num2)
    GUICtrlSetData($input, $final)
EndFunc  ;==>_add

Func _subtract()
    $num2 = GUICtrlRead($input)
    $final = Execute($num1 - $num2)
    GUICtrlSetData($input, $final)
EndFunc  ;==>_subtract

Func _multiply()
    $num2 = GUICtrlRead($input)
    $final = Execute($num1 * $num2)
    GUICtrlSetData($input, $final)
EndFunc  ;==>_multiply

Func _divide()
    $num2 = GUICtrlRead($input)
    $final = Execute($num1 / $num2)
    GUICtrlSetData($input, $final)
EndFunc  ;==>_divide

Func _sine()
    $final = Sin($num1)
    GUICtrlSetData($input, $final)
EndFunc  ;==>_sine

Func _cosine()
    $final = Cos($num1)
    GUICtrlSetData($input, $final)
EndFunc  ;==>_cosine

Func _tangent()
    $final = Tan($num1)
    GUICtrlSetData($input, $final)
EndFunc  ;==>_tangent

Func _sqrt()
    $final = Sqrt($num1)
    GUICtrlSetData($input, $final)
EndFunc  ;==>_sqrt

global $warming = true

Share this post


Link to post
Share on other sites
Creator

this is really cool!

why do you clear the display when making an operation?

i personally w'd like to see the digit im applying the operation to.

but that's personal. all i had to do was loose the "guictrlsetdata($input, "")"'s to let it act "my style" ;)

Share this post


Link to post
Share on other sites
ludocus

pretty nice..!

but please look at my calc (in sig)

and see how short the code is..

maybe you could shorten your code like that two.

Share this post


Link to post
Share on other sites
hanusherado

Its very pretty. it also works with numeric keypad as well. still its awsum

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.