Listening Shortcut A Script - A script I created to generate interactive posts

Post your working scripts, libraries and tools for AHK v1.1 and older
nilsonrdg
Posts: 23
Joined: 16 Feb 2017, 16:05
Location: Brazil
Contact:

Listening Shortcut A Script - A script I created to generate interactive posts

21 Oct 2018, 15:41

This is a simple autohotkey script.

It creates posts like these: https://listeningshortcuts.blogspot.com/
(About the videos: No political objectives, I used them because I believe they won't make copyright claims because of some sentences I'm posting there).

The original idea was to use the script to listen to words that I don't know before I watch the complete videos (youtube videos).

In the script there are two filters:

- The first is a list of new words that the user learns as he uses the script.

- The second is a list of the most common English words.

The script helps you filter the unknown words, and generated blog posts. So, you will be learning new words and keeping a list.

The script also provide a way to a fast listening of setences with uncommon words.

I learned a lot doing it.

If someone wants to test or improve it, here is it (it became too complex in the end.):

Original Code:

Code: Select all

global DelayVar
global FinalNumWord
global SpanColor 
global urlDictionary
global DelayVar
global WordChoice
global FileTextFinal
global CurrentFileText

SetingScript()

GetIniConfigs()

VideoId=
htmlFullCode=
Remaining=
Word=
ControlLoop := 0
FileText=
TextoInicial=


; --------------------------- Creating the interface -----------------------------------------

Gui, font, s10, Verdana 

Gui, Add, Text, , CREATION STEPS

Gui, Add, Button, gButtonsActionsLastWork, 0. Load last work

Gui, Add, Button, gButtonsActionsYT, 1. Choose a Youtube video

Gui, Add, Button, gButtonsActionsInsVid, 2. Insert VideoId
Gui, Add, Edit, vc_VideoId w200 h80, After copy the youtube link, click on the 'Insert VideoId button'.

Gui, Add, Button, gButtonsActionsInsTitle, 3. Insert Video Title
Gui, Add, Edit, vc_VideoTitle w200 h80, After copy the video title, click on the 'Insert Video Title'.

Gui, Add, Button, gButtonsActionsBaixarLegenda, 4. Download Subtitle

Gui, Add, Button, gButtonsActionsMoverSRT, 5. Mover SRT
Gui, Add, Button, gButtonsActionsSE, 6. Backup inputs
Gui, Add, Button, gButtonsActionsFilter, 7. Filter Subtitle
Gui, Add, Button, gButtonsActionsCreate, 8. PREVIEW
Gui, Add, Button, gButtonsActionsBlog, 9. Blog (without 'Global Script')
Gui, Add, Button, gButtonsActionsBlogWS, 9. Blog (with 'Global Script')
Gui, Add, Button, gButtonsActionsGetGlobal, 10. Copy "Global Javascript"

Gui, Add, Text, ym, Script Managing
Gui, Add, Button, gButtonsActionsFolder, Script Folder
Gui, Add, Button, gButtonsActionsReload, Reload
Gui, Add, Button, gButtonsActionsStop, Stop

Gui, Add, Text, ,
Gui, Add, Text, , Information
Gui, Add, Button, gButtonsActionsHotkeys, Show Hotkeys
Gui, Add, Button, gButtonsActionsRC, Readme and Credits
Gui, Add, Button, gButtonsActionsHelp, HELP
Gui, Add, Button, gButtonsActionsHelpVideo, Help Video

Gui, Add, Text, ,
Gui, Add, Text, , Tools
Gui, Add, Button, gButtonsActionsSort, Sort and Backup Lists
Gui, Add, Button, gButtonsActionsChangeInput, Change Input Data

Gui, Add, text, cBlue gButtonsActionsLaunchBlog, 
Gui, Add, Button, gButtonsActionsLaunchBlog, Example
Gui, Add, Button, gButtonsActionsResetingScript, Reset

Gui, Add, Text, ,
Gui, Add, Text, , Bonus
Gui, Add, Button, gButtonsActionsPhrasal, Search Phrasal Verbs

Gui, Add, Text, ym, SELECTING`n`rClick a word to add it to known words dic`n`r(or to search in dictionary)`n`rAdded words are supposed to no longer appear.
Gui, Add, ListBox, gRemovingWords vWordChoice w200 h400 Sort, |
Gui, Add, Button, gButtonsActionsEditingWords, Edit Words Instructions

Gui, Add, Text, ,
Gui, Add, Text, cBlue gLaunchModel, Click here to download`nblogger theme with the correct widths.

Gui, Add, Text, ym , 
Gui, Add, Text, ym , 

Gui, Add, Text, ym , Working Area`n`r`Here you will let only the chosen words`n`rIf you want you can edit/organize the list
Gui, Add, Edit, vc_Chosen w400 h300, 

Gui, Add, Text, , Notes:`n`rHere you can write a note that will appear in the post.
Gui, Add, Edit, vc_Notes w400 h50,

Gui, Add, Text, ,
Gui, Add, Text, ,
Gui, Add, Text, vc_WaitFilter w400 h20,
Gui, font, s30, Verdana 
Gui, Add, Text, vc_Progress w400 h40,

Gui, Show,, Listenning Warm Up Maker

SetTimer, labelToolTips, 500

return

; --------------------------- End Creating the interface ----------------------------------------


; ----------- This function filter the subtitle, so it will remain only uncommon words ----------
Filter()
{

GuiControl,, c_WaitFilter, Wait... The words are being filtered. Remaing Words:

global CurrentFileText
global Remaining
global ControlLoop
global FileText
global VideoId

Fill_Fields()

BackupSettingsFile()


sleep, 250
GuiControlGet, VideoId,,c_VideoId
VideoId := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","") ; It necessary to clean because a strange special character
sleep, 250


; Creating temp files, joining lists (user list + common words lists) etc.

FileDelete, %A_ScriptDir%\temp.txt

FileDelete, %A_ScriptDir%\JoinedList.txt
sleep, 150
FileCopy, %A_ScriptDir%\MyList.txt, %A_ScriptDir%\JoinedList.txt
sleep, 150
FileRead, MostCommonWords, %A_ScriptDir%\google-books-common-words.txt
sleep, 150
FileAppend, %MostCommonWords%, %A_ScriptDir%\JoinedList.txt

FileRead, TextoInicial, %A_ScriptDir%\CurrentSubtitle.txt

FileRead, FileText, %A_ScriptDir%\CurrentSubtitle.txt

FileRead, FileListString, %A_ScriptDir%\JoinedList.txt

; removing number characters from most common words list
FileListString := RegExReplace(FileListString, "\s\d*", "`n")
FileText := RegExReplace(FileText, "\d*", "")


Loop, parse, FileListString, `n, `r ; ALWAYS add `r as ignore char or it may fail
	{

if (ControlLoop = 1)
{
ControlLoop := 0

FileTextLocal := RegExReplace(FileText, "[^a-zA-Z0-9\-\']","`n")
GuiControl,, c_Chosen, %FileTextLocal%

InsertPhrasalinList()

CreateListBox(FileText)

Break
}
	FileTextMCW := A_LoopField
	;msgbox % A_LoopField
	if ErrorLevel
{
	
msgbox, Something went wrong!
FileTextLocal := RegExReplace(FileText, "[^a-zA-Z0-9\-\']","`n")
GuiControl,, c_Chosen, %FileTextLocal%
InsertPhrasalinList()
CreateListBox(FileText)

        break
}
	CleaningFile(FileTextMCW,FileText,0)

	}

; ----------------------- End function filter the subtitle ----------------------------


; Fill text areas if end of file was reached
if (ControlLoop = 0)
{
msgbox, End of list was reached or user stoped the script.
GuiControl,, c_Filtered, %FileText% 


guicontrol,, WordChoice, %CurrentFileText%
stringReplace, CurrentFileTextColumn,CurrentFileText,|,`n, All
CurrentFileTextColumn := RegExReplace(CurrentFileTextColumn, "[^a-zA-Z0-9\-\']","`n")
Sort, CurrentFileTextColumn, Random D`n
GuiControl,, c_Chosen, %CurrentFileTextColumn%


InsertPhrasalinList()
CreateListBox(FileText)
}

}

; This function remove special characters
CleaningFile(WordToChange,FileTextLocal,FimDeArquivo)
{
global FileText
global ControlLoop
global FinalNumWord

stringReplace, FileText, FileTextLocal, `n, %A_Space%, All

;remover tags html
FileText := RegExReplace(FileText, "<\s*\/\s*\w\s*.*?>|<\s*br\s*>", "")
FileText := RegExReplace(FileText, "<\s*\w.*?>", "")

stringReplace, FileText, FileText, --, , All
stringReplace, FileText, FileText, %A_Space%%A_Space%, %A_Space%, All
stringReplace, FileText, FileText, `r, %A_Space%, All
stringReplace, FileText, FileText, %A_Space%%WordToChange%%A_Space%, %A_Space%, All
stringReplace, FileText, FileText, `", , All
FileText := RegExReplace(FileText, " \d+", "")
FileText := RegExReplace(FileText, "[^a-zA-Z0-9 \-\']","")
FileText := RegExReplace(FileText, "\!","")


; Removing repeated words and sorting
stringReplace, FileText, FileText, %A_Space%, `n, All
Sort, FileText, u
stringReplace, FileText, FileText, `n, %A_Space%, All


; Counting Words

Len001 := StrLen(FileText)
FileTextTemp := RegExReplace(FileText, "\s","")
Len002 := StrLen(FileTextTemp)

Remaining := Len001 - Len002

GuiControl,, c_Progress, %Remaining%

if (Remaining<FinalNumWord or FimDeArquivo=1)
{
ControlLoop := 1
}


}
return


; Function to create script and preview
CreateScript(ChoseWords)
{

global DelayVar
global SpanColor
formattime, FileDate, , yyyy_MM_dd_hh_mm_ss

GuiControlGet, myNotes,,c_Notes

myNotes=<BR>%myNotes%<BR>

Fill_Fields()

global VideoId
Global urlDictionary

c_ChoseLines=

FileRead, FileContents, %A_ScriptDir%/CurrentSubtitle.txt

TimeSub1=
TimeSub2=

Loop, parse, FileContents, `n, `r  ; Specifying `n prior to `r allows both Windows and Unix files to be parsed.
{
ChoseLineAtual = %A_LoopField%

; removing HTML tags
ChoseLineAtual := RegExReplace(ChoseLineAtual, "<\s*\/\s*\w\s*.*?>|<\s*br\s*>", "")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "<\s*\w.*?>", "")
ChoseLineAtualOriginal = %ChoseLineAtual%

IfInString, ChoseLineAtual, -->
{
TimeSub2=%TimeSub1%
TimeSub1=%ChoseLineAtual%
}

if (DelayVar = 2)
{
ConvertedTime:=ConvertTime(TimeSub2)
}
else
{
ConvertedTime:=ConvertTime(TimeSub1)
}

LinkVideo = <span>&nbsp;&nbsp;&nbsp;<a href="javascript:JumpTo(%ConvertedTime%,'objetoPlayer%FileDate%');" style=";text-decoration: none;">&#9658; play</a></span>

Loop, parse, ChoseWords, `n  
{

Word = %A_LoopField%

; ---------------------------------------------------------------------------------------------
; This was the only way I found to replace whole words followed by special characters. I believe there's a simpler way

stringReplace, ChoseLineAtual, ChoseLineAtual,%Word%,tempwordx,
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx ", "targettempword")
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx,", "targettempword ,")
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx.", "targettempword .")
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx:", "targettempword :")
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx!", "targettempword !")
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx?", "targettempword ?")

ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx ", "targettempword ")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx,", "targettempword ,")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx.", "targettempword .")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx:", "targettempword :")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx!", "targettempword !")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx?", "targettempword ?")

; ---------------------------------------------------------------------------------------------

stringReplace, ChoseLineAtual, ChoseLineAtual,tempwordx, %Word%,

IfInString, ChoseLineAtual, targettempword
{

; This will remove middle word in phrasal verbs (it is needed to search the words on dictionary)
WordDic := RegExReplace(Word, "\s.*\s", "-")
WordDic := RegExReplace(WordDic, "\s", "-") ; recent changed

Link=<span><a id="awl_%FileDate%_%ConvertedTime%" eventAWL="DicUp_AWLScript('awl_%FileDate%_%ConvertedTime%');" href="%urlDictionary%%WordDic%" target="_blank" Alt="Search in dictionary">%Word%</a></span>

stringReplace, ChoseLineAtual, ChoseLineAtual,targettempword,%A_Space%%Link%%A_Space%

; ---------------------------------------------------------------------------------------------
; removing extra spaces caused by script to remove whole words

ChoseLineAtual := RegExReplace(ChoseLineAtual, "\s\,", ",")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "\s\.", ".")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "\s\:", ":")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "\s\!", "!")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "\s\?", "?")
; ---------------------------------------------------------------------------------------------

c_ChoseLines = %c_ChoseLines%`n%Space%"%ChoseLineAtual%"%LinkVideo%<br><br>`n

FileDelete, %A_ScriptDir%\Preview.htm
FileCopy, %A_ScriptDir%\Scripts.htm, %A_ScriptDir%\Preview.htm

;-----------------------------------------------------------------------------------------
; Creating HTML

Message=<br><span  id="Message%FileDate%" onclick="this.innerHTML='Load the Video. And, once the video has started, you can click on the links to go to dictionary, and on play to hear the words in the video context.'" style="color:#444;border:1px solid #CCC;background:#DDD;box-shadow: 0 0 5px -1px rgba(0,0,0,0.2);cursor:pointer;vertical-align:middle;max-width: 100px;padding: 5px;text-align: center;">How to listen</span><br><br>

LinkStartVideo=<div id='player%FileDate%' style="height:360px; width:640px; background:%SpanColor%;text-align:center;"><b><div onclick="Inicialize('player%FileDate%','%VideoId%','objetoPlayer%FileDate%');" onmouseover="Inicialize('player%FileDate%','%VideoId%','objetoPlayer%FileDate%');" style="height:360px; width:640px; background:%SpanColor%;text-align:center;color:blue"><BR><BR><BR><BR><BR><BR>LOAD VIDEO</div></b></div><span id="ads_%FileDate%"><script>awl_Ads('ads_%FileDate%');</script></span>

Corpo=<br><span style="font-style:verdana; font-size:10px; text-align:justify">List generated by <a href="https://listeningshortcuts.blogspot.com/p/about-listening-shortcut-autohotkey.html" target="_Blank">LSAScreator</a></span><br><br>%c_ChoseLines%`n`<br>

htmlFullCode=<span style="font-style:verdana; font-size:15px; text-align:justify">%myNotes%%Message%<table><tbody><tr><td>%LinkStartVideo%</td><td>%Corpo%</td></tr></tbody></table><center><br><br><a href="javascript:stopVideo('objetoPlayer%FileDate%');" style=";text-decoration: none;">Stop the Video</a></span> - <a href="javascript:JumpTo(0,'objetoPlayer%FileDate%');" style=";text-decoration: none;">Restart the Video (to watch it completely)</a></center>

htmlFullCode := RegExReplace(htmlFullCode, "eventAWL", "onmouseover")
FileAppend, %htmlFullCode%, %A_ScriptDir%\Preview.htm

}


}


}


run, %A_ScriptDir%\Preview.htm

}


ConvertTime(SubtitleTime)
{
SubtitleTime := RegExReplace(SubtitleTime, "\,\d\d\d$", "")
SubtitleTime := RegExReplace(SubtitleTime, " \-\-\> \d\d\:\d\d\:\d\d$", "")
SubtitleTime := RegExReplace(SubtitleTime, "\,\d\d\d$", "")

HoursSub := RegExReplace(SubtitleTime, ":.+", "")
MinSub := RegExReplace(SubtitleTime, "^\d\d:", "")
MinSub := RegExReplace(MinSub, ":\d\d$", "")
SecSub := RegExReplace(SubtitleTime, ".+:", "")
SubtitleTime = %HoursSub% %MinSub% %SecSub% - %SubtitleTime%


TotalSeconds := (SecSub + 60*MinSub + HoursSub*60*60)

Return TotalSeconds

}



SortLists()
{
formattime, FileDate, , yyyy-MM-dd-hh-mm-ss

FileRead, OutputVar, %A_ScriptDir%\MyList.txt

Sort, OutputVar, u

FileMove, %A_ScriptDir%\MyList.txt, %A_ScriptDir%\backup\%FileDate% - MyList.txt
sleep, 250
FileAppend, %OutputVar%,%A_ScriptDir%\MyList.txt
}


StopFilter()
{
global ControlLoop
ControlLoop := 1
}

Fill_Fields()
{
FileRead, UserInputs, %A_ScriptDir%/UserInputs.txt

  Loop, parse, UserInputs, `n
    {
	if (A_Index = 1)
	   GuiControl,, c_VideoId, %A_LoopField%
	
	if (A_Index = 2)
	   GuiControl,, c_VideoTitle, %A_LoopField%
    }
}


GetIniConfigs()
{
global DelayVar
global FinalNumWord
global urlDictionary

FileRead, UserInputs, %A_ScriptDir%/Config.txt

  Loop, parse, UserInputs, `n
    {
	if (A_Index = 1)
	DelayVar := RegExReplace(A_LoopField, ";.+", "")
	
	if (A_Index = 2)
	FinalNumWord := RegExReplace(A_LoopField, ";.+", "")

	if (A_Index = 3)
	SpanColor := RegExReplace(A_LoopField, ";.+", "")

	if (A_Index = 4)
	urlDictionary := RegExReplace(A_LoopField, ";.+", "")

    }

}

BackupSettingsFile()
{
GuiControlGet, VideoId,,c_VideoId
VideoIdFN := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","")
; VideoIdFN := RegExReplace(VideoId, " ","")
GuiControlGet, TitleRealVideo,,c_VideoTitle
TitleRealVideoFN := RegExReplace(TitleRealVideo, "\W","")

sleep, 250
FileCopy, %A_ScriptDir%/UserInputs.txt, %A_ScriptDir%/Inputs Backup/%TitleRealVideoFN% - %VideoIdFN%.txt

}



CreateListBox(FileTextFinal)
{
global CurrentFileText

CurrentFileText = %FileTextFinal%

stringReplace, FileTextFinal, FileTextFinal,%A_Space%,|, All

Gui, font, s10, Verdana 
guicontrol,, WordChoice, %FileTextFinal%
}



InsertPhrasalinList()
{
global VideoId
CurrentPhrasalChoice=

GuiControlGet, VideoId,,c_VideoId
VideoId := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","") ; It necessary to clean because a strange special character

FileRead, FileContents, %A_ScriptDir%/PhrasalVerbs.txt

Loop, parse, FileContents, `n, `r  ; Specifying `n prior to `r allows both Windows and Unix files to be parsed.
{
stringReplace, ChonsenPhrasalVerb, A_LoopField, %VideoId%;,, All

if (ChonsenPhrasalVerb<>A_LoopField)
{
CurrentPhrasalChoice = %ChonsenPhrasalVerb%`n%CurrentPhrasalChoice%
}
}

; msgbox Phrasal verbs inserted:`n`n%CurrentPhrasalChoice%

GuiControlGet, CurrentWordChoice,,c_Chosen
FileTextLocalSum = %CurrentPhrasalChoice%`n%CurrentWordChoice%
FileTextLocalSum := RegExReplace(FileTextLocalSum, "`n`n","`n")
GuiControl,, c_Chosen, %FileTextLocalSum%
}



; ------------ Button Actions --------------------------------


guiClose:
MsgBox, 4,, Do you really want to exit? (press Yes or No)
IfMsgBox Yes
{
   exitapp
}
return

LaunchModel:
FileDelete, %A_ScriptDir%/BloggerTheme.xml
run, https://listeningshortcuts.blogspot.com/p/downloads.html
clipboard=
tooltip, Aguarde o carregamento da página e copie o código da área de texto.
clipwait
FileAppend, %Clipboard%, %A_ScriptDir%/BloggerTheme.xml
run, %A_ScriptDir%
tooltip, Foi gerado o arquivo BloggerTheme.xls que você pode importar para o seu blog.
sleep, 5000
tooltip
return

ButtonsActionsEditingWords:

run, https://listeningshortcuts.blogspot.com/p/edit-instructions.html

return


ButtonsActionsGetGlobal:

FileRead, GlobalScript, %A_ScriptDir%\Scripts.htm
Clipboard = %GlobalScript%

msgbox, "Global Script" was copied, now you must put it as a Widget on blog.

return


ButtonsActionsLaunchBlog:

run, https://listeningshortcuts.blogspot.com/

return


ButtonsActionsResetingScript:

MsgBox, 4,, Do you really want to reset all? (press Yes or No)
IfMsgBox Yes
{
FileDelete, %A_ScriptDir%/CurrentSubtitle.txt
FileDelete, %A_ScriptDir%/JoinedList.txt
FileDelete, %A_ScriptDir%/MyList.txt
FileDelete, %A_ScriptDir%/PhrasalVerbs.txt
FileDelete, %A_ScriptDir%/UserInputs.txt
}
return

return

ButtonsActionsYT:

GuiControl,, c_VideoId,
GuiControl,, c_VideoTitle,

run, http://youtube.com
return

ButtonsActionsLastWork:

File=%A_ScriptDir%\UserInputs.txt
if !FileExist(File)
{
msgbox, There's no previous work.
}

Filter()
Fill_Fields()
return

ButtonsActionsRC:

run, https://listeningshortcuts.blogspot.com/p/readme.html

; FileRead, Readmetext, %A_ScriptDir%\Read-me and Credits.txt
; GuiControl,, c_Filtered, %Readmetext% 

return


ButtonsActionsHelp:
run, https://listeningshortcuts.blogspot.com/p/help.html
Return


ButtonsActionsBaixarLegenda:

GuiControlGet, VideoId,,c_VideoId
VideoId := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","") ; It necessary to clean because a strange special character
sleep, 500

MsgBox, 4,, Open http://www.lilsubs.com/? (press Yes or No)`n`nIn www.lilsubs.com`, select the "search box" and press CTRL+ALT+Y to insert video URL
IfMsgBox Yes
{
run, http://www.lilsubs.com/

tooltip, In www.lilsubs.com`, select the "search box" and press CTRL+ALT+Y to insert video URL

sleep, 10000
tooltip, In www.lilsubs.com`, select the "search box" and press CTRL+ALT+Y to insert video URL
sleep, 15000

tooltip,
}

return

; hotkey to fill subtitle search box
^!y::
send, https://www.youtube.com/watch?v=%VideoId%
send,{enter}
return

ButtonsActionsHotkeys:
; Find all hotkeys and show them

LinhaAnterior=
ListaAtalhos=

Loop Files, %A_ScriptDir%\*.ahk, R  ; R => Recurse into subfolders.
{

Loop, read, %A_LoopFileFullPath%
{
contadorhotkeysshow := 1
    Loop, parse, A_LoopReadLine, %A_Tab%
    {
    	LinhaAtual := A_LoopReadLine


        Marcador=`=`=`>
        IfInString, LinhaAnterior, %Marcador%
        {
	ListaAtalhos = %ListaAtalhos%`n%LinhaAnterior%: %LinhaAtual%
	
	StringReplace, ListaAtalhos, ListaAtalhos,`!,%A_Space%ALT%A_Space%, All
	StringReplace, ListaAtalhos, ListaAtalhos,`^,%A_Space%CTRL%A_Space%, All
	StringReplace, ListaAtalhos, ListaAtalhos,`#,%A_Space%WIN%A_Space%, All
	StringReplace, ListaAtalhos, ListaAtalhos,`+,%A_Space%SHIFT%A_Space%, All

	StringReplace, ListaAtalhos, ListaAtalhos,`;,, All
	StringReplace, ListaAtalhos, ListaAtalhos ,--`>,, All
        StringReplace, ListaAtalhos, ListaAtalhos,`:`:,, All
	
        }

    LinhaAnterior = %A_LoopField%
    }
}

}

Sort, ListaAtalhos

ListaAtalhos := RegExReplace(ListaAtalhos, "`n","`n`n")

msgbox, %ListaAtalhos%

Return



ButtonsActionsFolder:
Run, %A_ScriptDir%
Return



ButtonsActionsFilter:

File=%A_ScriptDir%\CurrentSubtitle.txt
if !FileExist(File)
{
msgbox, You didn't downloaded any subtitle!
}

Filter()
Return



ButtonsActionsCreate:
GuiControlGet, ChoseWords,,c_Chosen
CreateScript(ChoseWords)
Return


ButtonsActionsStop:
StopFilter()
Return



ButtonsActionsSort:
SortLists()
Return



ButtonsActionsReload:
Reload
Return


ButtonsActionsBlog:

global htmlFullCode

Loop Files, %A_ScriptDir%\Subtitles\*.*, R  ; Recurse into subfolders.
{
NumberOfPosts=%A_Index%
}


stringReplace, htmlFullCode, htmlFullCode, `n, , All  ; Removing line breaks


Clipboard=%htmlFullCode%

GuiControlGet, TitleRealVideo,,c_VideoTitle
TitleRealVideo := RegExReplace(TitleRealVideo, " \s", "+")

MsgBox, 4,, Code copied to clipboard! Do you want go to blogger?
IfMsgBox Yes
{
run, https://www.blogger.com/blog-this.g?n=%TitleRealVideo%+(Very+Fast-Listening+%NumberOfPosts%)
}

return


ButtonsActionsBlogWS:

global htmlFullCode

FileRead, GlobalScript, %A_ScriptDir%\Scripts.htm

Loop Files, %A_ScriptDir%\Subtitles\*.*, R  ; Recurse into subfolders.
{
NumberOfPosts=%A_Index%
}


stringReplace, htmlFullCode, htmlFullCode, `n, , All  ; Removing line breaks


Clipboard=%GlobalScript%`n`r`n`r`n`r`n`r%htmlFullCode%

GuiControlGet, TitleRealVideo,,c_VideoTitle
TitleRealVideo := RegExReplace(TitleRealVideo, " \s", "+")


MsgBox, 4,, Code copied to clipboard! Do you want go to blogger?
IfMsgBox Yes
{
run, https://www.blogger.com/blog-this.g?n=%TitleRealVideo%+(Very+Fast-Listening+%NumberOfPosts%)
}

return



ButtonsActionsInsVid:

msgbox, If you copied the address from browser address bar,`nThe code that must appear is that which follows 'watch?v='`nSometimes the filter doesn't work!

ClipboardVid := RegExReplace(Clipboard, "^h.*watch\?v\=", "")
ClipboardVid := RegExReplace(ClipboardVid, "&.*$", "")
GuiControl,, c_VideoId, %ClipboardVid% 

Return



ButtonsActionsInsTitle:
ClipboardVid := RegExReplace(Clipboard, "[^a-zA-Z0-9 \-\_]","")
GuiControl,, c_VideoTitle, %ClipboardVid% 
Return



ButtonsActionsSE:

GuiControlGet, VideoId,,c_VideoId
;VideoId := RegExReplace(VideoId, " ","")
VideoId := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","") ; It necessary to clean because a strange special character

GuiControlGet, TitleRealVideo,,c_VideoTitle

; Dados editados para inputuser.txt
FileDelete, %A_ScriptDir%/UserInputs.txt

FileAppend, %VideoId%`n, %A_ScriptDir%/UserInputs.txt
FileAppend, %TitleRealVideo%, %A_ScriptDir%/UserInputs.txt

sleep, 250
BackupSettingsFile()

Return



ButtonsActionsPhrasal:

PrepositionsList = up,down,uppon,after,around,on,over,down,behind,out,into,apart,forward,from,off,away,along,back,ahead,onto,up with,against

Sort, PrepositionsList, U D,
Sort, PrepositionsList, Random D,

stringReplace, PrepositionsList, PrepositionsList, `,, `n, All


CreateScript(PrepositionsList)
Return



ButtonsActionsMoverSRT:

FileSelectFile, SelectedFile, 3, , Open a file, Subtitle Documents (*.srt)

; Moving chosen input file to script folder
if SelectedFile =
{
    MsgBox, You must select a .SRT file
}
else
{
	FileCopy, %SelectedFile%, %A_ScriptDir%\CurrentSubtitle.txt,1
	FileMove, %SelectedFile%, %A_ScriptDir%\Subtitles\
}
return


; Changes the current input data
ButtonsActionsChangeInput:

FileSelectFile, SelectedFile, 3, %A_ScriptDir%\Inputs Backup\Chose a file.txt , Open a file, Subtitle Documents (*.txt)


; Moving chosen subtitle to script folder
if SelectedFile =
    MsgBox, You must select a input file to become current.
else
{
FileCopy, %SelectedFile%, %A_ScriptDir%/UserInputs.txt, 1
}


FileSelectFile, SelectedFile, 3, %A_ScriptDir%\Subtitles\Chose a file.txt , Open a file, Subtitle Documents (*.srt)


if SelectedFile =
{
    MsgBox, You must select a .SRT file
}
else
{
	FileCopy, %SelectedFile%, %A_ScriptDir%\CurrentSubtitle.txt,1
}


msgbox, Now you need to press "Load last work" button.

return

ButtonsActionsHelpVideo:

msgbox, Soon it will be available.

return



RemovingWords:

GuiControlGet, WordChoice,,WordChoice

MsgBox, 4,, Insert %WordChoice% in known words file?`n`r`n`rPressing 'No', it's searched in dictionary.
IfMsgBox Yes
{
stringReplace, FileText, WordChoice, %A_Space%, , All

FileAppend, %FileText%`n,%A_ScriptDir%\MyList.txt

stringReplace, CurrentFileText, CurrentFileText,%A_Space%,|, All

guicontrol,, WordChoice, |
sleep, 300

stringReplace, CurrentFileText,CurrentFileText,%WordChoice%,, All

guicontrol,, WordChoice, %CurrentFileText%

stringReplace, CurrentFileTextColumn,CurrentFileText,|,`n, All
CurrentFileTextColumn := RegExReplace(CurrentFileTextColumn, "[^a-zA-Z0-9\-\']","`n")
Sort, CurrentFileTextColumn, Random D`n
GuiControl,, c_Chosen, %CurrentFileTextColumn%
InsertPhrasalinList()
}
else
{

GuiControlGet, WordChoice,,WordChoice

stringReplace, WordChoice, WordChoice, %Space%, ,-
run, %urlDictionary%%WordChoice%
}

return

; ------------------------ End of Button action -----------------------



; ------------------------ Hotkeys -----------------------

; ==> Search on dictionary the selected word.
^!D::
sleep, 250
send, ^c
sleep, 500
Clipboard := RegExReplace(Clipboard, "[^a-zA-Z0-9\-\_]","-")
run, %urlDictionary%%Clipboard%
return

; ==> To send <BR> (use to insert lines breaks in notes)
^!B::
send,<BR>
return

; ==> Insert Phrasal Verb in PhrasalVerbs.txt file.
^!P::
Fill_Fields()
global VideoId
sleep, 500
send, ^c
sleep, 250

MsgBox, 4,, Do you want to insert "%Clipboard%" in PhrasalVerbs.txt? (press Yes or No)
IfMsgBox Yes
{
GuiControlGet, VideoId,,c_VideoId
VideoId := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","") ; It is necessary to clean because a strange special character

Clipboard := RegExReplace(Clipboard, "\s$","") ; It is necessary to clean space in final of the word
FileAppend, %VideoId%;%Clipboard%`n, %A_ScriptDir%\PhrasalVerbs.txt
}

MsgBox, 4,, Do you want to open PhrasalVerbs.txt? (press Yes or No)
IfMsgBox Yes
{
run, %A_ScriptDir%\PhrasalVerbs.txt
}


return

; ------------------------- End of Hotkeys ----------------------------------------------


; ------------------------- Showing tooltips -------------------------------------------

labelToolTips:

MouseGetPos, , , id, control

WinGetTitle, title, ahk_id %id%

windowtitle=Listenning Warm Up Maker

If (title=windowtitle)
{

ToolTipMensage = 
k = 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to load the last work and run the filter.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to open youtube to get a video address (copy the address).
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to insert video Id in the text area bellow.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to insert the video title in the text area bellow.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to go to a site where you can download the subtitle (.lrc).`nYou can use CTRL+ALT+Y to write video address in search box.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to move downloaded subtitle to script directory.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to backup inserted data in "InputBackup" folder.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to start filtering words.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to preview your work.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = If "Global Script" is on the page.`nYou can use theme.xml in blogger (click link at the right)
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = If "Global Script" isn't on the page.`nYou can use theme.xml in blogger (click link at the right)
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to copy only the "global code" to clipboard.`nThen you can put it in a blogger widget.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to open script folder.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to reload script.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to stop filtering, if it is taking too long to complete.`nIn the beggining it's recommended because there's a lot of contractions and others.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = 
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = 
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = 
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage =
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to sort words in JoinedList.txt (for more efficiency).
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = 
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = 
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Are you sure?`n`rThis will reset your learned words list and inputs.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to look for phrasal verbs.
}
ToolTip, %ToolTipMensage%

}
return


; ------------------------- End of Showing tooltips -------------------------------------


; Seting dictories and files

SetingScript()
{

File=%A_ScriptDir%\google-books-common-words.txt

if !FileExist(File)
{
msgbox, You must save the file "google-books-common-words.txt" in script folder.

MsgBox, 4,, Do you want to go to`nhttp://norvig.com/google-books-common-words.txt`n`rOr you want to find the file by yourself?`n`nPress 'Yes' to go to the page.
IfMsgBox Yes
{
run, http://norvig.com/google-books-common-words.txt
}

}



File=%A_ScriptDir%\backup
if !FileExist(File)
{
FileCreateDir, %A_ScriptDir%\backup
FileCreateDir, %A_ScriptDir%\Inputs Backup
FileCreateDir, %A_ScriptDir%\Subtitles

tooltip, Creating folders...
}


File=%A_ScriptDir%\Config.txt
if !FileExist(File)
{
FileAppend,1;Constante sentenças (1 or 2) - Use depend on extent of legend lines`n,%File%
FileAppend,15;word number`n,%File%
FileAppend,#a9c2d1;Div Color`n,%File%
FileAppend,https://www.collinsdictionary.com/dictionary/english/;Dictionary`n,%File%
}






File=%A_ScriptDir%\Scripts.htm
if !FileExist(File)
{

ScriptCode=
(
<script>

// Global Script - It must be on the page only one time. In blogger you can put it as a widget

var playerObject

function Inicialize(Objeto,VideoIdent,playerObject)
{

if (typeof playerObjectPrevious !== 'undefined') {
stopVideo(playerObjectPrevious);
}


      var tag = document.createElement('script');
      tag.src = "https://www.youtube.com/iframe_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

ObjetoLocal=Objeto;
VideoIdentLocal=VideoIdent;
playerObjectLocal=playerObject;

playerObjectPrevious = playerObjectLocal

setTimeout("InserirYT(ObjetoLocal,VideoIdentLocal,playerObjectLocal);",1000);
}

function InserirYT(ObjetoLocal,VideoIdentLocal,playerObjectLocal) {


  eval(playerObjectLocal + "= new YT.Player(ObjetoLocal, {height: '360', width: '640', videoId: VideoIdentLocal,})");

 }


function stopVideo(playerObjectLocal) {
eval(playerObjectLocal + ".stopVideo()");
      }



// ----------------- AWLScripts

function JumpTo(TimeSubtitle,playerObjectLocal) {


if (typeof playerObjectPrevious !== 'undefined' & playerObjectPrevious !== playerObjectLocal) {
stopVideo(playerObjectPrevious);
}

eval(playerObjectLocal + ".seekTo(TimeSubtitle)");
eval(playerObjectLocal + ".playVideo()");
}


// This will update the dictionary if it was needed
function DicUp_AWLScript(Var_AWLScript)
{
document.getElementById(Var_AWLScript).style.color='red';
}

// This will insert Ads
function awl_Ads(span_Ads)
{
document.getElementById(span_Ads).innerHTML="<BR><center><b><a href='https://listeningshortcuts.blogspot.com/p/you-can-also-contribute-in-bitcoins-if.html' target='_blank' style='text-decoration:note'>Contribute. Suggest a video (your video!)</a></b></center><BR>";
}


    </script>

<span id="AWLScriptMessage"></span>
)

FileAppend,%ScriptCode%,%File%

}


}





Mod 1 - To post on Steemit
Example: https://steemit.com/language/@nilson44/ ... -lesson-01

Code: Select all

global DelayVar
global FinalNumWord
global SpanColor 
global urlDictionary
global DelayVar
global WordChoice
global FileTextFinal
global CurrentFileText
global LinkSteemit
global TitleRealVideo

SetingScript()

GetIniConfigs()

VideoId=
htmlFullCode=
Remaining=
Word=
ControlLoop := 0
FileText=
TextoInicial=

LinkSteemit=
; --------------------------- Creating the interface -----------------------------------------

Gui, font, s10, Verdana 

Gui, Add, Text, , CREATION STEPS

Gui, Add, Button, gButtonsActionsLastWork, 0. Load last work

Gui, Add, Button, gButtonsActionsYT, 1. Choose a Youtube video

Gui, Add, Button, gButtonsActionsInsVid, 2. Insert VideoId
Gui, Add, Edit, vc_VideoId w200 h80, After copy the youtube link, click on the 'Insert VideoId button'.

Gui, Add, Button, gButtonsActionsInsTitle, 3. Insert Video Title
Gui, Add, Edit, vc_VideoTitle w200 h80, After copy the video title, click on the 'Insert Video Title'.

Gui, Add, Button, gButtonsActionsBaixarLegenda, 4. Download Subtitle

Gui, Add, Button, gButtonsActionsMoverSRT, 5. Mover SRT
Gui, Add, Button, gButtonsActionsSE, 6. Backup inputs
Gui, Add, Button, gButtonsActionsFilter, 7. Filter Subtitle
Gui, Add, Button, gButtonsActionsCreate, 8. PREVIEW
Gui, Add, Button, gButtonsActionsBlog, 9. Blog (without 'Global Script')
Gui, Add, Button, gButtonsActionsBlogWS, 9. Blog (with 'Global Script')
Gui, Add, Button, gButtonsActionsGetGlobal, 10. Copy "Global Javascript"

Gui, Add, Text, ym, Script Managing
Gui, Add, Button, gButtonsActionsFolder, Script Folder
Gui, Add, Button, gButtonsActionsReload, Reload
Gui, Add, Button, gButtonsActionsStop, Stop

Gui, Add, Text, ,
Gui, Add, Text, , Information
Gui, Add, Button, gButtonsActionsHotkeys, Show Hotkeys
Gui, Add, Button, gButtonsActionsRC, Readme and Credits
Gui, Add, Button, gButtonsActionsHelp, HELP
Gui, Add, Button, gButtonsActionsHelpVideo, Help Video

Gui, Add, Text, ,
Gui, Add, Text, , Tools
Gui, Add, Button, gButtonsActionsSort, Sort and Backup Lists
Gui, Add, Button, gButtonsActionsChangeInput, Change Input Data

Gui, Add, text, cBlue gButtonsActionsLaunchBlog, 
Gui, Add, Button, gButtonsActionsLaunchBlog, Example
Gui, Add, Button, gButtonsActionsResetingScript, Reset

Gui, Add, Text, ,
Gui, Add, Text, , Bonus
Gui, Add, Button, gButtonsActionsPhrasal, Search Phrasal Verbs
Gui, Add, Text, , Post steemit
Gui, Add, Button, gPostSteemit, Post in Steemit

Gui, Add, Text, ym, SELECTING`n`rClick a word to add it to known words dic`n`r(or to search in dictionary)`n`rAdded words are supposed to no longer appear.
Gui, Add, ListBox, gRemovingWords vWordChoice w200 h400 Sort, |
Gui, Add, Button, gButtonsActionsEditingWords, Edit Words Instructions

Gui, Add, Text, ,
Gui, Add, Text, cBlue gLaunchModel, Click here to download`nblogger theme with the correct widths.

Gui, Add, Text, ym , 
Gui, Add, Text, ym , 

Gui, Add, Text, ym , Working Area`n`r`Here you will let only the chosen words`n`rIf you want you can edit/organize the list
Gui, Add, Edit, vc_Chosen w400 h300, 

Gui, Add, Text, , Notes:`n`rHere you can write a note that will appear in the post.
Gui, Add, Edit, vc_Notes w400 h50,

Gui, Add, Text, ,
Gui, Add, Text, ,
Gui, Add, Text, vc_WaitFilter w400 h20,
Gui, font, s30, Verdana 
Gui, Add, Text, vc_Progress w400 h40,

Gui, Show,, Listenning Warm Up Maker

SetTimer, labelToolTips, 500

return

; --------------------------- End Creating the interface ----------------------------------------


; ----------- This function filter the subtitle, so it will remain only uncommon words ----------
Filter()
{

GuiControl,, c_WaitFilter, Wait... The words are being filtered. Remaing Words:

global CurrentFileText
global Remaining
global ControlLoop
global FileText
global VideoId

Fill_Fields()

BackupSettingsFile()


sleep, 250
GuiControlGet, VideoId,,c_VideoId
VideoId := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","") ; It necessary to clean because a strange special character
sleep, 250


; Creating temp files, joining lists (user list + common words lists) etc.

FileDelete, %A_ScriptDir%\temp.txt

FileDelete, %A_ScriptDir%\JoinedList.txt
sleep, 150
FileCopy, %A_ScriptDir%\MyList.txt, %A_ScriptDir%\JoinedList.txt
sleep, 150
FileRead, MostCommonWords, %A_ScriptDir%\google-books-common-words.txt
sleep, 150
FileAppend, %MostCommonWords%, %A_ScriptDir%\JoinedList.txt

FileRead, TextoInicial, %A_ScriptDir%\CurrentSubtitle.txt

FileRead, FileText, %A_ScriptDir%\CurrentSubtitle.txt

FileRead, FileListString, %A_ScriptDir%\JoinedList.txt

; removing number characters from most common words list
FileListString := RegExReplace(FileListString, "\s\d*", "`n")
FileText := RegExReplace(FileText, "\d*", "")


Loop, parse, FileListString, `n, `r ; ALWAYS add `r as ignore char or it may fail
	{

if (ControlLoop = 1)
{
ControlLoop := 0

FileTextLocal := RegExReplace(FileText, "[^a-zA-Z0-9\-\']","`n")
GuiControl,, c_Chosen, %FileTextLocal%

InsertPhrasalinList()

CreateListBox(FileText)

Break
}
	FileTextMCW := A_LoopField
	;msgbox % A_LoopField
	if ErrorLevel
{
	
msgbox, Something went wrong!
FileTextLocal := RegExReplace(FileText, "[^a-zA-Z0-9\-\']","`n")
GuiControl,, c_Chosen, %FileTextLocal%
InsertPhrasalinList()
CreateListBox(FileText)

        break
}
	CleaningFile(FileTextMCW,FileText,0)

	}

; ----------------------- End function filter the subtitle ----------------------------


; Fill text areas if end of file was reached
if (ControlLoop = 0)
{
msgbox, End of list was reached or user stoped the script.
GuiControl,, c_Filtered, %FileText% 


guicontrol,, WordChoice, %CurrentFileText%
stringReplace, CurrentFileTextColumn,CurrentFileText,|,`n, All
CurrentFileTextColumn := RegExReplace(CurrentFileTextColumn, "[^a-zA-Z0-9\-\']","`n")
Sort, CurrentFileTextColumn, Random D`n
GuiControl,, c_Chosen, %CurrentFileTextColumn%


InsertPhrasalinList()
CreateListBox(FileText)
}

}

; This function remove special characters
CleaningFile(WordToChange,FileTextLocal,FimDeArquivo)
{
global FileText
global ControlLoop
global FinalNumWord

stringReplace, FileText, FileTextLocal, `n, %A_Space%, All

;remover tags html
FileText := RegExReplace(FileText, "<\s*\/\s*\w\s*.*?>|<\s*br\s*>", "")
FileText := RegExReplace(FileText, "<\s*\w.*?>", "")

stringReplace, FileText, FileText, --, , All
stringReplace, FileText, FileText, %A_Space%%A_Space%, %A_Space%, All
stringReplace, FileText, FileText, `r, %A_Space%, All
stringReplace, FileText, FileText, %A_Space%%WordToChange%%A_Space%, %A_Space%, All
stringReplace, FileText, FileText, `", , All
FileText := RegExReplace(FileText, " \d+", "")
FileText := RegExReplace(FileText, "[^a-zA-Z0-9 \-\']","")
FileText := RegExReplace(FileText, "\!","")


; Removing repeated words and sorting
stringReplace, FileText, FileText, %A_Space%, `n, All
Sort, FileText, u
stringReplace, FileText, FileText, `n, %A_Space%, All


; Counting Words

Len001 := StrLen(FileText)
FileTextTemp := RegExReplace(FileText, "\s","")
Len002 := StrLen(FileTextTemp)

Remaining := Len001 - Len002

GuiControl,, c_Progress, %Remaining%

if (Remaining<FinalNumWord or FimDeArquivo=1)
{
ControlLoop := 1
}


}
return


; Function to create script and preview
CreateScript(ChoseWords)
{

global DelayVar
global SpanColor
formattime, FileDate, , yyyy_MM_dd_hh_mm_ss

GuiControlGet, myNotes,,c_Notes

myNotes=<BR>%myNotes%<BR>

Fill_Fields()

global VideoId
Global urlDictionary

c_ChoseLines=

FileRead, FileContents, %A_ScriptDir%/CurrentSubtitle.txt

TimeSub1=
TimeSub2=

Loop, parse, FileContents, `n, `r  ; Specifying `n prior to `r allows both Windows and Unix files to be parsed.
{
ChoseLineAtual = %A_LoopField%
SteemitLine = %A_LoopField%

; removing HTML tags
ChoseLineAtual := RegExReplace(ChoseLineAtual, "<\s*\/\s*\w\s*.*?>|<\s*br\s*>", "")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "<\s*\w.*?>", "")
ChoseLineAtualOriginal = %ChoseLineAtual%

IfInString, ChoseLineAtual, -->
{
TimeSub2=%TimeSub1%
TimeSub1=%ChoseLineAtual%
}

if (DelayVar = 2)
{
ConvertedTime:=ConvertTime(TimeSub2)
}
else
{
ConvertedTime:=ConvertTime(TimeSub1)
}

LinkVideo = <span>&nbsp;&nbsp;&nbsp;<a href="javascript:JumpTo(%ConvertedTime%,'objetoPlayer%FileDate%');" style=";text-decoration: none;">&#9658; play</a></span>

Loop, parse, ChoseWords, `n  
{

Word = %A_LoopField%

; ---------------------------------------------------------------------------------------------
; This was the only way I found to replace whole words followed by special characters. I believe there's a simpler way

stringReplace, ChoseLineAtual, ChoseLineAtual,%Word%,tempwordx,
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx ", "targettempword")
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx,", "targettempword ,")
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx.", "targettempword .")
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx:", "targettempword :")
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx!", "targettempword !")
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx?", "targettempword ?")

ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx ", "targettempword ")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx,", "targettempword ,")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx.", "targettempword .")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx:", "targettempword :")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx!", "targettempword !")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx?", "targettempword ?")

; ---------------------------------------------------------------------------------------------

stringReplace, ChoseLineAtual, ChoseLineAtual,tempwordx, %Word%,

IfInString, ChoseLineAtual, targettempword
{

; This will remove middle word in phrasal verbs (it is needed to search the words on dictionary)
WordDic := RegExReplace(Word, "\s.*\s", "-")
WordDic := RegExReplace(WordDic, "\s", "-") ; recent changed

Link=<span><a id="awl_%FileDate%_%ConvertedTime%" eventAWL="DicUp_AWLScript('awl_%FileDate%_%ConvertedTime%');" href="%urlDictionary%%WordDic%" target="_blank" Alt="Search in dictionary">%Word%</a></span>

stringReplace, ChoseLineAtual, ChoseLineAtual,targettempword,%A_Space%%Link%%A_Space%

; ---------------------------------------------------------------------------------------------
; removing extra spaces caused by script to remove whole words

ChoseLineAtual := RegExReplace(ChoseLineAtual, "\s\,", ",")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "\s\.", ".")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "\s\:", ":")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "\s\!", "!")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "\s\?", "?")
; ---------------------------------------------------------------------------------------------

c_ChoseLines = %c_ChoseLines%`n%Space%"%ChoseLineAtual%"%LinkVideo%<br><br>`n

FileDelete, %A_ScriptDir%\Preview.htm
FileCopy, %A_ScriptDir%\Scripts.htm, %A_ScriptDir%\Preview.htm

;-----------------------------------------------------------------------------------------
; Creating HTML

Message=<br><span  id="Message%FileDate%" onclick="this.innerHTML='Load the Video. And, once the video has started, you can click on the links to go to dictionary, and on play to hear the words in the video context.'" style="color:#444;border:1px solid #CCC;background:#DDD;box-shadow: 0 0 5px -1px rgba(0,0,0,0.2);cursor:pointer;vertical-align:middle;max-width: 100px;padding: 5px;text-align: center;">How to listen</span><br><br>

LinkStartVideo=<div id='player%FileDate%' style="height:360px; width:640px; background:%SpanColor%;text-align:center;"><b><div onclick="Inicialize('player%FileDate%','%VideoId%','objetoPlayer%FileDate%');" onmouseover="Inicialize('player%FileDate%','%VideoId%','objetoPlayer%FileDate%');" style="height:360px; width:640px; background:%SpanColor%;text-align:center;color:blue"><BR><BR><BR><BR><BR><BR>LOAD VIDEO</div></b></div><span id="ads_%FileDate%"><script>awl_Ads('ads_%FileDate%');</script></span>

Corpo=<br><span style="font-style:verdana; font-size:10px; text-align:justify">List generated by <a href="https://listeningshortcuts.blogspot.com/p/about-listening-shortcut-autohotkey.html" target="_Blank">LSAScreator</a></span><br><br>%c_ChoseLines%`n`<br>

htmlFullCode=<span style="font-style:verdana; font-size:15px; text-align:justify">%myNotes%%Message%<table><tbody><tr><td>%LinkStartVideo%</td><td>%Corpo%</td></tr></tbody></table><center><br><br><a href="javascript:stopVideo('objetoPlayer%FileDate%');" style=";text-decoration: none;">Stop the Video</a></span> - <a href="javascript:JumpTo(0,'objetoPlayer%FileDate%');" style=";text-decoration: none;">Restart the Video (to watch it completely)</a></center>

htmlFullCode := RegExReplace(htmlFullCode, "eventAWL", "onmouseover")

FileAppend, %htmlFullCode%, %A_ScriptDir%\Preview.htm

; Creating link to steemit
GuiControlGet, TitleRealVideo,,c_VideoTitle

stringReplace, SteemitLine,SteemitLine,%Word%,<a href="%urlDictionary%%WordDic%">%Word%</a>, All

LinkSteemit = %LinkSteemit%`n`r"%SteemitLine%" <a href="https://youtu.be/%VideoId%?t=%ConvertedTime%">Play</a>

}


}


}




run, %A_ScriptDir%\Preview.htm

}


ConvertTime(SubtitleTime)
{
SubtitleTime := RegExReplace(SubtitleTime, "\,\d\d\d$", "")
SubtitleTime := RegExReplace(SubtitleTime, " \-\-\> \d\d\:\d\d\:\d\d$", "")
SubtitleTime := RegExReplace(SubtitleTime, "\,\d\d\d$", "")

HoursSub := RegExReplace(SubtitleTime, ":.+", "")
MinSub := RegExReplace(SubtitleTime, "^\d\d:", "")
MinSub := RegExReplace(MinSub, ":\d\d$", "")
SecSub := RegExReplace(SubtitleTime, ".+:", "")
SubtitleTime = %HoursSub% %MinSub% %SecSub% - %SubtitleTime%


TotalSeconds := (SecSub + 60*MinSub + HoursSub*60*60)

Return TotalSeconds

}



SortLists()
{
formattime, FileDate, , yyyy-MM-dd-hh-mm-ss

FileRead, OutputVar, %A_ScriptDir%\MyList.txt

Sort, OutputVar, u

FileMove, %A_ScriptDir%\MyList.txt, %A_ScriptDir%\backup\%FileDate% - MyList.txt
sleep, 250
FileAppend, %OutputVar%,%A_ScriptDir%\MyList.txt
}


StopFilter()
{
global ControlLoop
ControlLoop := 1
}

Fill_Fields()
{
FileRead, UserInputs, %A_ScriptDir%/UserInputs.txt

  Loop, parse, UserInputs, `n
    {
	if (A_Index = 1)
	   GuiControl,, c_VideoId, %A_LoopField%
	
	if (A_Index = 2)
	   GuiControl,, c_VideoTitle, %A_LoopField%
    }
}


GetIniConfigs()
{
global DelayVar
global FinalNumWord
global urlDictionary

FileRead, UserInputs, %A_ScriptDir%/Config.txt

  Loop, parse, UserInputs, `n
    {
	if (A_Index = 1)
	DelayVar := RegExReplace(A_LoopField, ";.+", "")
	
	if (A_Index = 2)
	FinalNumWord := RegExReplace(A_LoopField, ";.+", "")

	if (A_Index = 3)
	SpanColor := RegExReplace(A_LoopField, ";.+", "")

	if (A_Index = 4)
	urlDictionary := RegExReplace(A_LoopField, ";.+", "")

    }

}

BackupSettingsFile()
{
GuiControlGet, VideoId,,c_VideoId
VideoIdFN := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","")
; VideoIdFN := RegExReplace(VideoId, " ","")
GuiControlGet, TitleRealVideo,,c_VideoTitle
TitleRealVideoFN := RegExReplace(TitleRealVideo, "\W","")

sleep, 250
FileCopy, %A_ScriptDir%/UserInputs.txt, %A_ScriptDir%/Inputs Backup/%TitleRealVideoFN% - %VideoIdFN%.txt

}



CreateListBox(FileTextFinal)
{
global CurrentFileText

CurrentFileText = %FileTextFinal%

stringReplace, FileTextFinal, FileTextFinal,%A_Space%,|, All

Gui, font, s10, Verdana 
guicontrol,, WordChoice, %FileTextFinal%
}



InsertPhrasalinList()
{
global VideoId
CurrentPhrasalChoice=

GuiControlGet, VideoId,,c_VideoId
VideoId := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","") ; It necessary to clean because a strange special character

FileRead, FileContents, %A_ScriptDir%/PhrasalVerbs.txt

Loop, parse, FileContents, `n, `r  ; Specifying `n prior to `r allows both Windows and Unix files to be parsed.
{
stringReplace, ChonsenPhrasalVerb, A_LoopField, %VideoId%;,, All

if (ChonsenPhrasalVerb<>A_LoopField)
{
CurrentPhrasalChoice = %ChonsenPhrasalVerb%`n%CurrentPhrasalChoice%
}
}

; msgbox Phrasal verbs inserted:`n`n%CurrentPhrasalChoice%

GuiControlGet, CurrentWordChoice,,c_Chosen
FileTextLocalSum = %CurrentPhrasalChoice%`n%CurrentWordChoice%
FileTextLocalSum := RegExReplace(FileTextLocalSum, "`n`n","`n")
GuiControl,, c_Chosen, %FileTextLocalSum%
}



; ------------ Button Actions --------------------------------


PostSteemit:

run, https://steemit.com/submit.html

PostKeyWord := StrReplace(TitleRealVideo, A_Space, "")
StringLower, PostKeyWord, PostKeyWord

TitleSteemit = Listening Warming Up - %TitleRealVideo% - Lesson 

tooltip, Click in posting box and past the content

Clipboard =%TitleSteemit%`n - This is a post for English Students, it's a "warming up" for a listening practice.`n - These are some words which I didn't know on the this video.`n - You can open the links on a new tab to listen to the sentences (Play) or to see the words meaning (Word link).`n`r%LinkSteemit%`n`r<i>Created by Autohotkey Warming Up Listening Script <a href="https://autohotkey.com/boards/viewtopic.php?f=6&t=58138">Script Code</a></i>`n`r`n`r%PostKeyWord%

return


guiClose:
MsgBox, 4,, Do you really want to exit? (press Yes or No)
IfMsgBox Yes
{
   exitapp
}
return

LaunchModel:
FileDelete, %A_ScriptDir%/BloggerTheme.xml
run, https://listeningshortcuts.blogspot.com/p/downloads.html
clipboard=
tooltip, Aguarde o carregamento da página e copie o código da área de texto.
clipwait
FileAppend, %Clipboard%, %A_ScriptDir%/BloggerTheme.xml
run, %A_ScriptDir%
tooltip, Foi gerado o arquivo BloggerTheme.xls que você pode importar para o seu blog.
sleep, 5000
tooltip
return

ButtonsActionsEditingWords:

run, https://listeningshortcuts.blogspot.com/p/edit-instructions.html

return


ButtonsActionsGetGlobal:

FileRead, GlobalScript, %A_ScriptDir%\Scripts.htm
Clipboard = %GlobalScript%

msgbox, "Global Script" was copied, now you must put it as a Widget on blog.

return


ButtonsActionsLaunchBlog:

run, https://listeningshortcuts.blogspot.com/

return


ButtonsActionsResetingScript:

MsgBox, 4,, Do you really want to reset all? (press Yes or No)
IfMsgBox Yes
{
FileDelete, %A_ScriptDir%/CurrentSubtitle.txt
FileDelete, %A_ScriptDir%/JoinedList.txt
FileDelete, %A_ScriptDir%/MyList.txt
FileDelete, %A_ScriptDir%/PhrasalVerbs.txt
FileDelete, %A_ScriptDir%/UserInputs.txt
}
return

return

ButtonsActionsYT:

GuiControl,, c_VideoId,
GuiControl,, c_VideoTitle,

run, http://youtube.com
return

ButtonsActionsLastWork:

File=%A_ScriptDir%\UserInputs.txt
if !FileExist(File)
{
msgbox, There's no previous work.
}

Filter()
Fill_Fields()
return

ButtonsActionsRC:

run, https://listeningshortcuts.blogspot.com/p/readme.html

; FileRead, Readmetext, %A_ScriptDir%\Read-me and Credits.txt
; GuiControl,, c_Filtered, %Readmetext% 

return


ButtonsActionsHelp:
run, https://listeningshortcuts.blogspot.com/p/help.html
Return


ButtonsActionsBaixarLegenda:

GuiControlGet, VideoId,,c_VideoId
VideoId := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","") ; It necessary to clean because a strange special character
sleep, 500

MsgBox, 4,, Open http://www.lilsubs.com/? (press Yes or No)`n`nIn www.lilsubs.com`, select the "search box" and press CTRL+ALT+Y to insert video URL
IfMsgBox Yes
{
run, http://www.lilsubs.com/

tooltip, In www.lilsubs.com`, select the "search box" and press CTRL+ALT+Y to insert video URL

sleep, 10000
tooltip, In www.lilsubs.com`, select the "search box" and press CTRL+ALT+Y to insert video URL
sleep, 15000

tooltip,
}

return

; hotkey to fill subtitle search box
^!y::
send, https://www.youtube.com/watch?v=%VideoId%
send,{enter}
return

ButtonsActionsHotkeys:
; Find all hotkeys and show them

LinhaAnterior=
ListaAtalhos=

Loop Files, %A_ScriptDir%\*.ahk, R  ; R => Recurse into subfolders.
{

Loop, read, %A_LoopFileFullPath%
{
contadorhotkeysshow := 1
    Loop, parse, A_LoopReadLine, %A_Tab%
    {
    	LinhaAtual := A_LoopReadLine


        Marcador=`=`=`>
        IfInString, LinhaAnterior, %Marcador%
        {
	ListaAtalhos = %ListaAtalhos%`n%LinhaAnterior%: %LinhaAtual%
	
	StringReplace, ListaAtalhos, ListaAtalhos,`!,%A_Space%ALT%A_Space%, All
	StringReplace, ListaAtalhos, ListaAtalhos,`^,%A_Space%CTRL%A_Space%, All
	StringReplace, ListaAtalhos, ListaAtalhos,`#,%A_Space%WIN%A_Space%, All
	StringReplace, ListaAtalhos, ListaAtalhos,`+,%A_Space%SHIFT%A_Space%, All

	StringReplace, ListaAtalhos, ListaAtalhos,`;,, All
	StringReplace, ListaAtalhos, ListaAtalhos ,--`>,, All
        StringReplace, ListaAtalhos, ListaAtalhos,`:`:,, All
	
        }

    LinhaAnterior = %A_LoopField%
    }
}

}

Sort, ListaAtalhos

ListaAtalhos := RegExReplace(ListaAtalhos, "`n","`n`n")

msgbox, %ListaAtalhos%

Return



ButtonsActionsFolder:
Run, %A_ScriptDir%
Return



ButtonsActionsFilter:

File=%A_ScriptDir%\CurrentSubtitle.txt
if !FileExist(File)
{
msgbox, You didn't downloaded any subtitle!
}

Filter()
Return



ButtonsActionsCreate:
GuiControlGet, ChoseWords,,c_Chosen
CreateScript(ChoseWords)
Return


ButtonsActionsStop:
StopFilter()
Return



ButtonsActionsSort:
SortLists()
Return



ButtonsActionsReload:
Reload
Return


ButtonsActionsBlog:

global htmlFullCode

Loop Files, %A_ScriptDir%\Subtitles\*.*, R  ; Recurse into subfolders.
{
NumberOfPosts=%A_Index%
}


stringReplace, htmlFullCode, htmlFullCode, `n, , All  ; Removing line breaks


Clipboard=%htmlFullCode%

GuiControlGet, TitleRealVideo,,c_VideoTitle
TitleRealVideo := RegExReplace(TitleRealVideo, " \s", "+")

MsgBox, 4,, Code copied to clipboard! Do you want go to blogger?
IfMsgBox Yes
{
run, https://www.blogger.com/blog-this.g?n=%TitleRealVideo%+(Very+Fast-Listening+%NumberOfPosts%)
}

return


ButtonsActionsBlogWS:

global htmlFullCode

FileRead, GlobalScript, %A_ScriptDir%\Scripts.htm

Loop Files, %A_ScriptDir%\Subtitles\*.*, R  ; Recurse into subfolders.
{
NumberOfPosts=%A_Index%
}


stringReplace, htmlFullCode, htmlFullCode, `n, , All  ; Removing line breaks


Clipboard=%GlobalScript%`n`r`n`r`n`r`n`r%htmlFullCode%

GuiControlGet, TitleRealVideo,,c_VideoTitle
TitleRealVideo := RegExReplace(TitleRealVideo, " \s", "+")


MsgBox, 4,, Code copied to clipboard! Do you want go to blogger?
IfMsgBox Yes
{
run, https://www.blogger.com/blog-this.g?n=%TitleRealVideo%+(Very+Fast-Listening+%NumberOfPosts%)
}

return



ButtonsActionsInsVid:

msgbox, If you copied the address from browser address bar,`nThe code that must appear is that which follows 'watch?v='`nSometimes the filter doesn't work!

ClipboardVid := RegExReplace(Clipboard, "^h.*watch\?v\=", "")
ClipboardVid := RegExReplace(ClipboardVid, "&.*$", "")
GuiControl,, c_VideoId, %ClipboardVid% 

Return



ButtonsActionsInsTitle:
ClipboardVid := RegExReplace(Clipboard, "[^a-zA-Z0-9 \-\_]","")
GuiControl,, c_VideoTitle, %ClipboardVid% 
Return



ButtonsActionsSE:

GuiControlGet, VideoId,,c_VideoId
;VideoId := RegExReplace(VideoId, " ","")
VideoId := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","") ; It necessary to clean because a strange special character

GuiControlGet, TitleRealVideo,,c_VideoTitle

; Dados editados para inputuser.txt
FileDelete, %A_ScriptDir%/UserInputs.txt

FileAppend, %VideoId%`n, %A_ScriptDir%/UserInputs.txt
FileAppend, %TitleRealVideo%, %A_ScriptDir%/UserInputs.txt

sleep, 250
BackupSettingsFile()

Return



ButtonsActionsPhrasal:

PrepositionsList = up,down,uppon,after,around,on,over,down,behind,out,into,apart,forward,from,off,away,along,back,ahead,onto,up with,against

Sort, PrepositionsList, U D,
Sort, PrepositionsList, Random D,

stringReplace, PrepositionsList, PrepositionsList, `,, `n, All


CreateScript(PrepositionsList)
Return



ButtonsActionsMoverSRT:

FileSelectFile, SelectedFile, 3, , Open a file, Subtitle Documents (*.srt)

; Moving chosen input file to script folder
if SelectedFile =
{
    MsgBox, You must select a .SRT file
}
else
{
	FileCopy, %SelectedFile%, %A_ScriptDir%\CurrentSubtitle.txt,1
	FileMove, %SelectedFile%, %A_ScriptDir%\Subtitles\
}
return


; Changes the current input data
ButtonsActionsChangeInput:

FileSelectFile, SelectedFile, 3, %A_ScriptDir%\Inputs Backup\Chose a file.txt , Open a file, Subtitle Documents (*.txt)


; Moving chosen subtitle to script folder
if SelectedFile =
    MsgBox, You must select a input file to become current.
else
{
FileCopy, %SelectedFile%, %A_ScriptDir%/UserInputs.txt, 1
}


FileSelectFile, SelectedFile, 3, %A_ScriptDir%\Subtitles\Chose a file.txt , Open a file, Subtitle Documents (*.srt)


if SelectedFile =
{
    MsgBox, You must select a .SRT file
}
else
{
	FileCopy, %SelectedFile%, %A_ScriptDir%\CurrentSubtitle.txt,1
}


msgbox, Now you need to press "Load last work" button.

return

ButtonsActionsHelpVideo:

msgbox, Soon it will be available.

return



RemovingWords:

GuiControlGet, WordChoice,,WordChoice

MsgBox, 4,, Insert %WordChoice% in known words file?`n`r`n`rPressing 'No', it's searched in dictionary.
IfMsgBox Yes
{
stringReplace, FileText, WordChoice, %A_Space%, , All

FileAppend, %FileText%`n,%A_ScriptDir%\MyList.txt

stringReplace, CurrentFileText, CurrentFileText,%A_Space%,|, All

guicontrol,, WordChoice, |
sleep, 300

stringReplace, CurrentFileText,CurrentFileText,%WordChoice%,, All

guicontrol,, WordChoice, %CurrentFileText%

stringReplace, CurrentFileTextColumn,CurrentFileText,|,`n, All
CurrentFileTextColumn := RegExReplace(CurrentFileTextColumn, "[^a-zA-Z0-9\-\']","`n")
Sort, CurrentFileTextColumn, Random D`n
GuiControl,, c_Chosen, %CurrentFileTextColumn%
InsertPhrasalinList()
}
else
{

GuiControlGet, WordChoice,,WordChoice

stringReplace, WordChoice, WordChoice, %Space%, ,-
run, %urlDictionary%%WordChoice%
}

return

; ------------------------ End of Button action -----------------------



; ------------------------ Hotkeys -----------------------

; ==> Search on dictionary the selected word.
^!D::
sleep, 250
send, ^c
sleep, 500
Clipboard := RegExReplace(Clipboard, "[^a-zA-Z0-9\-\_]","-")
run, %urlDictionary%%Clipboard%
return

; ==> To send <BR> (use to insert lines breaks in notes)
^!B::
send,<BR>
return

; ==> Insert Phrasal Verb in PhrasalVerbs.txt file.
^!P::
Fill_Fields()
global VideoId
sleep, 500
send, ^c
sleep, 250

MsgBox, 4,, Do you want to insert "%Clipboard%" in PhrasalVerbs.txt? (press Yes or No)
IfMsgBox Yes
{
GuiControlGet, VideoId,,c_VideoId
VideoId := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","") ; It is necessary to clean because a strange special character

Clipboard := RegExReplace(Clipboard, "\s$","") ; It is necessary to clean space in final of the word
FileAppend, %VideoId%;%Clipboard%`n, %A_ScriptDir%\PhrasalVerbs.txt
}

MsgBox, 4,, Do you want to open PhrasalVerbs.txt? (press Yes or No)
IfMsgBox Yes
{
run, %A_ScriptDir%\PhrasalVerbs.txt
}


return

; ------------------------- End of Hotkeys ----------------------------------------------


; ------------------------- Showing tooltips -------------------------------------------

labelToolTips:

MouseGetPos, , , id, control

WinGetTitle, title, ahk_id %id%

windowtitle=Listenning Warm Up Maker

If (title=windowtitle)
{

ToolTipMensage = 
k = 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to load the last work and run the filter.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to open youtube to get a video address (copy the address).
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to insert video Id in the text area bellow.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to insert the video title in the text area bellow.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to go to a site where you can download the subtitle (.lrc).`nYou can use CTRL+ALT+Y to write video address in search box.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to move downloaded subtitle to script directory.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to backup inserted data in "InputBackup" folder.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to start filtering words.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to preview your work.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = If "Global Script" is on the page.`nYou can use theme.xml in blogger (click link at the right)
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = If "Global Script" isn't on the page.`nYou can use theme.xml in blogger (click link at the right)
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to copy only the "global code" to clipboard.`nThen you can put it in a blogger widget.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to open script folder.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to reload script.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to stop filtering, if it is taking too long to complete.`nIn the beggining it's recommended because there's a lot of contractions and others.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = 
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = 
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = 
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage =
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to sort words in JoinedList.txt (for more efficiency).
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = 
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = 
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Are you sure?`n`rThis will reset your learned words list and inputs.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to look for phrasal verbs.
}
ToolTip, %ToolTipMensage%

}
return


; ------------------------- End of Showing tooltips -------------------------------------


; Seting dictories and files

SetingScript()
{

File=%A_ScriptDir%\google-books-common-words.txt

if !FileExist(File)
{
msgbox, You must save the file "google-books-common-words.txt" in script folder.

MsgBox, 4,, Do you want to go to`nhttp://norvig.com/google-books-common-words.txt`n`rOr you want to find the file by yourself?`n`nPress 'Yes' to go to the page.
IfMsgBox Yes
{
run, http://norvig.com/google-books-common-words.txt
}

}



File=%A_ScriptDir%\backup
if !FileExist(File)
{
FileCreateDir, %A_ScriptDir%\backup
FileCreateDir, %A_ScriptDir%\Inputs Backup
FileCreateDir, %A_ScriptDir%\Subtitles

tooltip, Creating folders...
}


File=%A_ScriptDir%\Config.txt
if !FileExist(File)
{
FileAppend,1;Constante sentenças (1 or 2) - Use depend on extent of legend lines`n,%File%
FileAppend,15;word number`n,%File%
FileAppend,#a9c2d1;Div Color`n,%File%
FileAppend,https://www.collinsdictionary.com/dictionary/english/;Dictionary`n,%File%
}






File=%A_ScriptDir%\Scripts.htm
if !FileExist(File)
{

ScriptCode=
(
<script>

// Global Script - It must be on the page only one time. In blogger you can put it as a widget

var playerObject

function Inicialize(Objeto,VideoIdent,playerObject)
{

if (typeof playerObjectPrevious !== 'undefined') {
stopVideo(playerObjectPrevious);
}


      var tag = document.createElement('script');
      tag.src = "https://www.youtube.com/iframe_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

ObjetoLocal=Objeto;
VideoIdentLocal=VideoIdent;
playerObjectLocal=playerObject;

playerObjectPrevious = playerObjectLocal

setTimeout("InserirYT(ObjetoLocal,VideoIdentLocal,playerObjectLocal);",1000);
}

function InserirYT(ObjetoLocal,VideoIdentLocal,playerObjectLocal) {


  eval(playerObjectLocal + "= new YT.Player(ObjetoLocal, {height: '360', width: '640', videoId: VideoIdentLocal,})");

 }


function stopVideo(playerObjectLocal) {
eval(playerObjectLocal + ".stopVideo()");
      }



// ----------------- AWLScripts

function JumpTo(TimeSubtitle,playerObjectLocal) {


if (typeof playerObjectPrevious !== 'undefined' & playerObjectPrevious !== playerObjectLocal) {
stopVideo(playerObjectPrevious);
}

eval(playerObjectLocal + ".seekTo(TimeSubtitle)");
eval(playerObjectLocal + ".playVideo()");
}


// This will update the dictionary if it was needed
function DicUp_AWLScript(Var_AWLScript)
{
document.getElementById(Var_AWLScript).style.color='red';
}

// This will insert Ads
function awl_Ads(span_Ads)
{
document.getElementById(span_Ads).innerHTML="<BR><center><b><a href='https://listeningshortcuts.blogspot.com/p/you-can-also-contribute-in-bitcoins-if.html' target='_blank' style='text-decoration:note'>Contribute. Suggest a video (your video!)</a></b></center><BR>";
}


    </script>

<span id="AWLScriptMessage"></span>
)

FileAppend,%ScriptCode%,%File%

}


}




Mod 2
- A mode to use text from steemit.
- It doesn't work with videos no more.
- It gets the data automatic from a steemit post.

Examples:
https://postsforlazypeople.wordpress.com/
https://steemit.com/language/@nilson44/ ... -traveling

Code: Select all

global TagsSteem
global DelayVar
global FinalNumWord
global SpanColor 
global urlDictionary
global DelayVar
global WordChoice
global FileTextFinal
global CurrentFileText
global LinkSteemit
global TitleRealVideo
global HTMLWords
global DateInstance
global BlogText

; Use to identify works not related to videos
FormatTime, DateInstance, %tStr%, yyyy-MM-dd-hh-mm-tt


; This variable is related to posting words from webpages texts
HTMLWords=

SetingScript()

GetIniConfigs()

VideoId=
htmlFullCode=
Remaining=
Word=
ControlLoop := 0
FileText=
TextoInicial=

LinkSteemit=
; --------------------------- Creating the interface -----------------------------------------

Gui, font, s10, Verdana 

Gui, Add, Text, vc_CreationSteps, CREATION STEPS

Gui, Add, Button, vgButtonsActionsLastWork gButtonsActionsLastWork, 0. Load last work

Gui, Add, Button, vgButtonsActionsYT gButtonsActionsYT, 1. Choose a Youtube video

Gui, Add, Button, vgButtonsActionsInsVid gButtonsActionsInsVid, 2. Insert VideoId
Gui, Add, Edit, vc_VideoId w100 h80, After copy the youtube link, click on the 'Insert VideoId button'.

Gui, Add, Button, vgButtonsActionsInsTitle gButtonsActionsInsTitle, 3. Insert Video Title
Gui, Add, Edit, vc_VideoTitle w100 h80, After copy the video title, click on the 'Insert Video Title'.

Gui, Add, Button, vgButtonsActionsBaixarLegenda gButtonsActionsBaixarLegenda, 4. Download Subtitle

Gui, Add, Button, vgButtonsActionsMoverSRT gButtonsActionsMoverSRT, 5. Mover SRT
Gui, Add, Button, vgButtonsActionsSE gButtonsActionsSE, 6. Backup inputs
Gui, Add, Button, vgButtonsActionsFilter gButtonsActionsFilter, 7. Filter Subtitle
Gui, Add, Button, vgButtonsActionsCreate gButtonsActionsCreate, 8. PREVIEW
Gui, Add, Button, vgButtonsActionsBlog gButtonsActionsBlog, 9. Blog (without 'Global Script')
Gui, Add, Button, vgButtonsActionsBlogWS gButtonsActionsBlogWS, 9. Blog (with 'Global Script')
Gui, Add, Button, vgButtonsActionsGetGlobal gButtonsActionsGetGlobal, 10. Copy "Global Javascript"


Gui, Add, Text, ym, Script Managing
Gui, Add, Button, gButtonsActionsFolder, Script Folder
Gui, Add, Button, gButtonsActionsReload, Reload
Gui, Add, Button, gButtonsActionsStop, Stop

Gui, Add, Text, ,
Gui, Add, Text, , Information
Gui, Add, Button, gButtonsActionsHotkeys, Show Hotkeys
Gui, Add, Button, vgButtonsActionsRC gButtonsActionsRC, Readme and Credits
Gui, Add, Button, vgButtonsActionsHelp gButtonsActionsHelp, HELP
Gui, Add, Button, vgButtonsActionsHelpVideo gButtonsActionsHelpVideo, Help Video

Gui, Add, Text, ,
Gui, Add, Text, , Tools
Gui, Add, Button, gButtonsActionsSort, Sort and Backup Lists
Gui, Add, Button, vgButtonsActionsChangeInput gButtonsActionsChangeInput, Change Input Data

Gui, Add, text, cBlue gButtonsActionsLaunchBlog, 
Gui, Add, Button, vgButtonsActionsLaunchBlog gButtonsActionsLaunchBlog, Example
Gui, Add, Button, gButtonsActionsResetingScript, Reset

Gui, Add, Text, ym , 
Gui, Add, Text, , Bonus
Gui, Add, Button, gButtonsActionsPhrasal, Search Phrasal Verbs
Gui, Add, Text, vPostSteemit, Post steemit
Gui, Add, Button, vgPostSteemit, Post in Steemit
Gui, Add, Text, ,
Gui, Add, Text, , Filtering Words From a Web Page
Gui, Add, Button, gGetWebPageData, 1. Get Webpage Data
Gui, Add, Text, , Page URL
Gui, Add, Edit, vc_PageUrl w200 h80, 
Gui, Add, Text, , Article Title
Gui, Add, Edit, vc_PageTitle w200 h80,
Gui, Add, Button, gButtonsActionsFilter2, 2. Filter Subtitle
Gui, Add, Button, gPostWebpageWords, 3. Post Webpage words
Gui, Add, Text, , 
Gui, Add, Button, gButtonsActionsLaunchBlog2, Example Web Page

Gui, Add, Text, , Steemit Tags`n(use: Control+Alt+T to insert)
Gui, Add, edit, vc_SteemitTags h50 w200,

Gui, Add, Text, ym, SELECTING`n`rClick a word to add it to known words dic`n`r(or to search in dictionary)`n`rAdded words will no longer appear.
Gui, Add, ListBox, gRemovingWords vWordChoice w200 h400 Sort, |

Gui, Add, Button, gButtonsActionsEditingWords, Edit Words Instructions

Gui, Add, Text, ,
Gui, Add, Text, cBlue gLaunchModel, Click here to download`nblogger theme with the correct widths.
Gui, Add, Text, ,
Gui, Add, Button, gebook, Use ebook
Gui, Add, Button, gConvertEbook, Convert ebook

Gui, Add, Text, ym , 
Gui, Add, Text, ym , 

Gui, Add, Text, ym , Working Area`n`r`Here you will let only the chosen words`n`rIf you want you can edit/organize the list
Gui, Add, Edit, vc_Chosen w200 h300, Welcome
Gui, Add, Text, ,
Gui, Add, Text, , Remarks:`n`rHere you can write a note that will`n`rappear in the post.`nOr the credits in case of`nwords from a web page.
Gui, Add, Edit, vc_Remarks w200 h100,

Gui, Add, Text, ,
Gui, Add, Text, vc_WaitFilter w200 h20,
Gui, font, s30, Verdana 
Gui, Add, Text, vc_Progress w200 h40,

Gui, Show,, Listenning Warm Up Maker

; Hiding controls that isn't used no more
HideControls("gButtonsActionsHelpVideo,gButtonsActionsRC,gButtonsActionsHelp,c_CreationSteps,gButtonsActionsLastWork,gButtonsActionsYT,c_VideoId,gButtonsActionsInsTitle,gButtonsActionsBaixarLegenda,gButtonsActionsMoverSRT,gButtonsActionsFilter,gButtonsActionsCreate,gButtonsActionsBlog,gButtonsActionsBlogWS,gButtonsActionsGetGlobal,gButtonsActionsInsVid,c_VideoTitle,gButtonsActionsSE,gButtonsActionsChangeInput,gButtonsActionsLaunchBlog,gPostSteemit,PostSteemit")

SetTimer, labelToolTips, 500



return

; --------------------------- End Creating the interface ----------------------------------------


; ----------- This function filter the subtitle, so it will remain only uncommon words ----------
Filter()
{

GuiControl,, c_WaitFilter, Wait... The words are being filtered. Remaing Words:

global CurrentFileText
global Remaining
global ControlLoop
global FileText
global VideoId

Fill_Fields()

BackupSettingsFile()


sleep, 250
GuiControlGet, VideoId,,c_VideoId
VideoId := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","") ; It necessary to clean because a strange special character
sleep, 250


; Creating temp files, joining lists (user list + common words lists) etc.

FileDelete, %A_ScriptDir%\temp.txt

FileDelete, %A_ScriptDir%\JoinedList.txt
sleep, 150
FileCopy, %A_ScriptDir%\MyList.txt, %A_ScriptDir%\JoinedList.txt
sleep, 150
FileRead, MostCommonWords, %A_ScriptDir%\google-books-common-words.txt
sleep, 150
FileAppend, %MostCommonWords%, %A_ScriptDir%\JoinedList.txt

FileRead, TextoInicial, %A_ScriptDir%\CurrentSubtitle.txt

FileRead, FileText, %A_ScriptDir%\CurrentSubtitle.txt

FileRead, FileListString, %A_ScriptDir%\JoinedList.txt

; removing number characters from most common words list
FileListString := RegExReplace(FileListString, "\s\d*", "`n")
FileText := RegExReplace(FileText, "\d*", "")


Loop, parse, FileListString, `n, `r ; ALWAYS add `r as ignore char or it may fail
	{

if (ControlLoop = 1)
{
ControlLoop := 0

FileTextLocal := RegExReplace(FileText, "[^a-zA-Z0-9\-\']","`n")
GuiControl,, c_Chosen, %FileTextLocal%

InsertPhrasalinList()

CreateListBox(FileText)

Break
}
	FileTextMCW := A_LoopField
	if ErrorLevel
{
	
msgbox, Something went wrong!
FileTextLocal := RegExReplace(FileText, "[^a-zA-Z0-9\-\']","`n")
GuiControl,, c_Chosen, %FileTextLocal%
InsertPhrasalinList()
CreateListBox(FileText)

        break
}
	CleaningFile(FileTextMCW,FileText,0)

	}

; ----------------------- End function filter the subtitle ----------------------------


; Fill text areas if end of file was reached
if (ControlLoop = 0)
{
;msgbox, End of list was reached or user stoped the script.
GuiControl,, c_Filtered, %FileText% 


guicontrol,, WordChoice, %CurrentFileText%
stringReplace, CurrentFileTextColumn,CurrentFileText,|,`n, All
CurrentFileTextColumn := RegExReplace(CurrentFileTextColumn, "[^a-zA-Z0-9\-\']","`n")
;Sort, CurrentFileTextColumn, Random D`n
GuiControl,, c_Chosen, %CurrentFileTextColumn%


InsertPhrasalinList()
CreateListBox(FileText)
}

}

; This function remove special characters
CleaningFile(WordToChange,FileTextLocal,FimDeArquivo)
{
global FileText
global ControlLoop
global FinalNumWord

stringReplace, FileText, FileTextLocal, `n, %A_Space%, All

;remover tags html
FileText := RegExReplace(FileText, "<\s*\/\s*\w\s*.*?>|<\s*br\s*>", "")
FileText := RegExReplace(FileText, "<\s*\w.*?>", "")

stringReplace, FileText, FileText, --, , All
stringReplace, FileText, FileText, %A_Space%%A_Space%, %A_Space%, All
stringReplace, FileText, FileText, `r, %A_Space%, All
stringReplace, FileText, FileText, %A_Space%%WordToChange%%A_Space%, %A_Space%, All
stringReplace, FileText, FileText, `", , All
FileText := RegExReplace(FileText, " \d+", "")
FileText := RegExReplace(FileText, "[^a-zA-Z0-9 \-\']","")
FileText := RegExReplace(FileText, "\!","")


; Removing repeated words and sorting
stringReplace, FileText, FileText, %A_Space%, `n, All
Sort, FileText, u
stringReplace, FileText, FileText, `n, %A_Space%, All


; Counting Words

Len001 := StrLen(FileText)
FileTextTemp := RegExReplace(FileText, "\s","")
Len002 := StrLen(FileTextTemp)

Remaining := Len001 - Len002

GuiControl,, c_Progress, %Remaining%

if (Remaining<FinalNumWord or FimDeArquivo=1)
{
ControlLoop := 1
}


}
return


; Function to create script and preview
CreateScript(ChoseWords)
{
indexSentence := 1
global DelayVar
global SpanColor
formattime, FileDate, , yyyy_MM_dd_hh_mm_ss

GuiControlGet, myRemarks,,c_Remarks

myRemarks=<BR>%myRemarks%<BR>

Fill_Fields()

global VideoId
Global urlDictionary

c_ChoseLines=

FileRead, FileContents, %A_ScriptDir%/CurrentSubtitle.txt

TimeSub1=
TimeSub2=


; This was needed because in texts paragraphs are too long, but now this script is not useful for subtitles.
FileContents := RegExReplace(FileContents, "\.",".`n`r")
FileContents := RegExReplace(FileContents, "\!","!`n`r")
FileContents := RegExReplace(FileContents, "\?","?`n`r")

; Used to avoid repeated lines
ChoseLineAtualLoop1=

; Used to delete repeated line

Loop, parse, FileContents, `n, `r  ; Specifying `n prior to `r allows both Windows and Unix files to be parsed.
{

ChoseLineAtual = %A_LoopField%
SteemitLine = %A_LoopField%
; removing HTML tags
ChoseLineAtual := RegExReplace(ChoseLineAtual, "<\s*\/\s*\w\s*.*?>|<\s*br\s*>", "")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "<\s*\w.*?>", "")
ChoseLineAtualOriginal = %ChoseLineAtual%


IfInString, ChoseLineAtual, -->
{
TimeSub2=%TimeSub1%
TimeSub1=%ChoseLineAtual%
}

if (DelayVar = 2)
{
ConvertedTime:=ConvertTime(TimeSub2)
}
else
{
ConvertedTime:=ConvertTime(TimeSub1)
}

LinkVideo = <span>&nbsp;&nbsp;&nbsp;<a href="javascript:JumpTo(%ConvertedTime%,'objetoPlayer%FileDate%');" style=";text-decoration: none;">&#9658; play</a></span>

Loop, parse, ChoseWords, `n  
{

Word = %A_LoopField%

; ---------------------------------------------------------------------------------------------
; This was the only way I found to replace whole words followed by special characters. I believe there's a simpler way

stringReplace, ChoseLineAtual, ChoseLineAtual,%Word%,tempwordx,
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx ", "targettempword")
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx,", "targettempword ,")
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx.", "targettempword .")
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx:", "targettempword :")
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx!", "targettempword !")
ChoseLineAtual := RegExReplace(ChoseLineAtual, " tempwordx?", "targettempword ?")

ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx ", "targettempword ")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx,", "targettempword ,")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx.", "targettempword .")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx:", "targettempword :")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx!", "targettempword !")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "^tempwordx?", "targettempword ?")

; ---------------------------------------------------------------------------------------------


stringReplace, ChoseLineAtual, ChoseLineAtual,tempwordx, %Word%,

IfInString, ChoseLineAtual, targettempword
{

if (ChoseLineAtualOriginal = ChoseLineAtualLoop1)
{
c_ChoseLines := RegExReplace(c_ChoseLines, "^.+RepetitionVerification.<br><br>","")
}


c_ChoseLines := RegExReplace(c_ChoseLines, "RepetitionVerification","")



ChoseLineAtualLoop1 := ChoseLineAtualOriginal

; This will remove middle word in phrasal verbs (it is needed to search the words on dictionary)
WordDic := RegExReplace(Word, "\s.*\s", "+")
WordDic := RegExReplace(WordDic, "\s", "+") ; recent changed


Link=<span><a id="awl_%FileDate%_%ConvertedTime%" eventAWL="DicUp_AWLScript('awl_%FileDate%_%ConvertedTime%');" href="%urlDictionary%%WordDic%" target="_blank" Alt="Search in dictionary">%Word%</a></span>





stringReplace, ChoseLineAtual, ChoseLineAtual,targettempword,%A_Space%%Link%%A_Space%

; ---------------------------------------------------------------------------------------------
; removing extra spaces caused by script to remove whole words

ChoseLineAtual := RegExReplace(ChoseLineAtual, "\s\,", ",")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "\s\.", ".")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "\s\:", ":")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "\s\!", "!")
ChoseLineAtual := RegExReplace(ChoseLineAtual, "\s\?", "?")
; ---------------------------------------------------------------------------------------------


; If there's webpage title then will be used HTMLWords code
GuiControlGet, PageTitle,,c_PageTitle
if PageTitle 
{
; not using indexSentence, because there's always something to delete
c_ChoseLines = %Space% - "%ChoseLineAtual% RepetitionVerification"<br><br>`n%c_ChoseLines%`n
indexSentence := indexSentence + 1
}
else
{
c_ChoseLines = %c_ChoseLines%`n%Space%"%ChoseLineAtual%"%LinkVideo%<br><br>`n
}

; This variable is related to posting words from webpages texts
HTMLWords = %c_ChoseLines%


FileDelete, %A_ScriptDir%\Preview.htm
FileCopy, %A_ScriptDir%\Scripts.htm, %A_ScriptDir%\Preview.htm

;-----------------------------------------------------------------------------------------
; Creating HTML

Message=<br><span  id="Message%FileDate%" onclick="this.innerHTML='Load the Video. And, once the video has started, you can click on the links to go to dictionary, and on play to hear the words in the video context.'" style="color:#444;border:1px solid #CCC;background:#DDD;box-shadow: 0 0 5px -1px rgba(0,0,0,0.2);cursor:pointer;vertical-align:middle;max-width: 100px;padding: 5px;text-align: center;">How to listen</span><br><br>

LinkStartVideo=<div id='player%FileDate%' style="height:360px; width:640px; background:%SpanColor%;text-align:center;"><b><div onclick="Inicialize('player%FileDate%','%VideoId%','objetoPlayer%FileDate%');" onmouseover="Inicialize('player%FileDate%','%VideoId%','objetoPlayer%FileDate%');" style="height:360px; width:640px; background:%SpanColor%;text-align:center;color:blue"><BR><BR><BR><BR><BR><BR>LOAD VIDEO</div></b></div><span id="ads_%FileDate%"><script>awl_Ads('ads_%FileDate%');</script></span>

Corpo=<br><span style="font-style:verdana; font-size:10px; text-align:justify">List generated by <a href="https://listeningshortcuts.blogspot.com/p/about-listening-shortcut-autohotkey.html" target="_Blank">LSAScreator</a></span><br><br>%c_ChoseLines%`n`<br>

htmlFullCode=<span style="font-style:verdana; font-size:15px; text-align:justify">%myRemarks%%Message%<table><tbody><tr><td>%LinkStartVideo%</td><td>%Corpo%</td></tr></tbody></table><center><br><br><a href="javascript:stopVideo('objetoPlayer%FileDate%');" style=";text-decoration: none;">Stop the Video</a></span> - <a href="javascript:JumpTo(0,'objetoPlayer%FileDate%');" style=";text-decoration: none;">Restart the Video (to watch it completely)</a></center>

htmlFullCode := RegExReplace(htmlFullCode, "eventAWL", "onmouseover")


; If there's webpage title then will be used HTMLWords code
GuiControlGet, PageTitle,,c_PageTitle

if PageTitle 
{
GuiControlGet, PageTitle,,c_PageTitle
GuiControlGet, PageUrl,,c_PageUrl
GuiControlGet, RemarksText,,c_Remarks


LinkWebPage = Read the text: %PageUrl%

CreatedBy = Created by 

HTMLWords := RegExReplace(HTMLWords, "<a", "<b><a")
HTMLWords := RegExReplace(HTMLWords, "</a>", "</a></b>")

LinkSourceText = %BlogText%<i><a href="%PageUrl%" target="_Blank">%PageTitle% (read on Steemit)</a></i>

; (Tip: use right mouse click to open the dictionary links in a new tab. So, you can stay in this page.)
;https://steemit.com/language/@nilson44/sttpscript-straight-to-the-point-script-a-learning-english-autohotkey-script

LinkSobre = <a href="https://postsforlazypeople.wordpress.com/2018/11/26/about-the-sttpscript/">Created with SttPscript</a>


htmlFullCode = <div style="align: justify">%LinkSobre%<br><br>%LinkSourceText%<br><br>%HTMLWords%<br>%RemarksText%<br></div>

Clipboard := RegExReplace(Clipboard, "RepetitionVerification","")
Clipboard := htmlFullCode
}


FileAppend, %htmlFullCode%, %A_ScriptDir%\Preview.htm



; Creating link to steemit
GuiControlGet, TitleRealVideo,,c_VideoTitle

stringReplace, SteemitLine,SteemitLine,%Word%,<a href="%urlDictionary%%WordDic%">%Word%</a>, All

LinkSteemit = %LinkSteemit%`n`r"%SteemitLine%" <a href="https://youtu.be/%VideoId%?t=%ConvertedTime%">Play</a>

}


}


}




run, %A_ScriptDir%\Preview.htm

}


ConvertTime(SubtitleTime)
{
SubtitleTime := RegExReplace(SubtitleTime, "\,\d\d\d$", "")
SubtitleTime := RegExReplace(SubtitleTime, " \-\-\> \d\d\:\d\d\:\d\d$", "")
SubtitleTime := RegExReplace(SubtitleTime, "\,\d\d\d$", "")

HoursSub := RegExReplace(SubtitleTime, ":.+", "")
MinSub := RegExReplace(SubtitleTime, "^\d\d:", "")
MinSub := RegExReplace(MinSub, ":\d\d$", "")
SecSub := RegExReplace(SubtitleTime, ".+:", "")
SubtitleTime = %HoursSub% %MinSub% %SecSub% - %SubtitleTime%


TotalSeconds := (SecSub + 60*MinSub + HoursSub*60*60)

Return TotalSeconds

}



SortLists()
{
formattime, FileDate, , yyyy-MM-dd-hh-mm-ss

FileRead, OutputVar, %A_ScriptDir%\MyList.txt

Sort, OutputVar, u

FileMove, %A_ScriptDir%\MyList.txt, %A_ScriptDir%\backup\%FileDate% - MyList.txt
sleep, 250
FileAppend, %OutputVar%,%A_ScriptDir%\MyList.txt
}


StopFilter()
{
global ControlLoop
ControlLoop := 1
}


Fill_Fields3()
{
FileRead, UserInputs, %A_ScriptDir%/UserInputs2.txt

  Loop, parse, UserInputs, `n
    {
	if (A_Index = 1)
	   GuiControl,, c_PageUrl, %A_LoopField%
	
	if (A_Index = 2)
	   GuiControl,, c_PageTitle, %A_LoopField%
    }
}

Fill_Fields()
{
FileRead, UserInputs, %A_ScriptDir%/UserInputs.txt

  Loop, parse, UserInputs, `n
    {
	if (A_Index = 1)
	   GuiControl,, c_VideoId, %A_LoopField%
	
	if (A_Index = 2)
	   GuiControl,, c_VideoTitle, %A_LoopField%
    }
}


GetIniConfigs()
{
global DelayVar
global FinalNumWord
global urlDictionary

FileRead, UserInputs, %A_ScriptDir%/Config.txt

  Loop, parse, UserInputs, `n
    {
	if (A_Index = 1)
	DelayVar := RegExReplace(A_LoopField, ";.+", "")
	
	if (A_Index = 2)
	FinalNumWord := RegExReplace(A_LoopField, ";.+", "")

	if (A_Index = 3)
	SpanColor := RegExReplace(A_LoopField, ";.+", "")

	if (A_Index = 4)
	urlDictionary := RegExReplace(A_LoopField, ";.+", "")

	if (A_Index = 5)
	BlogText := RegExReplace(A_LoopField, ";.+", "")
    }

}

BackupSettingsFile()
{
GuiControlGet, VideoId,,c_VideoId
VideoIdFN := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","")
; VideoIdFN := RegExReplace(VideoId, " ","")
GuiControlGet, TitleRealVideo,,c_VideoTitle
TitleRealVideoFN := RegExReplace(TitleRealVideo, "\W","")

sleep, 250


GuiControlGet, PageUrl,,c_PageUrl
if PageUrl = ""
{
FileCopy, %A_ScriptDir%/UserInputs.txt, %A_ScriptDir%/Inputs Backup/%TitleRealVideoFN% - %VideoIdFN%.txt
}

}



CreateListBox(FileTextFinal)
{
global CurrentFileText

CurrentFileText = %FileTextFinal%

stringReplace, FileTextFinal, FileTextFinal,%A_Space%,|, All

Gui, font, s10, Verdana 
guicontrol,, WordChoice, %FileTextFinal%
}



InsertPhrasalinList()
{
global VideoId
CurrentPhrasalChoice=

GuiControlGet, VideoId,,c_VideoId
VideoId := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","") ; It necessary to clean because a strange special character

FileRead, FileContents, %A_ScriptDir%/PhrasalVerbs.txt

Loop, parse, FileContents, `n, `r  ; Specifying `n prior to `r allows both Windows and Unix files to be parsed.
{
stringReplace, ChonsenPhrasalVerb, A_LoopField, %VideoId%;,, All

if (ChonsenPhrasalVerb<>A_LoopField)
{
CurrentPhrasalChoice = %ChonsenPhrasalVerb%`n%CurrentPhrasalChoice%
}
}

; msgbox Phrasal verbs inserted:`n`n%CurrentPhrasalChoice%

GuiControlGet, CurrentWordChoice,,c_Chosen
FileTextLocalSum = %CurrentPhrasalChoice%`n%CurrentWordChoice%
FileTextLocalSum := RegExReplace(FileTextLocalSum, "`n`n","`n")
GuiControl,, c_Chosen, %FileTextLocalSum%
}



; ------------ Button Actions --------------------------------

ConvertEbook:

; This is used to replace. ? ! by line breaks

FileSelectFile, SelectedFile, 3, %A_ScriptDir%\Subtitles\Chose a file.txt , Open a file, Subtitle Documents (*.txt)
TempEbookFile = %A_ScriptDir%\Subtitles\TempEbookFile.txt

if SelectedFile =
{
    MsgBox, You must select a .txt file!
}
else
{

LineNumber := 0

Loop
{
LineNumber := LineNumber + 1

FileReadLine, LineText, %SelectedFile%, %LineNumber%

if ErrorLevel
{
Msgbox, File created!
Break
}

LineText := RegExReplace(LineText, "\.",".`n`r")
LineText := RegExReplace(LineText, "\!","!`n`r")
LineText := RegExReplace(LineText, "\?","?`n`r")

FileAppend, %LineText%, %TempEbookFile%

}

; Delete the old file
FileDelete, %SelectedFile%

sleep, 1000

;Rename the remaining file
FileMove, %TempEbookFile%, %SelectedFile%


}

return

ebook:

; This is used to work only with part of the ebook

CurrentSubtitleFile = %A_ScriptDir%\CurrentSubtitle.txt
TempEbookFile = %A_ScriptDir%\Subtitles\TempEbookFile.txt

FileDelete, %CurrentSubtitleFile%

FileSelectFile, SelectedFile, 3, %A_ScriptDir%\Subtitles\Chose a file.txt , Open a file, Subtitle Documents (*.txt)


if SelectedFile =
{
    MsgBox, You must select a .txt file!
}
else
{

LineNumber := 0

Loop
{
LineNumber := LineNumber + 1

FileReadLine, LineText, %SelectedFile%, %LineNumber%

if ErrorLevel
{
Msgbox, File created!
Break
}

    if (LineNumber<20)
        {
	FileAppend, %LineText%`n`r, %CurrentSubtitleFile%
	}
	else
	{
	FileAppend, %LineText%`n`r, %TempEbookFile%
	}

}

; Delete the old file

FileDelete, %SelectedFile%

sleep, 1000

; Rename the remaining file
FileMove, %TempEbookFile%, %SelectedFile%


SplitPath, SelectedFile , eBookFileName

GuiControl,, c_PageTitle, %eBookFileName%

GuiControl,, c_PageUrl, https://www.google.com.br/search?q=%eBookFileName%

}

return

GetWebPageData:
run, https://steemit.com/created/
GuiControl,, c_VideoID,NoVideo%DateInstance%
GuiControl,, c_VideoTitle,NoVideo%DateInstance%

Gui, Minimize
sleep, 500

Clipboard=
ShowMessage("Copy the URL of the desired post.",5000)
Clipwait
PageUrl := Clipboard

Gui, Restore
sleep, 250

GuiControl,, c_PageUrl, %PageUrl% 


; ------------------- Getting other post contents -------------------------

; Creates an Internet Explore COM object

GuiControl,, c_PageTitle, Aguarde...
ie	:= ComObjCreate("InternetExplorer.Application")

; Navigate to a website
; In this example, I've used this post's address
ie.navigate(PageUrl)

; This ensures the webpage completely loads before doing anything else
while ie.ReadyState != 4
	Sleep, 100

; Shows the actual internet explorer window
ie.visible	:= true

; By looking up the element that contains your votes in the html, I see it's in a span with a class name of "number".
; getElementByClassName() returns a node list. It's like an array.
; [0] is the first item in the node list.
; innertext is the actual value of the span tag.
; This is saved to the FileContents variable


htmlTagsFull := ie.document.getElementsByClassName("TagList__horizontal")[0].innerHTML

TagsSteem := RegExReplace(htmlTagsFull, "<.+?>", ",")
TagsSteem := RegExReplace(TagsSteem, "\s", "")
TagsSteem := RegExReplace(TagsSteem, ",+", ",")
TagsSteem := RegExReplace(TagsSteem, "^,", "")
TagsSteem := RegExReplace(TagsSteem, ",$", "")

GuiControl,, c_SteemitTags, %TagsSteem% 

PageTitle := ie.document.getElementsByTagName("title")[0].innerHTML

PageTitle := RegExReplace(PageTitle, "— Steemit" , "")

GuiControl,, c_PageTitle, %PageTitle% 

FileContents := ie.document.getElementsByClassName("PostFull__body entry-content")[0].innerHTML

FileContents := RegExReplace(FileContents, "<.+?>" , "")

FileContents := RegExReplace(FileContents, "\&nbsp;" , " ")

fileDelete, %A_ScriptDir%/CurrentSubtitle.txt
sleep, 500
FileAppend, %FileContents%, %A_ScriptDir%/CurrentSubtitle.txt,UTF-8

; Quits out of the application.
; Always inclue a quit or you'll have leftover executables running in the background.

ie.quit

; ------------------- End of Getting other post contents -------------------------

; Updating inputs
filedelete, %A_ScriptDir%/UserInputs2.txt
sleep,1000
fileAppend,%PageUrl%`n`r%PageTitle%,%A_ScriptDir%/UserInputs2.txt


return


PostWebpageWords:

Fill_Fields3()

GuiControlGet, ChoseWords,,c_Chosen
CreateScript(ChoseWords)

Clipboard := RegExReplace(Clipboard , "<span>", "")

Clipboard := RegExReplace(Clipboard , "</span>", "")

; run, https://steemit.com/submit.html
; https://wordpress.com/post/postsforlazypeople.wordpress.com

ShowMessage("The post html code was copied to clipboard.`nNow, you can go to your blog and paste it in html code editor.",0)

return



PostSteemit:

run, https://steemit.com/submit.html

PostKeyWord := StrReplace(TitleRealVideo, A_Space, "")
StringLower, PostKeyWord, PostKeyWord

TitleSteemit = Listening Warming Up - %TitleRealVideo% - Lesson 

tooltip, Click in posting box and past the content

Clipboard =%TitleSteemit%`n - This is a post for English Students, it's a "warming up" for a listening practice.`n - These are some words which I didn't know on the this video.`n - You can open the links on a new tab to listen to the sentences (Play) or to see the words meaning (Word link).`n`r%LinkSteemit%`n`r<i>Created by Autohotkey Warming Up Listening Script <a href="https://autohotkey.com/boards/viewtopic.php?f=6&t=58138">Script Code</a></i>`n`r`n`r%PostKeyWord%

return


guiClose:
MsgBox, 4,, Do you really want to exit? (press Yes or No)
IfMsgBox Yes
{
   exitapp
}
return

LaunchModel:
FileDelete, %A_ScriptDir%/BloggerTheme.xml
run, https://listeningshortcuts.blogspot.com/p/downloads.html
clipboard=
tooltip, Aguarde o carregamento da página e copie o código da área de texto.
clipwait
FileAppend, %Clipboard%, %A_ScriptDir%/BloggerTheme.xml
run, %A_ScriptDir%
tooltip, Foi gerado o arquivo BloggerTheme.xls que você pode importar para o seu blog.
sleep, 5000
tooltip
return

ButtonsActionsEditingWords:

run, https://listeningshortcuts.blogspot.com/p/edit-instructions.html

return


ButtonsActionsGetGlobal:

FileRead, GlobalScript, %A_ScriptDir%\Scripts.htm
Clipboard = %GlobalScript%

msgbox, "Global Script" was copied, now you must put it as a Widget on blog.

return


ButtonsActionsLaunchBlog:

run, https://listeningshortcuts.blogspot.com/

return

ButtonsActionsLaunchBlog2:

run, https://postsforlazypeople.wordpress.com/

return


ButtonsActionsResetingScript:

MsgBox, 4,, Do you really want to reset all? (press Yes or No)
IfMsgBox Yes
{
FileDelete, %A_ScriptDir%/CurrentSubtitle.txt
FileDelete, %A_ScriptDir%/JoinedList.txt
FileDelete, %A_ScriptDir%/MyList.txt
FileDelete, %A_ScriptDir%/PhrasalVerbs.txt
FileDelete, %A_ScriptDir%/UserInputs.txt
FileDelete, %A_ScriptDir%/Config.txt
FileDelete, %A_ScriptDir%/UserInputs2.txt
}
return

return

ButtonsActionsYT:

GuiControl,, c_VideoId,
GuiControl,, c_VideoTitle,

run, http://youtube.com
return

ButtonsActionsLastWork:

File=%A_ScriptDir%\UserInputs.txt
if !FileExist(File)
{
msgbox, There's no previous work.
}

Filter()
Fill_Fields()
return

ButtonsActionsRC:

run, https://listeningshortcuts.blogspot.com/p/readme.html

; FileRead, Readmetext, %A_ScriptDir%\Read-me and Credits.txt
; GuiControl,, c_Filtered, %Readmetext% 

return


ButtonsActionsHelp:
run, https://listeningshortcuts.blogspot.com/p/help.html
Return


ButtonsActionsBaixarLegenda:

GuiControlGet, VideoId,,c_VideoId
VideoId := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","") ; It necessary to clean because a strange special character
sleep, 500

MsgBox, 4,, Open http://www.lilsubs.com/? (press Yes or No)`n`nIn www.lilsubs.com`, select the "search box" and press CTRL+ALT+Y to insert video URL
IfMsgBox Yes
{
run, http://www.lilsubs.com/

tooltip, In www.lilsubs.com`, select the "search box" and press CTRL+ALT+Y to insert video URL

sleep, 10000
tooltip, In www.lilsubs.com`, select the "search box" and press CTRL+ALT+Y to insert video URL
sleep, 15000

tooltip,
}

return

; hotkey to fill subtitle search box
^!y::
send, https://www.youtube.com/watch?v=%VideoId%
send,{enter}
return

ButtonsActionsHotkeys:
; Find all hotkeys and show them

LinhaAnterior=
ListaAtalhos=

Loop Files, %A_ScriptDir%\*.ahk, R  ; R => Recurse into subfolders.
{

Loop, read, %A_LoopFileFullPath%
{
contadorhotkeysshow := 1
    Loop, parse, A_LoopReadLine, %A_Tab%
    {
    	LinhaAtual := A_LoopReadLine


        Marcador=`=`=`>
        IfInString, LinhaAnterior, %Marcador%
        {
	ListaAtalhos = %ListaAtalhos%`n%LinhaAnterior%: %LinhaAtual%
	
	StringReplace, ListaAtalhos, ListaAtalhos,`!,%A_Space%ALT%A_Space%, All
	StringReplace, ListaAtalhos, ListaAtalhos,`^,%A_Space%CTRL%A_Space%, All
	StringReplace, ListaAtalhos, ListaAtalhos,`#,%A_Space%WIN%A_Space%, All
	StringReplace, ListaAtalhos, ListaAtalhos,`+,%A_Space%SHIFT%A_Space%, All

	StringReplace, ListaAtalhos, ListaAtalhos,`;,, All
	StringReplace, ListaAtalhos, ListaAtalhos ,--`>,, All
        StringReplace, ListaAtalhos, ListaAtalhos,`:`:,, All
	
        }

    LinhaAnterior = %A_LoopField%
    }
}

}

Sort, ListaAtalhos

ListaAtalhos := RegExReplace(ListaAtalhos, "`n","`n`n")

msgbox, %ListaAtalhos%

Return



ButtonsActionsFolder:
Run, %A_ScriptDir%
Return



ButtonsActionsFilter:

File=%A_ScriptDir%\CurrentSubtitle.txt
if !FileExist(File)
{
msgbox, You didn't downloaded any subtitle!
}

Filter()
Return


ButtonsActionsFilter2:

Fill_Fields3()

File=%A_ScriptDir%\CurrentSubtitle.txt
if !FileExist(File)
{
msgbox, You didn't downloaded any subtitle!
}

fileDelete, %A_ScriptDir%/UserInputs.txt

fileAppend,NoVideo%DateInstance%`n`rNoVideo%DateInstance%,%A_ScriptDir%/UserInputs.txt

Filter()

Return

ButtonsActionsCreate:
GuiControlGet, ChoseWords,,c_Chosen
CreateScript(ChoseWords)
Return


ButtonsActionsStop:
StopFilter()
Return



ButtonsActionsSort:
SortLists()
Return



ButtonsActionsReload:
Reload
Return


ButtonsActionsBlog:

global htmlFullCode

Loop Files, %A_ScriptDir%\Subtitles\*.*, R  ; Recurse into subfolders.
{
NumberOfPosts=%A_Index%
}


stringReplace, htmlFullCode, htmlFullCode, `n, , All  ; Removing line breaks

htmlFullCode := RegExReplace(htmlFullCode, "RepetitionVerification","")
Clipboard=%htmlFullCode%

GuiControlGet, TitleRealVideo,,c_VideoTitle
TitleRealVideo := RegExReplace(TitleRealVideo, " \s", "+")

MsgBox, 4,, Code copied to clipboard! Do you want go to blogger?
IfMsgBox Yes
{
run, https://www.blogger.com/blog-this.g?n=%TitleRealVideo%+(Very+Fast-Listening+%NumberOfPosts%)
}

return


ButtonsActionsBlogWS:

global htmlFullCode

FileRead, GlobalScript, %A_ScriptDir%\Scripts.htm

Loop Files, %A_ScriptDir%\Subtitles\*.*, R  ; Recurse into subfolders.
{
NumberOfPosts=%A_Index%
}


stringReplace, htmlFullCode, htmlFullCode, `n, , All  ; Removing line breaks


Clipboard=%GlobalScript%`n`r`n`r`n`r`n`r%htmlFullCode%

GuiControlGet, TitleRealVideo,,c_VideoTitle
TitleRealVideo := RegExReplace(TitleRealVideo, " \s", "+")


MsgBox, 4,, Code copied to clipboard! Do you want go to blogger?
IfMsgBox Yes
{
run, https://www.blogger.com/blog-this.g?n=%TitleRealVideo%+(Very+Fast-Listening+%NumberOfPosts%)
}

return



ButtonsActionsInsVid:

msgbox, If you copied the address from browser address bar,`nThe code that must appear is that which follows 'watch?v='`nSometimes the filter doesn't work!

ClipboardVid := RegExReplace(Clipboard, "^h.*watch\?v\=", "")
ClipboardVid := RegExReplace(ClipboardVid, "&.*$", "")
GuiControl,, c_VideoId, %ClipboardVid% 

Return



ButtonsActionsInsTitle:
ClipboardVid := RegExReplace(Clipboard, "[^a-zA-Z0-9 \-\_]","")
GuiControl,, c_VideoTitle, %ClipboardVid% 
Return



ButtonsActionsSE:

GuiControlGet, VideoId,,c_VideoId
;VideoId := RegExReplace(VideoId, " ","")
VideoId := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","") ; It necessary to clean because a strange special character

GuiControlGet, TitleRealVideo,,c_VideoTitle

; Dados editados para inputuser.txt
FileDelete, %A_ScriptDir%/UserInputs.txt

FileAppend, %VideoId%`n, %A_ScriptDir%/UserInputs.txt
FileAppend, %TitleRealVideo%, %A_ScriptDir%/UserInputs.txt

sleep, 250
BackupSettingsFile()

Return



ButtonsActionsPhrasal:

PrepositionsList = up,down,uppon,after,around,on,over,down,behind,out,into,apart,forward,from,off,away,along,back,ahead,onto,up with,against

Sort, PrepositionsList, U D,
;Sort, PrepositionsList, Random D,

stringReplace, PrepositionsList, PrepositionsList, `,, `n, All


CreateScript(PrepositionsList)
Return



ButtonsActionsMoverSRT:

FileSelectFile, SelectedFile, 3, , Open a file, Subtitle Documents (*.srt)

; Moving chosen input file to script folder
if SelectedFile =
{
    MsgBox, You must select a .SRT file
}
else
{
	FileCopy, %SelectedFile%, %A_ScriptDir%\CurrentSubtitle.txt,1
	FileMove, %SelectedFile%, %A_ScriptDir%\Subtitles\
}
return


; Changes the current input data
ButtonsActionsChangeInput:

FileSelectFile, SelectedFile, 3, %A_ScriptDir%\Inputs Backup\Chose a file.txt , Open a file, Subtitle Documents (*.txt)


; Moving chosen subtitle to script folder
if SelectedFile =
    MsgBox, You must select a input file to become current.
else
{
FileCopy, %SelectedFile%, %A_ScriptDir%/UserInputs.txt, 1
}


FileSelectFile, SelectedFile, 3, %A_ScriptDir%\Subtitles\Chose a file.txt , Open a file, Subtitle Documents (*.srt)


if SelectedFile =
{
    MsgBox, You must select a .SRT file
}
else
{
	FileCopy, %SelectedFile%, %A_ScriptDir%\CurrentSubtitle.txt,1
}


msgbox, Now you need to press "Load last work" button.

return

ButtonsActionsHelpVideo:

msgbox, Soon it will be available.

return



RemovingWords:

GuiControlGet, WordChoice,,WordChoice

MsgBox, 4,, Insert "%WordChoice%" in known words file?`n`r`n`rPressing 'No'`, it'll be searched in dictionary.

IfMsgBox Yes
{
FileAppend, %WordChoice%`n,%A_ScriptDir%\MyList.txt

stringReplace, CurrentFileText, CurrentFileText,%A_Space%,|, All

CurrentFileText = |%CurrentFileText%|

stringReplace, CurrentFileText, CurrentFileText,|%WordChoice%|,|, All

CurrentFileText := RegExReplace(CurrentFileText, "^\|","")
CurrentFileText := RegExReplace(CurrentFileText, "\|$","")


CurrentFileTextColumn := RegExReplace(CurrentFileText, "[^a-zA-Z0-9\-\']","`n")

guicontrol,, WordChoice, |
guicontrol,, WordChoice, %CurrentFileText%

GuiControl,, c_Chosen,
GuiControl,, c_Chosen, %CurrentFileTextColumn%


InsertPhrasalinList()
}

IfMsgBox No
{
GuiControlGet, WordChoice,,WordChoice
stringReplace, WordChoice, WordChoice, %Space%, ,+
run, %urlDictionary%%WordChoice%
}

return

; ------------------------ End of Button action -----------------------



; ------------------------ Hotkeys -----------------------

;  ==> Inserir tags do Steemit
^!T::
GuiControlGet, SteemitTags,,c_SteemitTags
send, %SteemitTags%
return

;  ==> Comment on steemit about using a post
^!C::
Clipboard=
ShowMessage("Copy your post url.",2000)
Clipwait
ShowMessage("Select the comment box and past the message.",2000)
Clipboard = Your post was used by SttPscript to filter some new English words to a daily lesson => %Clipboard%
return


; ==> Search on dictionary the selected word.
^!D::
sleep, 250
send, ^c
sleep, 500
Clipboard := RegExReplace(Clipboard, "[^a-zA-Z0-9\-\_]","+")
run, %urlDictionary%%Clipboard%
return

; ==> To send <BR> (use to insert lines breaks in Remarks)
^!B::
send,<BR>
return

; ==> Insert Phrasal Verb in PhrasalVerbs.txt file.
^!P::
Fill_Fields()
global VideoId
sleep, 500
send, ^c
sleep, 250

MsgBox, 4,, Do you want to insert "%Clipboard%" in PhrasalVerbs.txt? (press Yes or No)
IfMsgBox Yes
{
GuiControlGet, VideoId,,c_VideoId
VideoId := RegExReplace(VideoId, "[^a-zA-Z0-9\-\_]","") ; It is necessary to clean because a strange special character

Clipboard := RegExReplace(Clipboard, "\s$","") ; It is necessary to clean space in final of the word
FileAppend, %VideoId%;%Clipboard%`n, %A_ScriptDir%\PhrasalVerbs.txt
}

MsgBox, 4,, Do you want to open PhrasalVerbs.txt? (press Yes or No)
IfMsgBox Yes
{
run, %A_ScriptDir%\PhrasalVerbs.txt
}


return

; ------------------------- End of Hotkeys ----------------------------------------------


; ------------------------- Showing tooltips -------------------------------------------

labelToolTips:

MouseGetPos, , , id, control

WinGetTitle, title, ahk_id %id%

windowtitle=Listenning Warm Up Maker

If (title=windowtitle)
{

ToolTipMensage = 
k = 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to load the last work and run the filter.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to open youtube to get a video address (copy the address).
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to insert video Id in the text area bellow.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to insert the video title in the text area bellow.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to go to a site where you can download the subtitle (.lrc).`nYou can use CTRL+ALT+Y to write video address in search box.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to move downloaded subtitle to script directory.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to backup inserted data in "InputBackup" folder.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to start filtering words.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to preview your work.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = If "Global Script" is on the page.`nYou can use theme.xml in blogger (click link at the right)
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = If "Global Script" isn't on the page.`nYou can use theme.xml in blogger (click link at the right)
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to copy only the "global code" to clipboard.`nThen you can put it in a blogger widget.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to open script folder.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to reload script.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to stop filtering, if it is taking too long to complete.`nIn the beggining it's recommended because there's a lot of contractions and others.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = 
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = 
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = 
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage =
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to sort words in JoinedList.txt (for more efficiency).
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = 
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = 
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Are you sure?`n`rThis will reset your learned words list and inputs.
}
k := k + 1
CurrentButton = Button%k%
if (control=CurrentButton)
{
ToolTipMensage = Click to look for phrasal verbs.
}
ToolTip, %ToolTipMensage%

}
return


; ------------------------- End of Showing tooltips -------------------------------------


; Seting dictories and files

SetingScript()
{

File=%A_ScriptDir%\google-books-common-words.txt

if !FileExist(File)
{
msgbox, You must save the file "google-books-common-words.txt" in script folder.

MsgBox, 4,, Do you want to go to`nhttp://norvig.com/google-books-common-words.txt`n`rOr you want to find the file by yourself?`n`nPress 'Yes' to go to the page.
IfMsgBox Yes
{
run, http://norvig.com/google-books-common-words.txt
}

}



File=%A_ScriptDir%\backup
if !FileExist(File)
{
FileCreateDir, %A_ScriptDir%\backup
FileCreateDir, %A_ScriptDir%\Inputs Backup
FileCreateDir, %A_ScriptDir%\Subtitles

tooltip, Creating folders...
}


File=%A_ScriptDir%\Config.txt
if !FileExist(File)
{
FileAppend,1;Constante sentenças (1 or 2) - Use depend on extent of legend lines`n,%File%
FileAppend,15;word number`n,%File%
FileAppend,#a9c2d1;Div Color`n,%File%
FileAppend,https://collinsdictionary.com/dictionary/english/`n,%File%
FileAppend,These are the sentences with words that I didn't know the meaning`, the pronunciation or some other issue. Sentences source:;Default text`n,%File%
}






File=%A_ScriptDir%\Scripts.htm
if !FileExist(File)
{

ScriptCode=
(
<script>

// Global Script - It must be on the page only one time. In blogger you can put it as a widget

var playerObject

function Inicialize(Objeto,VideoIdent,playerObject)
{

if (typeof playerObjectPrevious !== 'undefined') {
stopVideo(playerObjectPrevious);
}


      var tag = document.createElement('script');
      tag.src = "https://www.youtube.com/iframe_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

ObjetoLocal=Objeto;
VideoIdentLocal=VideoIdent;
playerObjectLocal=playerObject;

playerObjectPrevious = playerObjectLocal

setTimeout("InserirYT(ObjetoLocal,VideoIdentLocal,playerObjectLocal);",1000);
}

function InserirYT(ObjetoLocal,VideoIdentLocal,playerObjectLocal) {


  eval(playerObjectLocal + "= new YT.Player(ObjetoLocal, {height: '360', width: '640', videoId: VideoIdentLocal,})");

 }


function stopVideo(playerObjectLocal) {
eval(playerObjectLocal + ".stopVideo()");
      }



// ----------------- AWLScripts

function JumpTo(TimeSubtitle,playerObjectLocal) {


if (typeof playerObjectPrevious !== 'undefined' & playerObjectPrevious !== playerObjectLocal) {
stopVideo(playerObjectPrevious);
}

eval(playerObjectLocal + ".seekTo(TimeSubtitle)");
eval(playerObjectLocal + ".playVideo()");
}


// This will update the dictionary if it was needed
function DicUp_AWLScript(Var_AWLScript)
{
document.getElementById(Var_AWLScript).style.color='red';
}

// This will insert Ads
function awl_Ads(span_Ads)
{
document.getElementById(span_Ads).innerHTML="<BR><center><b><a href='https://listeningshortcuts.blogspot.com/p/you-can-also-contribute-in-bitcoins-if.html' target='_blank' style='text-decoration:note'>Contribute. Suggest a video (your video!)</a></b></center><BR>";
}


    </script>

<span id="AWLScriptMessage"></span>
)

FileAppend,%ScriptCode%,%File%

}


}



ShowMessage(ScreenMessage,MessageTime)
{
Progress, m2 b fs11 zh0,  %ScreenMessage%

if (MessageTime>0){
sleep, %MessageTime%
}
else {
KeyWait, LButton, D
}

Progress, Off

}


HideControls(ControlsToHide)
{

Loop, parse, ControlsToHide, `, 
{
GuiControl, Hide, %A_LoopField%
}

}

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: furqan and 80 guests