Win - Loss - Draw Counter for OBS Overlay

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Caeden
Posts: 1
Joined: 10 Nov 2017, 21:54

Win - Loss - Draw Counter for OBS Overlay

10 Nov 2017, 22:49

Hi all, my first post here so let me know if this is in the wrong thread or any rules are being broken.

I'm trying to write a script that will read preferably a single text file (though not adverse to reading multiple ones) that displays a W-L-D record for a stream overlay. I can easily make separate, individual scripts with hotkeys for wins, losses and draws. But the output of those scripts would be three individual text windows in OBS. I'm wondering if it's possible to make a single script with a single text file, where I could have hotkeys to adjust the three variables, and another hotkey to reset them all.

I want the output from the text file to look something like this, with the hyphens if possible:

W - L - D
# - # - #

I've tried various things, but none seem to work. Wondering if any of you guys have insight. Thanks!
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: Win - Loss - Draw Counter for OBS Overlay

11 Nov 2017, 04:34

It is. You'll need to make a GUI with transparent background (I guess), that has 3 text controls (can even have different controls), each displaying their corresponding variable. GuiControl allows to modify controls on the go, without recreating the GUI window.
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
User avatar
noname
Posts: 515
Joined: 19 Nov 2013, 09:15

Re: Win - Loss - Draw Counter for OBS Overlay

11 Nov 2017, 10:16

You'll need to make a GUI with transparent background (I guess)
I read the post at least 5 times and still cannot see what actually is needed :) . Do you want to " read " a file and display it like SirRFI is guessing on screen in an ahk OSD window ? Or do you want to " create a file " with values that can be updated in realtime to use them to display them using the OBS software . Also are those values numbers like 12-2-0 ?
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Win - Loss - Draw Counter for OBS Overlay

11 Nov 2017, 10:41

Here is the basics:

Code: Select all

#SingleInstance force
#NoEnv

; Set up Gui
Gui, Add, Text, xm w100, Num Played
Gui, Add, Text, x+5 w50 vNumPlayed

Gui, Add, Text, xm w100, Num Wins
Gui, Add, Text, x+5 w50 vNumWins

Gui, Add, Text, xm w100, Num Loss
Gui, Add, Text, x+5 w50 vNumLoss

Gui, Add, Text, xm w100, Win Percent
Gui, Add, Text, x+5 w50 vWinPercent

Gui, Add, Text, xm w100, Lose Percent
Gui, Add, Text, x+5 w50 vLosePercent

; Read values from disk
IniRead, NumPlayed, WinLoss.ini, Stats, NumPlayed, 0
IniRead, NumWins, WinLoss.ini, Stats, NumWins, 0
IniRead, NumLoss, WinLoss.ini, Stats, NumLoss, 0

; Display values in GUI
GoSub, CalculateStats

Gui, Show
return

GuiClose:
    ExitApp

; Win
Numpad7::
NumpadHome::
    NumWins++
    NumPlayed++
    GoSub, CalculateStats
    return

; Loss
Numpad8::
NumpadUp::
    NumLoss++
    NumPlayed++
    GoSub, CalculateStats
    return

; Reset
Numpad0::
NumpadIns::
    NumWins := 0
    NumLoss := 0
    NumPlayed := 0
    GoSub, CalculateStats
    return



CalculateStats:
    ; Calculate stats
    Multiplier := 100 / NumPlayed
    WinPercent := Round(Multiplier * NumWins, 2)
    LosePercent := Round(Multiplier * NumLoss, 2)
    
    ; Update GuiControls
    GuiControl, , NumPlayed, % NumPlayed
    GuiControl, , NumWins, % NumWins
    GuiControl, , NumLoss, % NumLoss
    GuiControl, , WinPercent, % WinPercent " %"
    GuiControl, , LosePercent, % LosePercent " %"
    
    ; Write new values to disk
    IniWrite, % NumPlayed, WinLoss.ini, Stats, NumPlayed
    IniWrite, % NumWins, WinLoss.ini, Stats, NumWins
    IniWrite, % NumLoss, WinLoss.ini, Stats, NumLoss
    return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ccqcl, Descolada, inseption86, mikeyww and 387 guests