LimeSeed Posted August 29, 2008 Share Posted August 29, 2008 You know how when you go into the windows calculator under accessories, you can click view>scientific and then the gui instantly resizes and displays new buttons. Would there be any way for me to do this? global $warming = true Link to comment Share on other sites More sharing options...
Achilles Posted August 29, 2008 Share Posted August 29, 2008 GUICtrlSetResizing() and to reset you window you WinMove() My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
martin Posted August 29, 2008 Share Posted August 29, 2008 You know how when you go into the windows calculator under accessories, you can click view>scientific and then the gui instantly resizes and displays new buttons. Would there be any way for me to do this?#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIResizeMode",BitOr($GUI_DOCKWIDTH,$GUI_DOCKHEIGHT,$GUI_DOCKTOP,$GUI_DOCKLEFT)) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 327, 94, 193, 125) $Input1 = GUICtrlCreateInput("", 176, 24, 121, 21) $Button1 = GUICtrlCreateButton("Button1", 64, 24, 75, 25, 0) $Button2 = GUICtrlCreateButton("Button2", 80, 136, 75, 25, 0) $Button3 = GUICtrlCreateButton("Button3", 200, 136, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Button1 winmove($form1,"",193,125,327,300) EndSwitch WEnd Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
LimeSeed Posted August 30, 2008 Author Share Posted August 30, 2008 #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIResizeMode",BitOr($GUI_DOCKWIDTH,$GUI_DOCKHEIGHT,$GUI_DOCKTOP,$GUI_DOCKLEFT)) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 327, 94, 193, 125) $Input1 = GUICtrlCreateInput("", 176, 24, 121, 21) $Button1 = GUICtrlCreateButton("Button1", 64, 24, 75, 25, 0) $Button2 = GUICtrlCreateButton("Button2", 80, 136, 75, 25, 0) $Button3 = GUICtrlCreateButton("Button3", 200, 136, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Button1 winmove($form1,"",193,125,327,300) EndSwitch WEnd thank you martin, you continue to be one of the most helpful members on this forum! global $warming = true Link to comment Share on other sites More sharing options...
LimeSeed Posted August 30, 2008 Author Share Posted August 30, 2008 expandcollapse popup#NoTrayIcon #include <guiconstants.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> ;calculator created by isaac flaum $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) $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($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) GUISetBkColor(0x494e48) guisetstate(@SW_SHOW) 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 = $advanced) winmove("Calc", "", default, default, 150, 250) 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) EndSelect Until $i = 1 func _add() $num2 = guictrlread($input) $final = $num1 + $num2 guictrlsetdata($input, $final) EndFunc func _subtract() $num2 = guictrlread($input) $final = $num1 - $num2 guictrlsetdata($input, $final) EndFunc func _multiply() $num2 = guictrlread($input) $final = ($num1 * $num2) guictrlsetdata($input, $final) EndFunc func _divide() $num2 = guictrlread($input) $final = ($num1 / $num2) guictrlsetdata($input, $final) EndFunc func _sine() $final = sin($num1) guictrlsetdata($input, $final) EndFunc Func _cosine() $final = cos($num1) guictrlsetdata($input, $final) EndFunc Func _tangent() $final = tan($num1) guictrlsetdata($input, $final) EndFunc ok, so now my calculator works pretty well, and looks good. i have 2 problems though 1 how do i get the buttons and input box to stay in the same place in the gui window when i resize the gui? 2 when i set the background colors of the buttons using guictrlsetbkcolor($7, 0xFFFFFF) i can't click on the buttons rapidly, they have a delay. when i remove this code, it works rapidly. any way to keep the code and still get it to move rapidly, like add arrays to the buttons? global $warming = true Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted August 30, 2008 Share Posted August 30, 2008 1 how do i get the buttons and input box to stay in the same place in the gui window when i resize the gui?Use GUICtrlSetResizing(), see helpfile for example. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
LimeSeed Posted August 30, 2008 Author Share Posted August 30, 2008 Use GUICtrlSetResizing(), see helpfile for example.i tried using the helpfile but i couldnt find the right command, none of them would work :-( global $warming = true Link to comment Share on other sites More sharing options...
rasim Posted August 30, 2008 Share Posted August 30, 2008 i tried using the helpfile but i couldnt find the right command, none of them would work :-(1. Just add a Opt("GUIResizeMode", $GUI_DOCKALL) option in begin of your script. Link to comment Share on other sites More sharing options...
LimeSeed Posted August 30, 2008 Author Share Posted August 30, 2008 1. Just add a Opt("GUIResizeMode", $GUI_DOCKALL) option in begin of your script.thanks! now how do i fix the problem about the buttons not working quickly? global $warming = true Link to comment Share on other sites More sharing options...
Achilles Posted August 30, 2008 Share Posted August 30, 2008 thanks! now how do i fix the problem about the buttons not working quickly?They work fine on my computer.Also, pressing the decimal button isn't working. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
LimeSeed Posted August 30, 2008 Author Share Posted August 30, 2008 expandcollapse popup#NoTrayIcon #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) 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) guictrldelete($input) Dim $input = guictrlcreateinput("", 5, 5, 168, 20) winmove("Calc", "", default, default, 185, 220) guictrlsetstate($sin, $GUI_SHOW) guictrlsetstate($cos, $GUI_SHOW) guictrlsetstate($tan, $GUI_SHOW) guictrlsetstate($sqrt, $GUI_SHOW) Case ($msg = $simple) winmove("Calc", "", Default, Default, 150, 220) guictrldelete($input) guictrlsetstate($sin, $GUI_HIDE) guictrlsetstate($cos, $GUI_HIDE) guictrlsetstate($tan, $GUI_HIDE) guictrlsetstate($sqrt, $GUI_HIDE) $input = GUICtrlCreateInput("", 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 func _subtract() $num2 = guictrlread($input) $final = $num1 - $num2 guictrlsetdata($input, $final) EndFunc func _multiply() $num2 = guictrlread($input) $final = ($num1 * $num2) guictrlsetdata($input, $final) EndFunc func _divide() $num2 = guictrlread($input) $final = ($num1 / $num2) guictrlsetdata($input, $final) EndFunc func _sine() $final = sin($num1) guictrlsetdata($input, $final) EndFunc Func _cosine() $final = cos($num1) guictrlsetdata($input, $final) EndFunc Func _tangent() $final = tan($num1) guictrlsetdata($input, $final) EndFunc Func _sqrt() $final = sqrt($num1) guictrlsetdata($input, $final) EndFunc i now fixed the calculator thanks guys, but how do i make it so that the buttons can be clicked repeatedly with the new colors?? global $warming = true Link to comment Share on other sites More sharing options...
martin Posted August 30, 2008 Share Posted August 30, 2008 i now fixed the calculator thanks guys, but how do i make it so that the buttons can be clicked repeatedly with the new colors??The buttons do work for me.The precedence of operations needs to be sorted out I think. 9*2+2= should give 20.Also, I think it would be better if the last entered number was not removed when an operator was typed. So 9* leaves 9 in the input. A 'normal' calculator will let you change the operator like this9*+2=11which is not so good if you want to multiply by a negative number of course. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
LimeSeed Posted August 30, 2008 Author Share Posted August 30, 2008 (edited) The buttons do work for me.The precedence of operations needs to be sorted out I think. 9*2+2= should give 20.Also, I think it would be better if the last entered number was not removed when an operator was typed. So 9* leaves 9 in the input. A 'normal' calculator will let you change the operator like this9*+2=11which is not so good if you want to multiply by a negative number of course.i fixed the problem so it leaved the nine in the input, but take the setbkcolor out of all the buttons and watch how quickly you are able to press it. How would i make it so that 9*2+8 = 26? oh i think i know! NVM i have no idea!! Edited August 30, 2008 by LimeSeed global $warming = true Link to comment Share on other sites More sharing options...
martin Posted August 30, 2008 Share Posted August 30, 2008 i fixed the problem so it leaved the nine in the input, but take the setbkcolor out of all the buttons and watch how quickly you are able to press it. How would i make it so that 9*2+8 = 26? oh i think i know! NVM i have no idea!!expandcollapse popup#NoTrayIcon #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) ;order of creation very important $0 must be first then thorough to $9 with nothing else in between $0 = GUICtrlCreateButton("0", 40, 135, 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) $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) $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) $input = GUICtrlCreateInput("", 5, 5, 135, 20, $ES_READONLY) $equals = GUICtrlCreateButton("=", 5, 135, 30, 30, $BS_FLAT) $clear = GUICtrlCreateButton("C", 75, 135, 30, 30, $BS_FLAT) ;these 4 must be grouped together wehn created $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($0, 0x5a6a50) GUICtrlSetBkColor($1, 0x5a6a50) 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($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) $inputstage = 1;waiting for number to be entered, when sign pressed we are at stage two until next digit is entered Do $msg = GUIGetMsg() If ($msg = -3) Then $i = 1 EndIf Select Case $msg >= $0 And $msg <= $9 If $inputstage = 2 Then GUICtrlSetData($input, "") $inputstage = 1 EndIf $pnum = GUICtrlRead($input) GUICtrlSetData($input, $pnum & Chr($msg - $0 + 0x30)) Case ($msg = $copy) $pnum = GUICtrlRead($input) ClipPut($pnum) Case ($msg = $paste) $data = ClipGet() GUICtrlSetData($input, $data) Case $msg >= $divide And $msg <= $minus $inputstage = 2 $num1 = GUICtrlRead($input) Switch $msg Case ($msg = $plus) $operation = 0 Case ($msg = $minus) $operation = 1 Case ($msg = $multiply) $operation = 2 Case ($msg = $divide) $operation = 3 EndSwitch Case ($msg = $clear) $inputstage = 1 $num1 = 0 $num2 = 0 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 $operation = -1 $inputstage = 2 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) GUICtrlDelete($input) Dim $input = GUICtrlCreateInput("", 5, 5, 168, 20) WinMove("Calc", "", Default, Default, 185, 220) GUICtrlSetState($sin, $GUI_SHOW) GUICtrlSetState($cos, $GUI_SHOW) GUICtrlSetState($tan, $GUI_SHOW) GUICtrlSetState($sqrt, $GUI_SHOW) Case ($msg = $simple) WinMove("Calc", "", Default, Default, 150, 220) GUICtrlDelete($input) GUICtrlSetState($sin, $GUI_HIDE) GUICtrlSetState($cos, $GUI_HIDE) GUICtrlSetState($tan, $GUI_HIDE) GUICtrlSetState($sqrt, $GUI_HIDE) $input = GUICtrlCreateInput("", 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 Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
LimeSeed Posted August 30, 2008 Author Share Posted August 30, 2008 (edited) @martin, your code didn't work. i did 3*3+3 and it came out with 6 and not 12 :-( ill figure out a way eventually, and im still having the problem where the buttons click slowly. Oh i see you were fixing where it erased the number. i already did that in my post above. expandcollapse popup#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) 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) $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) $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 i like this one better that i made because when you do 3*3 and click equals it says 9 and then press equals again and it keeps * by 3!! and it still fixes the problem of erasing the number after the operation! Edited August 30, 2008 by LimeSeed global $warming = true Link to comment Share on other sites More sharing options...
Zedna Posted August 30, 2008 Share Posted August 30, 2008 Little enhancement - menu radio items: use $advanced = guictrlcreatemenuitem("Advanced", $edit,0,1) $simple = guictrlcreatemenuitem("Simple", $edit,1,1) GUICtrlSetState($simple, $GUI_CHECKED) instead of $advanced = guictrlcreatemenuitem("Advanced", $edit) $simple = guictrlcreatemenuitem("Simple", $edit) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
LimeSeed Posted August 31, 2008 Author Share Posted August 31, 2008 Little enhancement - menu radio items: use $advanced = guictrlcreatemenuitem("Advanced", $edit,0,1) $simple = guictrlcreatemenuitem("Simple", $edit,1,1) GUICtrlSetState($simple, $GUI_CHECKED) instead of $advanced = guictrlcreatemenuitem("Advanced", $edit) $simple = guictrlcreatemenuitem("Simple", $edit) k thanks, fixed it! global $warming = true Link to comment Share on other sites More sharing options...
LimeSeed Posted September 1, 2008 Author Share Posted September 1, 2008 k thanks, fixed it!anyone figure out how to make the buttons click faster? Still having trouble with that. maybe if i use if statements rather than case statements?? global $warming = true Link to comment Share on other sites More sharing options...
TalivanIBM Posted September 3, 2008 Share Posted September 3, 2008 (edited) Hi, i don't know why the numbers go slowly when are clicked, but i have a sugestion....... Case $advanced GUICtrlSetPos($input, 5, 5, 168, 20) ;===> Change this and you don't have to delete the control WinMove("Calc", "", Default, Default, 185, 220) GUICtrlSetState($sin, $GUI_SHOW) GUICtrlSetState($cos, $GUI_SHOW) GUICtrlSetState($tan, $GUI_SHOW) GUICtrlSetState($sqrt, $GUI_SHOW) Case $simple WinMove("Calc", "", Default, Default, 150, 220) GUICtrlSetPos($input, 5, 5, 135, 20) ;===> Change this and you don't have to delete the control GUICtrlSetState($sin, $GUI_HIDE) GUICtrlSetState($cos, $GUI_HIDE) GUICtrlSetState($tan, $GUI_HIDE) GUICtrlSetState($sqrt, $GUI_HIDE) i was studying your script, when you click the +, -, * and / twice you don't remembre the first number, alway i have to click =, then i have a little solution to this....... expandcollapse popup#NoTrayIcon #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) Local $num1 ;=====> Change $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, 0, 1) ;=====> Change $simple = GUICtrlCreateMenuItem("Simple", $edit, 1, 1) ;=====> Change GUICtrlSetState(-1, $GUI_CHECKED) ;=====> Change GUICtrlSetDefBkColor(0x5a6a50, $calc) ;=====> Change ;order of creation very important $0 must be first then thorough to $9 with nothing else in between $0 = GUICtrlCreateButton("0", 40, 135, 30, 30) $1 = GUICtrlCreateButton("1", 5, 100, 30, 30) $2 = GUICtrlCreateButton("2", 40, 100, 30, 30) $3 = GUICtrlCreateButton("3", 75, 100, 30, 30) $4 = GUICtrlCreateButton("4", 5, 65, 30, 30) $5 = GUICtrlCreateButton("5", 40, 65, 30, 30) $6 = GUICtrlCreateButton("6", 75, 65, 30, 30) $7 = GUICtrlCreateButton("7", 5, 30, 30, 30) $8 = GUICtrlCreateButton("8", 40, 30, 30, 30) $9 = GUICtrlCreateButton("9", 75, 30, 30, 30) $input = GUICtrlCreateInput("", 5, 5, 135, 20, $ES_READONLY) $equals = GUICtrlCreateButton("=", 5, 135, 30, 30, $BS_FLAT) $clear = GUICtrlCreateButton("C", 75, 135, 30, 30, $BS_FLAT) ;these 4 must be grouped together wehn created $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) ;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) GUICtrlSetState($sin, $GUI_HIDE) GUICtrlSetState($cos, $GUI_HIDE) GUICtrlSetState($tan, $GUI_HIDE) GUICtrlSetState($sqrt, $GUI_HIDE) GUISetBkColor(0x494e48) GUISetState(@SW_SHOW) $inputstage = 1;waiting for number to be entered, when sign pressed we are at stage two until next digit is entered Do $msg = GUIGetMsg() Switch $msg Case $0 To $9 If $inputstage = 2 Then If $operation >= 0 Then $num1 = GUICtrlRead($input) ;=====> Change GUICtrlSetData($input, "") $inputstage = 1 EndIf $pnum = GUICtrlRead($input) GUICtrlSetData($input, $pnum & Chr($msg - $0 + 0x30)) Case $copy $pnum = GUICtrlRead($input) ClipPut($pnum) Case $paste $data = ClipGet() GUICtrlSetData($input, $data) Case $divide To $minus $inputstage = 2 $oper = $operation ;=====> Change Switch $msg Case $plus _Oper($oper) ;=====> Change $operation = 0 Case $minus _Oper($oper) ;=====> Change $operation = 1 Case $multiply _Oper($oper) ;=====> Change $operation = 2 Case $divide _Oper($oper) ;=====> Change $operation = 3 EndSwitch $oper = -1 ;=====> Change Case $clear $inputstage = 1 $num1 = 0 $num2 = 0 GUICtrlSetData($input, "") Case $equals If $operation = 0 Then _add($num1) ElseIf $operation = 1 Then _subtract($num1) ElseIf $operation = 2 Then _multiply($num1) ElseIf $operation = 3 Then _divide($num1) Else MsgBox(0, "Error", "No Operation Was Selected", 5) EndIf $operation = -1 $inputstage = 2 Case $exit ExitLoop Case $about MsgBox(0, "Calc", "This calculator was created by Isaac Flaum using Autoit as an efficent, good looking calculator", 10) Case $advanced GUICtrlSetPos($input, 5, 5, 168, 20) ;=====> Change WinMove("Calc", "", Default, Default, 185, 220) GUICtrlSetState($sin, $GUI_SHOW) GUICtrlSetState($cos, $GUI_SHOW) GUICtrlSetState($tan, $GUI_SHOW) GUICtrlSetState($sqrt, $GUI_SHOW) Case $simple WinMove("Calc", "", Default, Default, 150, 220) GUICtrlSetPos($input, 5, 5, 135, 20) ;=====> Change GUICtrlSetState($sin, $GUI_HIDE) GUICtrlSetState($cos, $GUI_HIDE) GUICtrlSetState($tan, $GUI_HIDE) GUICtrlSetState($sqrt, $GUI_HIDE) Case $sin $num1 = GUICtrlRead($input) _sine() Case $cos $num1 = GUICtrlRead($input) _cosine() Case $tan $num1 = GUICtrlRead($input) _tangent() Case $sqrt $num1 = GUICtrlRead($input) _sqrt() EndSwitch Until $msg = -3 Func _Oper($oper) ;=====> Function Created Switch $oper Case 0 _add($num1) Case 1 _subtract($num1) Case 2 _multiply($num1) Case 3 _divide($num1) EndSwitch EndFunc;==>_Oper Func _add($num1) $num2 = GUICtrlRead($input) $final = $num1 + $num2 GUICtrlSetData($input, $final) EndFunc;==>_add Func _subtract($num1) $num2 = GUICtrlRead($input) $final = $num1 - $num2 GUICtrlSetData($input, $final) EndFunc;==>_subtract Func _multiply($num1) $num2 = GUICtrlRead($input) $final = ($num1 * $num2) GUICtrlSetData($input, $final) EndFunc;==>_multiply Func _divide($num1) $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 i was testing some things for the buttons but i don't have solution for now. Edited September 3, 2008 by TalivanIBM Link to comment Share on other sites More sharing options...
LimeSeed Posted September 3, 2008 Author Share Posted September 3, 2008 (edited) Hi, i don't know why the numbers go slowly when are clicked, but i have a sugestion....... Case $advanced GUICtrlSetPos($input, 5, 5, 168, 20) ;===> Change this and you don't have to delete the control WinMove("Calc", "", Default, Default, 185, 220) GUICtrlSetState($sin, $GUI_SHOW) GUICtrlSetState($cos, $GUI_SHOW) GUICtrlSetState($tan, $GUI_SHOW) GUICtrlSetState($sqrt, $GUI_SHOW) Case $simple WinMove("Calc", "", Default, Default, 150, 220) GUICtrlSetPos($input, 5, 5, 135, 20) ;===> Change this and you don't have to delete the control GUICtrlSetState($sin, $GUI_HIDE) GUICtrlSetState($cos, $GUI_HIDE) GUICtrlSetState($tan, $GUI_HIDE) GUICtrlSetState($sqrt, $GUI_HIDE) i was studying your script, when you click the +, -, * and / twice you don't remembre the first number, alway i have to click =, then i have a little solution to this....... expandcollapse popup#NoTrayIcon #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) Local $num1 ;=====> Change $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, 0, 1) ;=====> Change $simple = GUICtrlCreateMenuItem("Simple", $edit, 1, 1) ;=====> Change GUICtrlSetState(-1, $GUI_CHECKED) ;=====> Change GUICtrlSetDefBkColor(0x5a6a50, $calc) ;=====> Change ;order of creation very important $0 must be first then thorough to $9 with nothing else in between $0 = GUICtrlCreateButton("0", 40, 135, 30, 30) $1 = GUICtrlCreateButton("1", 5, 100, 30, 30) $2 = GUICtrlCreateButton("2", 40, 100, 30, 30) $3 = GUICtrlCreateButton("3", 75, 100, 30, 30) $4 = GUICtrlCreateButton("4", 5, 65, 30, 30) $5 = GUICtrlCreateButton("5", 40, 65, 30, 30) $6 = GUICtrlCreateButton("6", 75, 65, 30, 30) $7 = GUICtrlCreateButton("7", 5, 30, 30, 30) $8 = GUICtrlCreateButton("8", 40, 30, 30, 30) $9 = GUICtrlCreateButton("9", 75, 30, 30, 30) $input = GUICtrlCreateInput("", 5, 5, 135, 20, $ES_READONLY) $equals = GUICtrlCreateButton("=", 5, 135, 30, 30, $BS_FLAT) $clear = GUICtrlCreateButton("C", 75, 135, 30, 30, $BS_FLAT) ;these 4 must be grouped together wehn created $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) ;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) GUICtrlSetState($sin, $GUI_HIDE) GUICtrlSetState($cos, $GUI_HIDE) GUICtrlSetState($tan, $GUI_HIDE) GUICtrlSetState($sqrt, $GUI_HIDE) GUISetBkColor(0x494e48) GUISetState(@SW_SHOW) $inputstage = 1;waiting for number to be entered, when sign pressed we are at stage two until next digit is entered Do $msg = GUIGetMsg() Switch $msg Case $0 To $9 If $inputstage = 2 Then If $operation >= 0 Then $num1 = GUICtrlRead($input);=====> Change GUICtrlSetData($input, "") $inputstage = 1 EndIf $pnum = GUICtrlRead($input) GUICtrlSetData($input, $pnum & Chr($msg - $0 + 0x30)) Case $copy $pnum = GUICtrlRead($input) ClipPut($pnum) Case $paste $data = ClipGet() GUICtrlSetData($input, $data) Case $divide To $minus $inputstage = 2 $oper = $operation ;=====> Change Switch $msg Case $plus _Oper($oper) ;=====> Change $operation = 0 Case $minus _Oper($oper) ;=====> Change $operation = 1 Case $multiply _Oper($oper) ;=====> Change $operation = 2 Case $divide _Oper($oper) ;=====> Change $operation = 3 EndSwitch $oper = -1 ;=====> Change Case $clear $inputstage = 1 $num1 = 0 $num2 = 0 GUICtrlSetData($input, "") Case $equals If $operation = 0 Then _add($num1) ElseIf $operation = 1 Then _subtract($num1) ElseIf $operation = 2 Then _multiply($num1) ElseIf $operation = 3 Then _divide($num1) Else MsgBox(0, "Error", "No Operation Was Selected", 5) EndIf $operation = -1 $inputstage = 2 Case $exit ExitLoop Case $about MsgBox(0, "Calc", "This calculator was created by Isaac Flaum using Autoit as an efficent, good looking calculator", 10) Case $advanced GUICtrlSetPos($input, 5, 5, 168, 20) ;=====> Change WinMove("Calc", "", Default, Default, 185, 220) GUICtrlSetState($sin, $GUI_SHOW) GUICtrlSetState($cos, $GUI_SHOW) GUICtrlSetState($tan, $GUI_SHOW) GUICtrlSetState($sqrt, $GUI_SHOW) Case $simple WinMove("Calc", "", Default, Default, 150, 220) GUICtrlSetPos($input, 5, 5, 135, 20) ;=====> Change GUICtrlSetState($sin, $GUI_HIDE) GUICtrlSetState($cos, $GUI_HIDE) GUICtrlSetState($tan, $GUI_HIDE) GUICtrlSetState($sqrt, $GUI_HIDE) Case $sin $num1 = GUICtrlRead($input) _sine() Case $cos $num1 = GUICtrlRead($input) _cosine() Case $tan $num1 = GUICtrlRead($input) _tangent() Case $sqrt $num1 = GUICtrlRead($input) _sqrt() EndSwitch Until $msg = -3 Func _Oper($oper) ;=====> Function Created Switch $oper Case 0 _add($num1) Case 1 _subtract($num1) Case 2 _multiply($num1) Case 3 _divide($num1) EndSwitch EndFunc;==>_Oper Func _add($num1) $num2 = GUICtrlRead($input) $final = $num1 + $num2 GUICtrlSetData($input, $final) EndFunc;==>_add Func _subtract($num1) $num2 = GUICtrlRead($input) $final = $num1 - $num2 GUICtrlSetData($input, $final) EndFunc;==>_subtract Func _multiply($num1) $num2 = GUICtrlRead($input) $final = ($num1 * $num2) GUICtrlSetData($input, $final) EndFunc;==>_multiply Func _divide($num1) $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 i was testing some things for the buttons but i don't have solution for now. nice job! i was too lazy to do this! NVM i fixed thsi, just forgot to post it, ill post it! AHH u messed it up, now its all wierd, i have 625 in the box and clicked divide, and it went to like 13595 which is weird!! Edited September 3, 2008 by LimeSeed global $warming = true Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now