Moved auto update check to before GUI creation, updated to use gitea API

main
Yuriy 2 years ago
parent 1d2f57ebf6
commit 5af097f8ec

@ -10,15 +10,10 @@ if(InStr(A_ScriptName, ".ahk")){
Menu, Tray, Icon, %A_ScriptDir%\assets\FreedomainSMP.ico
}
/*IconLocation :
if(!FileExist())
FileInstall, %A_ScriptDir%\Lib\FreedomainShare_Scheduled.ico, Dest [, Flag (1 = overwrite)]
ErrorLoggingDirectory = %1%
*/
ErrorLoggingDirectory = %1%
; Add menus to the toolbar icon
Menu, tray, NoStandard ; remove standard tray
Menu, Tray, Add, Exit, KillScript
@ -35,7 +30,7 @@ global FullScriptName
;---Notes/Extra Info/#Includes------------------------------------------------------
ScriptName = Freedomain Social Media Poster
ScriptVersion = 2.71
ScriptVersion = 2.70
FullScriptName := ScriptName . " " . ScriptVersion
;---ToDo---
@ -163,7 +158,7 @@ IniRead, TotalRunTime, %SettingsIniFilepath%, %ScriptSettingsSection%, TotalRunT
;---Auto Updater Settings---
;------------------------------------------------
; Misc Auto Update settings
global FreedomainProgramUpdaterFilepath
/*global FreedomainProgramUpdaterFilepath
FreedomainProgramUpdaterFilepath := A_ScriptDir . "\Freedomain Program Updater.exe"
global FreedomainProgramUpdaterURL
@ -174,6 +169,10 @@ FreedomScriptsChangelogURL = https://freedomainplaylists.com/wp-content/Freedoma
global UpdateURL
UpdateURL = https://freedomainplaylists.com/wp-content/FreedomainScripts/Freedomain`%20Social`%20Media`%20Poster.exe
*/
global GitReleasesAPIURL
GitReleasesAPIURL = https://git.zinchuk.xyz/api/v1/repos/yuriy/Freedomain_Social_Media_Poster/releases
; Save filepath of the current script to %SettingsIniFilepath% so it can be read and used by the script updater
; Append informatio to ini files for Freedomain Program Updater
@ -191,6 +190,10 @@ if(!FileExist(FreedomainProgramUpdaterFilepath)){
; ToolTip
}
; check for updates if the setting is enabled
if(AutoUpdateCheck AND !UpdateAvailable AND !SkipUpdateCheckThisRun){
CheckForUpdates()
}
;---Load Settings From Previous Post---
@ -399,7 +402,7 @@ Gui, Add, Button,xp+%Marginspace% yp+35 w%EditBoxThirdsWidth% h30 gSaveAsTemplat
Gui, Add, Button,x+%MarginSpace% w%EditBoxThirdsWidth% h30 gLoadTemplate, Load Template
Gui, Add, Button, x+%MarginSpace% w%EditBoxThirdsWidth% h30 gLoadLastPost, Load Last Post
if(UpdateAvailable)
Gui, Add, Button, x%MarginSpaceDoubled% y+%MarginSpace% w%EditBoxHalfWidths% h30 gUpdateScript vUpdateAvailable, Update Available - Click to Install
Gui, Add, Button, x%MarginSpaceDoubled% y+%MarginSpace% w%EditBoxHalfWidths% h30 gUpdateScript vUpdateAvailable, Program Update Available
else,
Gui, Add, Button, x%MarginSpaceDoubled% y+%MarginSpace% w%EditBoxHalfWidths% h30 gUpdateScript vUpdateAvailable, Program is Up-to-Date
@ -425,10 +428,11 @@ if(DevMode){
Gui, Font, Normal
gui, Font, s5
; Miscellaneous Settings
DevModToggleButton := PlatformsGroupBoxXLocation + 130
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 gOpenGiteaPage, Gitea
@ -494,9 +498,6 @@ ControlFocus, Edit1, %FullScriptName%
;---Check for Update---
;------------------------------------------------
if(AutoUpdateCheck AND !UpdateAvailable AND !SkipUpdateCheckThisRun){
CheckForUpdates()
}
Return
@ -596,6 +597,10 @@ ToggleDevMode()
run, "%A_ScriptFullPath%" "LastPost"
Return
OpenGiteaPage:
run, https://git.zinchuk.xyz/yuriy/Freedomain_Social_Media_Poster
Return
CompileScript:
; msgbox, compiling
IniWrite, %changelog%, %ChangelogIniFilepath%, %ScriptSettingsSection%, Changelog

@ -30,45 +30,86 @@ DevModeMsgBox(Message){
CheckForUpdates(){
; msgbox, checking for updates
Message = Checking For Updates
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile")
SaveOrPostProgress(Message,PostType:="ErrorLoggingTextFile")
data := URLDownloadToVar(GitReleasesAPIURL)
; Msgbox % "data: " data
; Msgbox % "FreedomScriptsChangelogURL: " FreedomScriptsChangelogURL
; Msgbox % "ChangelogIniFilepath: " ChangelogIniFilepath
; Msgbox % "ScriptSettingsSectio: " ScriptSettingsSection
; Msgbox % "SettingsIniFilepath: " SettingsIniFilepath
; [{"id":3,"tag_name":"v2.71","target_commitish":"main","name":"2.71","body":"- Fixed and expanded Parler login check\r\n- Fixed long time bug where a newly created website tab would not get connected to properly\r\n- Temporarily removed Auto Update Support until I can integrate with gitea API","url":"https://git.zinchuk.xyz/api/v1/repos/yuriy/Freedomain_Social_Media_Poster/releases/3","html_url":"https://git.zinchuk.xyz/yuriy/Freedomain_Social_Media_Poster/releases/tag/v2.71","tarball_url":"https://git.zinchuk.xyz/yuriy/Freedomain_Social_Media_Poster/archive/v2.71.tar.gz","zipball_url":"https://git.zinchuk.xyz/yuriy/Freedomain_Social_Media_Poster/archive/v2.71.zip","draft":false,"prerelease":true,"created_at":"2023-01-26T23:45:25-05:00","published_at":"2023-01-26T23:45:25-05:00","author":{"id":1,"login":"yuriy","login_name":"","full_name":"Yuriy Zinchuk","email":"yuriy@noreply.localhost","avatar_url":"https://secure.gravatar.com/avatar/82acf184352c9232da15222248417df0?d=identicon","language":"","is_admin":false,"last_login":"0001-01-01T00:00:00Z","created":"2023-01-02T16:40:09-05:00","restricted":false,"active":false,"prohibit_login":false,"location":"","website":"","description":"","visibility":"public","followers_count":0,"following_count":0,"starred_repos_count":0,"username":"yuriy"},"assets":[{"id":4,"name":"Freedomain Social Media Poster.exe","size":1708544,"download_count":0,"created_at":"2023-01-26T23:45:19-05:00","uuid":"2ee05d49-a314-4079-bcc8-b6857dc29e98","browser_download_url":"https://git.zinchuk.xyz/attachments/2ee05d49-a314-4079-bcc8-b6857dc29e98"}]},{"id":2,"tag_name":"v2.70","target_commitish":"main","name":"2.70","body":"* Initial commit of V2.7 to git\r\n* Pushed codebase to personal [git instance](https://git.zinchuk.xyz/yuriy/Freedomain_Social_Media_Poster/)\r\n* Fixed Locals Posting\r\n* Fixed Gettr Posting\r\n* Fixed Flote Posting\r\n* Fixed MeWe Posting\r\n* Fixed Minds Posting\r\n* Fixed Steemit Posting\r\n* Fixed LinkedIn Image Posting\r\n* Removed Tumblr Support\r\n* Removed Pintrest support","url":"https://git.zinchuk.xyz/api/v1/repos/yuriy/Freedomain_Social_Media_Poster/releases/2","html_url":"https://git.zinchuk.xyz/yuriy/Freedomain_Social_Media_Poster/releases/tag/v2.70","tarball_url":"https://git.zinchuk.xyz/yuriy/Freedomain_Social_Media_Poster/archive/v2.70.tar.gz","zipball_url":"https://git.zinchuk.xyz/yuriy/Freedomain_Social_Media_Poster/archive/v2.70.zip","draft":false,"prerelease":true,"created_at":"2023-01-25T22:38:24-05:00","published_at":"2023-01-25T22:38:24-05:00","author":{"id":1,"login":"yuriy","login_name":"","full_name":"Yuriy Zinchuk","email":"yuriy@noreply.localhost","avatar_url":"https://secure.gravatar.com/avatar/82acf184352c9232da15222248417df0?d=identicon","language":"","is_admin":false,"last_login":"0001-01-01T00:00:00Z","created":"2023-01-02T16:40:09-05:00","restricted":false,"active":false,"prohibit_login":false,"location":"","website":"","description":"","visibility":"public","followers_count":0,"following_count":0,"starred_repos_count":0,"username":"yuriy"},"assets":[{"id":2,"name":"Freedomain Social Media Poster.exe","size":1707520,"download_count":1,"created_at":"2023-01-25T22:36:17-05:00","uuid":"d91a4ab0-b1fb-4c2f-adfa-e986e587cf0a","browser_download_url":"https://git.zinchuk.xyz/attachments/d91a4ab0-b1fb-4c2f-adfa-e986e587cf0a"}]}]
UrlDownloadToFile, %FreedomScriptsChangelogURL%, %ChangelogIniFilepath%
if(ErrorLevel){
Message = Failed to Download Changelog
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
parsed := JSON.Load(data)
IniRead, UpdateVersion, %ChangelogIniFilepath%, %ScriptSettingsSection%, ScriptVersion, %A_Space%
if(UpdateVersion = ""){
ToolTip
; MsgBox, update version is blank.
Return
Version := parsed.1.name
}
; msgbox, Version: %Version%`nScriptVersion: %ScriptVersion%
if(ScriptVersion = Version){
ToolTip
return
}
else, {
; msgbox, update found!
; Message = Program Update Found
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
IniWrite, 1, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable
if(ScriptVersion != UpdateVersion){
; msgbox, update found!
Message = Script Update Found
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
IniWrite, 1, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable
; GuiControl,, UpdateAvailable, Update Available - Click to View
}
; return
GuiControl,, UpdateAvailable, Update Available - Click to View
}
else, {
Message = No Updates Found
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
IniWrite, 0, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable
; @todo DELETE the rest of this.
/*
Msgbox % "Version: " Version
ChangeLog := parsed.1.body
exename := parsed.1.assets.1.name
exeURL := parsed.1.assets.1.browser_download_url
Msgbox % "exeURL: " exeURL
Msgbox % "exename: " exename
}
if(True)
return
; Msgbox % "FreedomScriptsChangelogURL: " FreedomScriptsChangelogURL
; Msgbox % "ChangelogIniFilepath: " ChangelogIniFilepath
; Msgbox % "ScriptSettingsSectio: " ScriptSettingsSection
; Msgbox % "SettingsIniFilepath: " SettingsIniFilepath
UrlDownloadToFile, %FreedomScriptsChangelogURL%, %ChangelogIniFilepath%
if(ErrorLevel){
Message = Failed to Download Changelog
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
IniRead, UpdateVersion, %ChangelogIniFilepath%, %ScriptSettingsSection%, ScriptVersion, %A_Space%
if(UpdateVersion = ""){
ToolTip
; MsgBox, update version is blank.
Return
}
if(ScriptVersion != UpdateVersion){
; msgbox, update found!
Message = Script Update Found
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
IniWrite, 1, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable
GuiControl,, UpdateAvailable, Update Available - Click to View
}
else, {
Message = No Updates Found
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
IniWrite, 0, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable
}
*/
ToolTip
return
}
@ -153,11 +194,11 @@ UpdateScript(){
; sleep, 5000
if(SaveFilepath = ""){
SaveFilepath := ErrorLoggingDirectory
}
SaveFilepath := ErrorLoggingDirectory
}
; if(!FileExist(SaveFilepath))
FileCreateDir, %SaveFilepath%
; if(!FileExist(SaveFilepath))
FileCreateDir, %SaveFilepath%
/* if(!TakeScreenshotsOfErrors)
Return
@ -982,14 +1023,14 @@ if(TotalTabsFound = 1){
; NumberOfTabLoops := Driver.Windows.Count + 2
loop % NumberOfTabLoops { ; loop through tabs to find matching tab
try driver.SwitchToNextWindow()
try driver.SwitchToNextWindow()
; sleep, 1000
; msgbox, looping through tabs
try CurrentTabTitle := driver.window.title
; sleep, 1000
; msgbox, looping through tabs
try CurrentTabTitle := driver.window.title
; caused by tab being manually closed. Not sure if this is the only cause though.
if(CurrentTabTitle = "") {
; caused by tab being manually closed. Not sure if this is the only cause though.
if(CurrentTabTitle = "") {
Message = CurrentTabTitle: %CurrentTabTitle%
DevModeMsgBox(Message)

Loading…
Cancel
Save