Read Text from Twitch and Send to Core

#NoEnv
#Persistent
Gui, Add, Edit, h400 w500 vMyEdit
gosub, refresh
Gui, Show
settimer, refresh, 7320
return

arr := ["`","%","\","@","~","^","<",">","+","-","_"]
LastGrabbed := "start"

; need to read last line and send it to our app
refresh:
;NP := "D:\Users\togag\.chatty\logs\#tmwtv.log" ; the log file to read
NP := "D:\Users\togag\.chatty\logs\#andymilonakis.log" ; the log file to read
FileRead, MyText, %NP% ; load-in the .log file
GrabbedText := StrTail(2,MyText) ; grab last x lines of text

if (GrabbedText != LastGrabbed)
{
GuiControl,, MyEdit, % GrabbedText ; send to GUI
    if WinExist("Core")
    {
       WinActivate ; use the window found above
       
       ; remove special chars to send into Core 
        testVar := "[(^@%`T,;-+=_*h<is> i:s a| $t?e\s/t.!){}]"
        ;str := RegexReplace(testVar, "[@\{\}$\^%\-+=_;\`<>()\[\]:\*|\\/]", "") ;all working
        ;str := RegexReplace(testVar, "[@\{\}$\^%\-+=_;\`<>\[\]:\*|\\/]", "")
        
        ; \.*?+[{|()^$
        
        str := RegexReplace(GrabbedText, "[@\{\}$\^%\-+=;\`<>\[\]:\*|\\/]", "")
        
        ;msgbox % str
       
       Send {Enter}              
       
       SendRaw %str%
       
       Send {Enter}
   }
}
LastGrabbed := GrabbedText ; record old comparison
return


;Return the last (k) lines of (str)
StrTail(k,str) ;; Inspired by Laszlo (http://www.autohotkey.com/forum/topic6928.html)
   {
   Loop,Parse,str,`n
      {
      i := Mod(A_Index,k)
      L%i% = %A_LoopField%
      }
   L := L%i%
   Loop,% k-1
      {
      If i < 1
         SetEnv,i,%k%
      i-- ;Mod does not work here
      L := L%i% "`n" L
      }
   Return L
   }

Latest Posts