Jump to content
Jayden

Operations (Calculating)

Recommended Posts

Jayden

Dear people! I want to make a script that for calculating Ohm's law.

I want to do something like divide but i dont know how to do it this is my script so far.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         Jaygrammer

 Script Function:
    Ohm's law Calculator

#ce ----------------------------------------------------------------------------

; Script Start

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 483, 230, -1, -1)
$v1 = GUICtrlCreateInput("Input1", 40, 64, 129, 21)
$c2 = GUICtrlCreateInput("Input2", 40, 112, 129, 21)
$v3 = GUICtrlCreateInput("Input3", 40, 160, 129, 21)
$Label1 = GUICtrlCreateLabel("Current", 40, 88, 124, 17)
$Label2 = GUICtrlCreateLabel("Voltage", 40, 136, 124, 17)
$Label3 = GUICtrlCreateLabel("Voltage", 40, 48, 124, 17)
$r1 = GUICtrlCreateInput("Input4", 200, 64, 129, 21)
$r2 = GUICtrlCreateInput("Input5", 200, 112, 129, 21)
$c3 = GUICtrlCreateInput("Input6", 200, 160, 129, 21)
$Label4 = GUICtrlCreateLabel("Current", 200, 136, 124, 17)
$Label5 = GUICtrlCreateLabel("Resistance", 200, 88, 124, 17)
$Label6 = GUICtrlCreateLabel("Resistance", 200, 48, 132, 17)
$Label7 = GUICtrlCreateLabel("Label7", 24, 8, 260, 25)
$Input7 = GUICtrlCreateInput("Input7", 368, 64, 73, 21)
$Input8 = GUICtrlCreateInput("Current", 368, 112, 73, 21)
$Input9 = GUICtrlCreateInput("Input9", 368, 160, 73, 21)
$Label8 = GUICtrlCreateLabel("Label8", 368, 48, 68, 17)
$Label9 = GUICtrlCreateLabel("Voltage", 368, 96, 68, 17)
$Label10 = GUICtrlCreateLabel("Resistance", 368, 144, 66, 17)
$Label11 = GUICtrlCreateLabel("=", 336, 160, 26, 17)
$Label12 = GUICtrlCreateLabel("=", 336, 112, 26, 17)
$Label13 = GUICtrlCreateLabel("=", 336, 64, 26, 17)
$Button1 = GUICtrlCreateButton("Calculate", 56, 192, 97, 25)
$Button2 = GUICtrlCreateButton("Cancel", 176, 192, 97, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button2
            Exit
        Case $calc ()

    EndSwitch
WEnd


func $calc ()
$inp1 = GUICtrlRead ($v1)
$inp2 = GUICtrlRead ($r1)
$inp3 = GUICtrlRead ($c2)
$inp4 = GUICtrlRead ($r2)
$inp5 = GUICtrlRead ($v3)
$inp6 = GUICtrlRead ($c3)

$inp ("/") $inp2

 

Thanks!

 

Share this post


Link to post
Share on other sites
rootx

You need read the help before start.... Anyway just to encourage you.... :D

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 483, 230, -1, -1)
$v1 = GUICtrlCreateInput("", 40, 64, 129, 21)
$c2 = GUICtrlCreateInput("Input2", 40, 112, 129, 21)
$v3 = GUICtrlCreateInput("Input3", 40, 160, 129, 21)
$Label1 = GUICtrlCreateLabel("Current", 40, 88, 124, 17)
$Label2 = GUICtrlCreateLabel("Voltage", 40, 136, 124, 17)
$Label3 = GUICtrlCreateLabel("Voltage", 40, 48, 124, 17)
$r1 = GUICtrlCreateInput("", 200, 64, 129, 21)
$r2 = GUICtrlCreateInput("Input5", 200, 112, 129, 21)
$c3 = GUICtrlCreateInput("Input6", 200, 160, 129, 21)
$Label4 = GUICtrlCreateLabel("Current", 200, 136, 124, 17)
$Label5 = GUICtrlCreateLabel("Resistance", 200, 88, 124, 17)
$Label6 = GUICtrlCreateLabel("Resistance", 200, 48, 132, 17)
$Label7 = GUICtrlCreateLabel("Label7", 24, 8, 260, 25)
$Input7 = GUICtrlCreateInput("", 368, 64, 73, 21)
$Input8 = GUICtrlCreateInput("Current", 368, 112, 73, 21)
$Input9 = GUICtrlCreateInput("Input9", 368, 160, 73, 21)
$Label8 = GUICtrlCreateLabel("Label8", 368, 48, 68, 17)
$Label9 = GUICtrlCreateLabel("Voltage", 368, 96, 68, 17)
$Label10 = GUICtrlCreateLabel("Resistance", 368, 144, 66, 17)
$Label11 = GUICtrlCreateLabel("=", 336, 160, 26, 17)
$Label12 = GUICtrlCreateLabel("=", 336, 112, 26, 17)
$Label13 = GUICtrlCreateLabel("=", 336, 64, 26, 17)
$Button1 = GUICtrlCreateButton("Calculate", 56, 192, 97, 25)
$Button2 = GUICtrlCreateButton("Cancel", 176, 192, 97, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button2
            Exit
        Case $Button1
            calc ()

    EndSwitch
WEnd


func calc ()
$inp1 = GUICtrlRead ($v1)
$inp2 = GUICtrlRead ($r1)
$inp3 = GUICtrlRead ($c2)
$inp4 = GUICtrlRead ($r2)
$inp5 = GUICtrlRead ($v3)
$inp6 = GUICtrlRead ($c3)

$result = $inp1 / $inp2
GUICtrlSetData($Input7,$result)

EndFunc

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×