Jump to content



Photo

Unit Converter


  • Please log in to reply
13 replies to this topic

#1 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 11 February 2007 - 11:11 PM

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
Attached File  Unit_Converter.au3   9.92K   660 downloads
Previous Downloads: 195

Edited by RazerM, 07 July 2007 - 07:06 PM.

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.





#2 WeMartiansAreFriendly

WeMartiansAreFriendly

    Where's the kaboom?

  • Active Members
  • PipPipPipPipPipPip
  • 1,245 posts

Posted 11 February 2007 - 11:33 PM

nice job!, i was going to make the same thing a while ago..
Posted ImageDon't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

#3 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 11 February 2007 - 11:58 PM

Nice.

Some suggestions:
1) In GUICtrlCreateCombo use Height=200 for WIN98 compatibility
2) Make new button also for Convert from right to left

#4 Valuater

Valuater

    www.PayFreeWireless.com

  • MVPs
  • 11,078 posts

Posted 12 February 2007 - 12:10 AM

nice, i noted you used Imperial

gallons, US = 3.8 Liters
gallons, Imp. = 4.56 Litres

A new one to me
Where are Imperial Gallons used???

is it
Liters or Litres ??????

again, nice job

8)

Posted Image

Clic The Pic!!!


#5 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 12 February 2007 - 12:11 AM

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.

#6 The Kandie Man

The Kandie Man

    All Your Base Are Belong To Us

  • Active Members
  • PipPipPipPipPipPip
  • 950 posts

Posted 16 February 2007 - 10:54 AM

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.
Attached File  Unit_Converter_TKM.au3   9.53K   283 downloads
"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

#7 Hello Me You

Hello Me You

    Prodigy

  • Active Members
  • PipPipPip
  • 152 posts

Posted 16 February 2007 - 12:00 PM

great job, thank you
Random

#8 Jango

Jango

    Polymath

  • Active Members
  • PipPipPipPip
  • 202 posts

Posted 16 February 2007 - 03:35 PM

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 ...

#9 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 17 February 2007 - 12:44 AM

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.

#10 Simucal

Simucal

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 777 posts

Posted 23 February 2007 - 02:09 AM

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, 23 February 2007 - 02:10 AM.

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)

#11 Valuater

Valuater

    www.PayFreeWireless.com

  • MVPs
  • 11,078 posts

Posted 24 February 2007 - 10:36 PM

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)


AutoIt         
#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, 04 July 2007 - 05:10 PM.

Posted Image

Clic The Pic!!!


#12 Dethredic

Dethredic

    http://gunnewiek.com/

  • Active Members
  • PipPipPipPipPipPip
  • 2,029 posts

Posted 01 June 2007 - 01:14 AM

Could you add currency conversions?
Posted Image"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

#13 smstroble

smstroble

    Prodigy

  • Active Members
  • PipPipPip
  • 191 posts

Posted 01 June 2007 - 02:10 AM

Nice script, you should also add pressure conversions.
MUHAHAHAHAHA

#14 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 01 June 2007 - 11:34 AM

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

Edit: Pressure conversion added.

Edited by RazerM, 01 June 2007 - 11:55 AM.

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users