From 5b2e8970bf9acb4e97a507c29f707e5cdcedc279 Mon Sep 17 00:00:00 2001 From: Yuriy Date: Fri, 17 May 2024 19:56:24 -0400 Subject: [PATCH] code cleanup, save gui positions between runs --- Freedomain Social Media Poster.ahk | 53 ++++++++++-------------------- 1 file changed, 18 insertions(+), 35 deletions(-) diff --git a/Freedomain Social Media Poster.ahk b/Freedomain Social Media Poster.ahk index 29a5fae..a2f50c7 100644 --- a/Freedomain Social Media Poster.ahk +++ b/Freedomain Social Media Poster.ahk @@ -140,6 +140,7 @@ IniRead, DiscordErrorLoggingWebhookBotURL, %SettingsIniFilepath%, SocialMediaPos IniRead, DiscordParlerWebhookURL, %SettingsIniFilepath%, SocialMediaPoster, DiscordParlerWebhookURL, %A_Space% IniRead, ChromeFilepath, %SettingsIniFilepath%, SocialMediaPoster, ChromeFilepath, %A_Space% IniRead, ConfirmBeforeSubmit, %SettingsIniFilepath%, %ScriptSettingsSection%, ConfirmBeforeSubmit, 1 +; IniRead, SaveGUIPosition, %SettingsIniFilepath%, %ScriptSettingsSection%, SaveGUIPosition, 1 @@ -474,6 +475,7 @@ Gui, Add, Checkbox, xp+10 yp+25 vAutoUpdateCheck Checked%AutoUpdateCheckCheckSta Gui, Add, Checkbox,vShowTooltipProgress Checked%ShowTooltipProgressCheckStatus% gUpdateVars, Show Tooltip of Progress Gui, Add, Checkbox, vSaveTagsBetweenPosts Checked%SaveTagsBetweenPostsCheckStatus% gUpdateVars, Save Tags Between Posts Gui, Add, Checkbox, vConfirmBeforeSubmit checked%ConfirmBeforeSubmit%, Confirm Before Submit +; Gui, Add, Checkbox, vSaveGUIPosition checked%SaveGUIPosition%, Save GUI Position ; Gui, Add, Checkbox, vPauseBetweenPosts Checked%PauseBetweenPostsCheckCheckStatus% gUpdateVars, Pause Briefly Between Posts ; Gui, Add, Checkbox, vAutoRestartChromeDebug Checked%PauseBetweenPostsCheckCheckStatus% gUpdateVars, Auto Restart Chrome in Debug Mode @@ -490,26 +492,16 @@ Gui, Add, Checkbox, y+7 vGab Checked%GabCheckStatus% gUpdateVars, Gab Gui, Add, Checkbox, y+7 vLocals Checked%LocalsCheckStatus% gUpdateVars, Locals Gui, Add, Checkbox, y+7 vTwetch Checked%TwetchCheckStatus% gUpdateVars, Twetch - ; Second Row -; Gui, Add, Checkbox, vLinkedIn Checked%LinkedINCheckStatus% gUpdateVars, LinkedIn Gui, Add, Checkbox, x+75 yp-190 vLinkedIn Checked%LinkedINCheckStatus% gUpdateVars, LinkedIn -; Gui, Add, Checkbox, y+7 vLinkedIn Checked%LinkedINCheckStatus% gUpdateVars, LinkedIn -; Gui, Add, Checkbox, y+7 vThinkspot Checked%ThinkSpotCheckStatus% gUpdateVars, Thinkspot -; Gui, Add, Checkbox, y+7 vFlote Checked%FloteCheckStatus% gUpdateVars, Flote -; Gui, Add, Checkbox, y+7 vParler Checked%ParlerCheckStatus% gUpdateVars, Parler Gui, Add, Checkbox, y+7 vSteemit Checked%SteemitCheckStatus% gUpdateVars, Steemit -; Gui, Add, Checkbox, y+7 vPintrest Checked%PintrestCheckStatus% gUpdateVars, Pintrest Gui, Add, Checkbox, y+7 vPocketNet Checked%PocketNetCheckStatus% , Bastyon -; Gui, Add, Checkbox, y+7 vTumblr Checked%TumblrCheckStatus% , Tumblr Gui, Add, Checkbox, y+7 vGettr Checked%GettrCheckStatus% gUpdateVars, Gettr Gui, Add, Checkbox, y+7 vMeWe Checked%MeWeCheckStatus% gUpdateVars, MeWe Gui, Font, Bold gui, Font, s15 -; : Gui, Add, Text, , My Text. -; Gui, Font, Color, Red Gui, Add, Button, x%PlatformsGroupBoxXLocation% y485 w300 h113 gPostPost, Publish ; Gui, Add, Button, x%PlatformsGroupBoxXLocation% y+20 w300 h30 gSchedulePost, Schedule Post @@ -521,33 +513,19 @@ gui, font, normal Gui, Add, StatusBar,, Total Posts Posted: %TotalPostsPosted% | Total Run Time: %TotalRunTime% Seconds | ; easier to just let the gui size be as needed instead of trying to recalculate the size each time an element is added -; Gui, Show, x%XPosition% y%YPosition% ,%FullScriptName% ; , w%GuiWidth%, %ScriptName% -Gui, Show, ,%FullScriptName% ; , w%GuiWidth%, %ScriptName% +; if(SaveGUIPosition) +Gui, Show, x%XPosition% y%YPosition% ,%FullScriptName% ; , w%GuiWidth%, %ScriptName% +; else, +; Gui, Show,,%FullScriptName% ; , w%GuiWidth%, %ScriptName% + +; Activate the Post Title input box so user can start instantly typing in their new message ControlFocus, Edit1, %FullScriptName% ; check for updates if the setting is enabled if(AutoUpdateCheck AND !UpdateAvailable){ - Message = Checking for Updates - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - ; DevModeMsgBox("checking for updates") - ; msgbox, checkin for update - ; DevModeMsgBox(GitReleasesAPIURL) - ; UpdateAvailable := - - if(CheckForUpdates(GitReleasesAPIURL)) - GuiControl,,UpdateAvailable, Uploader Update Available! - - if(CheckForChromeUpdates(ChromeFilepath)){ - GuiControl,,ChromeUpdateAvailable, Chrome Update Available! - ChromeUpdateAvailable := 1 - - } + SetTimer, CheckForUpdates, -1000 } - - -;---Check for Update--- -;------------------------------------------------ Return @@ -739,7 +717,10 @@ Return PostPost: -Gui, Submit +Gui, Submit, NoHide + +; Get GUI window position for saving to settings file +WinGetPos, XPosition, YPosition, , , A if(InStr(PostTags, "http")){ Message = Post Tags contain "http". Please edit and remove the url and try again. @@ -751,7 +732,6 @@ if(InStr(PostTags, "http")){ Gui, Destroy -; 20211023061711 ScheduledTime := SubStr(ScheduledTime, 1, 12) ; pull out time date up to the minute and exclude seconds ; Msgbox % "ScheduledTime: " ScheduledTime ; clipboard := ScheduledTime @@ -764,7 +744,6 @@ ScheduledTime := SubStr(ScheduledTime, 1, 12) ; pull out time date up to the min ; if the argument is an error logging post, we want to continue where it left off and log to the same place -; Msgbox % "ErrorLoggingDirectory: " ErrorLoggingDirectory if(InStr(ErrorLoggingDirectory, "\Templates\") OR ErrorLoggingDirectory = "" OR InStr(ErrorLoggingDirectory, "VideoLinks.ini")){ ; msgbox, creating new error logging files CreateErrorLoggingFiles() @@ -774,7 +753,7 @@ if(InStr(ErrorLoggingDirectory, "\Templates\") OR ErrorLoggingDirectory = "" OR ; Save Script Settings to File ; ------------------------------------------------ -WinGetPos, XPosition, YPosition, , , A + IniWrite, %XPosition%, %SettingsIniFilepath%, %ScriptSettingsSection%, XPosition IniWrite, %YPosition%, %SettingsIniFilepath%, %ScriptSettingsSection%, YPosition @@ -788,6 +767,7 @@ IniWrite, %PauseBetweenPosts%, %SettingsIniFilepath%, SocialMediaPoster, PauseBe IniWrite, %ErrorLoggingDirectory%, %SettingsIniFilepath%, %ScriptSettingsSection%, LastPost IniWrite, %ConfirmBeforeSubmit%, %SettingsIniFilepath%, %ScriptSettingsSection%, ConfirmBeforeSubmit +; IniWrite, %SaveGUIPosition%, %SettingsIniFilepath%, %ScriptSettingsSection%, SaveGUIPosition ; Used by Post Scheduler, filepath changes between script updates IniWrite, %A_ScriptFullPath%, %SettingsIniFilepath%, Filepaths, SocialMediaPosterFilepath @@ -1066,7 +1046,10 @@ Gui, Font, s%GUINormalFontSize% gui, font, s6 Gui, Add, StatusBar,, Total Posts Posted: %TotalPostsPosted% | Run Time: %ScriptRunTime% Seconds +; if(SaveGUIPosition) Gui, Show, x%XPosition% y%YPosition%, %FullScriptName% - Post Results +; else, +; Gui, Show,, %FullScriptName% - Post Results SaveCurrentChromeVersionToIniFile()