Here is one possible way to make this function into a single function:
function checkRatio($ooo, $hr)
{
$ran = (Get-Random -Minimum 1 -Maximum 9)
while ($hr -lt $ooo + "" + $ran) {
$wsh = New-Object -ComObject WScript.shell
$wsh.sendkeys('+{F15}')
$hr = (Get-Date).ToString('HH:mm')
$ran = (Get-Random -Minimum 1 -Maximum 9)
Clear-Host
write-host Checking Ratio: $ran : $hr : $ran
Start-Sleep -Seconds 58
}
}
This function takes two arguments:
$ooo: The number for which the ratio is to be checked.
$hr: The current hour and minute.
It uses while loop to check the ratio until the ratio is equal to the specified $ooo. Inside the loop, it uses New-Object -ComObject WScript.shell to run the command "+{F15}" which is likely a reference to the "F15" keyboard shortcut for "clear" in a window. It also uses Get-Random -Minimum 1 -Maximum 9 to generate a random number between 1 and 9. It then uses Clear-Host and write-host to clear the console output and print the ratio. Finally, it uses Start-Sleep -Seconds 58 to pause for 58 seconds before checking the ratio again.
You can call this function by passing in the number for which the ratio is to be checked and the current hour and minute as arguments:
checkRatio 16, "16:30"
This would check the ratio between the number 16 and the current hour and minute.