Compare commits

..

14 Commits

11 changed files with 246 additions and 22 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
Chromedriver-Mover.exe

View File

@@ -1,10 +1,13 @@
;---FUNCTIONS----------------------------------------------------------------------- ;---FUNCTIONS-----------------------------------------------------------------------
; Misc Functions that are called by both the Video and Social Media poster ; Misc Functions that are called by both the Video and Social Media poster
; -------------------------------Discord------------------------------- ; -------------------------------Discord-------------------------------
PostToDiscordChannel(Message,WebhookChannel){ PostToDiscordChannel(Message,WebhookChannel){
; Don't try to post a message if there is no webhook url
if(WebhookChannel = "")
Return
; Msgbox % "Message: " Message ; Msgbox % "Message: " Message
; Msgbox % "WebhookChannel: " WebhookChannel ; Msgbox % "WebhookChannel: " WebhookChannel
@@ -28,8 +31,6 @@ PostToDiscordChannel(Message,WebhookChannel){
} }
) )
; Msgbox % "JsonString: " JsonString
;
try WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1") try WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
try WebRequest.Open("POST", WebhookChannel, false) try WebRequest.Open("POST", WebhookChannel, false)
try WebRequest.SetRequestHeader("Content-Type", "application/json") try WebRequest.SetRequestHeader("Content-Type", "application/json")
@@ -50,14 +51,14 @@ TelegramMsgBox(Text:="", TelegramBotToken := "", TelegramBotChatID :=""){
; Replace all forbidden characters - https://www.ascii-code.com/ ; Replace all forbidden characters - https://www.ascii-code.com/
; Text := StrReplace(Text, "`%", "%25") ; percent with
Text := StrReplace(Text, "`n", "%0A") ; New Line Text := StrReplace(Text, "`n", "%0A") ; New Line
; Text := StrReplace(Text, "`n", "%0A") ; New Line ; Text := StrReplace(Text, "`n", "%0A") ; New Line
; Text := StrReplace(Text, " ", "%23") ; New Line ; Text := StrReplace(Text, " ", "%23") ; New Line
; Text := ; Text :=
; Text := StrReplace(Text, "`n", "%0A") ; New Line ; Text := StrReplace(Text, "`n", "%0A") ; New Line
; Text := StrReplace(Text, "`%", "%25") ; percent with
; Msgbox % "Text: " Text ; Msgbox % "Text: " Text
ErrorLoggingPath = %A_ScriptDir%\Lib\ErrorLogging\check.rups ErrorLoggingPath = %A_ScriptDir%\Lib\ErrorLogging\check.rups
@@ -93,6 +94,7 @@ TelegramMsgBox(Text:="", TelegramBotToken := "", TelegramBotChatID :=""){
; -------------------------------/TelegramAPI------------------------------- ; -------------------------------/TelegramAPI-------------------------------
; Telegram Message API ; Telegram Message API
; https://core.telegram.org/bots/api
;------------------------------------------------ ;------------------------------------------------
SendTelegramMessage(token, chatID, text := "", ParseMode := "MarkdownV2") ; you could add more options; compare the Telegram API docs SendTelegramMessage(token, chatID, text := "", ParseMode := "MarkdownV2") ; you could add more options; compare the Telegram API docs
{ {
@@ -142,6 +144,7 @@ pre-formatted fixed-width code block written in the Python programming language
; -------------------------------Telegram Image Sending------------------------------- ; -------------------------------Telegram Image Sending-------------------------------
; https://www.autohotkey.com/boards/viewtopic.php?t=68417 ; https://www.autohotkey.com/boards/viewtopic.php?t=68417
; https://core.telegram.org/bots/api
SendTelegramPhoto(token, chatID, file, caption := "", ParseMode := "MarkdownV2") ; you could add more options; compare the Telegram API docs SendTelegramPhoto(token, chatID, file, caption := "", ParseMode := "MarkdownV2") ; you could add more options; compare the Telegram API docs
{ {

View File

@@ -40,7 +40,7 @@ DownloadLatestChromium(){
ChromeExtractedDirectory = %A_ScriptDir%\Lib\chrome-win64 ChromeExtractedDirectory = %A_ScriptDir%\Lib\chrome-win64
ChromeDriverMoverEXEFilepath = %A_ScriptDir%\Lib\Chromedriver-Mover.exe ChromeDriverMoverEXEFilepath = %A_ScriptDir%\Lib\Chromedriver-Mover.exe
ChromeDriverMoverURL = https://git.freedomainplaylists.com/yuriy/Chromedriver-Mover/releases/download/1.1/Chromedriver-Mover.exe ChromeDriverMoverURL = https://freedomain.dev/attachments/b7b608b6-379a-42bb-a7c4-23fd67a05bb3
ChromeDriverProgramFilesExeFilepath = C:\Program Files\SeleniumBasic\chromedriver.exe ChromeDriverProgramFilesExeFilepath = C:\Program Files\SeleniumBasic\chromedriver.exe

View File

@@ -0,0 +1,71 @@
;---ENVIRONMENT---------------------------------------------------------------------
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
;#Warn ; Enable warnings to assist with detecting common errors.
;DetectHiddenWindows, On
#SingleInstance, Force
DetectHiddenWindows, ON
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;SetKeyDelay, 500
CoordMode, ToolTip, Screen
CoordMode, Mouse, Screen
; #NoTrayIcon
; Menu, Tray, Icon, RMScriptManager.ico
;---Notes/Extra Info/#Includes------------------------------------------------------
;---VARIABLES-----------------------------------------------------------------------
;---MAIN SCRIPT---------------------------------------------------------------------
AHKFilepath = %A_ScriptDir%\Chromedriver-Mover.ahk
Exefilepath = %A_ScriptDir%\Chromedriver-Mover.exe
icopath = %A_ScriptDir%\Chromedriver-Mover.ico
; Kill any active intances of the uploaders so the .exe file can be overwriten by the compilation
process, close, Chromedriver-Mover.exe
sleep, 1000
; Delete the .exe file so it can be repalced
if(FileExist(Exefilepath)){
FileDelete, %Exefilepath%
if(ErrorLevel){
msgbox, failed to delete Exe file. Please delete manually and re-run the compiler.
ExitApp
}
}
if(!FileExist(AHKFilepath)){
msgbox, %AHKFilepath% does not exist`nExiting
ExitApp
}
if(!FileExist(icopath)){
msgbox, %icopath% does not exist`nExiting
ExitApp
}
run, %comspec% /c ""C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe" /in "%AHKFilepath%" /out "%exefilepath%" /icon "%icopath%""
ExitApp
;---FUNCTIONS-----------------------------------------------------------------------

133
Chromedriver-Mover.ahk Normal file
View File

@@ -0,0 +1,133 @@
; ENVIRONMENT
;------------------------------------------------
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
;#Warn ; Enable warnings to assist with detecting common errors.
;DetectHiddenWindows, On
#SingleInstance, Force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;SetKeyDelay, 500
CoordMode, ToolTip, Screen
CoordMode, Mouse, Screen
; #NoTrayIcon
; Notes/Extra Info/#Includes
;------------------------------------------------
; #Include C:\Users\%A_Username%\Syncthing\Scripts\AutoHotKey\RadialMenu\My codes\My Global Variables.ahk
if(InStr(A_ScriptFullPath, ".ahk")){
try Menu, Tray, Icon, %A_ScriptDir%\Assets\icon.ico
}
; Menu, Tray, Icon, C:\Users\%A_Username%\Syncthing\Git\Copy-ChromeDriver-To-Program-Files\Assets\icon.ico
ChromeDriverTemporaryFilepath = %1%
; Msgbox % "Passed in ChromeDriverTemporaryFilepath: " ChromeDriverTemporaryFilepath
; msgbox
; VARIABLES
;------------------------------------------------
SettingsFilepath = %A_ScriptDir%\ChromedriverMover.ini
; Msgbox % "SettingsFilepath: " SettingsFilepath
if(ChromeDriverTemporaryFilepath)
IniWrite, %ChromeDriverTemporaryFilepath%, %SettingsFilepath%, Selenium, ChromeDriverTemporaryFilepath
; MAIN SCRIPT
;------------------------------------------------
StartScriptAsAdmin()
if(ChromeDriverTemporaryFilepath = "")
IniRead, ChromeDriverTemporaryFilepath, %SettingsFilepath%, Selenium, ChromeDriverTemporaryFilepath
ChromeDriverProgramFilesFilepath = C:\Program Files\SeleniumBasic\chromedriver.exe
if(FileExist(ChromeDriverProgramFilesFilepath)){
FileDelete, %ChromeDriverProgramFilesFilepath%
if(ErrorLevel){
msgbox, failed to delete old chromedriver from: C:\Program Files\SeleniumBasic\chromedriver.exe. Please make sure all Selenium Connected instances of Chromium are closed and then try again or move the Chromedriver.exe file manually from:`n%ChromeDriverTemporaryFilepath%
}
}
if(FileExist(ChromeDriverProgramFilesFilepath)){
msgbox, failed to delete old chromedriver from: C:\Program Files\SeleniumBasic\chromedriver.exe. Please run this program as admin or move the chromedriver manually from:`n%ChromeDriverTemporaryFilepath%
ExitApp
}
; msgbox, pause
; Msgbox % "ChromeDriverTemporaryFilepath: " ChromeDriverTemporaryFilepath
if(!InStr(ChromeDriverTemporaryFilepath, ".exe")){ ; parent directory passed in instead of exact filepath. Loop through directory contents and find the .exe file
Loop, files, %ChromeDriverTemporaryFilepath%\*.*, DFR
{ ; D = Directories, F = Files, R = Recursive
SplitPath, A_LoopFileFullPath, FileNameWExt, FileDir, FileExt, FileNameNoExt,
if(FileNameWExt = "chromedriver.exe"){
ChromeDriverTemporaryFilepath := A_LoopFileFullPath
break
}
}
}
if(!InStr(ChromeDriverTemporaryFilepath, ".exe")){
msgbox, Failed to find chromedriver.exe to move. Please move the chromedriver manually.
ExitApp
}
FileCopy, %ChromeDriverTemporaryFilepath%, %ChromeDriverProgramFilesFilepath%, 1
if(ErrorLevel){
msgbox, unable to copy chromedriver.exe from: `n%ChromeDriverTemporaryFilepath%`nto:`n%ChromeDriverProgramFilesFilepath%
ExitApp
}
if(!FileExist(ChromeDriverProgramFilesFilepath)){
msgbox, failed to move chromedriver to %ChromeDriverProgramFilesFilepath%. Please run this program as admin or move the chromedriver manually.
ExitApp
}
; clear the settings file
IniWrite, %A_Tab%, %SettingsFilepath%, Selenium, ChromeDriverTemporaryFilepath
ExitApp
; Functions
;------------------------------------------------
StartScriptAsAdmin(){
full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)")) {
try {
if A_IsCompiled
Run *RunAs "%A_ScriptFullPath%" /restart
else
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
}
ExitApp
}
if(!A_IsAdmin){
Msgbox, failed to get admin to move chromedriver to program files
Return
}
}
; Misc
;------------------------------------------------
; Escape::ExitApp

BIN
Chromedriver-Mover.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

View File

@@ -102,6 +102,11 @@ TimedToolTip(Text, x="", y="",RemoveAfterTime:=2000, SetWhichToolTip="") {
; -------------------------------LogErrorsToTextFile------------------------------- ; -------------------------------LogErrorsToTextFile-------------------------------
Func_LogErrorsToTextFile(Text){ Func_LogErrorsToTextFile(Text){
; Do not log if we do not have an errorlog filepath
if(ErrorLoggingFilePath = "")
return
; ErrorLoggingFile := Filepath ; ErrorLoggingFile := Filepath
FormatTime, TodayDate , YYYYMMDDHH24MISS, yyyyMMdd_hhmmss FormatTime, TodayDate , YYYYMMDDHH24MISS, yyyyMMdd_hhmmss
text = text =

View File

@@ -8,7 +8,12 @@ CheckForUpdates(GitReleasesAPIURL){
data := URLDownloadToVar(GitReleasesAPIURL) data := URLDownloadToVar(GitReleasesAPIURL)
; Msgbox % "data: " data ; Msgbox % "data: " data
parsed := JSON.Load(data) try, parsed := JSON.Load(data)
catch e {
Message = Failed to check for updates. Gitea Releases API returned blank or malformed data.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return
}
UpdateVersionNumber := parsed.1.name UpdateVersionNumber := parsed.1.name
@@ -17,10 +22,10 @@ CheckForUpdates(GitReleasesAPIURL){
if(ScriptVersion = UpdateVersionNumber OR ScriptVersion > UpdateVersionNumber){ if(ScriptVersion = UpdateVersionNumber OR ScriptVersion > UpdateVersionNumber){
ToolTip ToolTip
return 0 return 0
} }
else, { else, {
UpdateAvailable := 1 UpdateAvailable := 1
; msgbox, update found! ; msgbox, update found!
Message = Program Update Found Message = Program Update Found
@@ -36,7 +41,12 @@ CheckForUpdates(GitReleasesAPIURL){
UpdateScript(){ UpdateScript(){
data := URLDownloadToVar(GitReleasesAPIURL) data := URLDownloadToVar(GitReleasesAPIURL)
parsed := JSON.Load(data) try parsed := JSON.Load(data)
catch e {
Message = Failed to check for updates. Gitea Releases API returned blank or malformed data.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return
}
UpdateVersionNumber := parsed.1.name UpdateVersionNumber := parsed.1.name
ChangeLog := parsed.1.body ChangeLog := parsed.1.body

View File

@@ -1,4 +1,3 @@
Function Libraries used in the following Projects: Function Libraries used in the following Projects:
- [Freedomain Social Media Poster](https://git.freedomainplaylists.com/yuriy/Freedomain-Social-Media-Poster) - [Freedomain Social Media Poster](https://freedomain.dev/yuriy/social-media-poster)
- [Freedomain Video Uploader](https://git.freedomainplaylists.com/yuriy/Freedomain-Video-Uploader) - [Freedomain Video Uploader](https://freedomain.dev/yuriy/video-uploader)
- [Freedomain Reposter](https://git.freedomainplaylists.com/yuriy/Freedomain-Reposter)

View File

@@ -20,9 +20,9 @@ IfMsgBox Yes, {
; Open Instructions Gitea page ; Open Instructions Gitea page
if(InStr(A_ScriptName, "Video")) if(InStr(A_ScriptName, "Video"))
URL = https://git.freedomainplaylists.com/yuriy/Freedomain-Video-Uploader#installation URL = https://freedomain.dev/yuriy/video-uploader#installation
else, else,
URL = https://git.freedomainplaylists.com/yuriy/Freedomain-Social-Media-Poster#installation URL = https://freedomain.dev/yuriy/social-media-poster#installation
run, %URL% run, %URL%
run, "%A_ScriptFullPath%" "LastPost" run, "%A_ScriptFullPath%" "LastPost"
@@ -73,7 +73,6 @@ CheckSeleniumDriver(){
} }
DriverStatus := 1 DriverStatus := 1
if(ReuseTabs)
CreateArrayOfChromeTabs() CreateArrayOfChromeTabs()

View File

@@ -1,11 +1,14 @@
URLDownloadToVar(url){ URLDownloadToVar(url){
hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1") hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
hObject.Open("GET",url) hObject.Open("GET",url)
try hObject.Send() try {
hObject.Send()
}
catch e { catch e {
; MsgBox, 4096, Error, Failed to connect to:`n`n%url%`n`nAre you connected to the internet? Or is the website down?`n`nDisable Auto Update Check to disable this message.
return "" return ""
; msgbox, failed!
} }
return hObject.ResponseText return hObject.ResponseText