Jump to content

Unit Converter


RazerM
 Share

Recommended Posts

This program can convert Length, Area, Volume, Weight, Temperature and pressure to different units.

Length:

Inches

Feet

Yards

Miles

Millimetres

Centimetres

Metres

Kilometres

Area:

Square Inches

Square Feet

Square Yards

Acres

Square Miles

Square Millimetres

Square Centimetres

Square Metres

Hectares

Square Kilometres

Volume:

Cubic Inches

Cubic Feet

Fluid Ounces

Pints

Gallons

US Fluid Ounces

US Pints

US Gallons

Cubic Centimetres

Cubic Decimetres

Cubic Metres

Litres

Hectolitres

Weight:

Ounces

Pounds

Stone

Milligrams

Grams

Kilograms

Temperature:

Celsius

Fahrenheit

Kelvin

Pressure:

Pound-force per square inch

Bar

Atmosphere

Technical Atmosphere

Pascal

Update 01:

  • Combo boxes have height set to 200 for older versions of Windows
  • Combo boxes are static (The Kandie Man)
  • input boxes can use operators (The Kandie Man)
  • Enter key can be used (The Kandie Man)
Update 02:
  • Pressure conversion added
Unit_Converter.au3

Previous Downloads: 195

Edited by RazerM
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

I'll add the combo height and maybe the other convert button. Thanks for the replies.

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

Argh, the Autoit Forum MySQL database went down. I posted a reply to this a day ago and the backups must be a couple days old so my reply wasn't restored with the backup. :whistle:

Anyway, I hope you don't mind RazerM, but I really liked this script and decided to make a few changes to it.

  • I added expression support so you could enter scientific notation values.
  • I added a default button so the user can simply press enter to have the value converted.
  • I made all the comboboxes' values static.
Unit_Converter_TKM.au3

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

Nice script

What about adding computer related unit converstion sych as bytes <-> kilobytes etc ... also bit <-> kilobit etc ... and vice et versa

Also, it's always a problem (at least for me) to compute transfert rate in mbits/s in mbytes/s ...

Link to comment
Share on other sites

I have added your changes TKM, thanks a lot.

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

This is a really well done and useful script. I like it a lot.

Edit: A set of general UDF's for conversion of weight, temp, etc would be a nice addition as well.. if anyone wanted to use them outside of this script.

Edited by Simucal
AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Link to comment
Share on other sites

Just thought I would give this cool script some color and a Bump!!

EzSkin and Converter.....

Posted Image

Posted Image

EzSkin.au3 and additional Skin Designs

Enjoy!!!

8)

#NoTrayIcon
#include <GUIConstants.au3>
;===============================================================================
;
; Program Name:        Unit Converter
; Description::        Converts Length, Area, Volume, Weight, and Temperature to different units
; Requirement(s):    None
; Author(s):        RazerM
;
;===============================================================================
;

Opt("GUIOnEventMode", 1)
;GUICreate("Imperial to Metric Converter", 440, 130)

#region ; Code generated by EzSkin_1-2-3, Created by Valuater
; For personal use only, All Rights Reserved
; Author of this code: Valuater
; Thank you big_daddy and Joscpe

#include <GUIConstants.au3>
#include <EzSkin.au3>

$EzGUI = EzSkinGUICreate ("Imperial to Metric Converter", 480, 190)
$EzIcon = EzSkinIcon ($EzGUI)
GUICtrlSetOnEvent($EzIcon[1], "Close")
GUICtrlSetOnEvent($EzIcon[2], "Mini")

#endregion

$tab = GUICtrlCreateTab(30, 40, 420, 110)
GUICtrlSetOnEvent(-1, "TabClicked")

GUICtrlCreateTabItem("Length")
GUICtrlCreateLabel("From:", 40, 65)
$LengthFrom = GUICtrlCreateInput("", 40, 80, 150)
GUICtrlCreateLabel("To:", 290, 65)
$LengthTo = GUICtrlCreateInput("", 290, 80, 150)
$LengthConvert = EzSkinButton ("Convert", 200, 80, 80, 25)
GUICtrlSetOnEvent($LengthConvert, "ConvertLength")
$LengthFromUnits = GUICtrlCreateCombo("", 40, 110, 150, 200, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "Inches|Feet|Yards|Miles|Millimetres|Centimetres|Metres|Kilometres", "Inches")
$LengthToUnits = GUICtrlCreateCombo("", 290, 110, 150, 200, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "Inches|Feet|Yards|Miles|Millimetres|Centimetres|Metres|Kilometres", "Millimetres")

GUICtrlCreateTabItem("Area")
GUICtrlCreateLabel("From:", 40, 65)
$AreaFrom = GUICtrlCreateInput("", 40, 80, 150)
GUICtrlCreateLabel("To:", 290, 65)
$AreaTo = GUICtrlCreateInput("", 290, 80, 150)
$AreaConvert = EzSkinButton ("Convert", 200, 80, 80, 25)
GUICtrlSetOnEvent($AreaConvert, "ConvertArea")
$AreaFromUnits = GUICtrlCreateCombo("", 40, 110, 150, 200, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "Square Inches|Square Feet|Square Yards|Acres|Square Miles|Square Millimetres|Square Centimetres|Square Metres|Hectares|Square Kilometres", "Square Inches")
$AreaToUnits = GUICtrlCreateCombo("", 290, 110, 150, 200, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "Square Inches|Square Feet|Square Yards|Acres|Square Miles|Square Millimetres|Square Centimetres|Square Metres|Hectares|Square Kilometres", "Square Millimetres")

GUICtrlCreateTabItem("Volume")
GUICtrlCreateLabel("From:", 40, 65)
$VolumeFrom = GUICtrlCreateInput("", 40, 80, 150)
GUICtrlCreateLabel("To:", 290, 65)
$VolumeTo = GUICtrlCreateInput("", 290, 80, 150)
$VolumeConvert = EzSkinButton ("Convert", 200, 80, 80, 25)
GUICtrlSetOnEvent($VolumeConvert, "ConvertVolume")
$VolumeFromUnits = GUICtrlCreateCombo("", 40, 110, 150, 200, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "Cubic Inches|Cubic Feet|Fluid Ounces|Pints|Gallons|US Fluid Ounces|US Pints|US Gallons|Cubic Centimetres|Cubic Decimetres|Cubic Metres|Litres|Hectolitres", "Cubic Inches")
$VolumeToUnits = GUICtrlCreateCombo("", 290, 110, 150, 200, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "Cubic Inches|Cubic Feet|Fluid Ounces|Pints|Gallons|US Fluid Ounces|US Pints|US Gallons|Cubic Centimetres|Cubic Decimetres|Cubic Metres|Litres|Hectolitres", "Cubic Centimetres")

GUICtrlCreateTabItem("Weight")
GUICtrlCreateLabel("From:", 40, 65)
$WeightFrom = GUICtrlCreateInput("", 40, 80, 150)
GUICtrlCreateLabel("To:", 290, 65)
$WeightTo = GUICtrlCreateInput("", 290, 80, 150)
$WeightConvert = EzSkinButton ("Convert", 200, 80, 80, 25)
GUICtrlSetOnEvent($WeightConvert, "ConvertWeight")
$WeightFromUnits = GUICtrlCreateCombo("", 40, 110, 150, 200, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "Ounces|Pounds|Stone|Milligrams|Grams|Kilograms", "Ounces")
$WeightToUnits = GUICtrlCreateCombo("", 290, 110, 150, 200, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "Ounces|Pounds|Stone|Milligrams|Grams|Kilograms", "Milligrams")

GUICtrlCreateTabItem("Temperature")
GUICtrlCreateLabel("From:", 40, 65)
$TempFrom = GUICtrlCreateInput("", 40, 80, 150)
GUICtrlCreateLabel("To:", 290, 65)
$TempTo = GUICtrlCreateInput("", 290, 80, 150)
$TempConvert = EzSkinButton ("Convert", 200, 80, 80, 25)
GUICtrlSetOnEvent($TempConvert, "ConvertTemp")
$TempFromUnits = GUICtrlCreateCombo("", 40, 110, 150, 200, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "Celsius|Fahrenheit|Kelvin", "Celsius")
$TempToUnits = GUICtrlCreateCombo("", 290, 110, 150, 200, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "Celsius|Fahrenheit|Kelvin", "Fahrenheit")

GUICtrlCreateTabItem(" EzSkin!!!  &&  Converter ")
$TempSkin = GUICtrlCreateLabel("> More EzSkin Designs are located here <", 60, 90, 375, 30)
GUICtrlSetColor(-1, 0xff)
GUICtrlSetFont(-1, 14, 500, 6)
GUICtrlSetOnEvent(-1, "Get_Skins")
GUICtrlCreateTabItem("")

GUICtrlSetState($LengthConvert, $GUI_DEFBUTTON)

GUISetState()
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")

GUICtrlSetState($tab, $GUI_ONTOP)

While 1
    EzSkinOver ($EzGUI)
    Sleep(20)
WEnd

Func ConvertTemp()
    $vFrom = Execute(GUICtrlRead($TempFrom))
    If Not IsNumber(Number($vFrom)) Then Return SetError(1, 0, 0)
    Local $avUnits[3][2] = [["Kelvin", ")*1"], ["Fahrenheit", "+459.67)*5/9"], ["Celsius", "+273.15)"]]
    Local $avToUnits[3][2] = [["Kelvin", ")*1"], ["Fahrenheit", "*9/5-459.67)"], ["Celsius", "-273.15)"]]
    For $iUnit = 0 To UBound($avUnits) - 1
        If GUICtrlRead($TempFromUnits) = $avUnits[$iUnit][0] Then
            $vFrom = Execute("(" & $vFrom & $avUnits[$iUnit][1])
        EndIf
    Next
    For $iUnit = 0 To UBound($avToUnits) - 1
        If GUICtrlRead($TempToUnits) = $avToUnits[$iUnit][0] Then
            $vTo = Execute("(" & $vFrom & $avToUnits[$iUnit][1])
        EndIf
    Next
    GUICtrlSetData($TempTo, $vTo)
EndFunc   ;==>ConvertTemp

Func ConvertWeight()
    $vFrom = Execute(GUICtrlRead($WeightFrom))
    If Not IsNumber(Number($vFrom)) Then Return SetError(1, 0, 0)
    Local $avUnits[6][2] = [["Ounces", 1], ["Pounds", 16], ["Stone", 224], ["Milligrams", 3.52739619 * 10 ^ - 5], ["Grams", 0.0352739619], ["Kilograms", 35.2739619]]
    For $iUnit = 0 To UBound($avUnits) - 1
        If GUICtrlRead($WeightFromUnits) = $avUnits[$iUnit][0] Then
            $vFrom *= $avUnits[$iUnit][1]
        EndIf
    Next
    For $iUnit = 0 To UBound($avUnits) - 1
        If GUICtrlRead($WeightToUnits) = $avUnits[$iUnit][0] Then
            $vTo = $vFrom / $avUnits[$iUnit][1]
        EndIf
    Next
    GUICtrlSetData($WeightTo, $vTo)
EndFunc   ;==>ConvertWeight

Func ConvertVolume()
    $vFrom = Execute(GUICtrlRead($VolumeFrom))
    If Not IsNumber(Number($vFrom)) Then Return SetError(1, 0, 0)
    Local $avUnits[13][2] = [["Cubic Inches", 1], ["Cubic Feet", 1728], ["Fluid Ounces", 1.73387217], ["Pints", 34.6774434], ["Gallons", 277.419547], ["US Fluid Ounces", 1.80468751 ], ["US Pints", 28.8750001], ["US Gallons", 231.000001], ["Cubic Centimetres", 0.0610237441], ["Cubic Decimetres", 61.0237441], ["Cubic Metres", 61023.7441], ["Litres", 61.0237441], ["Hectolitres", 6102.37441]]
    For $iUnit = 0 To UBound($avUnits) - 1
        If GUICtrlRead($VolumeFromUnits) = $avUnits[$iUnit][0] Then
            $vFrom *= $avUnits[$iUnit][1]
        EndIf
    Next
    For $iUnit = 0 To UBound($avUnits) - 1
        If GUICtrlRead($VolumeToUnits) = $avUnits[$iUnit][0] Then
            $vTo = $vFrom / $avUnits[$iUnit][1]
        EndIf
    Next
    GUICtrlSetData($VolumeTo, $vTo)
EndFunc   ;==>ConvertVolume

Func ConvertArea()
    $vFrom = Execute(GUICtrlRead($AreaFrom))
    If Not IsNumber(Number($vFrom)) Then Return SetError(1, 0, 0)
    Local $avUnits[10][2] = [["Square Inches", 1], ["Square Feet", 144], ["Square Yards", 1296], ["Acres", 6272640], ["Square Miles", 4014489600], ["Square Millimetres", 0.0015500031], ["Square Centimetres", 0.15500031], ["Square Metres", 1550.0031], ["Hectares", 15500031], ["Square Kilometres", 1.5500031 * 10 ^ 9]]
    For $iUnit = 0 To UBound($avUnits) - 1
        If GUICtrlRead($AreaFromUnits) = $avUnits[$iUnit][0] Then
            $vFrom *= $avUnits[$iUnit][1]
        EndIf
    Next
    For $iUnit = 0 To UBound($avUnits) - 1
        If GUICtrlRead($AreaToUnits) = $avUnits[$iUnit][0] Then
            $vTo = $vFrom / $avUnits[$iUnit][1]
        EndIf
    Next
    GUICtrlSetData($AreaTo, $vTo)
EndFunc   ;==>ConvertArea

Func ConvertLength()
    $vFrom = Execute(GUICtrlRead($LengthFrom))
    If Not IsNumber(Number($vFrom)) Then Return SetError(1, 0, 0)
    Local $avUnits[8][2] = [["Inches", 1], ["Feet", 12], ["Yards", 36], ["Miles", 63360], ["Millimetres", 0.0393700787], ["Centimetres", 0.393700787], ["Metres", 39.3700787], ["Kilometres", 39370.0787]]
    For $iUnit = 0 To UBound($avUnits) - 1
        If GUICtrlRead($LengthFromUnits) = $avUnits[$iUnit][0] Then
            $vFrom *= $avUnits[$iUnit][1]
        EndIf
    Next
    For $iUnit = 0 To UBound($avUnits) - 1
        If GUICtrlRead($LengthToUnits) = $avUnits[$iUnit][0] Then
            $vTo = $vFrom / $avUnits[$iUnit][1]
        EndIf
    Next
    GUICtrlSetData($LengthTo, $vTo)
EndFunc   ;==>ConvertLength

Func TabClicked()
    Switch GUICtrlRead($tab)
        Case 0 ;Length Tab is visible
            GUICtrlSetState($LengthConvert, $GUI_DEFBUTTON)
        Case 1 ;Area Tab is visible
            GUICtrlSetState($AreaConvert, $GUI_DEFBUTTON)
        Case 2 ;Volume Tab is visible
            GUICtrlSetState($VolumeConvert, $GUI_DEFBUTTON)
        Case 3 ;Weight Tab is visible
            GUICtrlSetState($WeightConvert, $GUI_DEFBUTTON)
        Case 4 ;Temperature Tab is visible
            GUICtrlSetState($TempConvert, $GUI_DEFBUTTON)
    EndSwitch
EndFunc   ;==>TabClicked

Func Get_Skins()
    ShellExecute("http://www.autoitscript.com/forum/index.php?showtopic=41319")
EndFunc   ;==>Get_Skins

Func Close()
    Exit
EndFunc   ;==>Close

Func Mini()
    GUISetState(@SW_MINIMIZE)
EndFunc   ;==>Mini

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

  • 3 months later...

Currency rates constantly change so that's a no. I'll add pressure conversions just now.

Edit: Pressure conversion added.

Edited by RazerM
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...