Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; *******************************************************************************
- ; USER SETTINGS
- Local $enableShortBreaks = True ; true if the bot should take short breaks
- Local $shortBreakFrequencyMin = 30 ; minimum time between short breaks
- Local $shortBreakFrequencyMax = 45 ; maximum time between short breaks
- Local $shortBreakLengthMin = 5 ; minimum length of short breaks
- Local $shortBreakLengthMax = 10 ; maximum length of short breaks
- Local $enableLongBreaks = True ; true if the bot should take long breaks
- Local $longBreakFrequencyMin = 3 ; minimum time between long breaks
- Local $longBreakFrequencyMax = 5 ; maximum time between long breaks
- Local $longBreakLengthMin = 2 ; minimum length of long breaks
- Local $longBreakLengthMax = 3 ; maximum length of long breaks
- Local $enableRunningTooltip = False ; display a tooltip when running
- Local $enablePausedTooltip = True ; display a tooltip when taking a break
- Local $BotUnPauseKey = "{PAUSE}" ; UNpause the bot script, must be implemented in bot (can be same as pause key)
- Local $BotSafePauseKey = "-" ; set the SafePause setting in the bot, must be implemented in bot
- Local $ScriptStopKey = "{F11}" ; stop THIS script
- ; END USER SETTINGS
- ; *******************************************************************************
- HotKeySet($ScriptStopKey, "Stop")
- Local $nextShortBreak = Call("RandomShortBreak")
- Local $nextLongBreak = Call("RandomLongBreak")
- Local $minutesSinceShortBreak = 0
- Local $minutesSinceLongBreak = 0
- Local $screenSize = WinGetClientSize("[CLASS:D3 Main Window Class]")
- Local $tooltipX = $screenSize[0] - 100
- Local $tooltipY = 0
- ; Main Loop
- While True
- If $enableRunningTooltip Then
- Local $str = "Random Break Bot"
- If $enableShortBreaks Then
- $str = StringFormat("%s\nSinceShort: %d\nNextShort: %d", $str, $minutesSinceShortBreak, $nextShortBreak)
- EndIf
- If $enableLongBreaks Then
- $str = StringFormat("%s\nSinceLong: %d\nNextLong: %d", $str, $minutesSinceLongBreak, $nextLongBreak)
- EndIf
- ToolTip($str, $tooltipX, $tooltipY)
- EndIf
- If $enableLongBreaks And $minutesSinceLongBreak >= $nextLongBreak Then
- Call("TakeLongBreak")
- $nextLongBreak = Call("RandomLongBreak")
- $minutesSinceLongBreak = 0
- $minutesSinceShortBreak = 0 ; also reset
- EndIf
- If $enableShortBreaks And $minutesSinceShortBreak >= $nextShortBreak Then
- Local $breakTime = Call("TakeShortBreak")
- $nextShortBreak = Call("RandomShortBreak")
- $minutesSinceShortBreak = 0
- If $enableLongBreaks Then
- $minutesSinceLongBreak = $minutesSinceLongBreak + $breakTime
- ; If we've scheduled a short break that will overlap with the next long break,
- ; push it off so the long break will happen first.
- If $nextShortBreak + $shortBreakLengthMax >= $nextLongBreak - $minutesSinceLongBreak Then
- $nextShortBreak = $nextLongBreak
- EndIf
- EndIf
- EndIf
- Sleep(60000) ; 1 minute
- $minutesSinceShortBreak = $minutesSinceShortBreak + 1
- $minutesSinceLongBreak = $minutesSinceLongBreak + 1
- WEnd
- Func TakeShortBreak()
- Return TakeBreak("short", Random($shortBreakLengthMin, $shortBreakLengthMax, 1))
- EndFunc
- Func TakeLongBreak()
- Return TakeBreak("long", Random($longBreakLengthMin, $longBreakLengthMax, 1))
- EndFunc
- Func TakeBreak($type, $time)
- Send($BotSafePauseKey)
- For $i = 1 To $time
- If $enablePausedTooltip Then
- Tooltip(StringFormat("Random Break Bot\nTaking a %s break for %d more minutes.", $type, ($time - $i) + 1), $tooltipX, $tooltipY)
- EndIf
- Sleep(60000) ; 1 minute
- Next
- Send($BotUnPauseKey)
- Return $time
- EndFunc
- Func RandomShortBreak()
- Return Random($shortBreakFrequencyMin, $shortBreakFrequencyMax, 1)
- EndFunc
- Func RandomLongBreak()
- Return Random($longBreakFrequencyMin, $longBreakFrequencyMax, 1)
- EndFunc
- ; Catch the interrupt, stop the script
- Func Stop()
- Exit
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement