# Alcohol mixing calculator

## Recommended Posts

This is a script I made to enable me to be able to combine either something non-alcoholic with something alcoholic and know how much to add (easy on a calculator) but then also to be able to deal with two alcoholic drinks and know how much of the second one will be needed to get to a desired strength (much much harder to figure out). It runs through by adding the second alcoholic liquid in increments of 0.5 ml until it meets exactly or the first number that exceeds the desired strength. It simplifies the whole process since it just tries all the combinations rather that doing complicated math to equate one thing to another and try and work it that way. it is very easy to use.

Supply it with the original liquid, whether its wine or lemonade etc, then the strength of that liquid in % or 0 for non-alcoholic drink. Then set the percentage of the alcoholic liquid you will be using to add to the first liquid and what strength you would like your drink to be. Hit the button and you get your answer.

```AutoItSetOption('TrayAutoPause', 0)
Global \$OrigQty, \$OrigStr, \$AddStr, \$DesiredStr, \$Result
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
\$Form1 = GUICreate("Alcohol Calculator", 288, 188, -1, -1)
\$OrigQty = GUICtrlCreateInput("150", 16, 16, 121, 21, \$ES_CENTER)
\$OrigStr = GUICtrlCreateInput("12.5", 152, 16, 121, 21, \$ES_CENTER)
\$AddStr = GUICtrlCreateInput("40", 16, 72, 121, 21, \$ES_CENTER)
\$Label1 = GUICtrlCreateLabel("Amount of original liquid", 16, 40, 115, 17)
\$Label2 = GUICtrlCreateLabel("Strength of original liquid", 152, 40, 119, 17)
\$Label3 = GUICtrlCreateLabel("Strength of alcohol to use", 16, 96, 128, 17)
\$DesiredStr = GUICtrlCreateInput("20", 152, 72, 121, 21, \$ES_CENTER)
\$Label4 = GUICtrlCreateLabel("Desired alcohol strength", 152, 96, 118, 17)
\$calculate = GUICtrlCreateButton("Calculate", 104, 120, 83, 25)
\$Result = GUICtrlCreateInput("", 5, 152, 277, 21, \$ES_CENTER)
GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

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

EndSwitch
WEnd

; #FUNCTION# ====================================================================================================================
; Name ..........: Desired alcoholic strength calculator
; Description ...: This example code lets you calculate how much of an alcoholic drink to add to something else to make the resulting drink a certain strength.
; Syntax ........: Strength(\$MillilitersOfOriginalDrink, \$StrengthOfOriginalDrink, \$StrengthOfAddedLiquid, \$DesiredStrength)
; Parameters ....: \$MillilitersOfOriginalDrink- How much of a certain drink you start out with (either alcoholic or otherwise).
; \$StrengthOfOriginalDrink- If the original drink is alcoholic then put the percentage here else put 0.
; \$StrengthOfAddedLiquid- What strength of alcohol do you have to work with?.
; \$DesiredStrength - How strong do you want your resulting drink to be?.
; Return values .: Text string with the needed information.
; Author ........: Wesley G aka Morthawt
; ===============================================================================================================================
If \$DesiredStrength > \$StrengthOfAddedLiquid And \$StrengthOfOriginalDrink > 0 Then
MsgBox(0, 'Error', 'Your desired strength exceeds the strength of the liquid used to provide extra alcohol content.')
Exit
ElseIf \$DesiredStrength <= \$StrengthOfOriginalDrink And \$StrengthOfOriginalDrink <> 0 Then
MsgBox(0, 'Error', 'Your desired strength is lower than is even possible with the chosen liquids.' & @CRLF & @CRLF & 'Pick a higher desired strength.')
Exit
EndIf

Local \$Amount = 0, \$AlcoholContent = 0
\$ConstAlc = \$MillilitersOfOriginalDrink * (\$StrengthOfOriginalDrink / 100)
Do
\$Amount += 0.5 ; This is the increment of milliliters we will go up each time to try and reach the desired amount of strength.
\$AlcoholContent = Round((((\$ConstAlc + (\$Amount * \$StrengthOfAddedLiquid)) / (\$MillilitersOfOriginalDrink + \$Amount)) * 100), 2)

Until \$AlcoholContent >= \$DesiredStrength
GUICtrlSetData(\$Result, 'Add ' & \$Amount & 'ml of alcoholic liquid to get to ' & \$AlcoholContent & '%')
Return 1
EndFunc ;==>Strength```

##### Share on other sites

I was in the process of designing an automatic (ie arduino) mixing machine. Then I realized I probably would never sell it and become a raging alcoholic...

##### Share on other sites

Nice. Now we just need to make it interface with a robotic arm to mix drinks for us!

The truth has been suppressed since the dawn of time.

##### Share on other sites

I was in the process of designing an automatic (ie arduino) mixing machine. Then I realized I probably would never sell it and become a raging alcoholic...

What better way to become a raging alcoholic than knowing exactly how messed up you are going to get off your next drink lmao

Nice. Now we just need to make it interface with a robotic arm to mix drinks for us!

If only...

## Create an account

Register a new account

• ### Similar Content

After much searching I finally found a method to get eMails from an Exchange eMail account inbox.  I was hoping for AutoIT or vbscript but I couldn't find any that would read the inbox messages without using Outlook.
I needed this because I'm testing a web-form that generates an eMail sent to a shared mailbox "not what my current outlook is configured for".  so, I needed to connect to a different account, then get the inbox messages, and see if the auto-generated eMail message body contains what I submitted in the form.

I found a PowerShell script that was close and modified it to do just what I want, but I'd still like it to run in AutoIT but I'm not sure how to use the Microsoft.Exchange.WebServices.dll
Anybody have some ideas?
Thanks,
Mike
• By theak
Trying to find a quick way to convert 30k+ WordPerfect files into Word.
Will probably run it locally from an admin machine or server so user permissions won't affect it.
My idea was just to open the file, select all, copy, open new word doc, paste, file, save....
What would be the best way to go about scripting something in this way?
• By CarlD
This code is a subset of an AutoIt tool I wrote for the classic DOS word-processor XyWrite. The tool allows 7-bit Ascii encoding of XyWrite Programming Language programs, with "readability aids" that mimic the way this code looks natively on the DOS screen. This is a special 7-bit encoding that we've used for many years in the XyWrite community to discuss XPL code on the XyWrite Mailing List. But that's neither here nor there.
The present subset consists of three utilities, which I offer here for what they're worth. The first, DVIEW.AU3, takes a binary file and displays it in the default Windows text editor, displaying only Ascii chars 32-127, the other chars being represented by ".". The command-line usage is:
DVIEW.AU3 <file_in><Enter>
The second, DREAD.AU3 (that's "Dee-Read", not "dread" ), provides a similar display, except that characters outside the Ascii 32-127 range are represented by "{nnn}", where "nnn" is the 3-digit decimal Ascii number. (The initial "D" in these utilities' names stands for "decimal".) The output from DREAD.AU3 can be edited to make simple patches to binary files. The output file is named DREAD.TXT. The usage is:
The third utility, DWRITE.AU3, takes DREAD output and writes it back to disk as a binary file. So, once you edit the output from DREAD, you write it to disk with:
DWRITE.AU3 <file_in><Enter>
The default file_in is DREAD.TXT -- i.e., the output of DREAD.AU3. The output file is named DWRITE.BIN, which can be renamed as desired.
You'll see that each of these scripts processes the input file character by character. If there's a faster way of doing this, for example by manipulating bit patterns, I'd be pleased to hear about it.
Here are the three scripts. Enjoy.
• By cyanidemonkey
This is a small app I wrote awhile back to batch FFMPEG commands of videos. I have a camcorder that saves to a file type .mts and I wanted to convert them to .mp4 but was too lazy to write out the commands one at a time in the CMD window.

NOTES:
You will need to download ffmpeg, as it is the application doing the actual conversions (http://ffmpeg.org/). It can only do one directory at a time, it will not do recursive directories. The defaults are set up to convert .mts files to .mp4, if you want to change the input, output and command line options you can, however, you may need to read the documentation at the ffmpeg website. If you want to change the input file type, do this before opening the input browse button. The software will steal focus to communicate with the command line interface, It is best to set up a conversion job and leave the computer alone until it is done (hence the option to shutdown after converting files). If you try to use the computer while it is running chances are it will fail to convert one or more videos. Video processing can be PCU intensive, this application was designed to be set and forget. If you don't want to scale down to 720p remove " -s 1280x720 " from command line, remove " -r 30 " if you don't want the frame rate set to 30fps, if you do not require deinterlacing remove " - vf yadif=1 " from the command line options. You can choose to delete the original video files after they are converted to save disc space, but it pays to test one file first to make sure they convert correctly before batch deleting the original files (they are sent to the recycle bin, so you can restore them until you empty the recycle bin).
AutoIt Code:
×

• Wiki

• Back

• Git