Jacob_DiDiodato icon

Twitch Bot Control Panel

Jacob_DiDiodato | PRO | 03/09/17 07:46:43 AM UTC | 0 ⭐ | 13000 👁️ | Never ⏰ | []
AutoIt |

3.39 KB

|

None

|

0 👍

/

0 👎

;Project Name: twitchwriter.au3
;Author Name: Jacob DiDiodato
;Project Version: 1.0
;Last Edit: Thursday March 9th 2017 @ 3:33 AM
;This program is a simple bot for a twitch stream. It will send a message that you give it to the twitch chat if the chat is positioned correctly (The chatbox must have a position in it that is 1160X 615Y) every 20 minutes (approx.)
;Usage: Begin the program follow the prompts and the first thing you should do is select "edit messages" because the program, by default, has no messages in it and won't print anything unless it actually has a message to print
;Notes: The program has space for 5 messages by default. In order to increase it edit the number on line 13
 
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>
#include <GUIConstantsEx.au3>
 
Global $MAXMESSAGES = 5
 
Global $array[$MAXMESSAGES]
Global $arrPos = 0
Global $timePassed = 0
Global $second = 1000
Global $minute = 60 * $second
 
For $i = 0 To (UBound($array) - 1) Step 1
   $array[$i] = ""
Next
 
MsgBox(0, "Waiting", "First, select the twitch stream window")
 
Opt('MustDeclareVars', 1)
 
Func SendMsg($string)
   If $string <> "" Then
      MouseClick("left", 1160, 615)
      Send($string)
      Send("{Enter}")
      $arrPos = $arrPos + 1
   ElseIf $array[0] == "" Then
      Return
   Else
      $arrPos = 0
      SendMsg($array[$arrPos])
   EndIf
EndFunc
 
Func EditMessages()
   If IsArray($array) Then
      For $i = 0 To (UBound($array) - 1) Step 1
         Local $input
 
         $input = InputBox("New Message", "Enter a new message for message #" & ($i + 1) & ". Previous message was: " & $array[$i] & ". Enter nothing to stop input.")
 
         If $input == "" Then
            For $j = $i To (UBound($array) - 1) Step 1
               $array[$j] = ""
            Next
            Return
         Else
            $array[$i] = $input
         EndIf
 
         $arrPos = 0
      Next
   Else
      MsgBox(0, "Error", "This variable is not an array")
   EndIf
 
EndFunc
 
Func DisplayMessages($array)
   If IsArray($array) Then
      Local $MsgBoxMsg = ""
      For $i = 0 To (UBound($array) - 1) Step 1
         $MsgBoxMsg &= "Message " & String($i + 1) & ": " & $array[$i] & @LF
      Next
      MsgBox(0, "Messages", $MsgBoxMsg)
   Else
      MsgBox(0, "Error", "This variable is not an array")
   EndIf
EndFunc
 
Func MainGUI()
  Local $Button1, $Button2, $Button3, $Msg1, $Msg2, $Msg3, $Msg4, $Msg5, $buttonClicked
 
  GUICreate("Twitch Bot Control Panel", 320, 40)
 
  Opt("GUICoordMode", 2)
  $Button1 = GUICtrlCreateButton("Send Message", 10, 10, 100)
  $Button2 = GUICtrlCreateButton("Edit Messages", 0, -1)
  $Button3 = GUICtrlCreateButton("Display Messages", 0, -1)
 
  GUISetState()
 
  ; Run the GUI until the window is closed
  While 1
    Local $hTimer = TimerInit()
    $buttonClicked = GUIGetMsg()
    Select
     Case $buttonClicked = $GUI_EVENT_CLOSE
       ExitLoop
     Case $buttonClicked = $Button1
       If $arrPos == $MAXMESSAGES Then
         $arrPos = 0
       EndIf
       SendMsg($array[$arrPos])
       $timePassed = 0
     Case $buttonClicked = $Button2
       EditMessages()
     Case $buttonClicked = $Button3
       DisplayMessages($array)
    EndSelect
    Local $fDiff = TimerDiff($hTimer)
    $timePassed = $timePassed + $fDiff
    ;MsgBox(0, "", "Current time passed: " & String($timePassed))
    If $timePassed > ($minute * 20) Then
      If $arrPos == $MAXMESSAGES Then
         $arrPos = 0
       EndIf
       SendMsg($array[$arrPos])
       $timePassed = 0
    EndIf
  WEnd
EndFunc
 
MainGUI()

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎