deevee Posted June 23, 2008 Share Posted June 23, 2008 I need some help on some code I am working. I can not get it work can I get help? It's mostly cut and copied from other code. CODE#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Ohm's Law", 731, 332, 241, 229) $Button1 = GUICtrlCreateButton(" V = A * R ", 41, 118, 149, 39, 0) $Button2 = GUICtrlCreateButton(" A = V / R ", 211, 120, 149, 39, 0) $Button3 = GUICtrlCreateButton(" R = V / A ", 379, 120, 149, 39, 0) $Button4 = GUICtrlCreateButton(" P = V * A ", 549, 120, 149, 39, 0) $Button5 = GUICtrlCreateButton(" V = A * R ", 43, 172, 149, 39, 0) $Button6 = GUICtrlCreateButton(" A = V / R ", 213, 174, 149, 39, 0) $Button7 = GUICtrlCreateButton(" R = V / A ", 381, 174, 149, 39, 0) $Button8 = GUICtrlCreateButton(" P = V * A ", 551, 174, 149, 39, 0) $Input1 = GUICtrlCreateInput(" ", 33, 270, 87, 21) ; first number in $sign = GUICtrlCreateLabel("", 135, 270, 58, 24) ; changes * , / $Label12 = GUICtrlCreateLabel(" ", 317, 244, 99, 25) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input2 = GUICtrlCreateInput(" ", 195, 270, 99, 21) ; next number in $Label2 = GUICtrlCreateLabel("= ", 295, 270, 14, 19) ; = GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $output = GUICtrlCreateLabel(" ", 317, 270,99, 25) ;output output output output GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Label4 = GUICtrlCreateLabel("", 35, 244, 99, 25) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Label5 = GUICtrlCreateLabel("", 195, 242, 99, 25) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Button9 = GUICtrlCreateButton("Exit", 459, 248, 155, 49, 0) $Label6 = GUICtrlCreateLabel("Following are the formulas for computing voltage, current, resistance and power.", 51, 20, 473, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label7 = GUICtrlCreateLabel("Traditionally, E is used for voltage (energy), but V is often substituted.", 51, 38, 409, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label8 = GUICtrlCreateLabel(" V = voltage the volume of E", 55, 70, 155, 17) $Label9 = GUICtrlCreateLabel(" A = amps is current the push I", 237, 70, 167, 17) $Label10 = GUICtrlCreateLabel(" R = resistance in ohms", 57, 92, 111, 17) $Label11 = GUICtrlCreateLabel(" P = power in watts Makes Heat", 239, 92, 160, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $msg = GUIGetMsg() Select Case $msg = $button1 $Num = Number($Input1 * $Input2) GUICtrlSetData($Num,$output) GUICtrlSetData($Label4, "Amps") GUICtrlSetData($sign, "X") GUICtrlSetData($Label5, "Resistance") GUICtrlSetData($Label12, "Voltage") Case $msg = $button2 $results = ($Input1 * $Input2) GUICtrlSetData( $results, $output) GUICtrlSetData($Label4, "Voltage") GUICtrlSetData($sign, "/") GUICtrlSetData($Label5, "Resistance") GUICtrlSetData($Label12, "Amps") Case $msg = $button3 $results = ($Input1 * $Input2) GUICtrlSetData( $results,"") GUICtrlSetData($Label4, "Voltage") GUICtrlSetData($sign, "/") GUICtrlSetData($Label5, "Amps") GUICtrlSetData($Label12, "Resistance") Case $msg = $button4 $results = ($Input1 * $Input2) GUICtrlSetData( $results,"") GUICtrlSetData($Label4, "Voltage") GUICtrlSetData($sign, "X") GUICtrlSetData($Label5, "Amps") GUICtrlSetData($Label12, "Power/Watts") Case $msg = $button5 $results = ($Input1 * $Input2) GUICtrlSetData( $results,"") GUICtrlSetData($Label4, "Amps") GUICtrlSetData($sign, "X") GUICtrlSetData($Label5, "Resistance") GUICtrlSetData($Label12, "Voltage") Case $msg = $button6 $results = ($Input1 * $Input2) GUICtrlSetData( $results,"") GUICtrlSetData($Label4, "Voltage") GUICtrlSetData($sign, "/") GUICtrlSetData($Label5, "Resistance") GUICtrlSetData($Label12, "Amps") Case $msg = $button7 $results = ($Input1 * $Input2) GUICtrlSetData($results,"") GUICtrlSetData($Label4, "Voltage") GUICtrlSetData($sign, "/") GUICtrlSetData($Label5, "Amps") GUICtrlSetData($Label12, "Resistance") Case $msg = $button8 $results = ($Input1 * $Input2) GUICtrlSetData( $results,"") GUICtrlSetData($Label4, "Voltage") GUICtrlSetData($sign, "/") GUICtrlSetData($Label5, "Amps") GUICtrlSetData($Label12, "Power/Watts") ;Case $msg = $button9 ;$results = Random(1,100, 1) ; GUICtrlSetData($output, $results) ;GUICtrlSetData($die, "100 Sided Die") EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Link to comment Share on other sites More sharing options...
SadBunny Posted June 23, 2008 Share Posted June 23, 2008 Please explain what goes wrong at what point. If possible write a reproducer (= shortest possible piece of code that demonstrates your problem!). Also indicate what you have thought of and/or tried yourself in order to solve the problem. In short: help us help you! Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Kiti Posted June 23, 2008 Share Posted June 23, 2008 (edited) Please explain what goes wrong at what point. If possible write a reproducer (= shortest possible piece of code that demonstrates your problem!). Also indicate what you have thought of and/or tried yourself in order to solve the problem.In short: help us help you!Maybe he wants to make that last commented case work, and I think he doesn't know how to get the numbers from the imputs (and eventually make the calculations). He said he just copied another GUI with simple buttons, and he expanded that code, but there weren't any imputs involved there. Am I right?Look through SciTe Help to see the commands you need to know.Edit: But rename the exit button with a result button, because it confuses us, thus we don't know what your script want to do Edited June 23, 2008 by Kiti Think outside the box.My Cool Lego Technic Website -- see walking bipeds and much more!My YouTube account -- see cool physics experimentsMy scripts:Minesweeper bot: Solves advanced level in 1 second (no registry edit), very improved GUI, 4 solving stylesCan't go to the toilet because of your kids closing your unsaved important work? - Make a specific window uncloseableCock Shooter Bot -- 30 headshots out of 30 Link to comment Share on other sites More sharing options...
Kiti Posted June 23, 2008 Share Posted June 23, 2008 (edited) Take this example and expand it. #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) $Form1 = GUICreate("Form1", 355, 134, 312, 174) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") $Input1 = GUICtrlCreateInput("Input1", 24, 40, 121, 21) $Input2 = GUICtrlCreateInput("Input2", 184, 40, 121, 21) $Label1 = GUICtrlCreateLabel("X", 160, 40, 11, 17) $Button1 = GUICtrlCreateButton("Calculate !", 128, 80, 75, 25, 0) GUICtrlSetOnEvent($Button1, "Button1Click") GUISetState(@SW_SHOW) Msgbox(64, "","Write two numbers in the folowing inputs and press Calculate!") While 1 Sleep(100) WEnd Func Button1Click() $result = Guictrlread($input1)*Guictrlread($input2) Msgbox(64,"", $result) EndFunc Func Form1Close() Exit 0 EndFunc Edit: I think it's better to use OnEventMode rather than select cases... I think it's more easy and versatile. Try it! Edited June 23, 2008 by Kiti Think outside the box.My Cool Lego Technic Website -- see walking bipeds and much more!My YouTube account -- see cool physics experimentsMy scripts:Minesweeper bot: Solves advanced level in 1 second (no registry edit), very improved GUI, 4 solving stylesCan't go to the toilet because of your kids closing your unsaved important work? - Make a specific window uncloseableCock Shooter Bot -- 30 headshots out of 30 Link to comment Share on other sites More sharing options...
Malkey Posted June 23, 2008 Share Posted June 23, 2008 I need some help on some code I am working. I can not get it work can I get help? It's mostly cut and copied from other code.Seeing you are so good at cut and copy, you should be able to cut out the duplicate buttons if you wish. Try the following script. expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Ohm's Law", 731, 332, 241, 229) $Button1 = GUICtrlCreateButton(" V = A * R ", 41, 118, 149, 39, 0) $Button2 = GUICtrlCreateButton(" A = V / R ", 211, 120, 149, 39, 0) $Button3 = GUICtrlCreateButton(" R = V / A ", 379, 120, 149, 39, 0) $Button4 = GUICtrlCreateButton(" P = V * A ", 549, 120, 149, 39, 0) $Button5 = GUICtrlCreateButton(" V = A * R ", 43, 172, 149, 39, 0) $Button6 = GUICtrlCreateButton(" A = V / R ", 213, 174, 149, 39, 0) $Button7 = GUICtrlCreateButton(" R = V / A ", 381, 174, 149, 39, 0) $Button8 = GUICtrlCreateButton(" P = V * A ", 551, 174, 149, 39, 0) $Input1 = GUICtrlCreateInput(" ", 33, 270, 87, 21) ; first number in $sign = GUICtrlCreateLabel("", 135, 270, 58, 24) ; changes * , / $Label12 = GUICtrlCreateLabel(" ", 317, 244, 99, 25) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input2 = GUICtrlCreateInput(" ", 195, 270, 99, 21) ; next number in $Label2 = GUICtrlCreateLabel("= ", 295, 270, 14, 19) ; = GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $output = GUICtrlCreateLabel(" ", 317, 270, 99, 25) ;output output output output GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Label4 = GUICtrlCreateLabel("", 35, 244, 99, 25) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Label5 = GUICtrlCreateLabel("", 195, 242, 99, 25) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Button9 = GUICtrlCreateButton("Exit", 459, 248, 155, 49, 0) $Label6 = GUICtrlCreateLabel("Following are the formulas for computing voltage, current, resistance and power.", 51, 20, 473, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label7 = GUICtrlCreateLabel("Traditionally, E is used for voltage (energy), but V is often substituted.", 51, 38, 409, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label8 = GUICtrlCreateLabel(" V = voltage the volume of E", 55, 70, 155, 17) $Label9 = GUICtrlCreateLabel(" A = amps is current the push I", 237, 70, 167, 17) $Label10 = GUICtrlCreateLabel(" R = resistance in ohms", 57, 92, 111, 17) $Label11 = GUICtrlCreateLabel(" P = power in watts Makes Heat", 239, 92, 160, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $msg = GUIGetMsg() Select Case $msg = $Button1 $Num = Number(GUICtrlRead($Input1) * GUICtrlRead($Input2)) GUICtrlSetData($output, $Num) GUICtrlSetData($Label4, "Amps") GUICtrlSetData($sign, "X") GUICtrlSetData($Label5, "Resistance") GUICtrlSetData($Label12, "Voltage") Case $msg = $Button2 $results = Round((GUICtrlRead($Input1) / GUICtrlRead($Input2)), 8) GUICtrlSetData($output, $results) GUICtrlSetData($Label4, "Voltage") GUICtrlSetData($sign, "/") GUICtrlSetData($Label5, "Resistance") GUICtrlSetData($Label12, "Amps") Case $msg = $Button3 $results = Round((GUICtrlRead($Input1) / GUICtrlRead($Input2)), 8) GUICtrlSetData($output, $results) GUICtrlSetData($Label4, "Voltage") GUICtrlSetData($sign, "/") GUICtrlSetData($Label5, "Amps") GUICtrlSetData($Label12, "Resistance") Case $msg = $Button4 $results = (GUICtrlRead($Input1) * GUICtrlRead($Input2)) GUICtrlSetData($output, $results) GUICtrlSetData($Label4, "Voltage") GUICtrlSetData($sign, "X") GUICtrlSetData($Label5, "Amps") GUICtrlSetData($Label12, "Power/Watts") Case $msg = $Button5 $results = (GUICtrlRead($Input1) * GUICtrlRead($Input2)) GUICtrlSetData($output, $results) GUICtrlSetData($Label4, "Amps") GUICtrlSetData($sign, "X") GUICtrlSetData($Label5, "Resistance") GUICtrlSetData($Label12, "Voltage") Case $msg = $Button6 $results = Round((GUICtrlRead($Input1) / GUICtrlRead($Input2)), 8) GUICtrlSetData($output, $results) GUICtrlSetData($Label4, "Voltage") GUICtrlSetData($sign, "/") GUICtrlSetData($Label5, "Resistance") GUICtrlSetData($Label12, "Amps") Case $msg = $Button7 $results = (GUICtrlRead($Input1) / GUICtrlRead($Input2)) GUICtrlSetData($output, $results) GUICtrlSetData($Label4, "Voltage") GUICtrlSetData($sign, "/") GUICtrlSetData($Label5, "Amps") GUICtrlSetData($Label12, "Resistance") Case $msg = $Button8 $results = (GUICtrlRead($Input1) * GUICtrlRead($Input2)) GUICtrlSetData($output, $results) GUICtrlSetData($Label4, "Voltage") GUICtrlSetData($sign, "X") GUICtrlSetData($Label5, "Amps") GUICtrlSetData($Label12, "Power/Watts") Case $msg = $Button9 Exit EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Good luck! 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