code cleanup, added secondary attempt for submitting minds posts, added button to update chrome and chromedriver

main
Yuriy 1 year ago
parent 5c6dad5496
commit ed88b9b24a

@ -38,6 +38,7 @@ global UpdateVersionNumber
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\API-Functions.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\JSON.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\RunCMD.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Zip.ahk
ScriptName = Freedomain Social Media Poster
@ -84,7 +85,6 @@ global PauseBetweenPosts ; pause for a couple of seconds between posts so user h
global PauseTimeBetweenPosts
global TimeBetweenpostsInMiliseconds
global DevMode
global ScreenshotResult
global ScriptRunTime
global URLOfLastErrorPage
@ -126,12 +126,11 @@ ScriptSettingsSection := "SocialMediaPoster"
;------------------------------------------------
IniRead, TestingMode, %SettingsIniFilepath%, General, TestingMode, 0
IniRead, DevMode, %SettingsIniFilepath%, General, DevMode, 0
IniRead, ScreenshotResult, %SettingsIniFilepath%, General, ScreenshotResult, 0
IniRead, TelegramBotToken, %SettingsIniFilepath%, SocialMediaPoster, TelegramBotToken, %A_Space%
IniRead, TelegramBotChatID, %SettingsIniFilepath%, SocialMediaPoster, TelegramBotChatID, %A_Space%
IniRead, DiscordErrorLoggingWebhookBotURL, %SettingsIniFilepath%, SocialMediaPoster, DiscordErrorLoggingWebhookBotURL, %A_Space%
IniRead, DiscordParlerWebhookURL, %SettingsIniFilepath%, SocialMediaPoster, DiscordParlerWebhookURL, %A_Space%
IniRead, ChromeFilepath, %SettingsIniFilepath%, SocialMediaPoster, ChromeFilepath, %A_Space%
; IniRead, ChromeFilepath, %SettingsIniFilepath%, SocialMediaPoster, ChromeFilepath, %A_Space%
@ -425,42 +424,31 @@ Gui, Add, Button, x%MarginSpaceDoubled% y+%MarginSpace% w%EditBoxHalfWidths% h30
if(ChromeUpdateAvailable)
Gui, Add, Button,x+%MarginSpace% yp+0 w%EditBoxHalfWidths% h30 gCancelPost, Chrome Update Available
Gui, Add, Button,x+%MarginSpace% yp+0 w%EditBoxHalfWidths% h30 vChromeUpdateAvailable gUpdateChrome, Chrome Update Available!
else,
Gui, Add, Button,x+%MarginSpace% yp+0 w%EditBoxHalfWidths% h30 gCancelPost, Chrome Up-to-Date
Gui, Add, Button,x+%MarginSpace% yp+0 w%EditBoxHalfWidths% h30 vChromeUpdateAvailable gUpdateChrome , Chrome Up-to-Date
if(DevMode){
Gui, Add, Button, x%MarginSpace% y+10 w%EditBoxThirdsWidth% h30 gToggleTestingMode, TestingModeToggle
; Gui, Add, Button, x+%marginspace% w%EditBoxThirdsWidth% h30 gToggleTestingMode, TestingModeToggle
Gui, Add, Button, x+%marginspace% w%EditBoxThirdsWidth% h30 gCompileScript, Compile
Gui, Add, Button, x+%marginspace% w%EditBoxThirdsWidth% h30 gUploadFiles, UploadWinscp
Gui, Add, Button, x%MarginSpace% y+10 w%EditBoxThirdsWidth% h30 gOpenErrorLog, OpenErrorLog
}
; Gui, Add, Checkbox, vTakeScreenshotsOfErrors Checked gUpdateVars, Take Screenshots of Errors
; Gui, Add, Checkbox, vTakeScreenshotsOfErrors Checked%ScreenshotsOfErrorsCheckStatus% gUpdateVars, Take Screenshots of Errors
; TakeScreenshotsOfErrors := 0
; Gui, Add, Checkbox, vShowChangelog, Show `nChangelog (WIP)
Gui, Font, Normal
gui, Font, s5
; Miscellaneous Settings
DevModToggleButton := PlatformsGroupBoxXLocation + 80
Gui, Add, Button, x%DevModToggleButton% y5 w50 h10 gToggleDevMode, DevMode
Gui, Add, Button, x+5 yp+0 w50 h10 gToggleTestingMode, Testing Mode
Gui, Add, Button, x+5 yp+0 w50 h10 gToggleManualSubmit, Manual Submit
Gui, Add, Button, x+5 yp+0 w50 h10 gToggleManualSubmit, Man. Submit
Gui, Add, Button, x+5 yp+0 w50 h10 gOpenGiteaPage, Gitea
Gui, Font, Bold
Gui, Font, s%GUINormalFontSize%
Gui, Add, GroupBox,r4 x%PlatformsGroupBoxXLocation% y%MarginSpace% w300, Settings
Gui, Add, GroupBox,r4 x%PlatformsGroupBoxXLocation% y20 w300, Settings
Gui, Font, s11
Gui, Font, Normal
Gui, Add, Checkbox, xp+10 yp+25 vAutoUpdateCheck Checked%AutoUpdateCheckCheckStatus% gUpdateVars, Auto Update Check
@ -478,7 +466,7 @@ Gui, Font, s%GUINormalFontSize%
Gui, Font, Bold
Gui, Add, GroupBox,r6.4 x%PlatformsGroupBoxXLocation% y185 w300, Platforms
Gui, Add, GroupBox,r6.4 x%PlatformsGroupBoxXLocation% y210 w300, Platforms
Gui, Font, Normal
Gui, Add, Checkbox, xp+10 yp+30 vDiscord Checked%DiscordCheckStatus% gUpdateVars, Discord
Gui, Add, Checkbox, y+7 vTelegram Checked%TelegramCheckStatus% gUpdateVars, Telegram
@ -508,7 +496,7 @@ Gui, Font, Bold
gui, Font, s15
; : Gui, Add, Text, , My Text.
; Gui, Font, Color, Red
Gui, Add, Button, x%PlatformsGroupBoxXLocation% y+57 w300 h117 gPostPost, Publish
Gui, Add, Button, x%PlatformsGroupBoxXLocation% y485 w300 h113 gPostPost, Publish
; Gui, Add, Button, x%PlatformsGroupBoxXLocation% y+20 w300 h30 gSchedulePost, Schedule Post
@ -526,7 +514,11 @@ ControlFocus, Edit1, %FullScriptName%
; check for updates if the setting is enabled
if(AutoUpdateCheck AND !SkipUpdateCheckThisRun){
CheckForUpdates(GitReleasesAPIURL)
GuiControl,,UpdateAvailable, Uploader Update Available
GuiControl,,UpdateAvailable, Uploader Update Available!
; if(CheckForChromeUpdates(ChromeFilepath))
GuiControl,,ChromeUpdateAvailable, Chrome Update Available!
}
@ -568,11 +560,9 @@ SaveOrPostProgress(Message:=Message,PostType:="Tooltip,DiscordErrorLogging")
ErrorLoggingDirectory = %A_ScriptDir%\Lib\Templates\
FileSelectFolder, ErrorLoggingDirectory, %ErrorLoggingDirectory%
; FileSelectFolder, OutputVar [, *StartingFolder, Options, Prompt]
if(ErrorLevel){
Tooltip
Return
}
run, "%A_ScriptFullPath%" "%ErrorLoggingDirectory%"
@ -607,6 +597,33 @@ UpdateScript:
UpdateScript()
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, {
}
}
DownloadLatestChromium()
Return
/*
*/
CancelPost:
GuiClose:
; ExitApp
@ -736,11 +753,6 @@ if(InStr(ErrorLoggingDirectory, "\Templates\") OR ErrorLoggingDirectory = "" OR
} ;
; Msgbox % "SaveTagsBetweenPosts: "the SaveTagsBetweenPosts
; Msgbox % "TakeScreenshotsOfErrors: " TakeScreenshotsOfErrors
; Save settings to .ini file
; SaveSettingsToIniFile(SettingName)
IniWrite, %BoldTitleWAPI%, %SettingsIniFilepath%, SocialMediaPoster, BoldTitleWAPI
@ -750,7 +762,6 @@ IniWrite, %ShowTooltipProgress%, %SettingsIniFilepath%, SocialMediaPoster, ShowT
IniWrite, %AutoUpdateCheck%, %SettingsIniFilepath%, SocialMediaPoster, AutoUpdateCheck
IniWrite, %SaveTagsBetweenPosts%, %SettingsIniFilepath%, SocialMediaPoster, SaveTagsBetweenPosts
IniWrite, %PauseBetweenPosts%, %SettingsIniFilepath%, SocialMediaPoster, PauseBetweenPosts
; IniWrite, %TakeScreenshotsOfErrors%, %SettingsIniFilepath%, SocialMediaPoster, TakeScreenshotsOfErrors
IniWrite, %ErrorLoggingDirectory%, %SettingsIniFilepath%, %ScriptSettingsSection%, LastPost
@ -1108,10 +1119,6 @@ Tooltip
Return
OpenScreenshotsFolder:
run, %ErrorLoggingDirectory%
Return
; Discord
;------------------------------------------------

@ -1 +1 @@
Subproject commit f358623f8664934640d7ba1a11aa7493ead61870
Subproject commit 1962743565d49bd0ed3c36a67a05642483e28eff

@ -182,6 +182,20 @@ loop, 3 {
Return
}
; msgbox, submit with xpath
Xpath = (//span[@class='ng-star-inserted'][normalize-space()='Post'])[2]
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
if(Status){
Message = Failed to Submit Post after 2 different attempts
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
; msgbox, ork?
; click submit button
js = document.querySelector("button[class='m-button m-button--blue m-button--small m-button--dropdown'] span[class='ng-star-inserted']").click();
try status := driver.executeScript(js)
@ -189,8 +203,23 @@ loop, 3 {
Message = Clicking submit button with JS resulted in status: %status%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Message = Trying to click the Post button using Xpath
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Xpath = (//span[@class='ng-star-inserted'][normalize-space()='Post'])[2]
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
if(Status){
Message = Failed to Submit Post after 2 different attempts
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
}
SaveOrPostProgress(Message:="Waiting 5 seconds to confirm post got submitted",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
sleep, 5000

Loading…
Cancel
Save