[AutoIt]Semplice calcolatrice

14 08 2008

Ecco un semplicissimo script da me realizzato per ottenere una piccola calcolatrice :

 

 

;Autore : .:The Joker:.

#include <GUIConstants.au3>

GUICreate (“Calcolatrice by .:The Joker:.”,130,240)
GUISetBkColor(0xeee8aa)
$output = “”
$out  =  GUICtrlCreateInput ( “”, 5, 5 , 120 , 20 )
$1 =  GUICtrlCreateButton (“1″,5,35,25,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)

$2 =  GUICtrlCreateButton (“2″,35,35,25,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)

$3 =  GUICtrlCreateButton (“3″,65,35,25,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)

$4 =  GUICtrlCreateButton (“4″,5,75,25,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)

$5 =  GUICtrlCreateButton (“5″,35,75,25,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)

$6 =  GUICtrlCreateButton (“6″,65,75,25,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)

$7 =  GUICtrlCreateButton (“7″,5,115,25,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)

$8 =  GUICtrlCreateButton (“8″,35,115,25,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)

$9 =  GUICtrlCreateButton (“9″,65,115,25,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)

$0 = GUICtrlCreateButton(“0″,5,155,25,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)

$00 = GUICtrlCreateButton(“00″,35,155,25,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)
$ugua = GUICtrlCreateButton (“=”,5,195,86,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)
$addiz = GUICtrlCreateButton (“+”,100,35,25,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)
$sottr = GUICtrlCreateButton (“-”,100,75,25,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)
$molti = GUICtrlCreateButton (“x”,100,115,25,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)
$divisione = GUICtrlCreateButton (“:”,100,155,25,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)
$CE = GUICtrlCreateButton(“CE”,100,194,25,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)
$virg=GUICtrlCreateButton(“.”,65,155,25,25)
 GUICtrlSetColor(-1, 0×000000)
         GUICtrlSetBkColor(-1, 0xf8f8ff)
$operatore1 = 0
$operatore2 = 0
$risultato = 0
$piu = 0
$meno = 0
$per = 0
$diviso = 0
GUISetState( )

$msg = GUIGetMsg()

While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
   Select
      case $msg = $1
         $output = $output & “1″
         GUICtrlSetData( $out, $output )
      case $msg = $2
         $output = $output & “2″
         GUICtrlSetData( $out, $output )
      case $msg = $3
         $output = $output & “3″
         GUICtrlSetData( $out, $output )
      case $msg = $4
         $output = $output & “4″
         GUICtrlSetData( $out, $output )
      case $msg = $5
          $output = $output & “5″
         GUICtrlSetData( $out, $output )
      case $msg = $6
         $output = $output & “6″
         GUICtrlSetData( $out, $output )
      case $msg = $7
         $output = $output & “7″
         GUICtrlSetData( $out, $output )
      case $msg = $8
         $output = $output & “8″
         GUICtrlSetData( $out, $output )
      case $msg = $9
         $output = $output & “9″
         GUICtrlSetData( $out, $output )
  case $msg = $00
  $output = $output & “00″
   GUICtrlSetData( $out, $output )
   Case $msg=$0
         If $output <> “” Then
            $output = $output & “0″
            GUICtrlSetData( $out, $output )
         EndIf
      Case $msg = $virg
         $output = $output & “.”
         GUICtrlSetData( $out, $output )
      case $msg = $addiz
         $piu = 1
         read()
         GUICtrlSetData( $out, “” )
         $output = “”
      case $msg = $sottr
         $meno = 1
         read()
         GUICtrlSetData( $out, “” )
         $output = “”
      case $msg = $molti
         $per = 1
         read()
         GUICtrlSetData( $out, “” )
         $output = “”
         case $msg = $divisione
         $diviso = 1
         read()
         GUICtrlSetData( $out, “” )
         $output = “”
         case $msg = $ugua
         read()
         If $piu = 1 Then
            $risultato = $operatore1 + $operatore2
            GUICtrlSetData( $out, $risultato )
            $piu = 0
            $operatore1 = 0
            $operatore2 = 0
            $risultato = 0
         ElseIf $meno = 1 Then
            $risultato = $operatore1 – $operatore2
            GUICtrlSetData( $out, $risultato )
            $meno = 0
            $operatore1 = 0
            $operatore2 = 0
            $risultato = 0
         ElseIf $per = 1 Then
            $risultato = $operatore1 * $operatore2
            GUICtrlSetData( $out, $risultato )
            $per = 0
            $operatore1 = 0
            $operatore2 = 0
            $risultato= 0
         ElseIf $diviso = 1 Then
            $result = $operatore1 / $operatore2
            GUICtrlSetData( $out, $risultato )
            $diviso = 0
            $operatore1 = 0
            $operatore2 = 0
            $risultato = 0
         EndIf
      case $msg = $CE
            clear()
   EndSelect
Wend
  
Func read()
   If $operatore1 = 0 Then
      $operatore1 = Number(GUICtrlRead($out))
   Else
      $operatore2 = Number(GUICtrlRead($out))
   EndIf
EndFunc

Func clear()
   $piu = 0
   $meno = 0
   $per = 0
   $diviso = 0
   $operatore1 = 0
   $operatore2 = 0
   $risultato = 0
   $output = “”
   GUICtrlSetData( $out, “” )
EndFunc


Azioni

Informazione

Lascia un commento