Prima Calcolatrice!!!

« Older   Newer »
  Share  
-Coyote-
CAT_IMG Posted on 16/5/2010, 14:23     +1   -1




Ciao a tutti!!! Come sapete so.lo ieri ho iniziato a programmare in autoit e ho gia creato un semplice programma, ora sono passato ad un livello maggiore!!!!! Ecco una bella calcolatrice:

SPOILER (click to view)
#include <buttonconstants.au3>
#include <editconstants.au3>
#include <guiconstantsex.au3>
#include <windowsconstants.au3>
$Calcolatrice = GUICreate("Prima Calcolatrice", 316, 340, 379, 401)
$Casella = GUICtrlCreateInput("", 16, 16, 281, 21)
$Button1 = GUICtrlCreateButton("1", 24, 64, 57, 41, $WS_GROUP)
$Button2 = GUICtrlCreateButton("2", 128, 64, 57, 41, $WS_GROUP)
$Button3 = GUICtrlCreateButton("3", 232, 64, 57, 41, $WS_GROUP)
$Button4 = GUICtrlCreateButton("4", 24, 112, 57, 41, $WS_GROUP)
$Button5 = GUICtrlCreateButton("5", 128, 112, 57, 41, $WS_GROUP)
$Button6 = GUICtrlCreateButton("6", 232, 112, 57, 41, $WS_GROUP)
$Button7 = GUICtrlCreateButton("7", 24, 160, 57, 41, $WS_GROUP)
$Button8 = GUICtrlCreateButton("8", 128, 160, 57, 41, $WS_GROUP)
$Button9 = GUICtrlCreateButton("9", 232, 160, 57, 41, $WS_GROUP)
$Button10 = GUICtrlCreateButton("0", 128, 208, 57, 41, $WS_GROUP)
$Button11 = GUICtrlCreateButton("+", 16, 272, 57, 25, $WS_GROUP)
$Button12 = GUICtrlCreateButton("-", 88, 272, 57, 25, $WS_GROUP)
$Button13 = GUICtrlCreateButton("x", 160, 272, 57, 25, $WS_GROUP)
$Button14 = GUICtrlCreateButton("/", 240, 272, 57, 25, $WS_GROUP)
$Button15 = GUICtrlCreateButton("=", 16, 304, 281, 25, $WS_GROUP)

GUISetState(@SW_SHOW)

While 1
$numeri = GUICtrlRead($Casella)
Switch GUIGetMsg ()
Case $GUI_EVENT_CLOSE
Exit

Case $Button1
GUICtrlSetData($Casella,$numeri&"1")
Case $Button2
GUICtrlSetData($Casella,$numeri&"2")
Case $Button3
GUICtrlSetData($Casella,$numeri&"3")
Case $Button4
GUICtrlSetData($Casella,$numeri&"4")
Case $Button5
GUICtrlSetData($Casella,$numeri&"5")
Case $Button6
GUICtrlSetData($Casella,$numeri&"6")
Case $Button7
GUICtrlSetData($Casella,$numeri&"7")
Case $Button8
GUICtrlSetData($Casella,$numeri&"8")
Case $Button9
GUICtrlSetData($Casella,$numeri&"9")
Case $Button10
GUICtrlSetData($Casella,$numeri&"0")
Case $Button12
GUICtrlSetData($Casella,$numeri&"-")
Case $Button11
GUICtrlSetData($Casella,$numeri&"+")
Case $Button14
GUICtrlSetData($Casella,$numeri&"/")
Case $Button13
GUICtrlSetData($Casella,$numeri&"*")
Case $Button15
$Ris = Execute($numeri)
GUICtrlSetData ($Casella,$Ris)


EndSwitch
WEnd


Se manca qualcosa ditemi xD
 
Top
Gianlu-thebest
CAT_IMG Posted on 16/5/2010, 14:31     +1   -1




Fai in modo che l'utente non possa scrivere nell'input manualmente, e poi metti il puntino per i decimali...
G00D Work :)
 
Top
-Coyote-
CAT_IMG Posted on 16/5/2010, 14:32     +1   -1




ok, grazie
 
Top
-Coyote-
CAT_IMG Posted on 16/5/2010, 18:48     +1   -1




Bene ragazzi, ho seguito i consigli di gianlu ed ecco la nuova versione 1.5 :

SPOILER (click to view)
#include <buttonconstants.au3>
#include <editconstants.au3>
#include <guiconstantsex.au3>
#include <windowsconstants.au3>
$Calcolatrice = GUICreate("Prima Calcolatrice", 317, 387, 379, 401)
GUISetBkColor(0x33ff00)
$Casella = GUICtrlCreateInput("", 16, 16, 281, 20)
$Button1 = GUICtrlCreateButton("1", 24, 64, 57, 41, $WS_GROUP)
$Button2 = GUICtrlCreateButton("2", 128, 64, 57, 41, $WS_GROUP)
$Button3 = GUICtrlCreateButton("3", 232, 64, 57, 41, $WS_GROUP)
$Button4 = GUICtrlCreateButton("4", 24, 112, 57, 41, $WS_GROUP)
$Button5 = GUICtrlCreateButton("5", 128, 112, 57, 41, $WS_GROUP)
$Button6 = GUICtrlCreateButton("6", 232, 112, 57, 41, $WS_GROUP)
$Button7 = GUICtrlCreateButton("7", 24, 160, 57, 41, $WS_GROUP)
$Button8 = GUICtrlCreateButton("8", 128, 160, 57, 41, $WS_GROUP)
$Button9 = GUICtrlCreateButton("9", 232, 160, 57, 41, $WS_GROUP)
$Button10 = GUICtrlCreateButton("0", 128, 208, 57, 41, $WS_GROUP)
$Button11 = GUICtrlCreateButton("+", 16, 272, 57, 25, $WS_GROUP)
$Button12 = GUICtrlCreateButton("-", 88, 272, 57, 25, $WS_GROUP)
$Button13 = GUICtrlCreateButton("x", 160, 272, 57, 25, $WS_GROUP)
$Button14 = GUICtrlCreateButton("/", 240, 272, 57, 25, $WS_GROUP)
$Button15 = GUICtrlCreateButton("=", 16, 344, 281, 25, $WS_GROUP)
$Button16 = GUICtrlCreateButton(".", 232, 208, 57, 41, $WS_GROUP)
$Button17 = GUICtrlCreateButton("AC", 160, 304, 57, 25, $WS_GROUP)
$Button18 = GUICtrlCreateButton("00", 24, 208, 57, 41, $WS_GROUP)
$Button19 = GUICtrlCreateButton("Esci", 88, 304, 57, 25, $WS_GROUP)

GUISetState(@SW_SHOW)

While 1
$numeri = GUICtrlRead($Casella)
Switch GUIGetMsg ()
Case $GUI_EVENT_CLOSE
Exit

Case $Button1
GUICtrlSetData($Casella,$numeri&"1")
Case $Button2
GUICtrlSetData($Casella,$numeri&"2")
Case $Button3
GUICtrlSetData($Casella,$numeri&"3")
Case $Button4
GUICtrlSetData($Casella,$numeri&"4")
Case $Button5
GUICtrlSetData($Casella,$numeri&"5")
Case $Button6
GUICtrlSetData($Casella,$numeri&"6")
Case $Button7
GUICtrlSetData($Casella,$numeri&"7")
Case $Button8
GUICtrlSetData($Casella,$numeri&"8")
Case $Button9
GUICtrlSetData($Casella,$numeri&"9")
Case $Button10
GUICtrlSetData($Casella,$numeri&"0")
Case $Button12
GUICtrlSetData($Casella,$numeri&"-")
Case $Button11
GUICtrlSetData($Casella,$numeri&"+")
Case $Button14
GUICtrlSetData($Casella,$numeri&"/")
Case $Button13
GUICtrlSetData($Casella,$numeri&"*")
Case $Button16
GUICtrlSetData($Casella,$numeri&".")
Case $Button17
GUICtrlSetData($Casella, "")
Case $Button18
GUICtrlSetData($Casella,$numeri&"00")
Case $Button19
Exit
Case $Button15
$Ris = Execute($numeri)
GUICtrlSetData ($Casella,$Ris)


EndSwitch
WEnd


Pero ho un problemino.... Ci ho provato per ore ed ore a scoprire come fare per non scrivere nell'Input manualmente ma senza successo.... Qualcuno mi puo dare una mano? xD

Forse oggi viene la versione 2.0 xD
 
Top
Grandebestia
CAT_IMG Posted on 16/5/2010, 19:30     +1   -1




Devi inserire questo codice alla riga 7:
SPOILER (click to view)
$Casella = GUICtrlCreateInput("", 16, 16, 281, 20, 0x0800) ;basta lo style $ES_READONLY che sarebbe 0x0800 (per usare la variablile bisogna inserire #include <guiconstantsex.au3>

Ciao
 
Top
-Coyote-
CAT_IMG Posted on 16/5/2010, 19:36     +1   -1




Grazie mille!!!!!! Sei stato di grande aiuto!!

Ecco la versione 1.7:

SPOILER (click to view)
#include <buttonconstants.au3>
#include <editconstants.au3>
#include <guiconstantsex.au3>
#include <windowsconstants.au3>
#include <guiconstantsex.au3>
$Calcolatrice = GUICreate("Prima Calcolatrice", 318, 430, 775, 289)
GUISetBkColor(0x33ff00)
$Casella = GUICtrlCreateInput("", 16, 16, 281, 20, 0x0800)
$Button1 = GUICtrlCreateButton("1", 24, 64, 57, 41, $WS_GROUP)
$Button2 = GUICtrlCreateButton("2", 128, 64, 57, 41, $WS_GROUP)
$Button3 = GUICtrlCreateButton("3", 232, 64, 57, 41, $WS_GROUP)
$Button4 = GUICtrlCreateButton("4", 24, 112, 57, 41, $WS_GROUP)
$Button5 = GUICtrlCreateButton("5", 128, 112, 57, 41, $WS_GROUP)
$Button6 = GUICtrlCreateButton("6", 232, 112, 57, 41, $WS_GROUP)
$Button7 = GUICtrlCreateButton("7", 24, 160, 57, 41, $WS_GROUP)
$Button8 = GUICtrlCreateButton("8", 128, 160, 57, 41, $WS_GROUP)
$Button9 = GUICtrlCreateButton("9", 232, 160, 57, 41, $WS_GROUP)
$Button10 = GUICtrlCreateButton("0", 128, 208, 57, 41, $WS_GROUP)
$Button11 = GUICtrlCreateButton("+", 16, 272, 57, 25, $WS_GROUP)
$Button12 = GUICtrlCreateButton("-", 88, 272, 57, 25, $WS_GROUP)
$Button13 = GUICtrlCreateButton("x", 160, 272, 57, 25, $WS_GROUP)
$Button14 = GUICtrlCreateButton("/", 240, 272, 57, 25, $WS_GROUP)
$Button15 = GUICtrlCreateButton("=", 16, 376, 281, 25, $WS_GROUP)
$Button16 = GUICtrlCreateButton(".", 232, 208, 57, 41, $WS_GROUP)
$Button17 = GUICtrlCreateButton("AC", 160, 304, 57, 25, $WS_GROUP)
$Button18 = GUICtrlCreateButton("00", 24, 208, 57, 41, $WS_GROUP)
$Button19 = GUICtrlCreateButton("Esci", 88, 304, 57, 25, $WS_GROUP)
$Button20 = GUICtrlCreateButton("(", 16, 304, 57, 25, $WS_GROUP)
$Button21 = GUICtrlCreateButton(")", 240, 304, 57, 25, $WS_GROUP)

GUISetState(@SW_SHOW)

While 1
$numeri = GUICtrlRead($Casella)
Switch GUIGetMsg ()
Case $GUI_EVENT_CLOSE
Exit

Case $Button1
GUICtrlSetData($Casella,$numeri&"1")
Case $Button2
GUICtrlSetData($Casella,$numeri&"2")
Case $Button3
GUICtrlSetData($Casella,$numeri&"3")
Case $Button4
GUICtrlSetData($Casella,$numeri&"4")
Case $Button5
GUICtrlSetData($Casella,$numeri&"5")
Case $Button6
GUICtrlSetData($Casella,$numeri&"6")
Case $Button7
GUICtrlSetData($Casella,$numeri&"7")
Case $Button8
GUICtrlSetData($Casella,$numeri&"8")
Case $Button9
GUICtrlSetData($Casella,$numeri&"9")
Case $Button10
GUICtrlSetData($Casella,$numeri&"0")
Case $Button12
GUICtrlSetData($Casella,$numeri&"-")
Case $Button11
GUICtrlSetData($Casella,$numeri&"+")
Case $Button14
GUICtrlSetData($Casella,$numeri&"/")
Case $Button13
GUICtrlSetData($Casella,$numeri&"*")
Case $Button16
GUICtrlSetData($Casella,$numeri&".")
Case $Button17
GUICtrlSetData($Casella, "")
Case $Button18
GUICtrlSetData($Casella,$numeri&"00")
Case $Button20
GUICtrlSetData($Casella,$numeri&"(")
Case $Button21
GUICtrlSetData($Casella,$numeri&")")
Case $Button19
Exit
Case $Button15
$Ris = Execute($numeri)
GUICtrlSetData ($Casella,$Ris)


EndSwitch
WEnd


Questa versione è munita anche di parentesi rotonde xD e non si può scrivere nell'Imput box
 
Top
Gianlu-thebest
CAT_IMG Posted on 16/5/2010, 21:51     +1   -1




G00d, puoi mettere in modo che, se l'operzione non riesce da errore, le parentesi si possono aprire solo dopo un operatore, e cambiare lo sfondo, il verde a me non piace, xD
 
Top
VforVentordici
CAT_IMG Posted on 17/5/2010, 14:21     +1   -1




Good ;) very very good ;)
 
Top
Aaly
CAT_IMG Posted on 17/5/2010, 14:37     +1   -1




gianlu non pensi di chiedere un po' troppo? xD
 
Top
MHack
CAT_IMG Posted on 17/5/2010, 14:39     +1   -1




Niente male ;)
 
Top
-Coyote-
CAT_IMG Posted on 17/5/2010, 15:07     +1   -1




ci provo con la cosa delle parentesi ma non so se mi viene xD
 
Top
Gianlu-thebest
CAT_IMG Posted on 17/5/2010, 16:05     +1   -1




-Coyote- Per le parentesi usa le funzioni
CODICE
StrinLeft($stringa,$caratteridaleggere_solonumero)


Ho sbalgiato, è StringRight($comandi,$uguali)!
 
Top
-Coyote-
CAT_IMG Posted on 18/5/2010, 18:38     +1   -1




non riesco a mettere la funzione delle parentesi...
 
Top
12 replies since 16/5/2010, 14:23   166 views
  Share