#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include #include #include #include GUICreate("Calculator", 260, 230) $operator = "" $clearDisplay = True ; Digit's buttons Local $CTRL_EdtScreen = GUICtrlCreateEdit("0.", 8, 2, 239, 23, BitOR($ES_READONLY, $ES_RIGHT), $WS_EX_STATICEDGE) Local $CTRL_LblMemory = GUICtrlCreateLabel("", 12, 39, 27, 26, $SS_SUNKEN) Local $CTRL_btn0 = GUICtrlCreateButton("0", 54, 171, 36, 29) Local $CTRL_btn1 = GUICtrlCreateButton("1", 54, 138, 36, 29) Local $CTRL_btn2 = GUICtrlCreateButton("2", 93, 138, 36, 29) Local $CTRL_btn3 = GUICtrlCreateButton("3", 132, 138, 36, 29) Local $CTRL_btn4 = GUICtrlCreateButton("4", 54, 106, 36, 29) Local $CTRL_btn5 = GUICtrlCreateButton("5", 93, 106, 36, 29) Local $CTRL_btn6 = GUICtrlCreateButton("6", 132, 106, 36, 29) Local $CTRL_btn7 = GUICtrlCreateButton("7", 54, 73, 36, 29) Local $CTRL_btn8 = GUICtrlCreateButton("8", 93, 73, 36, 29) Local $CTRL_btn9 = GUICtrlCreateButton("9", 132, 73, 36, 29) Local $CTRL_btnPeriod = GUICtrlCreateButton(".", 132, 171, 36, 29) ; Memory's buttons Local $CTRL_btnMClear = GUICtrlCreateButton("MC", 8, 73, 36, 29) Local $CTRL_btnMRestore = GUICtrlCreateButton("MR", 8, 106, 36, 29) Local $CTRL_btnMStore = GUICtrlCreateButton("MS", 8, 138, 36, 29) Local $CTRL_btnMAdd = GUICtrlCreateButton("M+", 8, 171, 36, 29) ; Operators Local $CTRL_btnChangeSign = GUICtrlCreateButton("+/-", 93, 171, 36, 29) Local $CTRL_btnDivision = GUICtrlCreateButton("/", 171, 73, 36, 29) Local $CTRL_btnMultiplication = GUICtrlCreateButton("*", 171, 106, 36, 29) Local $CTRL_btnSubtract = GUICtrlCreateButton("-", 171, 138, 36, 29) Local $CTRL_btnAdd = GUICtrlCreateButton("+", 171, 171, 36, 29) Local $CTRL_btnAnswer = GUICtrlCreateButton("=", 210, 171, 36, 29) Local $CTRL_btnInverse = GUICtrlCreateButton("1/x", 210, 138, 36, 29) Local $CTRL_btnSqrt = GUICtrlCreateButton("Sqrt", 210, 73, 36, 29) Local $CTRL_btnPercentage = GUICtrlCreateButton("%", 210, 106, 36, 29) Local $CTRL_btnBackspace = GUICtrlCreateButton("Backspace", 54, 37, 63, 29) Local $CTRL_btnClearE = GUICtrlCreateButton("CE", 120, 37, 62, 29) Local $CTRL_btnClear = GUICtrlCreateButton("C", 185, 37, 62, 29) Func _Add () $Display_String = ($Display_String & ' + ') $Real_String = ($Real_String & ' + ') GUICtrlSetData ($Display, $Display_String) GUICtrlSetState ($Display, $GUI_FOCUS) EndFunc GUISetState() Local $msg Do $msg = GUIGetMsg() if $msg=$CTRL_btnperiod then $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & ".") EndIf if $msg=$CTRL_btnMClear then $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "MC") EndIf if $msg=$CTRL_btnMStore then $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "MS") EndIf if $msg=$CTRL_btnMAdd then $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "M+") EndIf if $msg=$CTRL_btnChangeSign then $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "+/-") EndIf if $msg=$CTRL_btnMRestore then $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "MR") EndIf if $msg=$CTRL_btnInverse then $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "1/x") EndIf if $msg=$CTRL_btnSqrt then $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "Sqrt") EndIf if $msg=$CTRL_btnMRestore then $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "MR") EndIf if $msg=$CTRL_btnPercentage then $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "%") EndIf if $msg=$CTRL_btnsubtract then $operator = "-" $clearDisplay = True EndIf if $msg=$CTRL_btnclear then $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "C") EndIf if $msg=$CTRL_btnbackspace then $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "backspace") EndIf if $msg=$CTRL_btnClearE then $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "CE") EndIf if $msg=$CTRL_btnanswer then $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "=") EndIf if $msg=$CTRL_btnAdd then $operator = "+" $clearDisplay = True EndIf if $msg=$CTRL_btnmultiplication then $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "*") EndIf if $msg=$CTRL_btn0 then If $clearDisplay Then GUICtrlSetData($CTRL_edtscreen, "") $clearDisplay = False EndIf $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "0") EndIf if $msg=$CTRL_btn1 then If $clearDisplay Then GUICtrlSetData($CTRL_edtscreen, "") $clearDisplay = False EndIf $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "1") EndIf if $msg=$CTRL_btn2 then If $clearDisplay Then GUICtrlSetData($CTRL_edtscreen, "") $clearDisplay = False EndIf $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "2") EndIf if $msg=$CTRL_btn3 then If $clearDisplay Then GUICtrlSetData($CTRL_edtscreen, "") $clearDisplay = False EndIf $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "3") EndIf if $msg=$CTRL_btn4 then If $clearDisplay Then GUICtrlSetData($CTRL_edtscreen, "") $clearDisplay = False EndIf $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "4") EndIf if $msg=$CTRL_btn5 then If $clearDisplay Then GUICtrlSetData($CTRL_edtscreen, "") $clearDisplay = False EndIf $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "5") EndIf if $msg=$CTRL_btn6 then If $clearDisplay Then GUICtrlSetData($CTRL_edtscreen, "") $clearDisplay = False EndIf $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "6") EndIf if $msg=$CTRL_btn7 then If $clearDisplay Then GUICtrlSetData($CTRL_edtscreen, "") $clearDisplay = False EndIf $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "7") EndIf if $msg=$CTRL_btn8 then If $clearDisplay Then GUICtrlSetData($CTRL_edtscreen, "") $clearDisplay = False EndIf $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "8") EndIf if $msg=$CTRL_btn9 then If $clearDisplay Then GUICtrlSetData($CTRL_edtscreen, "") $clearDisplay = False EndIf $contents = GUICtrlread($CTRL_edtscreen) GUICtrlSetData( $CTRL_edtscreen,$contents & "9") EndIf Until $msg = $GUI_EVENT_CLOSE