Compare commits

...

4 Commits

Author SHA1 Message Date
0e02ae24bd small bug fixes and improvements 2024-05-09 21:48:29 -04:00
b19482e10d readme 2024-05-09 15:37:36 -04:00
d7d3ce039f formatting, added reusable lib for update checks 2024-05-09 15:36:35 -04:00
8395c5c367 generate date ordinals function 2024-05-08 13:59:06 -04:00
5 changed files with 65 additions and 22 deletions

View File

@@ -153,6 +153,7 @@ DownloadLatestChromium(){
Process, Close, chromedriver.exe Process, Close, chromedriver.exe
sleep, 5000 ; wait 5 seconds before checking again sleep, 5000 ; wait 5 seconds before checking again
continue
} }
else, else,
break break

View File

@@ -137,6 +137,10 @@ CheckDirExistAndCreate(Path){
; -------------------------------/CheckDirExistAndCreate------------------------------- ; -------------------------------/CheckDirExistAndCreate-------------------------------
; Script Updates
; ------------------------------------------------
CheckIfUpdateAvailable(Filepath, CurrentVersion){ CheckIfUpdateAvailable(Filepath, CurrentVersion){
FileRead, ScriptUpdateContents, %Filepath% FileRead, ScriptUpdateContents, %Filepath%
@@ -594,6 +598,11 @@ CheckIfUpdateInstalled(PassedInArgument :=""){
} }
} }
; https://www.autohotkey.com/boards/viewtopic.php?t=59936
GetDateOrdinalSuffix(D) {
Static Special := {1: "st", 2: "nd", 3: "rd", 21: "st", 22: "nd", 23: "rd", 31: "st"}
Return D . ((S := Special[D]) ? S : "th")
}

View File

@@ -1,3 +1,5 @@
Function Libraries used in the following Projects: Function Libraries used in the following Projects:
- [Freedomain Social Media Poster](https://freedomain.dev/yuriy/social-media-poster) - [Freedomain Social Media Poster](https://freedomain.dev/yuriy/social-media-poster)
- [Freedomain Video Uploader](https://freedomain.dev/yuriy/video-uploader) - [Freedomain Video Uploader](https://freedomain.dev/yuriy/video-uploader)
- [Freedomain Clips Uploader](https://freedomain.dev/yuriy/clips-uploader)
- [Freedomain Livestream Scheduler](https://freedomain.dev/yuriy/livestream-scheduler)

View File

@@ -722,7 +722,7 @@ Selenium_LoopToSendValueByName(ElementName,NumOfLoops:=1,SleepLength:=1000,Strin
Selenium_LoopToSendValueToXpath(Xpath,NumOfLoops:=1,SleepLength:=1000,StringTextContent:="",ClearElement:=0){ Selenium_LoopToSendValueToXpath(Xpath,NumOfLoops:=1,SleepLength:=1000,StringTextContent:="",ClearElement:=0){
; Msgbox % "StringTextContent: " StringTextContent ; Msgbox % "StringTextContent: " StringTextContent
; Msgbox % "ClearElement: " ClearElement ; Msgbox % "ClearElement: " ClearElement
loop, %NumOfLoops% { loop, %NumOfLoops% {
; msgbox % ClearElement ; msgbox % ClearElement
@@ -790,17 +790,27 @@ Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath,NumOfLoops:=1,SleepLength:=1
} }
Selenium_LoopToClearXpath(Xpath,NumOfLoops:=1,SleepLength:=1000){ Selenium_LoopToClearXpath(Xpath,NumberOfAttemps:=1,SleepLength:=1000){
loop, %NumOfLoops% { loop, %NumberOfAttemps% {
try driver.FindElementByXPath(Xpath).clear() try driver.FindElementByXPath(Xpath).clear()
catch e { catch e {
if(A_index = NumOfLoops){
Return "Failed" Return "Failed"
} }
sleep, %SleepLength% sleep, %SleepLength%
Continue
try, InerText := driver.findelementbyxpath(Xpath).Attribute("value")
; Msgbox % "InerText: " InerText
if(InerText = "")
return
if(A_index = NumberOfAttemps){
return "Failed after %NumberOfAttemps"
} }
Return
Continue
; Return
} }
} }
@@ -834,12 +844,12 @@ SaveDriverURLOFErrorPage(){ ; save the url of the result page. That way if a tab
GetHTMLValueFromXpathOuterHTML(XPATH, HTMLElementName){ GetHTMLValueFromXpathOuterHTML(XPATH, HTMLElementName){
Try ElementOuterHTML := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag Try ElementOuterHTML := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag
; try Clipboard := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag ; try Clipboard := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag
; Try MsgBox,,Element OuterHTML: `n, % driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag ; Try MsgBox,,Element OuterHTML: `n, % driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag
; Match string between quotes following the HTMLELEMENTNAME ; Match string between quotes following the HTMLELEMENTNAME
RegexStatement = %HTMLElementName%="([^"]+)" RegexStatement = %HTMLElementName%="([^"]+)"
; regexMatch := RegExMatch(ElementOuterHTML, "value=""([^""]+)""", match) ; regexMatch := RegExMatch(ElementOuterHTML, "value=""([^""]+)""", match)
regexMatch := RegExMatch(ElementOuterHTML, RegexStatement, match) regexMatch := RegExMatch(ElementOuterHTML, RegexStatement, match)

21
Update-Functions.ahk Normal file
View File

@@ -0,0 +1,21 @@
; This #include needs to be at the bottom of the parent script
CheckForUpdates:
; The GUI buttons must have variable set to vUpdateAvailable and vChromeUpdateAvailable for button to get updated
; The following variables need to be set in the parent script
; GitReleasesAPIURL
; ChromeFilepath
Message = Checking for Updates
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
if(CheckForUpdates(GitReleasesAPIURL))
GuiControl,,UpdateAvailable, Uploader Update Available!
if(CheckForChromeUpdates(ChromeFilepath)){
GuiControl,,ChromeUpdateAvailable, Chrome Update Available!
ChromeUpdateAvailable := 1
}
Return