Jump to content

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
Strength(GUICtrlRead($OrigQty), GUICtrlRead($OrigStr), GUICtrlRead($AddStr), GUICtrlRead($DesiredStr))

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
; ===============================================================================================================================
Func Strength($MillilitersOfOriginalDrink, $StrengthOfOriginalDrink, $StrengthOfAddedLiquid, $DesiredStrength)
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)
$StrengthOfAddedLiquid = $StrengthOfAddedLiquid / 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
Link to post
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 :D

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

If only...

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Divane
      Hello everyone. I need to convert any string to 3-digit decimal. It is possible to convert through online tools. Is there any way to do this in AutoIt.

      For Example ;
      8cdb3 = DECIMAL 056 099 100 098 051

      Is it possible the conversion above by AutoIt? Thanks.
    • By obiwanceleri
      Good evening! 
      I know this has been done to death in many programming languages and probably even in AutoIt. 
      But couldn't help myself and as a learning challenge I wrote "yet another converter" LOL
      I need your help to test it and show me "the error of my ways" but in a nutshell here's what it can do already (taken from my source file) :
      Converts all zip files recursively into a 7Zip file, with max compression REQUIRES AUTOIT Version 3.3.14.5 + Exact copy with attributes and folder structure + Extensive error checking, including files blocked by anti-virus (by file count) + Can stop process and restart later with the use of a log file + Can pause process (but in between compressing / extracting files) + Creates a .CSV file that can be used to check on compression ratios + Dynamic GUI that enables user to see console while 7zip is working + Gui can be stretched horizontally for long filenames + Up to 5 retries while transfering compressed files + Checks free space (at startup) to make sure you don't kill your OS LOL + Have converted 10,000+ files with no issues in file integrity. + Open to suggestions and program free to modify to your liking + Will eventually be fully modular and configurable (if there is interest for this) + Exit codes so you can have an idea where program went wrong (if it did) + Fully commented so users can tinker away. - Cannot save archive comments. - Not FULLY tested yet, do not use on .zip files that have no backups The program also has a very minimal GUI that can be stretched. Not a huge fan of million-button interfaces.
      I also assume some people running this program will have a 1024x768 monitor so the GUI is made accordingly.
      There is no way I am keeping this script for myself. If this is useful to anybody, feel free to use it and modify it. All I ask is you credit me (as I will credit those who contribute).
      Now here's the issues that are left to fix. Any help is greatly appreciated and I will add your name in the credits if you so wish.
      - For some reason while compression is under way, all my current explorer windows flicker; notably the cut-and-paste part. I can't seem to narrow it down. 
      - Also context menu is closed in explorer every time program compresses / extracts a new file
      - I've added support for retries if, for some reason, AutoIt can't move the converted file. This happened once after 5000-6000 conversions. Now that I've programmed the retries, the process is somewhat slower. It shouldn't affect speed though.  
      - After compressing 10,000+ files (Yes I have that many zip files! Think Mame) I've had a system meltdown. There's a leak somewhere. Am I supposed to close something and I'm not? I've added _IsPressed() lately so closing that .DLL is not the cause of this leak. 
      - Subtracting one array from another was a tricky thing to program (happens when user stops and restarts process), if you can think of a faster way I'm all in.
      Obviously if you find bugs or have suggestions, I'm all ears. 
      Changelog is included in the source file, including credits.
      PLEASE DON'T CONVERT ALL YOUR FILES YET. It's not fully tested (well I tested it but I need others to test too).
       
      Obiwanceleri
      Zip27z_102.au3
    • By TheSaint
      Here is a simple program that some of you might appreciate.
      It is a more full fleshed out version of something I worked on a while back as a proof of concept.
      I will just quote the information found in the Program Information dialog.

      Older Screenshot
      INItoSQL DB.zip
      INItoSQL DB v1.1.zip  (see Post #3 for update details)
      INItoSQL DB v1.4.zip  (see Post #4 for update details)
      INItoSQL DB v1.6.zip  (see Post #7 for update details) BIG THANKS to ResNullius for huge speed improvement etc.
      Program requires the sqlite3.dll, not included, but easily enough obtained.
      I have also included the beginnings of a new UDF (SimpleSQL_UDF) I am working, which you can use with the included 'Check conversion.au3' file to check a resulting conversion ... just modify the values for a few variables to suit your situation.
      I've not yet gotten around to coding a testing/checking results script, so I recommend the following open source program, which I have been using for some time. It was here, but is now here at GitHub - DB Browser for SQLite
    • By BigDaddyO
      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? 
      #To Launch! # C:\Windows\System32> powershell -ExecutionPolicy ByPass #This launches PowerShell and allows execution of .ps1 files # PS C:\Windows\System32> . "C:\Temp\eMail\getInbox.ps1" #The period . in front of the .ps1 file forces PS to display results on-screen # Where is the EWS .DLL file that you are using # Get the installer from https://www.microsoft.com/en-us/download/details.aspx?id=42022 # We only need 2 dll's from the install and they can be stored anywhere: "Microsoft.Exchange.WebServices.Auth.dll" & "Microsoft.Exchange.WebServices.dll" $EWSdll = "C:\Temp\eMail\Microsoft.Exchange.WebServices.dll" # Where do you want the output text file to be saved $Output = "C:\Temp\eMails.txt" # replace with your email address $email = "MyemailAddress@work.net" # only need to populate these if you're impersonating... $username = "myemail" $password = "Sup3rS3cre+" $domain = "ad.work.net" # load the assembly : point to the dll in the location you have the .dll file [void] [Reflection.Assembly]::LoadFile($EWSdll) # set ref to exchange, first references 2007, 2nd is 2010 (default) #$s = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2007_SP1) $s = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService # use first option if you want to impersonate, otherwise, grab your own credentials with the 3rd one. not sure what the 2nd one is for $s.Credentials = New-Object Net.NetworkCredential($username, $password, $domain) ##$s.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials #$s.UseDefaultCredentials = $true # discover the url from your email address $s.AutodiscoverUrl($email) # get a handle to the inbox $inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($s,[Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox) #create a property set (to let us access the body & other details not available from the FindItems call) $psPropertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties) $psPropertySet.RequestedBodyType = [Microsoft.Exchange.WebServices.Data.BodyType]::Text; # If you have a set number of items you want to get, use this and insert the # in the () # $items = $inbox.FindItems(5) # If you want to retrieve all items (Server limit is usually at 1000) then use this line # Details on the max returned by server: https://blogs.msdn.microsoft.com/exchangedev/2010/03/12/throttling-policies-and-the-ewsfindcountlimit/ $items = $inbox.FindItems($inbox.TotalCount) # Put some counts at the top of the output Write-host "Total Inbox count: $($inbox.TotalCount)" Write-host "Unread count: $($inbox.UnreadCount)" #These two lines, write the output to the specified text file Add-Content $Output "Total Inbox count: $($inbox.TotalCount)" Add-Content $Output "Unread count: $($inbox.UnreadCount)" foreach ($item in $items.Items) { # load the property set to allow us to get to the body $item.load($psPropertySet) # Get the Body text as-is $bod = $item.Body.Text #if you only want a short summary of the Body, then comment the above line and un-comment these 4 lines # $bod = $item.Body.Text -replace '\s+', ' ' # $bodCutOff = (100,$bod.Length | Measure-Object -Minimum).Minimum # $bod = $bod.Substring(0,$bodCutOff) # $bod = "$bod..." # output the results - first of all the From, Subject, References and Message ID write-host "====================================================================" Write-host "From: $($item.From.Name)" Write-host "Subject: $($item.Subject)" Write-host "Body: $($bod)" write-host "====================================================================" "" # Output the results to the specified Text file Add-Content $Output "" Add-Content $Output "====================================================================" Add-Content $Output "From: $($item.From.Name)" Add-Content $Output "Subject: $($item.Subject)" Add-Content $Output "Body:",$($bod) Add-Content $Output "====================================================================" Add-Content $Output "" } #see these URLs for more info # EWS Stuff # folder members: https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.folder_members%28v=exchg.80%29.aspx # exporting headers: https://www.allabout365.com/2010/10/export-email-headers-exchange-powershell/ # read emails with EWS: https://social.technet.microsoft.com/Forums/en-US/3fbf8348-2945-43aa-a0bc-f3b1d34da27c/read-emails-with-ews?forum=exchangesvrdevelopment  
      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?
×
×
  • Create New...