-
I forgot all about this.... Here it is. Copy and past it into powershell. Powershell should be standard on W11 and W10. Use powershell ISE. Click view at the top of the app.. Click Show script Pane. Paste the script in the new white script pane. Click the green arrow at the top of the powershell app. The rest should be self explanatory.
Simple powershell fuel usage script
Add-Type -AssemblyName System.Windows.Forms
# Create the form
$form = New-Object System.Windows.Forms.Form
$form.Text = "Fuel Consumption Calculator"
$form.Size = New-Object System.Drawing.Size(350,220)
$form.StartPosition = "CenterScreen"
# Labels
$label1 = New-Object System.Windows.Forms.Label
$label1.Text = "Liters Used:"
$label1.Location = New-Object System.Drawing.Point(20,20)
$form.Controls.Add($label1)
$label2 = New-Object System.Windows.Forms.Label
$label2.Text = "Kilometers Driven:"
$label2.Location = New-Object System.Drawing.Point(20,60)
$form.Controls.Add($label2)
$label3 = New-Object System.Windows.Forms.Label
$label3.Text = "Liters per 100 km:"
$label3.Location = New-Object System.Drawing.Point(20,140)
$form.Controls.Add($label3)
# Textboxes
$textBoxLiters = New-Object System.Windows.Forms.TextBox
$textBoxLiters.Location = New-Object System.Drawing.Point(150,20)
$form.Controls.Add($textBoxLiters)
$textBoxKms = New-Object System.Windows.Forms.TextBox
$textBoxKms.Location = New-Object System.Drawing.Point(150,60)
$form.Controls.Add($textBoxKms)
$textBoxResult = New-Object System.Windows.Forms.TextBox
$textBoxResult.Location = New-Object System.Drawing.Point(150,140)
$textBoxResult.ReadOnly = $true
$form.Controls.Add($textBoxResult)
# Calculate Button
$buttonCalc = New-Object System.Windows.Forms.Button
$buttonCalc.Text = "Calculate"
$buttonCalc.Location = New-Object System.Drawing.Point(50,100)
$buttonCalc.Add_Click({
$liters = [double]$textBoxLiters.Text
$kms = [double]$textBoxKms.Text
if ($kms -ne 0) {
$result = ($liters / $kms) * 100
$textBoxResult.Text = "{0:N2}" -f $result
} else {
$textBoxResult.Text = "Invalid input"
}
})
$form.Controls.Add($buttonCalc)
# Reset Button
$buttonReset = New-Object System.Windows.Forms.Button
$buttonReset.Text = "Reset"
$buttonReset.Location = New-Object System.Drawing.Point(180,100)
$buttonReset.Add_Click({
$textBoxLiters.Text = ""
$textBoxKms.Text = ""
$textBoxResult.Text = ""
})
$form.Controls.Add($buttonReset)
# Show the form
$form.Topmost = $true
$form.Add_Shown({$form.Activate()})
[void]$form.ShowDialog()
-
1999 TD42t coil cab ute - 3.1t
average 16.0-16.4L / 100km
This is about a 50/50 mix of light traffic driving and highway driving.