Compare commits

..

11 Commits

Author SHA1 Message Date
cf56ae8136 formatting and cleanup 2024-05-18 00:44:13 -04:00
738e1af443 merged modules 2024-05-17 23:36:39 -04:00
f71def4542 added chrome goto 2024-05-17 23:32:09 -04:00
20c2f44b0c added sample function call 2024-05-17 22:31:35 -04:00
997ee862ed bug fix for msgbox confirm function 2024-05-17 20:25:45 -04:00
b378de8106 function add and expansion 2024-05-17 19:36:18 -04:00
ed307493b8 renamed lib 2024-05-17 18:40:09 -04:00
2860e4868f formatting and cleanup 2024-05-16 14:46:11 -04:00
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
6 changed files with 271 additions and 138 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
@@ -309,13 +310,16 @@ DownloadLatestChromium(){
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
MsgBox 0x40,, %Message% MsgBox 0x40,, %Message%
ChromeFilepath := ; clear out chromefilepath variable in case the path changed
ToolTip ToolTip
return return
} }
/*
*/
CheckForChromeUpdates(ChromeFilepath := ""){
CheckForChromeUpdates(ChromeFilepath := ""){
if(ChromeFilepath = "") if(ChromeFilepath = "")
ChromeFilepath := GetInstalledChromeFilepath() ChromeFilepath := GetInstalledChromeFilepath()
@@ -329,10 +333,10 @@ DownloadLatestChromium(){
else, Return 0 else, Return 0
} }
GetInstalledChromeFilepath(){ GetInstalledChromeFilepath(){
; ChromeFilepath is global variable ; ChromeFilepath is global variable
if(ChromeFilepath = ""){ if(ChromeFilepath = ""){
@@ -364,9 +368,9 @@ DownloadLatestChromium(){
} }
ToolTip ToolTip
} }
GetInstalledChromeVersion(){ GetInstalledChromeVersion(){
if(ChromeFilepath = ""){ if(ChromeFilepath = ""){
GetInstalledChromeFilepath() GetInstalledChromeFilepath()
@@ -379,10 +383,10 @@ DownloadLatestChromium(){
InstalledChromeVersion := StrReplace(InstalledChromeVersion, "`r") ; replace any newline characters that powershell returns InstalledChromeVersion := StrReplace(InstalledChromeVersion, "`r") ; replace any newline characters that powershell returns
return InstalledChromeVersion return InstalledChromeVersion
} }
GetLatestChromeStableVersion(){ GetLatestChromeStableVersion(){
; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints ; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints
json_str := urldownloadtovar("https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json") json_str := urldownloadtovar("https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json")
@@ -399,10 +403,10 @@ DownloadLatestChromium(){
} }
return ChromeStableLatestVersion return ChromeStableLatestVersion
} }
GetDownloadURLOfChromeAndDriver(InstalledChromeVersion){ GetDownloadURLOfChromeAndDriver(InstalledChromeVersion){
; Will return the download URL of Chrome for Testing and Chrome Driver, seperated by a || ; Will return the download URL of Chrome for Testing and Chrome Driver, seperated by a ||
; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints ; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints
@@ -449,4 +453,4 @@ DownloadLatestChromium(){
URLS = %chromeDLURL64%||%chromedriverDLURL64% URLS = %chromeDLURL64%||%chromedriverDLURL64%
return URLS return URLS
} }

View File

@@ -137,6 +137,10 @@ CheckDirExistAndCreate(Path){
; -------------------------------/CheckDirExistAndCreate------------------------------- ; -------------------------------/CheckDirExistAndCreate-------------------------------
; Script Updates
; ------------------------------------------------
CheckIfUpdateAvailable(Filepath, CurrentVersion){ CheckIfUpdateAvailable(Filepath, CurrentVersion){
FileRead, ScriptUpdateContents, %Filepath% FileRead, ScriptUpdateContents, %Filepath%
@@ -605,6 +609,33 @@ GetDateOrdinalSuffix(D) {
; OnMsgbox - Custom Msgbox Screens ; OnMsgbox - Custom Msgbox Screens
;------------------------------------------------ ;------------------------------------------------
ConfirmBeforeSubmitMsgboxFunc(){
/*
; Snippet to for check:
if (ConfirmBeforeSubmit && ConfirmBeforeSubmitMsgboxFunc() != true) {
Message = User Selected STOP button when asked for confirmation. Cancelling Rest of Site Upload.
SaveOrPostProgress(Message:=Message, PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
return
}
*/
OnMessage(0x44, "OnMsgBoxUserConfirmation")
MsgBox 0x21, User Confirmation, Please check that all data was input correctly and fix any mistakes and then click PROCEED to finalize the Upload.`n`nClick STOP to cancel the rest of this Upload and move on to the next website.
OnMessage(0x44, "")
IfMsgBox OK, {
return true
} Else IfMsgBox Cancel, {
Message = User Selected STOP button when asked for confirmation. Cancelling Rest of Site Upload.
Return %Message%
}
}
OnMsgBoxUpdateAvailable() { OnMsgBoxUpdateAvailable() {
DetectHiddenWindows, On DetectHiddenWindows, On
Process, Exist Process, Exist

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

@@ -721,21 +721,27 @@ 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 % "ClearElement: " ClearElement
loop, %NumOfLoops% { loop, %NumOfLoops% {
; msgbox % ClearElement
if(ClearElement){ if(ClearElement){
Loop, 3 { ; have to do it multiple times to make it trigger properly Loop, 3 { ; sometimes have to do it multiple times to make it trigger properly
Try PreviousValue := driver.findelementbyxpath(Xpath).Attribute("value") ;Xpath Value
try, driver.FindElementByXPath(Xpath).clear() try, driver.FindElementByXPath(Xpath).clear()
sleep, 500
Try CurrentValue := driver.findelementbyxpath(Xpath).Attribute("value") ;Xpath Value
if(PreviousValue != CurrentValue){
break
}
sleep, 1000
; msgbox
} }
} }
try driver.FindElementByXPath(Xpath).sendKeys(StringTextContent) ; Input Text
; ToolTip, Loop attempt: %A_index%
try driver.FindElementByXPath(Xpath).sendKeys(StringTextContent) ; Click on "upload image" button
catch e { catch e {
if(A_index = NumOfLoops){ if(A_index = NumOfLoops){
Return "Failed" Return "Failed"
@@ -790,17 +796,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 +850,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)

79
Shared-GoTos.ahk Normal file
View File

@@ -0,0 +1,79 @@
; 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, Update Available!
}
if(CheckForChromeUpdates(ChromeFilepath)){
GuiControl,,ChromeUpdateAvailable, Chrome Update Available!
ChromeUpdateAvailable := 1
}
ToolTip
Return
UpdateChrome:
if(CheckForChromeUpdates = "")
Status := CheckForChromeUpdates(ChromeFilepath)
if(!status){
OnMessage(0x44, "OnMsgBoxConfirmChromiumOverwrite")
MsgBox 0x41, Already Up-to-Date, Yor current Chromium version is already up to date. `nDo you want to download and overwrite it?
OnMessage(0x44, "")
IfMsgBox OK, {
Return
} Else IfMsgBox Cancel, {
}
}
Status := DownloadLatestChromium()
if(Status)
GuiControl,,ChromeUpdateAvailable, Chrome Up-to-Date
Return
/*
*/
PasteClipboardToEditBox:
if(A_GuiControl = "PasteClipboardToSMPBody"){
GuiControl,,PostBody, %Clipboard%
}
if(A_GuiControl = "PasteClipboardToSMPTitle"){
GuiControl,,PostTitle, %Clipboard%
}
if(A_GuiControl = "PasteClipboardToFLSTitle"){
GuiControl,,LivestreamTitle, %Clipboard%
}
if(A_GuiControl = "PasteClipboardToFLSDescription"){
GuiControl,,LivestreamDescription, %Clipboard%
}
if(A_GuiControl = "PasteClipboardToFLSTags"){
GuiControl,,LivestreamTags, %Clipboard%
}
Return

1
Update-Functions.ahk Normal file
View File

@@ -0,0 +1 @@
; Code migrated to Shared-GoTo's