diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e7b8424 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +Settings.ini +VideoLinks.ini +body.txt +**/ErrorLogging +**/Backups +**/Debug +**/Templates +**/Testing \ No newline at end of file diff --git a/Assets/FreedomainSMP.ico b/Assets/FreedomainSMP.ico new file mode 100644 index 0000000..534922d Binary files /dev/null and b/Assets/FreedomainSMP.ico differ diff --git a/Assets/FreedomainShare_Scheduled.ico b/Assets/FreedomainShare_Scheduled.ico new file mode 100644 index 0000000..787d001 Binary files /dev/null and b/Assets/FreedomainShare_Scheduled.ico differ diff --git a/Assets/Instructions.docx b/Assets/Instructions.docx new file mode 100644 index 0000000..241eb14 Binary files /dev/null and b/Assets/Instructions.docx differ diff --git a/Assets/Instructions_Updated_20211212_143912.docx b/Assets/Instructions_Updated_20211212_143912.docx new file mode 100644 index 0000000..8aaaed2 Binary files /dev/null and b/Assets/Instructions_Updated_20211212_143912.docx differ diff --git a/Assets/Share.ico b/Assets/Share.ico new file mode 100644 index 0000000..2a6e35e Binary files /dev/null and b/Assets/Share.ico differ diff --git a/Assets/Update Selenium ChromeDriver.docx b/Assets/Update Selenium ChromeDriver.docx new file mode 100644 index 0000000..30ed241 Binary files /dev/null and b/Assets/Update Selenium ChromeDriver.docx differ diff --git a/Assets/Update Selenium ChromeDriver.pdf b/Assets/Update Selenium ChromeDriver.pdf new file mode 100644 index 0000000..049e9e6 Binary files /dev/null and b/Assets/Update Selenium ChromeDriver.pdf differ diff --git a/Assets/Update.ico b/Assets/Update.ico new file mode 100644 index 0000000..48250ae Binary files /dev/null and b/Assets/Update.ico differ diff --git a/Freedomain Social Media Poster.ahk b/Freedomain Social Media Poster.ahk new file mode 100644 index 0000000..b3cf1a9 --- /dev/null +++ b/Freedomain Social Media Poster.ahk @@ -0,0 +1,4219 @@ +#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. +;#Warn ; Enable warnings to assist with detecting common errors. +#SingleInstance, Force +SendMode Input ; Recommended for new scripts due to its superior speed and reliability. +SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. +CoordMode, ToolTip, Screen +CoordMode, Mouse, Screen +FileEncoding, UTF-8-RAW ; Needed for special symbols that are used in video descritions +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% +; Add menus to the toolbar icon + +Menu, tray, NoStandard ; remove standard tray + +Menu, Tray, Add, Exit, KillScript +Menu, Tray, Add, Pause, PauseScript +Menu, Tray, Add, Start New Post, ReloadScript +Menu, Tray, Add, Reload wLast Post, LoadLastPost +Menu, Tray, Default, Reload wLast Post + + +global ScriptName +global ScriptVersion +global FullScriptName + + +;---Notes/Extra Info/#Includes------------------------------------------------------ +ScriptName = Freedomain Social Media Poster +ScriptVersion = 2.70 +FullScriptName := ScriptName . " " . ScriptVersion + +changelog = +( + Fixed Locals Posting + Fixed Gettr Posting + Fixed Flote Posting + Fixed MeWe Posting + Fixed Minds Posting + Fixed Steemit Posting + Fixed LinkedIn Image Posting + Removed Tumblr Support + Removed Pintrest support + ) +Changelog := StrReplace(changelog, A_Tab, "") +Changelog := StrReplace(changelog, "`n", "--") + + + +;---ToDo--- +;------------------------------------------------ +; Steemit not submitting +; linkedin image posting not working + + +; @todo: fix post scheduling - countdown not working + +; @todo: being called from video uploader, skip over locals if video uploaed there +; @todo: add testing mode functionality similiar to video uploader +; @todo: Add option to auto restart chrome in debug mode +; @todo: Add hashtags to LinkedIn +; @todo: add icons? maybe? +; @todo: finish adding functionality for checkboxes next to title +; @todo: Make website buttons activate tab for site +; @todo: make facebook button open tab for facebook + +; @todo: Errorlog not getting appended to on > 1 run (ErrorLoggingFilePath) variable is missing somehwere +; @todo: add a progress of 5/10 to show +; @todo: start new post after update if description has no text in it when update run +; @todo: tags aren't saved with templates +; @todo: Add tags support on all sites that support it - ask stef is useful +; @todo: save post tags and title to teh same file as ini file instead of two files + +; @todo: Add workaround for all chrome tabs not being counted properly by selenium, using array? +; @todo: add support for scheduled posts. + +; Misc info +;------------------------------------------------ +; Parler has a 1k char limit + + +;---Global Variables--- +;------------------------------------------------ +global Driver +global DriverStatus +global CurrentSite +global DiscordParlerWebhookURL +global DiscordErrorLoggingWebhookBotURL +global TooltipXPosition +global ShowTooltipProgress +global ErrorLoggingDirectory +global ErrorLoggingFilePath +global StatusFileFilePath +global PostTitleFilePath +global PostBodyFilePath +global ErrorLogVar +global PostTitle +global PostBody +global PostTitleAndBody +global PostTags +global ImageAttachmentFilepath +global ReuseTabs +global WindowTitle ; Tab title of already existing window of each site +global PauseBetweenPosts ; pause for a couple of seconds between posts so user has a chance to visually see confirmation +global PauseTimeBetweenPosts +global TimeBetweenpostsInMiliseconds +global DevMode +global ScreenshotResult +global ScriptRunTime +global URLOfLastErrorPage + +; Website Post Statuses +global Discord +global SubScribeStar +global Telegram +global Minds +global Gab +global Locals +global LinkedIn +global MeWe +global Twetch +global ThinkSpot +global Flote +global PocketNet +global parler +global Gettr +global steemit +; global Pintrest +; global Tumblr + +; Check if Lib folder exists and create it if not +LibFolder := A_ScriptDir . "\Lib" +ErrorLoggingFolder := A_ScriptDir . "\Lib\ErrorLogging" +FileCreateDir, %ErrorLoggingFolder% + +; Set filepaths for different files and folders +global SettingsIniFilepath +SettingsIniFilepath := A_ScriptDir . "\Settings.ini" + +global ChangelogIniFilepath +ChangelogIniFilepath := A_ScriptDir . "\Lib\FreedomScriptsChangelogINI" + +global ScriptSettingsSection +ScriptSettingsSection := "SocialMediaPoster" + +;---General Info--- +;------------------------------------------------ +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% + + +;---Checkbox Settings--- +;------------------------------------------------ +IniRead, BoldTitleWAPI, %SettingsIniFilepath%, SocialMediaPoster, BoldTitleWAPI, 1 +(BoldTitleWAPI)?(BoldTitleCheckStatus := 1) : (BoldTitleCheckStatus := 0) + +IniRead, NewLineBetweenTitle, %SettingsIniFilepath%, SocialMediaPoster, NewLineBetweenTitle, 1 +(NewLineBetweenTitle)?(SpaceBetweenTitleBodyCheckStatus := 1) : (SpaceBetweenTitleBodyCheckStatus := 0) + + +IniRead, ShowTooltipProgress, %SettingsIniFilepath%, SocialMediaPoster, ShowTooltipProgress, 1 +(ShowTooltipProgress)?(ShowTooltipProgressCheckStatus := 1) : (ShowTooltipProgressCheckStatus := 0) + +IniRead, ReuseTabs, %SettingsIniFilepath%, SocialMediaPoster, ReuseTabs, 1 +(ReuseTabs)?(ReuseTabsCheckStatus := 1) : (ReuseTabsCheckStatus := 0) + +IniRead, AutoUpdateCheck, %SettingsIniFilepath%, SocialMediaPoster, AutoUpdateCheck, 1 +(AutoUpdateCheck)?(AutoUpdateCheckCheckStatus := 1) : (AutoUpdateCheckCheckStatus := 0) + +IniRead, SaveTagsBetweenPosts, %SettingsIniFilepath%, SocialMediaPoster, SaveTagsBetweenPosts, 1 +(SaveTagsBetweenPosts)?(SaveTagsBetweenPostsCheckStatus := 1) : (SaveTagsBetweenPostsCheckStatus := 0) +if(SaveTagsBetweenPosts) +IniRead, PostTags, %SettingsIniFilepath%, SocialMediaPoster, PostTags, %A_Space% + +IniRead, PauseBetweenPosts, %SettingsIniFilepath%, SocialMediaPoster, PauseBetweenPosts, 0 +(PauseBetweenPosts)?(PauseBetweenPostsCheckCheckStatus := 1) : (PauseBetweenPostsCheckCheckStatus := 0) +if(PauseBetweenPosts){ + IniRead, PauseTimeBetweenPosts, %SettingsIniFilepath%, SocialMediaPoster, PauseTimeBetweenPosts, 3 + TimeBetweenpostsInMiliseconds := PauseTimeBetweenPosts * 1000 +} + + +IniRead, UpdateAvailable, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable, %A_Space% + +IniRead, TotalPostsPosted, %SettingsIniFilepath%, %ScriptSettingsSection%, TotalPostsPosted,0 +IniRead, TotalRunTime, %SettingsIniFilepath%, %ScriptSettingsSection%, TotalRunTime, 0 + +;---Auto Updater Settings--- +;------------------------------------------------ +; Misc Auto Update settings +global FreedomainProgramUpdaterFilepath +FreedomainProgramUpdaterFilepath := A_ScriptDir . "\Freedomain Program Updater.exe" + +global FreedomainProgramUpdaterURL +FreedomainProgramUpdaterURL = https://freedomainplaylists.com/wp-content/FreedomainScripts/Freedomain`%20Program`%20Updater.exe + +global FreedomScriptsChangelogURL +FreedomScriptsChangelogURL = https://freedomainplaylists.com/wp-content/FreedomainScripts/FreedomScriptsChangelogINI + +global UpdateURL +UpdateURL = https://freedomainplaylists.com/wp-content/FreedomainScripts/Freedomain`%20Social`%20Media`%20Poster.exe + +; 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 +ProgramExeFilepath := A_ScriptFullPath +ProgramExeFilepath := StrReplace(ProgramExeFilepath, ".ahk", ".exe") +IniWrite, %ProgramExeFilepath%, %SettingsIniFilepath%, %ScriptSettingsSection%, Filepath +IniWrite, %ScriptVersion%, %SettingsIniFilepath%, %ScriptSettingsSection%, ScriptVersion + + + +; Download Program Updater +if(!FileExist(FreedomainProgramUpdaterFilepath)){ + TooltipThis("Downloading Program Updater") + UrlDownloadToFile, %FreedomainProgramUpdaterURL%, %FreedomainProgramUpdaterFilepath% + ToolTip +} + + + +;---Load Settings From Previous Post--- +;------------------------------------------------ +if(ErrorLoggingDirectory = "LastPost"){ + IniRead, ErrorLoggingDirectory, %SettingsIniFilepath%, %ScriptSettingsSection%, LastPost, %A_Space% +} + +if(StrLen(ErrorLoggingDirectory) > 5){ ; if argument was passed in, read contents from that directory + SkipUpdateCheckThisRun := 1 + + if(InStr(ErrorLoggingDirectory, "VideoLinks.ini")){ ;PASSED IN FROM VIDEO UPLOADER + + VideoLinksFilepath = %ErrorLoggingDirectory% + + SplitPath, VideoLinksFilepath, OutFileName, VideoLinksDir, OutExtension, OutNameNoExt, OutDrive + PostTitleFilepath := VideoLinksDir . "\title.txt" + FileRead, PostTitle, %PostTitleFilepath% + ; Msgbox % "PostTitle: " PostTitle + + ; Read the post body from the text file adn then + ; SPlit it and remove the repeating text bit at the bottom + PostBodyFilepath := VideoLinksDir . "\body.txt" + FileRead, Postbody, %PostBodyFilepath% + SplitText = Free Documentaries: + Postbody := StrSplit(Postbody, SplitText) + Postbody := Postbody[1] + + ; Read post tags from text file + PostTagsFilepath := VideoLinksDir . "\keywords.txt" + + FileRead, PostTags, %PostTagsFilepath% + ; Msgbox % "PostTags: " PostTags + + + ; Read thumbnail filepath from video links file + IniRead, ImageAttachmentFilepath, %ErrorLoggingDirectory%,Misc, VideoThumbFilepath, %A_Space% + + ; Read video links from video links file + IniRead, BitChuteURL, %ErrorLoggingDirectory%,URLs, BitChuteURL, %A_Space% + IniRead, RumbleURL, %ErrorLoggingDirectory%,URLs, RumbleURL, %A_Space% + IniRead, StreamanityURL, %ErrorLoggingDirectory%,URLs, StreamanityURL, %A_Space% + ; IniRead, BitChuteURL, %ErrorLoggingDirectory%,URLs, BitChuteURL, %A_Space% + + if(BitChuteURL = ""){ + if(RumbleURL != "") + VideoURL := RumbleURL + else, + VideoURL := StreamanityURL + } + else, + VideoURL := BitChuteURL + ; Append bitchute url to bottom of description + PostBody := PostBody . "`n`n" . VideoURL + +/* Msgbox % "PostTitle: " PostTitle + Msgbox % "PostBody: " PostBody + + */ + Discord := 0 + Telegram := 0 + } + else, { ; otherwise passed in from a previous run. + + StatusFileFilePath := ErrorLoggingDirectory . "\" . "PostStatus.ini" + ErrorLoggingFilePath := ErrorLoggingDirectory . "\" . "ErrorLogging.txt" + FileRead, PostTitle, %ErrorLoggingDirectory%\PostTitle.txt + FileRead, PostBody, %ErrorLoggingDirectory%\PostBody.txt + IniRead, PostTags, %StatusFileFilePath%, General, PostTags, %A_Space% + IniRead, ImageAttachmentFilepath, %StatusFileFilePath%, General, ImageAttachmentFilepath, %A_Space% + + ReadWebsiteStatuses() ; Read .ini file of post statuses for each site + } +} + + +; Set checked status for each checkbox depending on each website's status +(Discord != "")?(DiscordCheckStatus := 0) : (DiscordCheckStatus := 1 ) +(SubScribeStar != "")?(SubScribeStarCheckStatus := 0) : (SubScribeStarCheckStatus := 1) +(Telegram != "")?(TelegramCheckStatus := 0) : (TelegramCheckStatus := 1) +(Minds != "")?(MindsCheckStatus := 0) : (MindsCheckStatus := 1) +(Gab != "")?(GabCheckStatus := 0) : (GabCheckStatus := 1) +(MeWe != "")?(MeWeCheckStatus := 0) : (MeWeCheckStatus := 1) ; UNCHECKED ALWAYS as of 2022/04/08 +(Gettr != "")?(GettrCheckStatus := 0) : (GettrCheckStatus := 1) +(Steemit != "")?(SteemitCheckStatus := 0) : (SteemitCheckStatus := 1) +(Locals != "")?(LocalsCheckStatus := 0) : (LocalsCheckStatus := 1) +(LinkedIN != "")?(LinkedINCheckStatus := 0) : (LinkedINCheckStatus := 1) +(Twetch != "")?(TwetchCheckStatus := 0) : (TwetchCheckStatus := 1) +(ThinkSpot != "")?(ThinkSpotCheckStatus := 0) : (ThinkSpotCheckStatus := 1) +(Flote != "")?(FloteCheckStatus := 0) : (FloteCheckStatus := 1) +; (Pintrest != "")?(PintrestCheckStatus := 0) : (PintrestCheckStatus := 1) +(Parler != "")?(ParlerCheckStatus := 0) : (ParlerCheckStatus := 1) +(PocketNet != "")?(PocketNetCheckStatus := 0) : (PocketNetCheckStatus := 1) +; (Tumblr != "")?(TumblrCheckStatus := 0) : (TumblrCheckStatus := 1) + + + +if(TestingMode){ ; Easy testing for Yuriy + DiscordCheckStatus := 0 + TelegramCheckStatus := 0 + SubScribeStarCheckStatus := 0 + MindsCheckStatus := 0 + LocalsCheckStatus := 0 + GettrCheckStatus := 0 + SteemitCheckStatus := 0 + GabCheckStatus := 0 + LinkedINCheckStatus := 0 + MeWeCheckStatus := 0 + TwetchCheckStatus := 0 + ThinkSpotCheckStatus := 0 + FloteCheckStatus := 0 + ; PintrestCheckStatus := 0 + ParlerCheckStatus := 0 + PocketNetCheckStatus := 0 + ; TumblrCheckStatus := 0 + ; PocketNetCheckStatus := 0 + +} + + +;---GUI Variables--- +;------------------------------------------------ +TooltipXPosition := Round((A_ScreenWidth / 2) - (A_ScreenWidth / 10)) ; Center Tooltip on the screen and a bit to the left + +GuiWidth := 950 +TemplatesGroupBoxWidth := 700 +MarginSpace = 10 +MarginSpaceDoubled := MarginSpace * 2 +EditBoxWidth := 700 +EditBoxHalfWidths := EditBoxWidth / 2 - (MarginSpace * 1.7) +EditBoxThirdsWidth := EditBoxWidth / 3 - (MarginSpace * 1.5) +GroupBox_PlatformsWidth := 180 +ImageSelectionButtonWidth := 100 +ImageFilepathEditBoxWidth := EditBoxWidth - ImageSelectionButtonWidth - MarginSpace +SelectFileButtonWidth := 50 +SelectFileButtonXPos := EditBoxWidth - SelectFileButtonWidth - MarginSpace +CharCountXPos := EditBoxWidth - 20 +; FilePathEditBoxWidth := EditBoxWidth - SelectFileButtonWidth - MarginSpace + +PlatformsGroupBoxXLocation := EditBoxWidth + (MarginSpace * 3) +; SettingsGroupBoxXLocation := PlatformsGroupBoxXLocation + ActionButtonWidths +SettingsGroupBoxXLocation := PlatformsGroupBoxXLocation + GroupBox_PlatformsWidth +ActionButtonWidths := 355 + +ActionButtonHalfWidths := (ActionButtonWidths / 2) - (MarginSpace / 2) + +Gui, Margin, %MarginSpace%, %MarginSpace% +GUINormalFontSize := 15 + + +Gui, Font, s10 +; Gui, Font, s8 +if(TestingMode){ + Gui, Add, Text,cRed yp+0 x%MarginSpace% ,TESTING MODE +} +if(DevMode){ + Gui, Add, Text,cRed yp+0 x+30 ,DEV MODE +} + + +Gui, Font, s%GUINormalFontSize% +Gui, Font, Bold +Gui, Add, Text, x%Marginspace% y+5 w%EditBoxWidth%, Post Title +Gui, Font, s8 +Gui, Add, Checkbox, xp+120 yp+10 vBoldTitleWAPI Checked%BoldTitleCheckStatus% gUpdateVars,Bold Title on Discord/Telegram +Gui, Add, Checkbox, xp+220 yp+0 vNewLineBetweenTitle Checked%SpaceBetweenTitleBodyCheckStatus% gUpdateVars,Blank Line Between Title+Body +Gui, Font, Normal +Gui, Font, s%GUINormalFontSize% +Gui, Add, Edit, x%MarginSpace% y+3 w%EditBoxWidth% vPostTitle gUpdateCharCount h75, %PostTitle% + +Gui, Font, Bold +Gui, Add, Text,w%EditBoxWidth%, Post Body +Gui, Font, Normal + + +Gui, Font, s%GUINormalFontSize% +Gui, Add, Edit, x%MarginSpace% y+2 w%EditBoxWidth% h150 vPostBody gUpdateCharCount, %PostBody% + +; Gui, font, color, cblack + + +Gui, Font, s%GUINormalFontSize% +Gui, Font, Bold +Gui, Add, Text, x%marginspace% y+%MarginSpace% w%EditBoxWidth% ,Tags + +Gui, Font, s7 +Gui, Font, Normal +; Gui, font, color, cRed +Gui, Add, Edit,yp-5 x%CharCountXPos% w30 vCharCount, + +Gui, Font, s%GUINormalFontSize% +Gui, Font, Normal +Gui, Add, Edit, x%MarginSpace% y+10 vPostTags gUpdateVars h33 w%EditBoxWidth%, %PostTags% + +Gui, Font, s%GUINormalFontSize% +Gui, Font, Bold +Gui, Add, Text,x%marginspace% w%EditBoxWidth%, Image Attachment Filepath +Gui, Font, Normal +Gui, Add, Edit, x%MarginSpace% y+2 vImageAttachmentFilepath gUpdateVars h33 w%ImageFilepathEditBoxWidth%, %ImageAttachmentFilepath% +Gui, Add, Button, gSelectFilepath w%ImageSelectionButtonWidth% x+M yp+0 h33, Select + +Gui, Font, Bold +Gui, Add, GroupBox,r2.5 x%MarginSpace% y+15 Center w%TemplatesGroupBoxWidth%, Other +Gui, Font, Normal +Gui, Add, Button,xp+%Marginspace% yp+35 w%EditBoxThirdsWidth% h30 gSaveAsTemplate, Save As Template +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 +else, +Gui, Add, Button, x%MarginSpaceDoubled% y+%MarginSpace% w%EditBoxHalfWidths% h30 gUpdateScript vUpdateAvailable, Program is Up-to-Date + + +Gui, Add, Button,x+%MarginSpace% yp+0 w%EditBoxHalfWidths% h30 gCancelPost, Close Window +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 + 130 +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, Font, Bold +Gui, Font, s%GUINormalFontSize% +Gui, Add, GroupBox,r4 x%PlatformsGroupBoxXLocation% y%MarginSpace% w300, Settings +Gui, Font, s11 +Gui, Font, Normal +Gui, Add, Checkbox, xp+10 yp+25 vReuseTabs Checked%ReuseTabsCheckStatus% gUpdateVars, Try to Re-Use Tabs +; Gui, Add, Checkbox, vNewChromeWindow Checked%AutoUpdateCheckCheckStatus% gUpdateVars, Create New Chrome Window (WIP) +Gui, Add, Checkbox,vShowTooltipProgress Checked%ShowTooltipProgressCheckStatus% gUpdateVars, Show Tooltip of Progress +Gui, Add, Checkbox, vAutoUpdateCheck Checked%AutoUpdateCheckCheckStatus% gUpdateVars, Auto Update Check +Gui, Add, Checkbox, vSaveTagsBetweenPosts Checked%SaveTagsBetweenPostsCheckStatus% gUpdateVars, Save Tags Between Posts +Gui, Add, Checkbox, vPauseBetweenPosts Checked%PauseBetweenPostsCheckCheckStatus% gUpdateVars, Pause Briefly Between Posts +; Gui, Add, Checkbox, vAutoRestartChromeDebug Checked%PauseBetweenPostsCheckCheckStatus% gUpdateVars, Auto Restart Chrome in Debug Mode +Gui, Font, s%GUINormalFontSize% + + + + + +Gui, Font, Bold +Gui, Add, GroupBox,r8 x%PlatformsGroupBoxXLocation% y185 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 +Gui, Add, Checkbox, y+7 vSubscribeStar Checked%SubScribeStarCheckStatus%gUpdateVars, SubscribeStar +Gui, Add, Checkbox, y+7 vMinds Checked%MindsCheckStatus% gUpdateVars, Minds +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+60 yp-185 vMeWe Checked%MeWeCheckStatus% gUpdateVars, MeWe +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, Font, Bold +gui, Font, s12 +; : Gui, Add, Text, , My Text. +; Gui, Font, Color, Red +Gui, Add, Button, x%PlatformsGroupBoxXLocation% y+65 w300 h50 gPostPost, Post! + +Gui, Add, Button, x%PlatformsGroupBoxXLocation% y+20 w300 h30 gSchedulePost, Schedule Post + + +; Gui, Font, s%GUINormalFontSize% +gui, font, s6 +Gui, Add, StatusBar,, Total Posts Posted: %TotalPostsPosted% | Total Run Time: %TotalRunTime% Seconds | + +Gui, Show,,%FullScriptName% ; ,w%GuiWidth%, %ScriptName% +ControlFocus, Edit1, %FullScriptName% + +;---Check for Update--- +;------------------------------------------------ +if(AutoUpdateCheck AND !UpdateAvailable AND !SkipUpdateCheckThisRun){ + CheckForUpdates() +} +Return + + + + + +;---Misc GoSubs--- +;------------------------------------------------ +SaveAsTemplate: +TemplateDirectory = %A_ScriptDir%\Lib\Templates +if(!FileExist(TemplateDirectory)){ + FileCreateDir, %TemplateDirectory% +} + +InputBox, TemplateName, Input Name, Please Input Name for the Template: +if(ErrorLevel) +Return + +TemplateDirectory = %A_ScriptDir%\Lib\Templates\%TemplateName% +CreateErrorLoggingFiles(TemplateDirectory) + +FileAppend, %PostTitle%, %PostTitleFilePath% ; save post content to txt file +FileAppend, %PostBody%, %PostBodyFilePath% ; save post content to txt file + +IniWrite, %ImageAttachmentFilepath%, %StatusFileFilePath%, General, ImageAttachmentFilepath +IniWrite, %PostTags%, %StatusFileFilePath%, General, PostTags +Return + + +LoadTemplate: +Message = Loading Template +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%" +ExitApp + +ReloadScript: +Reload +Return + +KillScript: +ExitApp +Return + +PauseScript: +Pause, Toggle +Return + + +LoadLastPost: +; IniWrite, %ErrorLoggingDirectory%, %SettingsIniFilepath%, SocialMediaPoster, LastPost +; IniRead, ErrorLoggingDirectory, %SettingsIniFilepath%, %ScriptSettingsSection%, LastPost, %A_Space% +; Msgbox % "SettingsIniFilepath: " SettingsIniFilepath +; Msgbox % "ErrorLoggingDirectory: " ErrorLoggingDirectory +; msgbox, 4096, Sorry, Sorry this doesn't do anything yet. +run, "%A_ScriptFullPath%" "LastPost" +ExitApp + + + + +UpdateScript: +UpdateScript() +Return + +CancelPost: +GuiClose: +; ExitApp +Gui, Submit, +Return + +OpenErrorLog: +run, %ErrorLoggingDirectory% +Return + +ToggleTestingMode: +ToggleTestingMode() +run, %A_ScriptFullPath% "LastPost" +Return + +ToggleManualSubmit: +ToggleManualSubmit() +run, %A_ScriptFullPath% "LastPost" +Return + +ToggleDevMode: +ToggleDevMode() +run, "%A_ScriptFullPath%" "LastPost" +Return + +CompileScript: +; msgbox, compiling +IniWrite, %changelog%, %ChangelogIniFilepath%, %ScriptSettingsSection%, Changelog +IniWrite, %ScriptVersion%, %ChangelogIniFilepath%, %ScriptSettingsSection%, ScriptVersion +IniWrite, %UpdateURL%, %ChangelogIniFilepath%, %ScriptSettingsSection%, UpdateURL + +run, "%A_scriptdir%\Lib\Releases\Compile Scripts to EXE.ahk" SocialMediaPoster Production +; ExitApp +Return + +UploadFiles: +msgbox, this button needs to be re-programmed. Search for "UploadFiles:" in main program +Return + +SelectFilepath: +FileSelectFile, SelectedImageFilepath +GuiControl,, ImageAttachmentFilepath, %SelectedImageFilepath% +Return + +UpdateVars: +Gui, Submit, NoHide +Return + +UpdateCharCount: +Gui, Submit, NoHide +Count := StrLen(PostBody) + +/*if(Count > 256){ + GuiControl,, Twetch, 0 + +} +*/ + +GuiControl,, CharCount, %Count% +Return + + + +TryFailedAgain: +; msgbox %ErrorLoggingDirectory% +run, %A_ScriptFullPath% "LastPost" +ExitApp +; Return + +SchedulePost: +ScheduledPost := 1 +Gui, Submit +Gui, Destroy + +Gui, Font, Normal +Gui, Font, s20 +Gui, Add, Text, Center w350 x%marginspace%,Time to Post At +Gui, Add, DateTime, x%marginspace% vScheduledTime gUpdateVars w350, hh:mm tt +Gui, Font, s8 +Gui, Add, Checkbox, vDisplayCountdownTooltip gUpdateVars checked, Display Tooltip with Countdown +Gui, Font, s20 +Gui, Add, Button,gPostPost w350, Schedule Post Time +gui, show, w370 +Return + + + +PostPost: +Gui, Submit + +; Msgbox % "PostTags: " PostTags + +if(InStr(PostTags, "http")){ + Message = Post Tags contain "http". Please edit and remove the url and try again. + Msgbox, 4096, Error, %Message% + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar") + Return +} + + +Gui, Destroy + +; 20211023061711 +ScheduledTime := SubStr(ScheduledTime, 1, 12) ; pull out time date up to the minute and exclude seconds +; Msgbox % "ScheduledTime: " ScheduledTime +; clipboard := ScheduledTime +; Msgbox % "ScheduledTime: " ScheduledTime + +; DevModeMsgBox("stop") + +; if argument is passed to the script we want to do the following: +; If the argument is a template post, we want to create a new ErrorLogging directory for it +; 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() + +} ; + +; Msgbox % "SaveTagsBetweenPosts: "the SaveTagsBetweenPosts + +; Msgbox % "TakeScreenshotsOfErrors: " TakeScreenshotsOfErrors +; Save settings to .ini file +; SaveSettingsToIniFile(SettingName) + + +IniWrite, %BoldTitleWAPI%, %SettingsIniFilepath%, SocialMediaPoster, BoldTitleWAPI +IniWrite, %NewLineBetweenTitle%, %SettingsIniFilepath%, SocialMediaPoster, NewLineBetweenTitle +IniWrite, %ReuseTabs%, %SettingsIniFilepath%, SocialMediaPoster, ReuseTabs +IniWrite, %ShowTooltipProgress%, %SettingsIniFilepath%, SocialMediaPoster, ShowTooltipProgress +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 + + + +; Combines two variables together so they can be used as needed later +if(NewLineBetweenTitle) +PostTitleAndBody := PostTitle . "`n`n" . PostBody +else, +PostTitleAndBody := PostTitle . "`n" . PostBody + + +if(PostBody = ""){ + PostTitleAndBody := PostTitle +} +if(PostTitle = ""){ + PostTitleAndBody := PostBody + +} + +; Format text to javascript +JSPostTitleAndBody := FormatTextToJSText(PostTitleAndBody) +JSPostTitle := FormatTextToJSText(PostTitle) +JSPostBody := FormatTextToJSText(PostBody) + +FileAppend, %PostTitle%, %PostTitleFilePath% ; save post content to txt file +FileAppend, %PostBody%, %PostBodyFilePath% ; save post content to txt file +IniWrite, %ImageAttachmentFilepath%, %StatusFileFilePath%, General, ImageAttachmentFilepath + +IniWrite, %PostTags%, %StatusFileFilePath%, General, PostTags +IniWrite, %PostTags%, %SettingsIniFilepath%, SocialMediaPoster, PostTags +IniWrite, %ShowTooltipProgress%, %SettingsIniFilepath%, SocialMediaPoster, ShowTooltipProgress + +; TimeBetweenPosts := 5000 ; 5 seconds +; TimeBetweenpostsInSeconds := round(TimeBetweenPosts/1000) +; Msgbox % "TimeBetweenpostsInSeconds: " TimeBetweenpostsInSeconds + + +; Create a list of websites that are going to get psoted to for error logging purposes +(Discord = 1)?(PostedWebsites .= "Discord|") : () +(Telegram = 1)?(PostedWebsites .= "Telegram|") : () +(SubScribeStar = 1)?(PostedWebsites .= "SubScribeStar|") : () +(Minds = 1)?(PostedWebsites .= "Minds|") : () +(Gab = 1)?(PostedWebsites .= "Gab|") : () +(MeWe = 1)?(PostedWebsites .= "MeWe|") : () +(Locals = 1)?(PostedWebsites .= "Locals|") : () +(LinkedIn = 1)?(PostedWebsites .= "LinkedIn|") : () +(Twetch = 1)?(PostedWebsites .= "Twetch|") : () +(ThinkSpot = 1)?(PostedWebsites .= "ThinkSpot|") : () +(Flote = 1)?(PostedWebsites .= "Flote|") : () +(PocketNet = 1)?(PostedWebsites .= "PocketNet|") : () +(Gettr = 1)?(PostedWebsites .= "Gettr|") : () +(Parler = 1)?(PostedWebsites .= "Parler|") : () +(Steemit = 1)?(PostedWebsites .= "Steemit|") : () +(Pintrest = 1)?(PostedWebsites .= "Pintrest|") : () +(Tumblr = 1)?(PostedWebsites .= "Tumblr|") : () + +Message = Starting SMP with: **V%ScriptVersion%** `nTo sites: %PostedWebsites% `nWith Title: **%PostTitle%** `nWith Body:%PostBody% `nWith Tags: %PostTags% +SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging") + + + +if(InStr(PostBody, "www.dlive.tv") AND !InStr(PostBody, "https://www.dlive.tv")){ ; if posting Dlive link, turn it into hyperlink + PostBody := StrReplace(PostBody, "www.dlive.tv", "https://www.dlive.tv") +} + + + + +; Msgbox % "PostTitleAndBody: " PostTitleAndBody +; 20211023060415 +if(ScheduledPost){ + ; CheckSeleniumDriver() + ; Menu, Tray, Icon, %A_ScriptDir%\Lib\FreedomainShare_Scheduled.ico + Loop, { + FormatTime, CurrentTime, YYYYMMDDHH24MISS, yyyyMMddhhmm + ; FormatTime, TodayDate , YYYYMMDDHH24MISS, yyyyMMdd_hhmmss + + EnvSub, CurrentTime, ScheduledTime, Minutes + TimeLeft := StrReplace(CurrentTime, "-", "") + + if(TimeLeft = 0) + break + + if(DisplayCountdownTooltip){ + Message = Minutes Until SMP: %TimeLeft% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip") + } + + sleep, 15000 ; 15 seconds + } +} + + + +StartTime := A_TickCount + + + +if(Discord) +Gosub, PostToDiscord +if(Telegram) +Gosub, PostToTelegram +if(Parler) +Gosub, PostToParler +if(SubscribeStar) +Gosub, PostToSubscribeStar +if(Minds) +Gosub, PostToMinds +if(Gab) +Gosub, PostToGab +if(LinkedIN) +Gosub, PostToLinkedIN +if(MeWe) +Gosub, PostToMeWe +if(Twetch) +Gosub, PostToTwetch +if(Thinkspot) +Gosub, PostToThinkSpot +if(Flote) +Gosub, PostToFlote +if(Locals) +Gosub, PostToLocals +/*if(Parler) +Gosub, PostToParler +if(Facebook) +Gosub, PostToFacebook +*/ +if(Steemit) +Gosub, PostToSteemit +if(Pintrest) +Gosub, PostToPintrest +if(Pocketnet) +Gosub, PostToPocketNet +if(Gettr) +Gosub, PostToGettr +; if(Tumblr) +; Gosub, PostToTumblr + + +CurrentSite := +Message = Social Media Posting Complete +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + +ScriptRunTime := round(((A_TickCount - StartTime) / 1000), 2) + +if(URLOfLastErrorPage != ""){ + Message = Activating Tab of last failed post. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip") + + FindAndActivateTab(URLOfLastErrorPage) +} + + + +ReadWebsiteStatuses() ; Read .ini file of post statuses for each site + +; Gui,Destroy +ToolTip + +WebsiteButtonWidths = 115 +WebsiteStatusEditWidths = 150 + +StatusTextWidth := (WebsiteButtonWidths + WebsiteStatusEditWidths) * 2 +StatusTextSecondRowXPos := WebsiteStatusEditWidths + WebsiteButtonWidths + (MarginSpace * 4) +ErrorSummaryLogXPos := StatusTextSecondRowXPos + WebsiteStatusEditWidths + WebsiteButtonWidths + (MarginSpace * 2) +ErrorSummaryLogSplitLineXPos := ErrorSummaryLogXPos - (MarginSpace) +ErrorLogSummaryWidth := 385 +ErrorLogSummaryHeight := 480 +ButtonHeights := 30 + + + + +Gui, Font, s%GUINormalFontSize% +Gui, Font, Bold +Gui, Add, Text,w%StatusTextWidth% y%MarginSpace% Center, Status + + +Gui, Add, Button,x%MarginSpace% y40 w%WebsiteButtonWidths% Center h%ButtonHeights%, Discord +Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Discord% + + +Gui, Add, Button,x%MarginSpace% w%WebsiteButtonWidths% Center h%ButtonHeights%, Telegram +Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Telegram% + +gui, font, s8 +Gui, Add, Button,x%MarginSpace% w%WebsiteButtonWidths% Center h%ButtonHeights%, SubScribeStar +Gui, Font, s%GUINormalFontSize% +Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %SubscribeStar% + +Gui, Add, Button,x%MarginSpace% w%WebsiteButtonWidths% h%ButtonHeights% Center, Minds +Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Minds% + +Gui, Add, Button,x%MarginSpace% w%WebsiteButtonWidths% h%ButtonHeights% Center, Gab +Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Gab% + +Gui, Add, Button,x%MarginSpace% w%WebsiteButtonWidths% h%ButtonHeights% Center, Locals +Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Locals% + +Gui, Add, Button,x%MarginSpace% w%WebsiteButtonWidths% h%ButtonHeights% Center, Gettr +Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Gettr% + +Gui, Add, Button,x%MarginSpace% w%WebsiteButtonWidths%Center h%ButtonHeights%, Twetch +Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Twetch% + +Gui, Add, Button,x%MarginSpace% w%WebsiteButtonWidths% h%ButtonHeights% Center, LinkedIn +Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %LinkedIn% + +Gui, Add, Button,x%MarginSpace% w%WebsiteButtonWidths% h%ButtonHeights% Center, MeWe +Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %MeWe% + + +Gui, Font, s9 +Gui, Add, Button, x%MarginSpace% y+20 w165 h50 gCancelPost, Close +Gui, Add, Button, x+%Marginspace% w215 h50 gSendErrorLoggingThroughTelegram, Telegram Detailed Errorlog +Gui, Add, Button, x+%Marginspace% h50 w165 gTryFailedAgain, Try Failed Again + + +Gui, Font, s%GUINormalFontSize% + +gui, font, s8 +Gui, Add, Button,x%StatusTextSecondRowXPos% y40 w%WebsiteButtonWidths%Center h%ButtonHeights%, ThinkSpot +Gui, Font, s%GUINormalFontSize% +Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %ThinkSpot% + +Gui, Font, s%GUINormalFontSize% + +Gui, Add, Button,x%StatusTextSecondRowXPos% y+%MarginSpace% w%WebsiteButtonWidths% h%ButtonHeights% Center, Flote +Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Flote% + +Gui, Add, Button,x%StatusTextSecondRowXPos% y+%MarginSpace% w%WebsiteButtonWidths% h%ButtonHeights% Center, Parler +Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Parler% + +Gui, Add, Button,x%StatusTextSecondRowXPos% y+%MarginSpace% w%WebsiteButtonWidths% h%ButtonHeights% Center, Steemit +Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Steemit% + +; Gui, Add, Button,x%StatusTextSecondRowXPos% y+%MarginSpace% w%WebsiteButtonWidths% h%ButtonHeights% Center, Pintrest +; Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Pintrest% + +Gui, Add, Button,x%StatusTextSecondRowXPos% y+%MarginSpace% w%WebsiteButtonWidths% h%ButtonHeights% Center, Bastyon +Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %PocketNet% + +; Gui, Add, Button,x%StatusTextSecondRowXPos% y+%MarginSpace% w%WebsiteButtonWidths% h%ButtonHeights% Center, Tumblr +; Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Tumblr% + +Gui, Font, s8 +Gui, Add, Button, x%StatusTextSecondRowXPos% y+40 w270 h40 Center gCopyPostToClipboard, Copy Post To Clipboard `nFor Easy Pasting to Other Sites +Gui, Add, Button, x%StatusTextSecondRowXPos% y+%MarginSpace% w270 h40 Center gCopyImageFilepathToClipboard, Copy Image Filepath To Clipboard + + +/*Gui, Add, Button,x%MarginSpace% w%WebsiteButtonWidths% h%ButtonHeights% Center, PocketNet +Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %PocketNet% + +*/ +Gui, Font, s%GUINormalFontSize% +Gui, Font, Bold +; gui, add, text, x%ErrorSummaryLogSplitLineXPos% y20 h200 0x11 ; 0x11 is a "line" ; refer to here: https://autohotkey.com/board/topic/50910-draw-line-gui/ +Gui, Add, Text, x%ErrorSummaryLogXPos% y%MarginSpace% w%ErrorLogSummaryWidth% Center, Error Log Summary + +Gui, Font, Normal +Gui, Font, s10 +Gui, Add, Edit, x%ErrorSummaryLogXPos% y+%MarginSpace% w%ErrorLogSummaryWidth% h%ErrorLogSummaryHeight%, %ErrorLogVar% +Gui, Font, s%GUINormalFontSize% + +gui, font, s6 +Gui, Add, StatusBar,, Total Posts Posted: %TotalPostsPosted% | Run Time: %ScriptRunTime% Seconds + +Gui, Show,, %FullScriptName% - Post Results + + +SaveCurrentChromeVersionToIniFile() +AddToTotalRunTime() + +Return + + +SendErrorLoggingThroughTelegram: +Message = Uploading Errorlog to FDRBotTesting Telegram Server. +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + +; ErrorLoggingFilePath := VideoFolderDir . "\" . "ErrorLogging.txt" +; Msgbox % "ErrorLoggingFilePath: " ErrorLoggingFilePath + +; Credentials to FDRBotTesting Channel +ELTelegramBotToken=1422687468:AAEzdzkck5PhgOG687cEn1cChp5cJFodjVM +ELTelegramBotChatID=-1001460795978 + +; DevModeMsgBox(ErrorLoggingFilePath) + +Status := SendTelegramFile(ELTelegramBotToken, ELTelegramBotChatID, ErrorLoggingFilePath, caption := "" ) +if(InStr(Status, "error_code")){ + Message = Telegram Post Failed due to an API Issue. Error was saved to ErrorLogging file. Please send it to Yuriy. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + + ; SaveOrPostProgress(Message:=Status,PostType:=",ErrorLoggingTextFile") + Message = Telegram Error: %Status% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + + ; msgbox, 4096, Error!, %Message% + ToolTip + Return +} +ToolTip +Message = Errorlog was successfully uploaded to the FDRBotTesting Telegram Server.`nThank You! +msgbox, 4096, Success!, %Message% + +; Clipboard := ErrorLoggingFilePath +; Message = %ErrorLoggingFilePath% `n`nwas copied to the clipboard for easy attachment +; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +; msgbox, 4096, Filepath Copied to Clipboard, %ErrorLoggingFilePath%`n`nwas copied to the clipboard for easy attachment. +Return + + + + + +CopyErrorLoggingFilepath: +; Msgbox % "ErrorLoggingFilePath: " ErrorLoggingFilePath +Clipboard := ErrorLoggingFilePath +msgbox,,Copied to Clipboard, The Filepath for the errorlogging file was copied to your clipboard:`n`n%ErrorLoggingFilePath% +Return + +SaveDriverTitle(){ + Message := "Driver.Title: " . driver.title + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") +} + + +CopyPostToClipboard: +clipboard := PostTitleAndBody +Message = Post Title and Body Copied to Clipboard +; ToolTip, Post Title and Body Copied to Clipboard, 850, 0 +SaveOrPostProgress(Message:=Message,PostType:="Tooltip") +sleep, 2000 +Tooltip +Return + +CopyImageFilepathToClipboard: +clipboard := ImageAttachmentFilepath +Message = Image Filepath Copied to Clipboard +; ToolTip, Post Title and Body Copied to Clipboard, 850, 0 +SaveOrPostProgress(Message:=Message,PostType:="Tooltip") +sleep, 2000 +Tooltip +Return + + +OpenScreenshotsFolder: +run, %ErrorLoggingDirectory% +Return + + +PostScreenshotsToUploadStatus: +SaveOrPostProgress(Message:="Uploading screenshots of Errors:",PostType:=",ErrorLoggingTextFile,DiscordParler") + + +Loop, %NumOfScreenshots% { + Filepath := ScreenshotFilepaths[A_index] ; find value from position in array + UploadImageToDiscord(DiscordParlerWebhookURL,, Filepath) + +} + +Tooltip +Return + + +;---------------Facebook---------------------------------- +PostToFacebook: +CurrentSite := "Facebook" + +Message = Navigating to Post Creation Page +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +Status := NavigateFromBaseURLTo("https://www.facebook.com/") +if(Status){ + Message = Failed to Navigate to Feed Page + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +} + +sleep, 2000 +js = document.querySelector("div[class='m9osqain a5q79mjw gy2v8mqq jm1wdb64 k4urcfbm qv66sw1b'] span[class='a8c37x1j ni8dbmo4 stjgntxs l9j0dhe7']").click() + +; js = document.querySelector('a[aria-label$="Timeline"] + div > div:nth-child(1)').click() +try driver.executeScript(js) + +IniWrite, Incomplete, %StatusFileFilePath%, Status, Facebook +try Clipboard := PostTitleAndBody +SaveDriverURLOFErrorPage() + +Return + + + + + + + +; try html := driver.pagesource ; save page's entire HTML to a variable +; Clipboard := html +; Msgbox % "html: " html + +; Pull out greeting message +/*GreetingMessage := StrSplit(HTML, "What's on your mind,") +GreetingMessage := GreetingMessage[2] +GreetingMessage := StrSplit(GreetingMessage, "") +GreetingMessage := GreetingMessage[1] +GreetingMessage := "What's on your mind," . GreetingMessage +*/ +; Msgbox % "GreetingMessage: " GreetingMessage + +; //span[normalize-space()="What's on your mind, Yuriy?"] +; + +Message = Inputting Post +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +; Msgbox % "Status: " Status +if(ImageAttachmentFilepath = "" AND Status){ ; upload a temporary file and then remove it and input psot + Message = Inputting post using temporary image attachment workaround + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + Xpath = //div[@aria-label='Create a post']//div//input[@type='file'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=TemporaryImageFilepath) + if(Status){ + Message = Post Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + ; driver.FindElementByXPath(Xpath).SendKeys(TemporaryImageFilepath) + + sleep, 2000 + ; remove attachment + Xpath = //div[@aria-label='Remove post attachment'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=3000) + if(Status){ + Message = Upload Failed: Failed to remove temporary image. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + ; driver.FindElementByXPath(Xpath).click() +/* + + Xpath = //span[normalize-space()="What's on your mind, Stefan?"] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Failed to click with Relative Xpath + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + ; click on "what's on your mind text box" + Xpath = //div[@aria-label='Create a post']//div[1]//div[1]//div[1]//span[1] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Failed to click "What's on your mind" box to input post with relative and direct xpath + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + Return + } + } + */ +} +if(ImageAttachmentFilepath != "") { ; otherwise send image straight to upload input box. The post box will open up automatically + Message = Attaching Image + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + Xpath = //div[@aria-label='Create a post']//div//input[@type='file'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Post Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } +/* ; Attach image button + Xpath = //div[@aria-label='Photo/Video']//div//div//div//div//div//i[@data-visualcompletion='css-img'] + Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) + if(Status){ + Message = Failed to click "Attach Image" button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + ; Input filepath of image/video + Status := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) + if(Status) + { + Message = Upload Failed: Unable to Find "Open File" window to input Video filepath into + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + */ + + Message = Waiting 5 Seconds For Thumbnail Preview to Load + SaveOrPostProgress(Message:=Message,PostType:="Tooltip") + ; Wait for thumbnail to load + sleep, 5000 + +} + +Message = Posting Exited Early for Testing +; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") +Return + +; Xpath = //div[@data-block='true']//div +Xpath = //div[@data-block='true']//div +Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody) +if(Status){ + Message = Failed to input Text Post message with Relative and direct Xpath + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} + + + +IniWrite, Input - NOT Submitted, %StatusFileFilePath%, Status, Facebook +Message = Post Button Click Skipped. Please Double Check and Submit Post Manually +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar") +SaveDriverURLOFErrorPage() +Return + + + +Message = Submitting Post +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + +; Click Post Button +xpath = //div[@aria-label='Post']//div//div//div//span[contains(text(),'Post')] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) +if(Status){ + Message = Failed to click "Post" button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + +IniWrite, Successful, %StatusFileFilePath%, Status, Facebook + +AddToTotalPostsPostedCount() + + + +PauseBetweenPosts() +; TakeScreenshotOfPage() +; ; sleep, %TimeBetweenPosts% +DevModeMsgBox("done!") + +Return +;---------------/Facebook---------------------------------- + + + +; -------------------------------Parler------------------------------- +PostToParler: +CurrentSite := "Parler" + +Message = Navigating to Post Creation Page +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + +Status := NavigateFromBaseURLTo("https://parler.com") +if(Status){ + Message = Failed to Navigate to Feed Page + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +} + + +; Check login status by checking the header of the page for "Feed" text +js = return document.querySelector(".header__contain").innerText +try status := driver.executeScript(js) +if(InStr(!status, "Feed")){ + ; SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + + +/*try CurrentTabURL := driver.Url +; Msgbox % "CurrentTabURL: " CurrentTabURL +if(InStr(CurrentTabURL, "/login")){ + SaveOrPostProgress(Message:="Cookies Expired. Trying to Log back in",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + Xpath = //div[@class='form__contain']//button[@class='button'][normalize-space()='Log In'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + SaveOrPostProgress(Message:="Failed to click login button",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + } + sleep, 1000 +} + +*/ + +; Message = Trying to click on "Parley.." to start new post +; SaveOrPostProgress(Message:=Message,PostType:="Tooltip") + +; sleep, 5000 ; sleep 2 seconds for page to fully load in case it's being slow + +; js = document.getElementsByClassName('input-trigger')[0].click() +; try driver.executeScript(JS) ;Execute Javascript + + + /* ; if failed to click into box then error out + if(Status){ + Message = Post Failed: Page didn't load properly + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + */ + ; Msgbox % "Status: " Status + + Message = Inputting Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +/* ; click into popup box + xpath = //div[@placeholder='Parley...'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=3,SleepLength:=1000) + if(Status){ + Message = Failed to click into Parler Post Box. Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + */ + + ; Input post contents + Xpath = //textarea[@placeholder='Write something...'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody) + if(Status){ + Message = Failed to input post contents + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + + ; Do a double check that post got input + + ; js = return document.querySelector("textarea[placeholder='Write something...']").textContent; + ; try ParlerTextStatus := driver.executeScript(js) ;navigate using javascript + + Xpath = //textarea[@placeholder='Write something...'] + try ParlerTextStatus := driver.findelementbyxpath(Xpath).Attribute("value") ;XPath: ID=site-title & span tag + + + if(StrLen(ParlerTextStatus) < 5){ + Message = Failed to input post contents. Post that got input: %ParlerTextStatus% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + ; driver.FindElementByXPath(Xpath).SendKeys("heyyyy") + + + + /* ; Input Post content pop up + Xpath = //div[@id='create-parley-wysiwyg'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody) + if(Status){ + Message = Failed to input Post Message with relative Xpath + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + ; Input post with JS + JsToExecute = document.querySelector("#create-parley-wysiwyg").innerText = '%JSPostTitleAndBody%' + try Status := driver.executeScript(JsToExecute) + ; Check if text got input + JsToExecute = return document.querySelector("#create-parley-wysiwyg").innerText + try Status := driver.executeScript(JsToExecute) + if(Status = ""){ + Message = Failed to Input with JS as well + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + Xpath = /html[1]/body[1]/div[3]/div[1]/div[1]/div[1]/div[1]/div[3]/div[1]/div[2]/div[1]/div[1]/form[1]/div[1]/div[2]/div[1] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody) + if(Status){ + try CurrentTab := driver.url + Message = Failed to input Post: `nCurrent Tab URL: %CurrentTab% + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + } + } + */ + + + if(ImageAttachmentFilepath != ""){ + Message = Attaching Image + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + Xpath = //input[@type='file'] + try driver.FindElementByXPath(Xpath).SendKeys(ImageAttachmentFilepath) + catch e { + Message = Failed to Attach Image + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + Message = Waiting 5 seconds for image to upload + SaveOrPostProgress(Message:=Message,PostType:="Tooltip") + sleep, 5000 + } + else, { + SaveOrPostProgress(Message:="Waiting 2 seconds for Everything to Finish Loading",PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 2000 + } + + ; SaveOrPostProgress(Message:="Waiting 2 seconds for Everything to Finish Loading",PostType:="Tooltip,ErrorLoggingTextFile") + ; sleep, 2000 + + + ; sleep, 5000 + Xpath = //button[normalize-space()='Parley'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Failed to Submit Post (#4064) + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + +/* Message = Waiting 5 seconds to double check that the post got submitted + SaveOrPostProgress(Message:=Message,PostType:="Tooltip, ErrorLoggingTextFile") + sleep, 5000 + + ; check the text contents of the input box to make sure that the post got submitted + JsToExecute = return document.querySelector("div[id='create-parley-wysiwyg'] div").textContent; + try Status := driver.executeScript(JsToExecute) + if(Status != ""){ + Xpath = //button[@id='submit-button'] ; click the submit button again + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + + ; Message = Post got input but did not submit properly and still present after 5 seconds`nPost Content: %Status% + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + + +} + +*/ +; DevModeMsgBox(Status) + + /* js = document.getElementById('submit-button').click(); + status := JS_TryToExecute(js,2,2000) + + */ + +/* sleep, 3000 + jscheck = return document.getElementsByClassName('emoji-wysiwyg-editor')[0].textContent; + try Status := driver.executeScript(jsCheck) + if(Status != ""){ + Message = Failed to Submit Post (#2523) + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + */ + + ; Msgbox % "Status: " Status + IniWrite, Successful, %StatusFileFilePath%, Status, Parler + + AddToTotalPostsPostedCount() + + + + PauseBetweenPosts() + ; TakeScreenshotOfPage() + DevModeMsgBox("done!") + + Return + ; -------------------------------/Parler------------------------------- + + + + + + + ; ----------------------r---------Discord------------------------------- + PostToDiscord: + CurrentSite := "Discord" + + ; SaveOrPostProgress(Message:="Posting through API",PostType:="Tooltip,ErrorLoggingTextFile") + Message = Posting Through API + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + if(DiscordParlerWebhookURL = ""){ + Message = Webhook Link not found. Please set "DiscordParlerWebhookURL" in %SettingsIniFilepath%. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + + if(BoldTitleWAPI){ + if(NewLineBetweenTitle) + Message = **%PostTitle%**`n`n%PostBody% + else, + Message = **%PostTitle%**`n%PostBody% + } + else, { ; NOT bold title + if(NewLineBetweenTitle) + Message = %PostTitle%`n`n%PostBody% + else, + Message = %PostTitle%`n%PostBody% + } + + +/* + if(PostTitle != "") + Message = **%PostTitle%**`n%PostBody% + else, + Message = %PostBody% + + */ + if(ImageAttachmentFilepath != ""){ + SingleQuotationMark = " + ; remove any single quotes from filepath + ImageAttachmentFilepath := StrReplace(ImageAttachmentFilepath, SingleQuotationMark, "") + + if(StrLen(Message) > 1999){ ; split message into two parts if longer than this + loop % StrLen(Message) { + + if(A_index < 1900) + Continue + + SplitCharNumber := A_index + ; IndexMinusOne := A_index - 1 + + SplitLocationText := SubStr(Message, SplitCharNumber, 1) + if(SplitLocationText = " "){ + Break + ; Msgbox % "SplitLocation: " SplitLocation + } + } + + + DiscordMessagePartOne := SubStr(Message, 1, SplitCharNumber) + SplitCharNumber := SplitCharNumber + 1 + DiscordMessagePartTwo := SubStr(Message, SplitCharNumber) + ; Msgbox % "DiscordMessagePartOne: " DiscordMessagePartOne + ; Msgbox % "DiscordMessagePartTwo: " DiscordMessagePartTwo + + Status := SaveOrPostProgress(Message:=DiscordMessagePartOne,PostType:="ErrorLoggingTextFile,DiscordParler") + Status := SaveOrPostProgress(Message:=DiscordMessagePartTwo,PostType:="ErrorLoggingTextFile,DiscordParler") + Status := UploadImageToDiscord(DiscordParlerWebhookURL, "", ImageAttachmentFilepath) + + ; Msgbox % "StatusOne: " StatusOne + ; Msgbox % "StatusTwo: " StatusTwo + +/* if(!InStr(StatusOne, "id")){ ; if error for each of the messages, post its + parsed := JSON.Load(StatusOne) + StatusOneFailure := parsed.content[1] + + parsed := JSON.Load(StatusTwo) + StatusTwoFailure := parsed.content[1] + + Message = Partial Failure for the following reason: %StatusOneFailure% OR %StatusTwoFailure% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + } + */ + } ; end of strlen > 1999 + else, { + Status := UploadImageToDiscord(DiscordParlerWebhookURL, Message, ImageAttachmentFilepath) + SaveOrPostProgress(Message:="Status",PostType:="ErrorLoggingTextFile") + + if(!InStr(Status, "id")){ + parsed := JSON.Load(Status) + Error := parsed.content[1] + ; Msgbox % "error: " error + Message = Discord Post Failed due to API Issue. Error was saved to errorlog; please forward to Yuriy + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + } + } + else { + if(StrLen(Message) > 1999){ ; split message into two parts if longer than this + loop % StrLen(Message) { + + if(A_index < 1900) + Continue + + SplitCharNumber := A_index + + SplitLocationText := SubStr(Message, SplitCharNumber, 1) + if(SplitLocationText = " "){ + Break + } + } + + DiscordMessagePartOne := SubStr(Message, 1, SplitCharNumber) + SplitCharNumber := SplitCharNumber + 1 + DiscordMessagePartTwo := SubStr(Message, SplitCharNumber) + + Status := SaveOrPostProgress(Message:=DiscordMessagePartOne,PostType:="ErrorLoggingTextFile,DiscordParler") + Status := SaveOrPostProgress(Message:=DiscordMessagePartTwo,PostType:="ErrorLoggingTextFile,DiscordParler") + } + else, + SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordParler") + } + + IniWrite, Successful, %StatusFileFilePath%, Status, Discord + AddToTotalPostsPostedCount() + Return + ; -------------------------------/Discord------------------------------- + + ; -------------------------------SubScribeStar------------------------------- + PostToSubscribeStar: + CurrentSite := "SubScribeStar" + + + IniRead, SubscribeStarProfileURL, %SettingsIniFilepath%, SocialMediaPoster, SubscribeStarProfileURL, %A_Space% + if(SubscribeStarProfileURL = ""){ + Message = SubscribeStarProfileURL is blank. Please update Settings.ini + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") + + + Status := NavigateFromBaseURLTo(SubscribeStarProfileURL) + if(Status){ + Message = Failed to Navigate to Feed URL + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + } + + Message = Checking Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + ; Xpath = //div[@class='top_bar-login'] + Xpath = //div[@class='top_bar-login'] + ; MsgBox,,Xpath Value,% driver.findelementbyxpath(Xpath).Attribute("value") ;XPath: ID=site-title & span tag + Try LoginStatus := driver.findelementbyxpath(Xpath).Attribute("innerText") ; Grabb innertext + if(InStr(LoginStatus, "Log In")){ ; need to log in + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + sleep, 5000 + Xpath = //button[@type='submit'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + } + + Message = Inputting Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + ; Click on "Start your post by clicking here" + Xpath = //div[contains(text(),'Create Post')] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) + if(Status){ + Message = Failed to Click "Create Post" button with relative xpath + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + Xpath = //div[@class='new_post']//div[@class='new_post-create_button'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Failed to click "Create Post" button with Contains(Text) xpath and relative Xpath - Trying wtih ID + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + + Status := Selenium_LoopToClickID(IDName:="cover_upload",NumOfLoops:=5,SleepLength:=1000) + if(Status){ + Message = Post Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + ; TakeScreenshotOfPage() + SaveDriverURLOFErrorPage() + Return + } + } + } + + ; sleep, 5000 + ; msgbox + + ; Clear any previous content from the post box + Message = Clearing if any text exists from an unposted post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + Xpath = //trix-editor[@role='textbox'] + Status := Selenium_LoopToClearXpath(Xpath,NumOfLoops:=5,SleepLength:=1000) + if(Status){ + } + ; try driver.FindElementByXPath(Xpath).clear() ;Clears content from an element and sets + + + ; Input Text into pop-up edit box + SaveOrPostProgress(Message:="Inputting Post Content",PostType:="Tooltip,ErrorLoggingTextFile") + + Xpath = //trix-editor[@role='textbox'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitleAndBody) + if(Status){ + Message = Failed to Input Post using Direct Xpath. Trying with Relative + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + ; TakeScreenshotOfPage() + ; msgbox, 1 + + Xpath = /html/body/div/div[3]/div[2]/div[2]/div/div[1]/form/div[2]/div[1]/trix-editor + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitleAndBody) + if(Status){ + Message = Failed to Input Post using Relative Xpath. Trying with Javascript + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + + SubscribeStarJSDescription := FormatTextToJSText(PostTitleAndBody) + js = document.querySelector("trix-editor[role='textbox']").value = "%SubscribeStarJSDescription%"; + try driver.executeScript(js) ;Executes a Javascript on the webpage, mostly used for buttons. + catch e { + Message = Failed to Input Post Contents (E#8281) + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + ; TakeScreenshotOfPage() + SaveDriverURLOFErrorPage() + Return + } + ; msgbox, 3 + } + + + } + + ; Attach an image if a filepath was provided + if(ImageAttachmentFilepath != ""){ + SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") + + ; this works for both images and videos + Xpath = //input[@multiple='multiple'] + driver.FindElementByXPath(Xpath).SendKeys(ImageAttachmentFilepath) + + +/* Xpath = //span[@class='trix-button-group trix-upload-buttons']//button[2] + Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) + if(Status){ + Message = Failed to click on Picture Upload button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + } + + InputStatus := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) + if(InputStatus = "Failed") + { + Message = Upload Failed:`nUnable to Find "Open File" window to input filepath into + SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordErrorLogging") + Return + } + */ + + SaveOrPostProgress(Message:="Waiting 5 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 5000 + } + + + ; Click the post Button + SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") + + Xpath = //button[contains(text(),'Post')] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) + if(Status){ + Message = Failed to Submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + IniWrite, Successful, %StatusFileFilePath%, Status, SubScribeStar + AddToTotalPostsPostedCount() + + + + PauseBetweenPosts() + ; TakeScreenshotOfPage() + DevModeMsgBox("done!") + + Return + ; -------------------------------/SubScribeStar------------------------------- + + ; -------------------------------Telegram------------------------------- + ; API documentation + ; https://core.telegram.org/bots/api#sendmessage + PostToTelegram: + CurrentSite := "Telegram" + + ; SaveOrPostProgress(Message:="Posting through API",PostType:="Tooltip,ErrorLoggingTextFile") + Message = Posting Through API + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + if(TelegramBotToken = "" Or TelegramBotChatID =""){ + Message = TelegramBotToken or TelegramBotChatID is missing from %SettingsIniFilepath%. `nPlease input them and rerun the script. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + ; Msgbox, 4096, Error!, TelegramBotToken or TelegramBotChatID is missing from %SettingsIniFilepath%. `nPlease input them and rerun the script. + Return + } + + + LineBreakChar = `%0A ; Used for API + + + TelegramTitle := ASCIISTRReplace(PostTitle) + TelegramBody := ASCIISTRReplace(PostBody) + + +/* TelegramTitle := PostTitle + TelegramBody := PostBody + + */ + + ; Msgbox % "TelegramBody: " TelegramBody + + if(PostBody = ""){ + if(BoldTitleWAPI) + Message := "*" . TelegramTitle . "*" + else, + Message := TelegramTitle + } + else, { ; if postbody is not blank + ; MsgBox, we in post body + if(BoldTitleWAPI){ + if(NewLineBetweenTitle) + Message := "*" . TelegramTitle . "*" . "`n`n" . TelegramBody + else, + Message := "*" . TelegramTitle . "*" . "`n" . TelegramBody + } + else, { ; NOT Bold Title + if(NewLineBetweenTitle) + Message := TelegramTitle . "`n`n" . TelegramBody + else, + Message := TelegramTitle . "`n" . TelegramBody + + } + } + + ; Msgbox % "Message: " Message + ; REMOVE + ; Message := PostTitle . "`n" . PostBody + + ; Msgbox % "TelegramTitle: " TelegramTitle + ; Msgbox % "TelegramBody: " TelegramBody + + ; Msgbox % "Message: " Message + + + if(ImageAttachmentFilepath != "" AND StrLen(Message) > 1020){ ; utilize function that converts image to MIME/multi form + ; Telegram API character limit of 4096 for a basic message. + ; @todo: add functionality to split messages longer than 4096 characters + ; msgbox, 2 + + if(BoldTitleWAPI) + TelegramTitle := "*" . TelegramTitle . "*" + else, + TelegramTitle := TelegramTitle + + Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, ImageAttachmentFilepath, caption := TelegramTitle ) ; you could add more options; compare the Telegram API docs + Status := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBody ) + } + else if(ImageAttachmentFilepath != "" AND StrLen(Message) <= 1020){ + Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, ImageAttachmentFilepath, caption := Message ) ; you could add more options; compare the Telegram API docs + + } + else, + { ; send just the text + ; Msgbox % "Message: " Message + Status := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := Message ) + } + + if(Status){ + Message = Upload Failed due to API issue. Telegram API Returned Value:`n %Status% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + ; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordParler") + IniWrite, Successful, %StatusFileFilePath%, Status, Telegram + AddToTotalPostsPostedCount() + + Return + ; -------------------------------/Telegram------------------------------- + + + + + ; -------------------------------LinkedIn------------------------------- + PostToLinkedIN: + CurrentSite := "LinkedIn" + + if(StrLen(PostTitleAndBody) > 1300){ + Message = Post longer than LinkedIn's 1300 character limit. Posting Skipped. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + IniWrite, Skipped - Too Long, %StatusFileFilePath%, Status, LinkedIn + Return + } + + + URLAttempt := NavigateFromBaseURLTo("https://www.linkedin.com/login") + if(URLAttempt = "Failed") + Return + + Message = Checking Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + sleep, 1000 + try CurrentTabURL := driver.Url + if(InStr(CurrentTabURL, "login")){ + Message = Login Cookies Expired. Please Re-Login + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + Message = Clicking "Start a Post" button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + loop, 3 { + Xpath = //button[normalize-space()='Start a post'] ; start a post button + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(!Status) + Break + ; Msgbox % "Status: " Status + if(Status AND A_index = 1){ + try CurrentURL := driver.url + Message = Failed to click on "Start a post" button`nChecking Login Status`nCurrent URL: %CurrentURL% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + try html := driver.pagesource ; save page's entire HTML to a variable + if(InStr(HTML, "Sign In") AND InStr(HTML, "Forgot password")){ + Xpath = //button[normalize-space()='Sign in'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + sleep, 2000 + driver.Get("https://www.linkedin.com/feed/") ;Open selected URL + ; driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + continue + } + else, ; otherwise check and toggle the chat popup on the side + { + Message = Checking if Chat Sidebar is in the way + SaveOrPostProgress(Message:=Message,PostType:="Tooltip") + try html := driver.pagesource ; save page's entire HTML to a variable + if(InStr(HTML,"You are on the messaging overlay. Press enter to minimize it.")){ ; if sidebar is open + Xpath = //body//div//aside//button[2] ; click to minimize it + try driver.FindElementByXPath(Xpath).click() + Message = Chat sidebar was minimized + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + Continue ; continue to next loop + } + } + } + ; DevModeMsgBox("test") + ; Check if linked in post popup appeared + Xpath = //div[@aria-label='Text editor for creating content'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Failed to click into Create Post popup to input post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + } + } + + if(Status){ + Message = Post Failed: Please Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + if(ImageAttachmentFilepath != ""){ + ; Click the upload image button + SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") + + ; click attach image button + Xpath = //li-icon[@type='image']//*[name()='svg'] + Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) + if(Status){ + Message = Failed to click "Attach Image" button with Selenium + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + Xpath = //input[@id='image-sharing-detour-container__file-input'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Failed to Attach photo with both attempts. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + if(WinExist("Open")) ; if open image popup still exists, close it + WinClose, Open + ; Return + } + else, { + Status := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) + if(Status) + { + Message = Failed to input filepath into "Open File" window. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + } + ; sleep, 10000 + + Xpath = //span[normalize-space()='Done'] ; click done button + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) + if(Status){ + Message = Failed to click "Done" button on image upload + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + SaveOrPostProgress(Message:="Waiting 5 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 5000 + + } + + Message = Inputting Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + ; Input Post text contents + loop, 3 { + Xpath = //div[@aria-label='Text editor for creating content'] ; Input text of post + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitleAndBody) + if(Status){ + Message = Failed to input post content + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + } + + ; Double check that post got input + Jscheck = return document.querySelector("div[aria-label='Text editor for creating content']").innerText + try Status := driver.executeScript(Jscheck) + ; DevModeMsgBox(Status) + if(StrLen(Status) > 5) + Break + + if(A_index = 3){ + Message = Post Failed: Failed to input Post for some reason + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + ; Continue + } + +/* if(!Status){ ; if BLANK + Message = Post Failed: Failed to input Post for some reason + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + */ + ; sleep, 2000 + + if(InStr(PostTitleAndBody, "http") OR InStr(PostTitleAndBody, "www")){ + Message = Waiting 10 seconds for Preview to Get Fetched + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 10000 + } + else, { + sleep, 2000 + } + + + SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") + + + Xpath = //span[normalize-space()='Post'] ; Click the final "post" button + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) + if(Status){ + Jscheck = return document.querySelector("div[aria-label='Text editor for creating content']").textContent ; Grabb innertext + try TextContent := driver.executeScript(Jscheck) + + Message = Failed to Submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + + Message = Failed to Submit Post: Text Content that got input: %TextContent% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + +/* ; Keep trying to click the home button until able to and then move on to next site because sometimes it takes a while for a post to upload + Xpath = //span[normalize-space()='Home'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=30,SleepLength:=1000) + + */ + + IniWrite, Successful, %StatusFileFilePath%, Status, LinkedIn + AddToTotalPostsPostedCount() + + DevModeMsgBox("done!") + + PauseBetweenPosts() + ; TakeScreenshotOfPage() + DevModeMsgBox("done!") + + Return + ; -------------------------------/LinkedIn------------------------------- + + + ; -------------------------------Minds------------------------------- + PostToMinds: + CurrentSite := "Minds" + + + SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + URLAttempt := NavigateFromBaseURLTo("https://www.minds.com/newsfeed/subscriptions") + if(URLAttempt = "Failed") + Return + + sleep, 1000 + + try CurrentTabURL := driver.Url + ; Msgbox % "CurrentTabURL: " CurrentTabURL + if(InStr(CurrentTabURL, "login")){ + Message = Login Cookies Expired. Trying to Re-Login + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 2000 + Xpath = //div[contains(text(),'Login')] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + } + + Message = Clicking into Speak your mind.. Box + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + loop, 3 { + if(A_index = 3){ + SaveOrPostProgress(Message:="Failed to click into -speak your mind..- input box.",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + ; Click the Big Compose Box at the top of the page + Xpath = //div[@class='m-composer__triggerOverlay'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) + ; Status := Selenium_LoopToClickXpath(Xpath,5,1000) + if(Status){ + SaveOrPostProgress(Message:="Post Failed: Check Login Status",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + ; check that popup appears by checking for "Create Blog" button in popup + js = return document.querySelector("div[class='m-composer__base'] div[class='m-composerTitleBar__createBlogTrigger ng-star-inserted']").innerText + try status := driver.executeScript(js) + if(InStr(Status, "Create Blog")){ + break + } + else, { + continue + } + + ; Msgbox % "status: " status + + + + } + + ; Attach Image + if(ImageAttachmentFilepath != ""){ + ; Click the upload image button + SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") + + + Xpath = //input[@type='file'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Failed to attach image (E#1203) + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + SaveOrPostProgress(Message:="Waiting 2 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") + + sleep, 2000 + + + SaveOrPostProgress(Message:="Inputting Post Content",PostType:="Tooltip,ErrorLoggingTextFile") + + ; Click the plus button to make the title box show up + Xpath = //div[@class='m-composer__base m-composer__base--withPreview']//i[@class='material-icons ng-star-inserted'][normalize-space()='add_circle_outline'] + try driver.FindElementByXPath(Xpath).click() + catch e { ; if failed to plus button, then input the post body and text into the same box + ; msgbox, failed to click Plus + ; goto, InputMindsPostCombined + } + + ; if plus button was clicked successfully, input title and body individually + ; Input title + ; Msgbox % "PostTitle: " PostTitle + Xpath = //textarea[@placeholder='Title'] + ; driver.FindElementByXPath(Xpath).SendKeys("heleeoeoe") + + ; CLick into title box + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + + ; Input text itno title box + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitle) + if(Status){ ; if failed to input title then skip to inputting both combined + ; msgbox, failed to input title + Message = Failed to input Title + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + MindsTitleStatus := "Failed" + ; Return + + ; goto, InputMindsPostCombined + } + + ; msgbox, title input? + ; Input body + if(MindsTitleStatus) + MindsPost := PostTitleAndBody + else, MindsPost := PostBody + + ; Msgbox % "PostBody: " PostBody + Xpath = //textarea[@id='minds-m-composer__textarea--1003'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=MindsPost) + if(Status){ + ; msgbox, failed to input body + Message = Failed to post with Xpath, trying with ID + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + Status := Selenium_LoopToSendValueToID("minds-m-composer__textarea--1003",5,1000,MindsPost) + if(Status){ + Message = Failed to input Post Content into Page + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + } + } else, { ; otherwise, input just text + SaveOrPostProgress(Message:="Inputting Text Post",PostType:="Tooltip,ErrorLoggingTextFile") + ; DevModeMsgBox("Inputting Text Post") + Xpath = //textarea[@id='minds-m-composer__textarea--1003'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody) + + DevModeMsgBox("done") + if(Status){ + Message = Failed to post with Xpath, trying with ID + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + Status := Selenium_LoopToSendValueToID("minds-m-composer__textarea--1003",5,1000,PostTitleAndBody) + if(Status){ + Message = Failed to input Post Content into Page + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + } + + + if(InStr(PostBody,"http")) + { + Message = Sleeping 5 seconds for preview to load + SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 5000 + } + + } + + ; sleep, 2000 + SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") + + + loop, 3 { + if(A_index = 3){ + SaveOrPostProgress(Message:="Failed to submit post",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + ; 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) + catch e { + Msgbox % "status: " status + + } + + SaveOrPostProgress(Message:="Waiting 5 seconds to confirm post got submitted",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + sleep, 5000 + + ; check that popup appears by checking for "Create Blog" button in popup + js = return document.querySelector("div[class='m-composer__base'] div[class='m-composerTitleBar__createBlogTrigger ng-star-inserted']").innerText + try status := driver.executeScript(js) + if(InStr(Status, "Create Blog")){ + continue + } + else, { + break + } + + + } + + +/* if(!TestingMode){ + SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") + + Xpath = Xpath = (//span[@class='ng-star-inserted'][normalize-space()='Post'])[2] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=5000) + sleep, 1000 + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=5000) + if(Status){ + Message = Failed to Submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + } + + */ + + ; Click the post button + + + IniWrite, Successful, %StatusFileFilePath%, Status, Minds + AddToTotalPostsPostedCount() + + + + PauseBetweenPosts() + ; TakeScreenshotOfPage() + DevModeMsgBox("done!") + + Return + ; -------------------------------/Minds------------------------------- + + ; -------------------------------Locals------------------------------- + PostToLocals: + CurrentSite := "Locals" + + ; @todo: Add auto-login to locals + SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") + + IniRead, LocalsURL, %SettingsIniFilepath%, %ScriptSettingsSection%, LocalsURL + Message = LocalsURL from Ini File: %LocalsURL% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + ; LocalsURL := StrReplace(Localsurl, "/share/post", "") + ; LocalsURL := Localsurl . "/login" + ; Message = Localsurl: %LocalsURL% + ; SaveOrPostProgress(Message:=Message,PostType:=",DiscordErrorLogging") + + Status := NavigateFromBaseURLTo(LocalsURL) + if(Status = "Failed") + Return + + sleep, 1000 + + Message = Checking Login Status + + try CurrentTabURL := driver.Url + if(InStr(CurrentTabURL, "/login") OR InStr(CurrentTabURL, "/register")){ + Message = Login Cookies Expired. Please Re-Login + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + ; Xpath = //textarea[@id='body'] + ; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=2000) + ; if(Status){ + ; Message = Trying to Log Back In + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + ; LocalsLoginURL := LocalsURL . "/login" + ; try driver.Get(LocalsLoginURL) ;Open selected URL + ; try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + + ; sleep, 3000 + ; js = document.getElementsByName('submit')[0].click(); + ; try driver.executeScript(js) + ; ; DevModeMsgBox(js) + ; ; clipboard := js + + ; try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + ; sleep, 5000 + ; ; try driver.Get(LocalsURL) ;Open selected URL + ; ; try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + + ; Xpath = //textarea[@id='body'] + ; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000) + ; { + ; Message = Post Failed: Check Login Status + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + ; Return + ; } + +/* Message = Post Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + + Message = Page did not load after 30 seconds. Force stopping refresh and trying to continue + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + send, {Escape} ; Temporary workaround, as Page seems to endlessly load for Stef + + Xpath = //textarea[@id='body'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + SaveOrPostProgress(Message:="Post Failed: Check Login Status",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + ; TakeScreenshotOfPage() + + Return + } + */ + + ; } + + + Message = Inputting Post Content + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + Xpath = //*[@id="body"] + try driver.FindElementByXPath(Xpath).click() + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody) + if(Status){ + Message = Failed to input Title + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + ; sleep, 1000 + +/* Xpath = //textarea[@id='body'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostBody) + if(Status){ + Message = Failed to Input Post Body + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + */ + + + if(ImageAttachmentFilepath != ""){ + ; Click the upload image button + SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") + + + Xpath = //input[@multiple='multiple'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Failed to Upload Image + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + ; driver.FindElementByXPath(Xpath).SendKeys(ImageAttachmentFilepath) + ; driver.FindElementByXPath(Xpath).SendKeys(ImageAttachmentFilepath) + + + SaveOrPostProgress(Message:="Waiting 10 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") + + sleep, 10000 + } + Message = Submitting Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + + +/* ; Click the final "post" button + SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") + Status := Selenium_LoopToClickName(ElementName:="submitPost",NumOfLoops:=5,SleepLength:=1000) + if(Status){ + Message = Failed to Submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + */ + + ; msgbox + + ; @todo: add error check into here to check the current page url and after page url + ; Click Publish post + js = document.getElementsByName('submitPost')[0].click(); ; Send content through javascript (Great for getting around emoji chrome limitaitons) + try driver.executeScript(js) + + Message = Double checking that post got submitted + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 5000 + + + try CurrentTabURL := driver.Url + if(InStr(CurrentTabURL, "share/post")) { ; post failed to submit if it's still on the create new post page + Message = Error: Post Failed to Submit. Please check tab for reason. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + +} + +/* ; Double check that post got submitted + js = return document.querySelector("#body").value + Status := driver.executeScript(js) + if(Status != ""){ + Message = Error: Post Failed to Submit for some reason + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + */ + + IniWrite, Successful, %StatusFileFilePath%, Status, Locals + AddToTotalPostsPostedCount() + + + + SaveOrPostProgress(Message:=Message,PostType:="Tooltip") + PauseBetweenPosts() + ; TakeScreenshotOfPage() + DevModeMsgBox("done!") + + + Return + ; -------------------------------/Locals------------------------------- + + + ; -------------------------------Gab------------------------------- + PostToGab: + CurrentSite := "Gab" + + + SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + GabPostURL = https://gab.com/compose + URLAttempt := NavigateFromBaseURLTo(GabPostURL) + if(URLAttempt = "Failed") + Return + + sleep, 1000 + Message = Checking Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + try CurrentTabURL := driver.Url + if(!InStr(CurrentTabURL, "/compose")){ + Message = Login Cookies Expired. Trying to Re-Login + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + ; navigate to login page + url = https://gab.com/auth/sign_in + try driver.Get(url) ;Open selected URL + try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + sleep, 1500 ; sleep long enough for password manager to input password + Xpath = //button[normalize-space()='Log in'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + SaveOrPostProgress(Message:="Failed to Login. Please Login Manually",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + ; navigate to post input page + URLAttempt := NavigateFromBaseURLTo(GabPostURL) + if(URLAttempt = "Failed") + Return + driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + } + + + ; Message = Inputting Post + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + SaveOrPostProgress(Message:="Inputting Post Content",PostType:="Tooltip,ErrorLoggingTextFile") + + Xpath = //body/div[@id='gabsocial']/div/div/div/div/div/div[2]/a[1] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=500) + if(!Status){ ; if successfully clicked on login button, we are logged out + Message = Login Cookies Expired. Trying to Re-Login + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + Xpath = //button[normalize-space()='Log in'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + sleep, 2000 + URLAttempt := NavigateFromBaseURLTo("https://gab.com/compose") + + } + + + Message = Inputting Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + if(ImageAttachmentFilepath != ""){ + ; Click the upload image button + SaveOrPostProgress(Message:="Attaching Image First",PostType:="Tooltip,ErrorLoggingTextFile") + + Xpath = //input[@type='file'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Failed to attach Image + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + SaveOrPostProgress(Message:="Waiting 10 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") + + sleep, 10000 + } + + Xpath = //div[@data-block='true']//div + Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=PostTitleAndBody) + if(Status){ + SaveOrPostProgress(Message:="Post Failed: Check Login Status",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + ; Click the final "post" button + SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") + + Xpath = //*[@id="gabsocial"]/div/div[2]/div[2]/main/div/div[3]/div/div + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000) + if(Status){ + Message = Failed to Submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + IniWrite, Successful, %StatusFileFilePath%, Status, Gab + AddToTotalPostsPostedCount() + + + + SaveOrPostProgress(Message:=Message,PostType:="Tooltip") + PauseBetweenPosts() + ; TakeScreenshotOfPage() + DevModeMsgBox("done!") + + Return + ; -------------------------------/Gab------------------------------- + + + ; -------------------------------PocketNet------------------------------- + ; -------------------------------Bastyon------------------------------- + PostToPocketNet: + CurrentSite := "Bastyon" + + + SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + URLAttempt := NavigateFromBaseURLTo("https://bastyon.com/index") + if(URLAttempt = "Failed") + Return + + ; Loop a bunch of times for page to load + SaveOrPostProgress(Message:="Waiting for Page to Load Fully",PostType:="Tooltip,ErrorLoggingTextFile") + loop, 12 { + + ; click into input box + js = document.querySelector(".emojionearea-editor.pastable").click() + try driver.executeScript(js) + + Xpath = //div[@class='emojionearea-editor pastable'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=5000) + if(!Status) + break + + Xpath = //b[normalize-space()='Sign in'] + try Status := driver.findelementbyxpath(Xpath).Attribute("textContent") ;XPath: ID=site-title & span tag + if(InStr(Status, "Sign in")){ + break + } + + ; Msgbox % "Status: " Status + } + if(Status){ ; if failed to click into entry box + Message = Post Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + + + Message = Clearing Previous Post Content + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + js = document.querySelector("div[title='Clear post'] i[class='fas fa-times-circle']").click() + try driver.executeScript(js) + + sleep, 1000 + + js = document.querySelector(".btn1.medium").click() + try driver.executeScript(js) + + sleep, 1000 + + ; msgbox + + ; input post text content + Message = Inputting Post Content + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + JsToExecute = document.getElementsByClassName('emojionearea-editor pastable')[0].innerText = '%JSPostTitleAndBody%' + Status := JS_TryToExecute(JsToExecute) + if(Status){ + Message = Post Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + JsToExecute = return document.getElementsByClassName('emojionearea-editor pastable')[0].textContent; + try Status := driver.executeScript(JsToExecute) + if(Status = ""){ + Message = Post Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + ; Message = Post that got input: %Status% + ; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordErrorLogging") + ; DevModeMsgBox(Message) + ; msgbox % "textContent: " . textContent + + + + ; Doesn't work for some reason + ; JsToExecute = return document.querySelector("div.txt div.emojionearea.message div.emojionearea-editor.pastable").innerText + ; Status := JS_TryToExecute(JsToExecute) + ; if(Status){ + ; Message = Check Login Status: Failed to Input Post + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + ; Return + ; } + + + sleep, 2000 + + if(ImageAttachmentFilepath != ""){ + ; Message = Attaching Image + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip") + + ; Click the "Image" button + SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") +/* Xpath = //div[@title='Add Images to Post'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Failed to Click "Attach Image" Button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + */ + + + + ; sleep, 5000 + + Xpath = //input[@type='file'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=3,SleepLength:=5000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Failed to Attach Image + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + SaveOrPostProgress(Message:="Waiting 10 Seconds For Image to Upload",PostType:="Tooltip,ErrorLoggingTextFile") + + sleep, 10000 + + + } + + ; Input Tags + Xpath = //div[@class='search fastSearchShow']//input[@id='text'] + TagsArray := StrSplit(PostTags, ",") + TagsArrayLength := TagsArray.Length() ; Save total number of items in the array + loop, %TagsArrayLength% { + Tag := TagsArray[A_Index] + Tag := StrReplace(Tag, " ", "") + DevModeMsgBox(Tag) + ; Tag = %Tag% + Xpath = //input[@placeholder='Categories and tags'] + driver.FindElementByXPath(Xpath).SendKeys(Tag) + driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.ENTER) + + ; driver.findElementsByClass("sminput").item[2].click() + + ; JsToExecute = document.querySelector("#text[placeholder='Add Categories/Tags']").value = "#%Tag%" + ; Status := JS_TryToExecute(JsToExecute) + ; + ; driver.SendKeys(driver.Keys.SPACE) + ; + ; JsToExecute = return document.querySelector("#text[placeholder='Add Categories/Tags']").value + ; Status := JS_TryToExecute(JsToExecute) + + if(A_index = 5) + Break + + + /*Tag := TagsArray[A_Index] + Tag := StrReplace(Tag, " ", "") + ; Tag = %Tag% + Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=Tag) + try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.Space) + + */ + ; if(A_index = 8) ; Steemit only allows 8 tags + ; Break + } + ; msgbox + +/* Xpath = //div[@class='emojionearea-editor pastable'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=3,SleepLength:=1000,StringTextContent:=PostTitleAndBody) + if(Status){ + SaveOrPostProgress(Message:="Failed to Input Post",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + + ; Send, + } + */ + + + ; Msgbox,4096,Pause!!,asdf + + SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") + + ; CLick the post button + Xpath = //button[normalize-space()='Post'] + loop, 3 { + try driver.FindElementByXPath(Xpath).click() + sleep, 1500 + } + ; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000) + ; sleep, 2000 + ; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000) +/* if(Status){ + Message = Failed to Submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + */ + Message = Waiting 5 seconds to double check that post got submitted + SaveOrPostProgress(Message:=Message,PostType:="Tooltip") + sleep, 5000 + ; try PossiblyError := driver.findElementsByClass("paddingmobilewrapper").item[1].Attribute("innerText") ; Grabb innertext + + ; CHeck if input box still contains text + JsToExecute = return document.getElementsByClassName('emojionearea-editor pastable')[0].textContent; + try Status := driver.executeScript(JsToExecute) + if(Status){ + ; sleep, 2000 + try Jscheck = return document.querySelector(".paddingmobilewrapper").textContent ; Grabb innertext + PossiblyError := driver.executeScript(Jscheck) + PossiblyError := StrReplace(PossiblyError, "`n", "") ; remove extra stuff from text + PossiblyError := StrReplace(PossiblyError, " ", "") ; remove extra stuff from text + PossiblyError := StrReplace(PossiblyError, A_Tab, "") ; remove extra stuff from text + + ; Msgbox % "PossiblyError: " PossiblyError + Message = Failed To Submit Post: Error was: %PossiblyError% + ; DevModeMsgBox(PossiblyError) + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + + ; sleep, 2000 + ; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000) +/* if(Status){ + Message = Failed to Submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + */ + + + IniWrite, Successful, %StatusFileFilePath%, Status, PocketNet + AddToTotalPostsPostedCount() + + + + SaveOrPostProgress(Message:=Message,PostType:="Tooltip") + PauseBetweenPosts() + ; TakeScreenshotOfPage() + DevModeMsgBox("done!") + + Return + ; -------------------------------/Bastyon------------------------------- + + + + ;-----------------------Steemit------------------------- + PostToSteemit: + CurrentSite := "Steemit" + + + + SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + URLAttempt := NavigateFromBaseURLTo("https://steemit.com/submit.html") + if(URLAttempt = "Failed") + Return + + + + Message = Checking for Content from Previous Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + ; Click CLear Button + Xpath = //button[normalize-space()='Clear'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Trying to log back in + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + Xpath = //a[normalize-space()='Login'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Upload Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + sleep, 2000 + ; otherwise button was clicked and we need to submit the saved credentials + Xpath = //button[normalize-space()='Login'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=20,SleepLength:=100) + ; DevModeMsgBox(Status) + if(Status){ + Message = Upload Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + else, + { + sleep, 3000 + Xpath = //button[normalize-space()='Clear'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Upload Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + } + + } + else, { + sleep, 500 + try, driver.switchToalert().accept() ; if text exists Steemit will pop up menu asking for confirmation for clearing + } + + + + +/* if(Status){ + Message = Post Failed, Please check login status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + ; Click "Accept" popup that asks if you're sure you want to clear post + try, driver.switchToalert().accept() + + */ + + + + Message = Inputting Post Content + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + ; Input title + Xpath = //input[@placeholder='Title'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitle) + if(Status){ + Message = Post Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + Xpath = //textarea[@placeholder='Write your story...'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostBody) + if(Status){ + Message = Failed to input Post Body + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + + if(ImageAttachmentFilepath != ""){ + Message = Attaching Thumbnail + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + Xpath = //input[@type='file'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Failed to attach Image + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + +/* + Xpath = //a[normalize-space()='selecting them'] + Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) + if(Status){ + Message = Failed to click on "Attach Image" button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + InputStatus := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) + if(InputStatus = "Failed") + { + Message = Upload Failed:`nUnable to Find "Open File" window to input filepath into + SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordErrorLogging") + Return + } + + */ + Message = Waiting 5 seconds for thumbnail to be generated + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + sleep, 5000 + } + + + message = Inputting Tags + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + ; Input Post Tags + Xpath = //input[@placeholder='#tag'] + TagsArray := StrSplit(PostTags, ",") + TagsArrayLength := TagsArray.Length() ; Save total number of items in the array + loop, %TagsArrayLength%{ + Tag := TagsArray[A_Index] + Tag := StrReplace(Tag, " ", "") + Tag = #%Tag% + Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=Tag) + try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.Space) + + if(A_index = 8) ; Steemit only allows 8 tags + Break + } + + + Message = Submitting Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + ; Click Submit Button + Xpath = //button[@type='submit'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Failed to submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + IniWrite, Successful, %StatusFileFilePath%, Status, Steemit + AddToTotalPostsPostedCount() + + + + PauseBetweenPosts() + ; TakeScreenshotOfPage() + DevModeMsgBox("done!") + + Return + ;-----------------------/Steemit------------------------- + + ;---Tumblr--- + ;------------------------------------------------ + PostToTumblr: + ; Return + CurrentSite := "Tumblr" + ; msgbox + + SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + URLAttempt := NavigateFromBaseURLTo("https://www.tumblr.com/new/text") + if(URLAttempt = "Failed") + Return + + sleep, 1000 + SaveOrPostProgress(Message:="Checking Login Status",PostType:="Tooltip,ErrorLoggingTextFile") + + try CurrentTabURL := driver.Url + if(InStr(CurrentTabURL, "/login")){ + Message = Login Cookies Expired. Trying to Re-Login + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + ; sleep, 2000 + Xpath = //span[normalize-space()='Log in'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + SaveOrPostProgress(Message:="Failed to Login. Please Login Manually",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + } + + + Message = Inputting Post Content + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + ; Input title + Xpath = //textarea[@placeholder='Title'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitle) + if(Status){ + Message = Post Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + ; Input Body of Post + Xpath = //p[@aria-label='Empty block; start writing or type forward slash to choose a block'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostBody) + if(Status){ + Message = Failed to input Post Body + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + + if(ImageAttachmentFilepath != ""){ + Message = Attaching Thumbnail + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + Xpath = //input[@role='button'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Failed to attach Image + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + Message = Waiting 5 seconds for thumbnail to be generated + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + sleep, 5000 + } + + + message = Inputting Tags + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + ; Input Post Tags + TumblrTags := StrReplace(PostTags, " ", "") + TumblrTags := TumblrTags . "," + ; Msgbox % "TumblrTags: " TumblrTags + Xpath = //textarea[@placeholder='#add tags'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=TumblrTags) + + + Message = Submitting Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + ; msgbox + + ; Click Submit Button + Xpath = //span[normalize-space()='Post now'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Failed to submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + IniWrite, Successful, %StatusFileFilePath%, Status, Tumblr + AddToTotalPostsPostedCount() + + + + + PauseBetweenPosts() + ; TakeScreenshotOfPage() + Return + ;---\Tumblr--- + ;------------------------------------------------ + + + + ;----------------Pintrest-------------------------------- + PostToPintrest: + CurrentSite := "Pintrest" + + + PintrestPostBodyArray := StrSplit(PostBody, "https") + PintrestPostBody := PintrestPostBodyArray[1] + + PintrestURL := PintrestPostBodyArray[2] + PintrestURL := StrSplit(PintrestURL, " ") + PintrestURL := PintrestURL[1] + + + if(PintrestURL != "") + PintrestURL := "https" . PintrestURL + + ; Msgbox % "PintrestURL: " PintrestURL + + + ; Msgbox % "PintrestPostTitleAndBody: " PintrestPostTitleAndBody + ; Msgbox % "PintrestURL: " PintrestURL + ; pintrest has a 500 character limit + if(StrLen(PintrestPostBody) > 499){ + Message = Post longer than Pintrest's 500 character limit. Posting Skipped. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + IniWrite, Skipped - Too Long, %StatusFileFilePath%, Status, Pintrest + Return + } + + if(ImageAttachmentFilepath = ""){ + Message = Post Skipped, No Image attached + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + IniWrite, Skipped - No Image, %StatusFileFilePath%, Status, Pintrest + Return + } + + SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + URLAttempt := NavigateFromBaseURLTo("https://www.pinterest.com/pin-builder/") + if(URLAttempt = "Failed") + Return + + + + Message = Inputting Post Content + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + ; Input title + Xpath = //textarea[@placeholder='Add your title'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitle) + if(Status){ + Message = Post Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + Xpath = //div[@role='combobox'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PintrestPostBody) + if(Status){ + Message = Failed to input Post Body + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + + if(ImageAttachmentFilepath != ""){ + Message = Attaching Thumbnail + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + ; Attach Thumbnail + Xpath = //input[@type='file'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + } + + Xpath = //textarea[@placeholder='Add a destination link'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PintrestURL) + if(Status){ + Message = Failed to Input Destination URL + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + ; msgbox + Message = Submitting Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +/* +OnMessage(0x44, "OnMsgBoxConfirmPost") +MsgBox 0x40040, Confirmation, Please Double Check Post Was Input and Submit It.`n`nThen click OK on this msgbox to move on to the next site. +OnMessage(0x44, "") + +*/ + + +; Click Submit Button +Xpath = //button[@data-test-id='board-dropdown-save-button'] +try Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=1000)driver.FindElementByXPath(Xpath).click() +if(Status){ + Message = Failed to Submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + +IniWrite, Successful, %StatusFileFilePath%, Status, Pintrest +AddToTotalPostsPostedCount() + + + +PauseBetweenPosts() +; TakeScreenshotOfPage() +DevModeMsgBox("done!") + +Return + +; -------------------------------/Pintrest------------------------------- + + +;---Gettr--- +;------------------------------------------------ +PostToGettr: +CurrentSite := "Gettr" + +SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +URLAttempt := NavigateFromBaseURLTo("https://gettr.com/") +if(URLAttempt = "Failed") +Return + +Message = Checking Login Status +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +sleep, 1000 + +; if string in tab url, then we are logged out +try CurrentTabURL := driver.Url +if(InStr(CurrentTabURL, "/onboarding")) +{ + Message = Login Cookies Expired. Please Re-Login + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + +; click input area +; Xpath =//button[contains(text(),'Post')] +; Xpath = ///div[@id='textarea-post'] +Xpath = //*[contains(text(),'What's new?')] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) +DevModeMsgBox("pause") + +; Input image +if(ImageAttachmentFilepath != ""){ + + ; Attach image + Xpath = //input[@type='file'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Failed to Attach Image + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + Message = Waiting for image to upload + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 3000 + + +} + + +; click input area +Xpath = //*[@id="textarea-post"] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + +; disable spellcheck on input field using javascript so text doesn't get garbled +js = document.getElementById('textarea-post').setAttribute("spellcheck", "false"); +driver.executeScript(js) ;Executes a Javascript on the webpage, mostly used for buttons. + +; DevModeMsgBox(JSPostTitleAndBody) +; JsToExecute = document.querySelector("#textarea-post").text = "%JSPostTitleAndBody%"; +; JsToExecute = document.getElementById('textarea-post')[0].text = "%JSPostTitleAndBody%"; +/* +; JsToExecute = document.getElementsByClassName('emojionearea-editor pastable')[0].innerText = '%JSPostTitleAndBody%' +Status := JS_TryToExecute(JsToExecute) +if(Status){ + Message = Post Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + +*/ + + +/*; Xpath = //*[@id="textarea-post"] +Msgbox % "PostTitleAndBody: " PostTitleAndBody +Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=PostTitleAndBody) +if(Status){ + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} +*/ + + + + +StrLengthOfPost := StrLen(PostTitleAndBody) + +SaveOrPostProgress(Message:="Inputting post very slow way to avoid issues with gettr's buggy text post-processing",PostType:="Tooltip,ErrorLoggingTextFile") + +Loop % StrLengthOfPost{ + ; IndexPlusOne := A_index + 1 + + Current_Char := SubStr(PostTitleAndBody, A_index, 1) + ; SubStr(String, StartingPos [, Length]) + ; MsgBox % Current_Char + ; Gettr_Index_Of_Line_Post := GettrPostArray[A_index] + ; DevModeMsgBox(Gettr_Index_Of_Line_Post) + + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=100,StringTextContent:=Current_Char) + if(Status){ + Message = Failed to Input Text + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + ; sleep, 10 + ; try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.Right) +} +sleep, 500 +; SaveOrPostProgress(Message:="Waiting 2 seconds before submitting",PostType:="Tooltip,ErrorLoggingTextFile") +; sleep, 2000 + + +SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") +sleep, 2000 + +; Click post button +Xpath = //span[normalize-space()='Post'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) +if(Status){ + Message = Failed to Submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + + +IniWrite, Successful, %StatusFileFilePath%, Status, gettr +AddToTotalPostsPostedCount() + + + +PauseBetweenPosts() +; TakeScreenshotOfPage() + +DevModeMsgBox("done!") + +Return + + +;---/Gettr--- + + +; -------------------------------MeWe------------------------------- +PostToMeWe: +CurrentSite := "MeWe" + + + +SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +URLAttempt := NavigateFromBaseURLTo("https://www.mewe.com/myworld") +if(URLAttempt = "Failed") +Return + +; Click out of try MeWe Premium popup if it appears +SaveOrPostProgress(Message:="Checking for Popups and closing them",PostType:="Tooltip,ErrorLoggingTextFile") +Xpath = //button[normalize-space()='Skip Trial'] +try driver.FindElementByXPath(Xpath).click() + +sleep, 1000 + +; Click on Tell your contacts what's happening button +SaveOrPostProgress(Message:="Clicking into Tell your Contacts.. Box",PostType:="Tooltip,ErrorLoggingTextFile") + +Xpath = //div[@class='postbox-placeholder_text'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) +if(Status){ + SaveOrPostProgress(Message:="Post Failed: Check Login Status",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + +; DevModeMsgBox("popup activated?") + + +; click into popup box to make sure it's activated +/*xpath = //div[@class='ql-editor ql-blank']//div +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) +DevModeMsgBox(Status) +*/ +; DevModeMsgBox("inputting post now after clickng") + +; input post title and body with javascript +JsToExecute = document.querySelector(".ql-editor").innerText = '%JSPostTitleAndBody%'; +try Status := driver.executeScript(JsToExecute) + + +; check that the input box contains text +JsToExecute = return document.querySelector(".ql-editor").innerText +try Status := driver.executeScript(JsToExecute) +if(StrLen(Status) < 5){ + Message = Failed to input post into popup box + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + + +/* +Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=PostTitleAndBody) +if(Status){ + Message = Failed to input text into page. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} +*/ + +; DevModeMsgBox("input worked?") + + +if(ImageAttachmentFilepath != ""){ + ; Click "Image" button + SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") + + Xpath = //input[@id='fake-upload-photo'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) +/* + ; Xpath = /html/body/div[2]/div/div[1]/div[2]/div[1]/div/div[2]/div/div[4]/div[1]/button[1] + Xpath = //button[@data-tooltip='Photo'] + Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) + if(Status){ + Message = Failed to click "Attach Photo" button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + InputStatus := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) + if(InputStatus = "Failed") + { + Message = Upload Failed:`nUnable to Find "Open File" window to input filepath into + SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordErrorLogging") + Return + } + */ + SaveOrPostProgress(Message:="Waiting 10 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") + + sleep, 10000 +} + + +; Click the "Post" button +SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") +Xpath = (//button[normalize-space()='Post'])[1] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000) +if(Status){ + Message = Failed to Submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + +IniWrite, Successful, %StatusFileFilePath%, Status, MeWe +AddToTotalPostsPostedCount() + + + +PauseBetweenPosts() +; TakeScreenshotOfPage() +DevModeMsgBox("done!") + + +Return +; -------------------------------/MeWe------------------------------- + +; -------------------------------Twetch------------------------------- +TwetchAttemptNumber := 1 +PostToTwetch: +CurrentSite := "Twetch" + +; if(StrLen(PostTitleAndBody) > 256){ + ; Message = Post Skipped as it's longer than 256 Characters + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + ; IniWrite, Skipped - Too Long, %StatusFileFilePath%, Status, Twetch + ; Return + ; } + + + SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + URLAttempt := NavigateFromBaseURLTo("https://twetch.com/") + if(URLAttempt = "Failed") + Return + + sleep, 1000 + + Message = Checking Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + try CurrentTabURL := driver.Url + if(InStr(CurrentTabURL, "/welcome")){ + Message = Login Cookies Expired. Trying to Re-Login + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + sleep, 2000 ; 2 seconds for password to get loaded in by chrome + + Xpath = //button[@type='submit'][normalize-space()='Sign in'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + SaveOrPostProgress(Message:="Failed to Login. Please Login Manually",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + Message = Waiting for Page to finish loading + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 2000 + driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + } + + + + ; SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + ; URLAttempt := NavigateFromBaseURLTo("https://twetch.com/") + ; if(URLAttempt = "Failed") + ; Return + + ; Message = + + + ; Click on "Create Post" + SaveOrPostProgress(Message:="Inputting Post Content",PostType:="Tooltip,ErrorLoggingTextFile") + +/*Xpath = //textarea[@id='downshift-post-editor-default-input'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) +if(Status){ + SaveOrPostProgress(Message:="Post Failed: Check Login Status",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} +*/ + +; Click into text input box at top of page +Xpath = //p[@data-slate-node='element'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + + + +; Input Post contents +Xpath = //div[@role='textbox'] +status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=5000,SendKeysContent:=PostTitleAndBody) +if(Status){ + Message = Failed to Input Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + ; TakeScreenshotOfPage() + SaveDriverURLOFErrorPage() + Return +} + +; DevModeMsgBox("input?") + +if(ImageAttachmentFilepath != ""){ + ; Click "Image" button + SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") + + Xpath = //input[@id='rich-file-input'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Failed to Attach Image + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + SaveOrPostProgress(Message:="Waiting 5 Seconds for Image to Upload ",PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 5000 +} + + + +; Click on "Post" button +sleep, 2000 + +SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") + +Xpath = //button[normalize-space()='Post $0.02'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=4,SleepLength:=1000) +if(Status){ + Message = Failed to click on Submit Post Button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + +sleep, 1000 + +Xpath = //p[normalize-space()='Insufficient wallet balance'] +try, FundsStatus := driver.findelementbyxpath(Xpath).Attribute("innerText") ; Grabb innertext +if(FundsStatus){ + Message = Insufficient wallet balance to post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + IniWrite, Insufficient wallet balance to post, %StatusFileFilePath%, Status, Twetch + Return +} + + +IniWrite, Successful, %StatusFileFilePath%, Status, Twetch +AddToTotalPostsPostedCount() + + + +PauseBetweenPosts() +; TakeScreenshotOfPage() +DevModeMsgBox("done!") + + +Return +; -------------------------------/Twetch------------------------------- + + +; -------------------------------Flote------------------------------- +PostToFlote: +CurrentSite := "Flote" + + +SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") +; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + +URLAttempt := NavigateFromBaseURLTo("https://flote.app/") +if(URLAttempt = "Failed") +Return + + +SaveOrPostProgress(Message:="Inputting Text",PostType:="Tooltip,ErrorLoggingTextFile") +sleep, 1000 + + +; Click button to select text input box +Xpath = //input[@placeholder='Share whatever flotes your boat..'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000) +if(Status){ + ; if error, then try clicking on "Login" button at the top right + Message = Unable to Click "Write New Post" Button. Trying to Re-Login + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + Xpath = //div[@class='nav-action-button blue-link half-padding-left half-padding-right white-space-no-wrap'] ; Log in button + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ ; if failed to click login button + SaveOrPostProgress(Message:="Post Failed: Check Login Status",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + else, { ; if login button was clicked successfully. try logging in + sleep, 2000 + Xpath = //button[@class='submit-button ng-star-inserted'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ ; if failed to click login button, give error and quit + SaveOrPostProgress(Message:="Post Failed: Check Login Status",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + Xpath = //div[@class='new-text-area'] ; start new post button + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) + } +} + +sleep, 1000 +; Wait for animation +; sleep, 5000 + +; Click into Title Inputbox +Xpath = //input[@placeholder='Title'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) +if(Status){ + Message = Failed to click into title inputbox, Please check login status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + +Message = Inputting Title +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +; Input Title +Xpath = //input[@placeholder='Title'] +Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitle) + +; Input Body +Message = Inputting Body +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +Xpath = //div[@class='ql-editor']//p +Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostBody) + +; DevModeMsgBox("testing") + +if(ImageAttachmentFilepath != ""){ + ; Click "Image" button + SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") + + ; Click Attach image button + Xpath = //*[@id="fileinput"] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Failed to Attach Image + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + Return + } + + Message = Waiting for Image to Finish Uploading + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + sleep, 5000 +} + +; DevModeMsgBox("test") + +; Message = Waiting 5 seconds for website to catch up +; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +; sleep, 5000 + +Message = Submitting Post +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +; button changes depending on if image is attached or not +if(ImageAttachmentFilepath) +Xpath = //span[normalize-space()='Upload & Post'] +else, +Xpath = //span[normalize-space()='Post'] + + +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) +if(Status){ + SaveOrPostProgress(Message:="Failed to Click Submit Button. Please submit manually",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() +} + + + +IniWrite, Failed to Submit, %StatusFileFilePath%, Status, Flote +AddToTotalPostsPostedCount() + + + +PauseBetweenPosts() +; TakeScreenshotOfPage() +DevModeMsgBox("done!") + + +Return +; -------------------------------/Flote------------------------------- + + + +; -------------------------------ThinkSpot------------------------------- +PostToThinkSpot: +CurrentSite := "Thinkspot" + +if(PostTags = ""){ + Message = Skipped: No Post Tags + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar") + IniWrite, Skipped: No Post Tags, %StatusFileFilePath%, Status, Thinkspot + Return +} + +SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + +URLAttempt := NavigateFromBaseURLTo("https://www.thinkspot.com/create/post") +if(URLAttempt = "Failed") +Return + + +Message = Checking Login Status +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +sleep, 1000 +try CurrentTabURL := driver.Url +if(InStr(CurrentTabURL, "/sign_in")){ + Message = Login Cookies Expired. Trying to Re-Login + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + ; SaveDriverURLOFErrorPage() + ; Return + Xpath = //input[@name='commit'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=1000) + if(!Status){ + Message = Logged in Successfully + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + Status := NavigateFromBaseURLTo("https://www.thinkspot.com/create/post") + (Status)?(Return):() + sleep, 2000 + } + +} + + + +/* +Xpath = //a[@href='/create/post'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) +if(Status){ + Message = Failed to Click "Create Post" button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} + +*/ + +; CLick into the title box of the new post window +Xpath = //div[@id='editorjs']//div[@class='ql-editor ql-blank'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) +if(Status){ + Message = Failed to Click Into Titlebox: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} + +sleep, 500 + +; Input the Post Title +SaveOrPostProgress(Message:="Inputting Post Title",PostType:="Tooltip,ErrorLoggingTextFile") +Xpath = //input[@id='title'] +Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=PostTitle) +if(Status){ + Message = Failed to Input Post Title: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} + +; Input post body +if(ImageAttachmentFilepath != "") +PostBody := PostBody . "`n" +SaveOrPostProgress(Message:="Inputting Post Content",PostType:="Tooltip,ErrorLoggingTextFile") +Xpath = //div[@id='editorjs']//p +Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=PostBody) +if(Status){ + Message = Failed to Input Post Body: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} + + +; Input Post Tags +Xpath = //span[@role='textbox'] +TagsArray := StrSplit(PostTags, ",") +TagsArrayLength := TagsArray.Length() ; Save total number of items in the array +loop, %TagsArrayLength%{ + Tag := TagsArray[A_Index] + + Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=Tag) + try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.ENTER) +} + + + +if(ImageAttachmentFilepath != ""){ + ; Click "Image" button + SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") + + ; Insert image by sending it directly. + ; elements aren't loaded until the attach image button is pressed though, so defeats the purpose +/*Xpath = //input[@class='ql-image'] +try driver.FindElementByXPath(Xpath).SendKeys(ImageAttachmentFilepath) + +*/ + +Xpath = //button[@class='ql-image'] +Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) +if(Status){ + Message = Failed to click "Attach Image" button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + Xpath = //input[@class='ql-image'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Failed to Attach Image (E#7611) + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } +} +else, { + InputStatus := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) + if(InputStatus = "Failed") + { + sleep, 2000 + Xpath = //i[@class='material-icons-outlined'][normalize-space()='image'] ; give it a second try :fingerscrossed: + Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) + + InputStatus := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) + if(InputStatus) + { ; Try sending directly to element + Xpath = //input[@class='ql-image'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Failed to Attach Image (E#7612) + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + } + } + +} + +SaveOrPostProgress(Message:="Waiting 10 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") + +sleep, 10000 +} + +; Click the Post button +SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") +Xpath = //button[normalize-space()='Post'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) +if(Status){ + Message = Failed to Submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} + + +IniWrite, Successful, %StatusFileFilePath%, Status, Thinkspot +AddToTotalPostsPostedCount() + + + +PauseBetweenPosts() +; TakeScreenshotOfPage() + +; dismiss the pop up that appears for some reason +; try driver.switchToalert().accept() +DevModeMsgBox("done!") + +Return +; -------------------------------/ThinkSpot------------------------------- + + + + +; -------------------------------Functions------------------------------- +#Include %A_ScriptDir%\Lib\SharedFunctions.ahk +#Include %A_ScriptDir%\Lib\Json.ahk +; #Include %A_scriptdir%\Lib\RunCMD.ahk + + +PauseBetweenPosts(){ + ; TimeBetweenpostsInMiliseconds := PauseTimeBetweenPosts*1000 + Message = Waiting %PauseTimeBetweenPosts% seconds before Moving on To Next Site + TooltipThis(Message) + ; Msgbox % "Message: " Message + ; Msgbox % "PauseTimeBetweenPosts: " PauseTimeBetweenPosts + sleep, %TimeBetweenpostsInMiliseconds% +} + + +ReadWebsiteStatuses(){ + ; Read status of each website and save them to variables to be used in GUI + IniRead, Gettr, %StatusFileFilePath%, Status, Gettr, %A_Space% + IniRead, Parler, %StatusFileFilePath%, Status, Parler, %A_Space% + IniRead, Steemit, %StatusFileFilePath%, Status, Steemit, %A_Space% + IniRead, Discord, %StatusFileFilePath%, Status, Discord, %A_Space% + IniRead, SubScribeStar, %StatusFileFilePath%, Status, SubScribeStar, %A_Space% + IniRead, Telegram, %StatusFileFilePath%, Status, Telegram, %A_Space% + IniRead, Minds, %StatusFileFilePath%, Status, Minds, %A_Space% + IniRead, Gab, %StatusFileFilePath%, Status, Gab, %A_Space% + IniRead, Locals, %StatusFileFilePath%, Status, Locals, %A_Space% + IniRead, LinkedIn, %StatusFileFilePath%, Status, LinkedIn, %A_Space% + IniRead, MeWe, %StatusFileFilePath%, Status, MeWe, %A_Space% + IniRead, Twetch, %StatusFileFilePath%, Status, Twetch, %A_Space% + IniRead, ThinkSpot, %StatusFileFilePath%, Status, ThinkSpot, %A_Space% + IniRead, Flote, %StatusFileFilePath%, Status, Flote, %A_Space% + IniRead, PocketNet, %StatusFileFilePath%, Status, PocketNet, %A_Space% + ; IniRead, Pintrest, %StatusFileFilePath%, Status, Pintrest, %A_Space% + ; IniRead, Tumblr, %StatusFileFilePath%, Status, Tumblr, %A_Space% +} + +; -------------------------------CreateErrorLoggingFiles------------------------------- +CreateErrorLoggingFiles(Path := ""){ + FormatTime, TodayDate, YYYYMMDDHH24MISS, yyyyMMdd_hhmmss + + ErrorLoggingDirectory := Path + + if(Path = ""){ + ErrorLoggingDirectory := A_ScriptDir . "\Lib\ErrorLogging" + ; If directory for error logging doesn't exist, create it + if(!FileExist(ErrorLoggingDirectory)) + FileCreateDir, %ErrorLoggingDirectory% + + ErrorLoggingDirectory := ErrorLoggingDirectory . "\" . TodayDate . "_FSMP" + } + ; Msgbox % "ErrorLoggingDirectory: " ErrorLoggingDirectory + FileCreateDir, %ErrorLoggingDirectory% + + ; Create variables with filepaths that content will be saved to. + ErrorLoggingFilePath := ErrorLoggingDirectory . "\" . "ErrorLogging.txt" + StatusFileFilePath := ErrorLoggingDirectory . "\" . "PostStatus.ini" + PostTitleFilePath := ErrorLoggingDirectory . "\" . "PostTitle.txt" + PostBodyFilePath := ErrorLoggingDirectory . "\" . "PostBody.txt" + + ; Msgbox % "ErrorLoggingDirectory: " ErrorLoggingDirectory + Return +} +; -------------------------------/CreateErrorLoggingFiles------------------------------- + +AddToTotalPostsPostedCount(){ + IniRead, TotalPostsPosted, %SettingsIniFilepath%, SocialMediaPoster, TotalPostsPosted, 0 + TotalPostsPosted += 1 + IniWrite, %TotalPostsPosted%, %SettingsIniFilepath%, SocialMediaPoster, TotalPostsPosted +} + +AddToTotalRunTime(){ + IniRead, TotalRunTime, %SettingsIniFilepath%, SocialMediaPoster, TotalRunTime, 0 + TotalRunTime := Round(TotalRunTime + ScriptRunTime),2 + ; TotalRunTime += ScriptRunTime + IniWrite, %TotalRunTime%, %SettingsIniFilepath%, SocialMediaPoster, TotalRunTime + +} + +OnMsgBoxConfirmPost() { + DetectHiddenWindows, On + Process, Exist + If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) { + WinMove,, 0 + } +} + + + diff --git a/Freedomain Social Media Poster.exe b/Freedomain Social Media Poster.exe new file mode 100644 index 0000000..c78ee4e Binary files /dev/null and b/Freedomain Social Media Poster.exe differ diff --git a/Lib/ChromeAutomationFunctions.ahk b/Lib/ChromeAutomationFunctions.ahk new file mode 100644 index 0000000..07fc606 --- /dev/null +++ b/Lib/ChromeAutomationFunctions.ahk @@ -0,0 +1,216 @@ +; Various functions used to control Selenium, Chrome and Chrome.AHK + + +;---Javascript--- +;------------------------------------------------ +JS_TryToExecute(JsToExecute,NumberofAttempts := 1,SleepLength:=1000){ + loop, %NumberofAttempts% { + try driver.executeScript(JsToExecute) + catch e { + Continue + } + Return + } + Return "Failed" +} + + + +; ValueToCheckOptions = innertext,textContent,InnerHTML,outerHTML,value,href,option value +js_SendAndCheckWithClassName(ClassName:="",ClassIndexNum:=0,ValueToCheck:="textContent",SleepLength:=1000,JSStringText:="TEXT"){ + jsSend = document.getElementsByClassName('%ClassName%')[%ClassIndexNum%].value = "%JSStringText%"; + try driver.executeScript(jsSend) + + sleep, %SleepLength% + + jsCheck = return document.getElementsByClassName('%ClassName%')[%ClassIndexNum%].%ValueToCheck%; + try Status := driver.executeScript(jsCheck) + ; Msgbox % "Status: " Status + + if(Status = "") + return "Failed" + else, + return "" +} + +; ValueToCheckOptions = innertext,textContent,InnerHTML,outerHTML,value,href,option value +js_SendAndCheckWithNAME(Element:="",IndexNum:=0,ValueToCheck:="textContent",SleepLength:=1000,JSStringText:=""){ + jsSend = document.getElementsByName('%Element%')[%IndexNum%].value = "%JSStringText%"; +/*Clipboard := jsSend +Msgbox % "jsSend: " jsSend + +*/ +; document.getElementsByClassName('%ClassName%')[%ClassIndexNum%].value = "%JSStringText%"; +try driver.executeScript(jsSend) + +sleep, %SleepLength% + +jsCheck = return document.getElementsByName('%Element%')[%IndexNum%].%ValueToCheck%; +; Clipboard := jscheck +; Msgbox % "jsCheck: " jsCheck +try Status := driver.executeScript(jsCheck) +; Msgbox % "Status: " Status +if(Status = "") +return "Failed" +else, +return "" +} + +; ValueToCheckOptions = innertext,textContent,InnerHTML,outerHTML,value,href,option value +js_SendAndCheckWithID(Element:="",ValueToCheck:="textContent",SleepLength:=1000,JSStringText:=""){ + ; Msgbox % "Element: " Element + ; Msgbox % "JSStringText: " JSStringText + jsSend = document.getElementById('%Element%').value = "%JSStringText%"; + ; Clipboard := jsSend + ; Msgbox % "jsSend: " jsSend + try driver.executeScript(jsSend) + + ; Msgbox % "JSStringText: " JSStringText + sleep, %SleepLength% + + jsCheck = return document.getElementById('%Element%').%ValueToCheck%; + try Status := driver.executeScript(jsCheck) + if(Status = "") + return "Failed" + else, + return "" +} + +;---\Javascript--- +;------------------------------------------------ + + +;---Selenium--- +;------------------------------------------------ +; When called these will try multiple times to click/input into a web element + +Selenium_LoopToClickID(IDName,NumOfLoops:=1,SleepLength:=1000){ + loop, %NumOfLoops% { + try driver.findElementsByID(IDName).item[1].click() ; Click on "upload image" button + catch e { + if(A_index = NumOfLoops){ + Return "Failed" + } + sleep, %SleepLength% + Continue + } + Return +} +} + + +Selenium_LoopToClickName(ElementName,NumOfLoops:=1,SleepLength:=1000){ + loop, %NumOfLoops% { + try driver.findElementsByName(ElementName).item[1].click() + catch e { + if(A_index = NumOfLoops){ + Return "Failed" + } + sleep, %SleepLength% + Continue + } + Return +} +} + + +Selenium_LoopToSendValueToID(IDName,NumOfLoops:=1,SleepLength:=1000,StringTextContent:=""){ + loop, %NumOfLoops% { + try driver.findElementsByID(IDName).item[1].sendKeys(StringTextContent) ; Click on "upload image" button + catch e { + if(A_index = NumOfLoops){ + Return "Failed" + } + sleep, %SleepLength% + Continue + } + Return +} +} +; Selenium_LoopToSendValueByName(ElementName:="NAME",NumOfLoops:=2,SleepLength:=1000,StringTextContent:="TEXT") +Selenium_LoopToSendValueByName(ElementName,NumOfLoops:=1,SleepLength:=1000,StringTextContent:=""){ + loop, %NumOfLoops% { + try driver.findElementsByName(ElementName).item[1].SendKeys(StringTextContent) + catch e { + if(A_index = NumOfLoops){ + Return "Failed" + } + sleep, %SleepLength% + Continue + } + Return +} +} + +Selenium_LoopToSendValueToXpath(Xpath,NumOfLoops:=1,SleepLength:=1000,StringTextContent:=""){ + loop, %NumOfLoops% { + ; ToolTip, Loop attempt: %A_index% + try driver.FindElementByXPath(Xpath).sendKeys(StringTextContent) ; Click on "upload image" button + catch e { + if(A_index = NumOfLoops){ + Return "Failed" + } + sleep, %SleepLength% + Continue + } + Return +} +} + + +Selenium_LoopToClickXpath(Xpath,NumOfLoops:=1,SleepLength:=1000){ + loop, %NumOfLoops% { + try driver.FindElementByXPath(Xpath).click() + catch e { + if(A_index = NumOfLoops){ + Return "Failed" + } + sleep, %SleepLength% + Continue + } + Return +} +} + +Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath,NumOfLoops:=1,SleepLength:=1000,WindowName:="Open"){ + loop, %NumOfLoops% { + ; TooltipThis("Clicking xpath") + try driver.FindElementByXPath(Xpath).click() + catch e { + if(A_index = NumOfLoops){ + Return "Failed to Click Xpath or Open File window did not show up on click" + } + sleep, %SleepLength% + Continue + } + ; tooltipthis("Checking if window exists") + sleep, 1000 + ; Msgbox % "WindowName: " WindowName + if(!WinExist(WindowName)){ + Message = %WindowName% not found on %A_index% attempt. + ; tooltipthis("Window not found") + + sleep, %SleepLength% + Continue + } + Return +} +} + + +Selenium_LoopToClearXpath(Xpath,NumOfLoops:=1,SleepLength:=1000){ + loop, %NumOfLoops% { + try driver.FindElementByXPath(Xpath).clear() + catch e { + if(A_index = NumOfLoops){ + Return "Failed" + } + sleep, %SleepLength% + Continue + } + Return +} +} + +;---\Selenium--- +;------------------------------------------------ diff --git a/Lib/Json.ahk b/Lib/Json.ahk new file mode 100644 index 0000000..e5b3d19 --- /dev/null +++ b/Lib/Json.ahk @@ -0,0 +1,374 @@ +/** + * Lib: JSON.ahk + * JSON lib for AutoHotkey. + * Version: + * v2.1.3 [updated 04/18/2016 (MM/DD/YYYY)] + * License: + * WTFPL [http://wtfpl.net/] + * Requirements: + * Latest version of AutoHotkey (v1.1+ or v2.0-a+) + * Installation: + * Use #Include JSON.ahk or copy into a function library folder and then + * use #Include + * Links: + * GitHub: - https://github.com/cocobelgica/AutoHotkey-JSON + * Forum Topic - http://goo.gl/r0zI8t + * Email: - cocobelgica gmail com + */ + + +/** + * Class: JSON + * The JSON object contains methods for parsing JSON and converting values + * to JSON. Callable - NO; Instantiable - YES; Subclassable - YES; + * Nestable(via #Include) - NO. + * Methods: + * Load() - see relevant documentation before method definition header + * Dump() - see relevant documentation before method definition header + */ +class JSON +{ + /** + * Method: Load + * Parses a JSON string into an AHK value + * Syntax: + * value := JSON.Load( text [, reviver ] ) + * Parameter(s): + * value [retval] - parsed value + * text [in, ByRef] - JSON formatted string + * reviver [in, opt] - function object, similar to JavaScript's + * JSON.parse() 'reviver' parameter + */ + class Load extends JSON.Functor + { + Call(self, ByRef text, reviver:="") + { + this.rev := IsObject(reviver) ? reviver : false + ; Object keys(and array indices) are temporarily stored in arrays so that + ; we can enumerate them in the order they appear in the document/text instead + ; of alphabetically. Skip if no reviver function is specified. + this.keys := this.rev ? {} : false + + static quot := Chr(34), bashq := "\" . quot + , json_value := quot . "{[01234567890-tfn" + , json_value_or_array_closing := quot . "{[]01234567890-tfn" + , object_key_or_object_closing := quot . "}" + + key := "" + is_key := false + root := {} + stack := [root] + next := json_value + pos := 0 + + while ((ch := SubStr(text, ++pos, 1)) != "") { + if InStr(" `t`r`n", ch) + continue + if !InStr(next, ch, 1) + this.ParseError(next, text, pos) + + holder := stack[1] + is_array := holder.IsArray + + if InStr(",:", ch) { + next := (is_key := !is_array && ch == ",") ? quot : json_value + + } else if InStr("}]", ch) { + ObjRemoveAt(stack, 1) + next := stack[1]==root ? "" : stack[1].IsArray ? ",]" : ",}" + + } else { + if InStr("{[", ch) { + ; Check if Array() is overridden and if its return value has + ; the 'IsArray' property. If so, Array() will be called normally, + ; otherwise, use a custom base object for arrays + static json_array := Func("Array").IsBuiltIn || ![].IsArray ? {IsArray: true} : 0 + + ; sacrifice readability for minor(actually negligible) performance gain + (ch == "{") + ? ( is_key := true + , value := {} + , next := object_key_or_object_closing ) + ; ch == "[" + : ( value := json_array ? new json_array : [] + , next := json_value_or_array_closing ) + + ObjInsertAt(stack, 1, value) + + if (this.keys) + this.keys[value] := [] + + } else { + if (ch == quot) { + i := pos + while (i := InStr(text, quot,, i+1)) { + value := StrReplace(SubStr(text, pos+1, i-pos-1), "\\", "\u005c") + + static tail := A_AhkVersion<"2" ? 0 : -1 + if (SubStr(value, tail) != "\") + break + } + + if (!i) + this.ParseError("'", text, pos) + + value := StrReplace(value, "\/", "/") + , value := StrReplace(value, bashq, quot) + , value := StrReplace(value, "\b", "`b") + , value := StrReplace(value, "\f", "`f") + , value := StrReplace(value, "\n", "`n") + , value := StrReplace(value, "\r", "`r") + , value := StrReplace(value, "\t", "`t") + + pos := i ; update pos + + i := 0 + while (i := InStr(value, "\",, i+1)) { + if !(SubStr(value, i+1, 1) == "u") + this.ParseError("\", text, pos - StrLen(SubStr(value, i+1))) + + uffff := Abs("0x" . SubStr(value, i+2, 4)) + if (A_IsUnicode || uffff < 0x100) + value := SubStr(value, 1, i-1) . Chr(uffff) . SubStr(value, i+6) + } + + if (is_key) { + key := value, next := ":" + continue + } + + } else { + value := SubStr(text, pos, i := RegExMatch(text, "[\]\},\s]|$",, pos)-pos) + + static number := "number", integer :="integer" + if value is %number% + { + if value is %integer% + value += 0 + } + else if (value == "true" || value == "false") + value := %value% + 0 + else if (value == "null") + value := "" + else + ; we can do more here to pinpoint the actual culprit + ; but that's just too much extra work. + this.ParseError(next, text, pos, i) + + pos += i-1 + } + + next := holder==root ? "" : is_array ? ",]" : ",}" + } ; If InStr("{[", ch) { ... } else + + is_array? key := ObjPush(holder, value) : holder[key] := value + + if (this.keys && this.keys.HasKey(holder)) + this.keys[holder].Push(key) + } + + } ; while ( ... ) + + return this.rev ? this.Walk(root, "") : root[""] + } + + ParseError(expect, ByRef text, pos, len:=1) + { + static quot := Chr(34), qurly := quot . "}" + + line := StrSplit(SubStr(text, 1, pos), "`n", "`r").Length() + col := pos - InStr(text, "`n",, -(StrLen(text)-pos+1)) + msg := Format("{1}`n`nLine:`t{2}`nCol:`t{3}`nChar:`t{4}" + , (expect == "") ? "Extra data" + : (expect == "'") ? "Unterminated string starting at" + : (expect == "\") ? "Invalid \escape" + : (expect == ":") ? "Expecting ':' delimiter" + : (expect == quot) ? "Expecting object key enclosed in double quotes" + : (expect == qurly) ? "Expecting object key enclosed in double quotes or object closing '}'" + : (expect == ",}") ? "Expecting ',' delimiter or object closing '}'" + : (expect == ",]") ? "Expecting ',' delimiter or array closing ']'" + : InStr(expect, "]") ? "Expecting JSON value or array closing ']'" + : "Expecting JSON value(string, number, true, false, null, object or array)" + , line, col, pos) + + static offset := A_AhkVersion<"2" ? -3 : -4 + throw Exception(msg, offset, SubStr(text, pos, len)) + } + + Walk(holder, key) + { + value := holder[key] + if IsObject(value) { + for i, k in this.keys[value] { + ; check if ObjHasKey(value, k) ?? + v := this.Walk(value, k) + if (v != JSON.Undefined) + value[k] := v + else + ObjDelete(value, k) + } + } + + return this.rev.Call(holder, key, value) + } + } + + /** + * Method: Dump + * Converts an AHK value into a JSON string + * Syntax: + * str := JSON.Dump( value [, replacer, space ] ) + * Parameter(s): + * str [retval] - JSON representation of an AHK value + * value [in] - any value(object, string, number) + * replacer [in, opt] - function object, similar to JavaScript's + * JSON.stringify() 'replacer' parameter + * space [in, opt] - similar to JavaScript's JSON.stringify() + * 'space' parameter + */ + class Dump extends JSON.Functor + { + Call(self, value, replacer:="", space:="") + { + this.rep := IsObject(replacer) ? replacer : "" + + this.gap := "" + if (space) { + static integer := "integer" + if space is %integer% + Loop, % ((n := Abs(space))>10 ? 10 : n) + this.gap .= " " + else + this.gap := SubStr(space, 1, 10) + + this.indent := "`n" + } + + return this.Str({"": value}, "") + } + + Str(holder, key) + { + value := holder[key] + + if (this.rep) + value := this.rep.Call(holder, key, ObjHasKey(holder, key) ? value : JSON.Undefined) + + if IsObject(value) { + ; Check object type, skip serialization for other object types such as + ; ComObject, Func, BoundFunc, FileObject, RegExMatchObject, Property, etc. + static type := A_AhkVersion<"2" ? "" : Func("Type") + if (type ? type.Call(value) == "Object" : ObjGetCapacity(value) != "") { + if (this.gap) { + stepback := this.indent + this.indent .= this.gap + } + + is_array := value.IsArray + ; Array() is not overridden, rollback to old method of + ; identifying array-like objects. Due to the use of a for-loop + ; sparse arrays such as '[1,,3]' are detected as objects({}). + if (!is_array) { + for i in value + is_array := i == A_Index + until !is_array + } + + str := "" + if (is_array) { + Loop, % value.Length() { + if (this.gap) + str .= this.indent + + v := this.Str(value, A_Index) + str .= (v != "") ? v . "," : "null," + } + } else { + colon := this.gap ? ": " : ":" + for k in value { + v := this.Str(value, k) + if (v != "") { + if (this.gap) + str .= this.indent + + str .= this.Quote(k) . colon . v . "," + } + } + } + + if (str != "") { + str := RTrim(str, ",") + if (this.gap) + str .= stepback + } + + if (this.gap) + this.indent := stepback + + return is_array ? "[" . str . "]" : "{" . str . "}" + } + + } else ; is_number ? value : "value" + return ObjGetCapacity([value], 1)=="" ? value : this.Quote(value) + } + + Quote(string) + { + static quot := Chr(34), bashq := "\" . quot + + if (string != "") { + string := StrReplace(string, "\", "\\") + ; , string := StrReplace(string, "/", "\/") ; optional in ECMAScript + , string := StrReplace(string, quot, bashq) + , string := StrReplace(string, "`b", "\b") + , string := StrReplace(string, "`f", "\f") + , string := StrReplace(string, "`n", "\n") + , string := StrReplace(string, "`r", "\r") + , string := StrReplace(string, "`t", "\t") + + static rx_escapable := A_AhkVersion<"2" ? "O)[^\x20-\x7e]" : "[^\x20-\x7e]" + while RegExMatch(string, rx_escapable, m) + string := StrReplace(string, m.Value, Format("\u{1:04x}", Ord(m.Value))) + } + + return quot . string . quot + } + } + + /** + * Property: Undefined + * Proxy for 'undefined' type + * Syntax: + * undefined := JSON.Undefined + * Remarks: + * For use with reviver and replacer functions since AutoHotkey does not + * have an 'undefined' type. Returning blank("") or 0 won't work since these + * can't be distnguished from actual JSON values. This leaves us with objects. + * Replacer() - the caller may return a non-serializable AHK objects such as + * ComObject, Func, BoundFunc, FileObject, RegExMatchObject, and Property to + * mimic the behavior of returning 'undefined' in JavaScript but for the sake + * of code readability and convenience, it's better to do 'return JSON.Undefined'. + * Internally, the property returns a ComObject with the variant type of VT_EMPTY. + */ + Undefined[] + { + get { + static empty := {}, vt_empty := ComObject(0, &empty, 1) + return vt_empty + } + } + + class Functor + { + __Call(method, ByRef arg, args*) + { + ; When casting to Call(), use a new instance of the "function object" + ; so as to avoid directly storing the properties(used across sub-methods) + ; into the "function object" itself. + if IsObject(method) + return (new this).Call(method, arg, args*) + else if (method == "") + return (new this).Call(arg, args*) + } + } +} diff --git a/Lib/RunCMD.ahk b/Lib/RunCMD.ahk new file mode 100644 index 0000000..d4f5d7d --- /dev/null +++ b/Lib/RunCMD.ahk @@ -0,0 +1,50 @@ + ; PowerShell +; https://www.autohotkey.com/boards/viewtopic.php?p=341237#p341237 + + +RunCMD(CmdLine, WorkingDir:="", Codepage:="CP0", Fn:="RunCMD_Output") { ; RunCMD v0.94 +Local ; RunCMD v0.94 by SKAN on D34E/D37C @ autohotkey.com/boards/viewtopic.php?t=74647 +Global A_Args ; Based on StdOutToVar.ahk by Sean @ autohotkey.com/board/topic/15455-stdouttovar + + Fn := IsFunc(Fn) ? Func(Fn) : 0 +, DllCall("CreatePipe", "PtrP",hPipeR:=0, "PtrP",hPipeW:=0, "Ptr",0, "Int",0) +, DllCall("SetHandleInformation", "Ptr",hPipeW, "Int",1, "Int",1) +, DllCall("SetNamedPipeHandleState","Ptr",hPipeR, "UIntP",PIPE_NOWAIT:=1, "Ptr",0, "Ptr",0) + +, P8 := (A_PtrSize=8) +, VarSetCapacity(SI, P8 ? 104 : 68, 0) ; STARTUPINFO structure +, NumPut(P8 ? 104 : 68, SI) ; size of STARTUPINFO +, NumPut(STARTF_USESTDHANDLES:=0x100, SI, P8 ? 60 : 44,"UInt") ; dwFlags +, NumPut(hPipeW, SI, P8 ? 88 : 60) ; hStdOutput +, NumPut(hPipeW, SI, P8 ? 96 : 64) ; hStdError +, VarSetCapacity(PI, P8 ? 24 : 16) ; PROCESS_INFORMATION structure + + If not DllCall("CreateProcess", "Ptr",0, "Str",CmdLine, "Ptr",0, "Int",0, "Int",True + ,"Int",0x08000000 | DllCall("GetPriorityClass", "Ptr",-1, "UInt"), "Int",0 + ,"Ptr",WorkingDir ? &WorkingDir : 0, "Ptr",&SI, "Ptr",&PI) + Return Format("{1:}", "", ErrorLevel := -1 + ,DllCall("CloseHandle", "Ptr",hPipeW), DllCall("CloseHandle", "Ptr",hPipeR)) + + DllCall("CloseHandle", "Ptr",hPipeW) +, A_Args.RunCMD := { "PID": NumGet(PI, P8? 16 : 8, "UInt") } +, File := FileOpen(hPipeR, "h", Codepage) + +, LineNum := 1, sOutput := "" + While (A_Args.RunCMD.PID + DllCall("Sleep", "Int",0)) + and DllCall("PeekNamedPipe", "Ptr",hPipeR, "Ptr",0, "Int",0, "Ptr",0, "Ptr",0, "Ptr",0) + While A_Args.RunCMD.PID and (Line := File.ReadLine()) + sOutput .= Fn ? Fn.Call(Line, LineNum++) : Line + + A_Args.RunCMD.PID := 0 +, hProcess := NumGet(PI, 0) +, hThread := NumGet(PI, A_PtrSize) + +, DllCall("GetExitCodeProcess", "Ptr",hProcess, "PtrP",ExitCode:=0) +, DllCall("CloseHandle", "Ptr",hProcess) +, DllCall("CloseHandle", "Ptr",hThread) +, DllCall("CloseHandle", "Ptr",hPipeR) + +, ErrorLevel := ExitCode + +Return sOutput +} diff --git a/Lib/SChrome.ahk b/Lib/SChrome.ahk new file mode 100644 index 0000000..535dcc8 --- /dev/null +++ b/Lib/SChrome.ahk @@ -0,0 +1,54 @@ +; Written by AHK_User 2019-10-11 +; Special thanks to tmplinshi, CH HAN and Joe Glines +; https://www.autohotkey.com/boards/viewtopic.php?f=7&t=32323&p=296136&hilit=schrome_get#p296136 +;Driver := SChrome_Get("https://stackoverflow.com/questions/37088589/selenium-wont-open-a-new-url-in-a-new-tab-python-chrome/39353910#39353910",,"Tab") + +; Written by AHK_User 2019-10-11 +; Special thanks to tmplinshi, CH HAN and Joe Glines + +SChrome_Get(URL := "", Profile := "Profile 1", IP_Port := "127.0.0.1:9222"){ + IP_Port_Nr := RegExReplace(IP_Port, ".*:(\d*)", "$1") + if WinExist("ahk_exe Chrome.exe"){ + WinGet, pid, PID, ahk_exe chrome.exe + for item in ComObjGet("winmgmts:").ExecQuery("SELECT * FROM Win32_Process WHERE ProcessId='" pid "'"){ + if RegExMatch(item.CommandLine, "i)--remote-debugging-port=\K\d+", port){ + break + } + } + if (Port=""){ + MsgBox, 36, ,Chrome Needs to be started in debugging mode in order for Autohotkey to connect to it.`nIs it ok to restart Chrome in debugmode to enable a connection? + IfMsgBox, Yes + { + While(WinExist("ahk_exe chrome.exe")) { + WinClose, ahk_exe chrome.exe + } + Process, WaitClose, chrome.exe + } + Else{ + Exit + } + } + } + + if(URL!="" or !winExist("ahk_class Chrome_WidgetWin_1")){ + ; run % "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --remote-debugging-port=" IP_Port_Nr ( winExist("ahk_class Chrome_WidgetWin_1") ? " --new-window " : " " ) URL + if(A_ComputerName = "WLatitude") + { + run, C:\Software\Chromium\chrome.exe --remote-debugging-port=%IP_Port_Nr% --profile-directory="%Profile%" ; %URL% + ; sleep, 1000 + ; run, C:\Software\Chromium\chrome.exe --remote-debugging-port=%IP_Port_Nr% --profile-directory="%Profile%" --new-window %URL% + } + else, + { + run, chrome.exe --remote-debugging-port=%IP_Port_Nr% --profile-directory="%Profile%" %URL% + ; sleep, 1000 + ; run, chrome.exe --remote-debugging-port=%IP_Port_Nr% --profile-directory="%Profile%" --new-window %URL% + + } + } + + Driver := ComObjCreate("Selenium.ChromeDriver") + Driver.SetCapability("debuggerAddress", IP_Port) + Driver.Start() + return Driver +} \ No newline at end of file diff --git a/Lib/SharedFunctions.ahk b/Lib/SharedFunctions.ahk new file mode 100644 index 0000000..a91005c --- /dev/null +++ b/Lib/SharedFunctions.ahk @@ -0,0 +1,1426 @@ +;---FUNCTIONS----------------------------------------------------------------------- +; Misc Functions that are called by both the Video and Social Media poster + + +; -------------------------------Variables------------------------------- +; Declare global variables here so they don't have to be declared in each script +global DriverURLArray +global DriverTitleArray +global LastWebsitePostURL +global ScreenshotsTaken +global ChromeFilepath +global CurrentTabURL + +; #Include %A_ScriptDir%\ChromeAutomationFunctions.ahk +; #Include %A_ScriptDir%\RunCMD.ahk + +#Include C:\Users\%A_username%\Syncthing\Freedomain\Uploaders\Lib\ChromeAutomationFunctions.ahk +#Include C:\Users\%A_username%\Syncthing\Freedomain\Uploaders\Lib\RunCMD.ahk + + +DevModeMsgBox(Message){ + if(!DevMode) + return + + Msgbox, 4096, DevModeMsgBox, %Message% + return +} + + +CheckForUpdates(){ + ; msgbox, checking for updates + Message = Checking For Updates + SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + ; 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 +} + + + + +UpdateScript(){ + ; Msgbox % "ChangelogIniFilepath: " ChangelogIniFilepath + ; Msgbox % "ScriptSettingsSection: " ScriptSettingsSection + + IniRead, Changelog, %ChangelogIniFilepath%, %ScriptSettingsSection%, Changelog, %A_Space% + Changelog := StrReplace(Changelog, "--", "`n-") + + IniRead, UpdateVersion, %ChangelogIniFilepath%, %ScriptSettingsSection%, ScriptVersion, %A_Space% + + if(ScriptVersion = UpdateVersion){ + IniWrite, 0, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable + MsgBox, You are Up-To-Date + ; IniRead, UpdateAvailable, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable, 0 + return + } + + Changelog = %ScriptVersion% -> %UpdateVersion%`n`n-%Changelog% + + OnMessage(0x44, "OnMsgBoxUpdateAvailable") + MsgBox 0x44, Update Available, %Changelog% + OnMessage(0x44, "") + + IfMsgBox Yes, { + Return + } Else IfMsgBox No, { + run, "%FreedomainProgramUpdaterFilepath%" "%ScriptSettingsSection%" + ; Return + ExitApp + } + return + } + + + + ; -------------------------------SaveOrPostProgress------------------------------- + ; PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging,DiscordVideos" + SaveOrPostProgress(Message:="",PostType:=""){ + + MessageBU := Message + ; Msgbox % "PostType: " PostType + ; Msgbox % "CurrentSite: " CurrentSite + + if(CurrentSite != "") + Message := CurrentSite . ": " . Message + + if(InStr(PostType, "Tooltip")){ + TooltipThis(Message) + } + if(InStr(PostType, "ErrorLoggingTextFile")){ + Func_LogErrorsToTextFile(Message) + } + if(InStr(PostType, "ErrorSummaryVar")){ + Func_LogErrorsToVar(Message) + } + if(InStr(PostType, "DiscordErrorLogging")){ + PostToDiscordChannel(Message,DiscordErrorLoggingWebhookBotURL) + } + if(InStr(PostType, "DiscordVideos")){ + Message := MessageBU + PostToDiscordChannel(Message,DiscordVideosWebhookURL) + } + if(InStr(PostType, "DiscordParler")){ + Message := MessageBU + PostToDiscordChannel(Message,DiscordParlerWebhookURL) + } + + + + } + ; -------------------------------/SaveOrPostProgress------------------------------- + TakeScreenshotOfPage(SaveFilepath := ""){ + + if(!ScreenshotResult) + return + + TooltipThis("Sleeping 5 Seconds Before Taking Screenshot") + ; sleep, 5000 + + if(SaveFilepath = ""){ + SaveFilepath := ErrorLoggingDirectory + } + + ; if(!FileExist(SaveFilepath)) + FileCreateDir, %SaveFilepath% + + /* if(!TakeScreenshotsOfErrors) + Return + */ + ; Take a screenshot of the page and save it. + FormatTime, TodayDate , YYYYMMDDHH24MISS, yyyyMMdd_hhmmss + + ; Msgbox % "ErrorLoggingDirectory: " ErrorLoggingDirectory + savepath = %SaveFilepath%\%TodayDate%.jpg + ; Msgbox % "savepath: " savepath + try driver.TakeScreenshot().SaveAs(savepath) + + ; ScreenshotsTaken := 1 + +} + + + + +; -------------------------------TooltipThis------------------------------- +TooltipThis(String){ + ; Xposition := StrLen(String) + StringFirstLine := StrSplit(String, "`n") + StringFirstLine := StringFirstLine[1] + Xposition := StrLen(StringFirstLine) + ; Msgbox % "String: " String + Xposition := Xposition * 4 + X := (A_ScreenWidth / 2) - Xposition + ; Msgbox % "X: " X + if(ShowTooltipProgress){ + ToolTip, %String%, %X%, 0 + } +} +; -------------------------------/TooltipThis------------------------------- + +;------------------------------------------------ +TimedToolTip(Text, x="", y="",RemoveAfterTime:=2000, SetWhichToolTip="") { + if(X = ""){ + Xposition := StrLen(Text) + ; Msgbox % "Xposition: " Xposition + Xposition := Xposition * 4 + ; Xposition := 0 + X := (A_ScreenWidth / 2) - Xposition + ; Msgbox % "X: " X + } + (y = "")?(y:=0):(y:=y) + + ; Msgbox % "y: " y + ToolTip, %Text%, %X%, %Y% + SetTimer, RMApp_ToolTipRASub, % - RemoveAfterTime + return + RMApp_ToolTipRASub: + ToolTip,,,, %WhichToolTip% + return +} + + +; -------------------------------LogErrorsToTextFile------------------------------- +Func_LogErrorsToTextFile(Text){ + ; ErrorLoggingFile := Filepath + FormatTime, TodayDate , YYYYMMDDHH24MISS, yyyyMMdd_hhmmss + text = + ( + + ---------------%TodayDate%--------------- + %Text% + + ) + FileAppend, %Text%, %ErrorLoggingFilePath% +} +; -------------------------------/LogErrorsToTextFile------------------------------- + +; -------------------------------LogErrorsToVar------------------------------- +Func_LogErrorsToVar(Text){ + ErrorLogVar .= "`n" . Text +} +; -------------------------------/LogErrorsToVar------------------------------- + + +; -------------------------------Discord------------------------------- +PostToDiscordChannel(Message,WebhookChannel){ + ; Msgbox % "Message: " Message + ; Msgbox % "WebhookChannel: " WebhookChannel + + ; Replace all the json forbidden characters + SingleQuote = " + ReplacedQuote = \" + + Message := StrReplace(Message, "\", "\\") ; Replace Tabs + Message := StrReplace(Message, SingleQuote, ReplacedQuote) ; Replace single quote + Message := StrReplace(Message, "`r", "") ; Replace Carriage return + Message := StrReplace(Message, A_Tab, "\t") ; Replace Tabs + Message := StrReplace(Message, "`n", "\n") ; Escape New Line Character + Message := StrReplace(Message, "`f", "\f") ; Replace Tabs + + + ; Convert into json string + JsonString= + ( + { + "content": "%Message%" + } + ) + + ; Msgbox % "JsonString: " JsonString + ; + try WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1") + try WebRequest.Open("POST", WebhookChannel, false) + try WebRequest.SetRequestHeader("Content-Type", "application/json") + try WebRequest.Send(JsonString) +} + + +; -------------------------------/Discord------------------------------- + + + +; -------------------------------TelegramAPI------------------------------- +TelegramMsgBox(Text:="", TelegramBotToken := "", TelegramBotChatID :=""){ + ; Send Images: + ; https://www.autohotkey.com/boards/viewtopic.php?f=76&t=68417&p=294332#p294332 + + ; Msgbox % "Text: " Text + + + ; Replace all forbidden characters - https://www.ascii-code.com/ + ; Text := StrReplace(Text, "`%", "%25") ; percent with + Text := StrReplace(Text, "`n", "%0A") ; New Line + ; Text := StrReplace(Text, "`n", "%0A") ; New Line + + ; Text := StrReplace(Text, " ", "%23") ; New Line + ; Text := + ; Text := StrReplace(Text, "`n", "%0A") ; New Line + + ; Msgbox % "Text: " Text + + ErrorLoggingPath = %A_ScriptDir%\Lib\ErrorLogging\check.rups + + loop 3 + { + UrlDownloadToFile https://api.telegram.org/bot%TelegramBotToken%/sendmessage?chat_id=%TelegramBotChatID%&text=%Text%, %ErrorLoggingPath% + sleep 1000 + ifexist %ErrorLoggingPath% + { + break + } + if A_index = 3 + { + Message = Post failed due to API Issue. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return "Failed" + ; MsgBox, 16,, something went wrong with sending + } + } + FileRead, TelegramOutput, %ErrorLoggingPath% + TelegramOutput := "API Result: " . TelegramOutput + ; Msgbox % "TelegramOutput: " TelegramOutput + filedelete %ErrorLoggingPath% + SaveOrPostProgress(Message:=TelegramOutput,PostType:="ErrorLoggingTextFile") + + if(InStr(TelegramOutput, "error_code")){ + Return "Failed" + } + +} + +; -------------------------------/TelegramAPI------------------------------- + +; Telegram Message API +;------------------------------------------------ +SendTelegramMessage(token, chatID, text := "", ParseMode := "MarkdownV2") ; you could add more options; compare the Telegram API docs +{ + ; ParseMode := "MarkdownV2" + ; msgbox + ; Msgbox % "text: " text + url_str := "https://api.telegram.org/bot" token "/sendMessage" + objParam := { "chat_id" : chatID + ,"parse_mode" : ParseMode + ,"text" : text } + + CreateFormData(postData, hdr_ContentType, objParam) + whr := ComObjCreate("WinHttp.WinHttpRequest.5.1") + whr.Open("POST", url_str, true) + whr.SetRequestHeader("Content-Type", hdr_ContentType) + ; whr.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") ; ??????? + whr.Option(6) := False ; No auto redirect + whr.Send(postData) + whr.WaitForResponse() + json_resp := whr.ResponseText + whr := ; free COM object + ; Msgbox % "json_resp: " json_resp + if(InStr(json_resp, "error_code")) + Return json_resp +} + +/* + +*bold \*text* +_italic \*text_ +__underline__ +~strikethrough~ +*bold _italic bold ~italic bold strikethrough~ __underline italic bold___ bold* +[inline URL](http://www.example.com/) +[inline mention of a user](tg://user?id=123456789) +`inline fixed-width code` +``` +pre-formatted fixed-width code block +``` +```python +pre-formatted fixed-width code block written in the Python programming language +``` + +*/ + + + +; -------------------------------Telegram Image Sending------------------------------- +; https://www.autohotkey.com/boards/viewtopic.php?t=68417 +SendTelegramPhoto(token, chatID, file, caption := "", ParseMode := "MarkdownV2") ; you could add more options; compare the Telegram API docs +{ + + ; ParseMode := "MarkdownV2" + url_str := "https://api.telegram.org/bot" token "/sendPhoto" + objParam := { "chat_id" : chatID + , "photo" : [file] + , "parse_mode" : ParseMode + , "caption" : caption} + + CreateFormData(postData, hdr_ContentType, objParam) + whr := ComObjCreate("WinHttp.WinHttpRequest.5.1") + whr.Open("POST", url_str, true) + whr.SetRequestHeader("Content-Type", hdr_ContentType) + ; whr.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") ; ??????? + whr.Option(6) := False ; No auto redirect + whr.Send(postData) + whr.WaitForResponse() + json_resp := whr.ResponseText + whr := ; free COM object + ; Msgbox % "json_resp: " json_resp + + if(InStr(json_resp, "error_code")) + Return json_resp +} + + +; -------------------------------Telegram Image Sending------------------------------- +; https://www.autohotkey.com/boards/viewtopic.php?t=68417 +SendTelegramVideo(token, chatID, file, caption := "", ParseMode := "MarkdownV2") ; you could add more options; compare the Telegram API docs +{ + + ; ParseMode := "MarkdownV2" + url_str := "https://api.telegram.org/bot" token "/sendVideo?caption=" caption + objParam := { "chat_id" : chatID + , "video" : [file] + , "parse_mode" : ParseMode } + + CreateFormData(postData, hdr_ContentType, objParam) + whr := ComObjCreate("WinHttp.WinHttpRequest.5.1") + whr.Open("POST", url_str, true) + whr.SetRequestHeader("Content-Type", hdr_ContentType) + ; whr.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") ; ??????? + whr.Option(6) := False ; No auto redirect + whr.Send(postData) + whr.WaitForResponse() + json_resp := whr.ResponseText + whr := ; free COM object + ; Msgbox % "json_resp: " json_resp + + if(InStr(json_resp, "error_code")) + Return json_resp +} + + + +; -------------------------------Telegram File Sending------------------------------- +; https://www.autohotkey.com/boards/viewtopic.php?t=68417 +SendTelegramFile(token, chatID, file, caption := "", ParseMode := "MarkdownV2") ; you could add more options; compare the Telegram API docs +{ + + ; ParseMode := "MarkdownV2" + url_str := "https://api.telegram.org/bot" token "/sendDocument?caption=" caption + objParam := { "chat_id" : chatID + , "document" : [file] + , "parse_mode" : ParseMode } + + CreateFormData(postData, hdr_ContentType, objParam) + whr := ComObjCreate("WinHttp.WinHttpRequest.5.1") + whr.Open("POST", url_str, true) + whr.SetRequestHeader("Content-Type", hdr_ContentType) + ; whr.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") ; ??????? + whr.Option(6) := False ; No auto redirect + whr.Send(postData) + whr.WaitForResponse() + json_resp := whr.ResponseText + whr := ; free COM object + ; Msgbox % "json_resp: " json_resp + + if(InStr(json_resp, "error_code")) + Return json_resp +} + + + + + + +; -------------------------------/Telegram API Image Sending------------------------------- + + +ASCIISTRReplace(Message){ + ; Msgbox % "Message of function: " Message + ; https://tech.saigonist.com/b/code/escaping-special-characters-markdown.html + ; Replace all forbidden characters - https://www.ascii-code.com/ + + LineBreakChar = `%0A ; Used for API + + + Message := StrReplace(Message, "\", "\\") ; replace all new line characters with the global charater + Message := StrReplace(Message, "*", "\*") ; replace all new line characters with the global charater + ; Message := StrReplace(Message, "`n", LineBreakChar) ; replace all new line characters with the global charater + Message := StrReplace(Message, "!", "\!") ; replace all new line characters with the global charater + Message := StrReplace(Message, "_", "\_") ; replace all new line characters with the global charater + Message := StrReplace(Message, "{", "\{") ; replace all new line characters with the global charater + Message := StrReplace(Message, "}", "\}") ; replace all new line characters with the global charater + Message := StrReplace(Message, "[", "\[") ; replace all new line characters with the global charater + Message := StrReplace(Message, "]", "\]") ; replace all new line characters with the global charater + Message := StrReplace(Message, "(", "\(") ; replace all new line characters with the global charater + Message := StrReplace(Message, ")", "\)") ; replace all new line characters with the global charater + Message := StrReplace(Message, "#", "\#") ; replace all new line characters with the global charater + Message := StrReplace(Message, "+", "\+") ; replace all new line characters with the global charater + Message := StrReplace(Message, "-", "\-") ; replace all new line characters with the global charater + Message := StrReplace(Message, ".", "\.") ; replace all new line characters with the global charater + Message := StrReplace(Message, ">", "\>") ; replace all new line characters with the global charater + Message := StrReplace(Message, "<", "\<") ; replace all new line characters with the global charater + Message := StrReplace(Message, "=", "\=") ; replace all new line characters with the global charater + Message := StrReplace(Message, "|", "\|") ; replace all new line characters with the global charater + Message := StrReplace(Message, "~", "\~") ; replace all new line characters with the global charater + Message := StrReplace(Message, "`", "\`") ; replace all new line characters with the global charater + Message := StrReplace(Message, "$", "\$") ; replace all new line characters with the global charater + ; Message := StrReplace(Message, "%", "\%") ; replace all new line characters with the global charater + Message := StrReplace(Message, "&", "\&") ; replace all new line characters with the global charater + + ; Msgbox % "replaced Message: " Message + + + Return Message +} + + + +; -------------------------------Discord Images------------------------------- +UploadImageToDiscord(Webhook, Message:="", Filepath:=""){ + + filepath := [Filepath] ; Create object + + objParam := {file: filepath, content: Message} + CreateFormData(PostData, hdr_ContentType, objParam) + + HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1") + HTTP.Open("POST", Webhook, true) + HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") + HTTP.SetRequestHeader("Content-Type", hdr_ContentType) + HTTP.SetRequestHeader("Pragma", "no-cache") + HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store") + HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") + HTTP.Send(PostData) + HTTP.WaitForResponse() + ; msgbox % HTTP.ResponseText + return HTTP.ResponseText +} +; -------------------------------/Discord Images------------------------------- + + +;---------------------------Discord Messages--------------------- +UploadMessageToDiscord(Webhook, Message:=""){ + + ; filepath := [Filepath] ; Create object + + objParam := {file: filepath, content: Message} + CreateFormData(PostData, hdr_ContentType, objParam) + + HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1") + HTTP.Open("POST", Webhook, true) + HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") + HTTP.SetRequestHeader("Content-Type", hdr_ContentType) + HTTP.SetRequestHeader("Pragma", "no-cache") + HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store") + HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") + HTTP.Send(PostData) + HTTP.WaitForResponse() + ; msgbox % HTTP.ResponseText + return HTTP.ResponseText +} + + + + +;---------------------------/Discord Messages--------------------- + + + + + + + +; -------------------------------CreateFormData - Creates "multipart/form-data" for http post------------------------------- + +; Used for WinHttp.WinHttpRequest.5.1, Msxml2.XMLHTTP ... +CreateFormData(ByRef retData, ByRef retHeader, objParam) { + New CreateFormData(retData, retHeader, objParam) +} + +; Used for WinInet +CreateFormData_WinInet(ByRef retData, ByRef retHeader, objParam) { + New CreateFormData(safeArr, retHeader, objParam) + + size := safeArr.MaxIndex() + 1 + VarSetCapacity(retData, size, 1) + DllCall("oleaut32\SafeArrayAccessData", "ptr", ComObjValue(safeArr), "ptr*", pdata) + DllCall("RtlMoveMemory", "ptr", &retData, "ptr", pdata, "ptr", size) + DllCall("oleaut32\SafeArrayUnaccessData", "ptr", ComObjValue(safeArr)) +} + +Class CreateFormData { + + __New(ByRef retData, ByRef retHeader, objParam) { + + CRLF := "`r`n" + + Boundary := this.RandomBoundary() + BoundaryLine := "------------------------------" . Boundary + + ; Loop input paramters + binArrs := [] + For k, v in objParam + { + If IsObject(v) { + For i, FileName in v + { + str := BoundaryLine . CRLF + . "Content-Disposition: form-data; name=""" . k . """; filename=""" . FileName . """" . CRLF + . "Content-Type: " . this.MimeType(FileName) . CRLF . CRLF + binArrs.Push( BinArr_FromString(str) ) + binArrs.Push( BinArr_FromFile(FileName) ) + binArrs.Push( BinArr_FromString(CRLF) ) + } + } + Else { + str := BoundaryLine . CRLF + . "Content-Disposition: form-data; name=""" . k """" . CRLF . CRLF + . v . CRLF + binArrs.Push( BinArr_FromString(str) ) + } + } + + str := BoundaryLine . "--" . CRLF + binArrs.Push( BinArr_FromString(str) ) + + retData := BinArr_Join(binArrs*) + retHeader := "multipart/form-data; boundary=----------------------------" . Boundary + } + + RandomBoundary() { + str := "0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z" + Sort, str, D| Random + str := StrReplace(str, "|") + Return SubStr(str, 1, 12) + } + + MimeType(FileName) { + n := FileOpen(FileName, "r").ReadUInt() + Return (n = 0x474E5089) ? "image/png" + : (n = 0x38464947) ? "image/gif" + : (n&0xFFFF = 0x4D42 ) ? "image/bmp" + : (n&0xFFFF = 0xD8FF ) ? "image/jpeg" + : (n&0xFFFF = 0x4949 ) ? "image/tiff" + : (n&0xFFFF = 0x4D4D ) ? "image/tiff" + : "application/octet-stream" + } + +} +;############################################################################################################# +; Update: 2015-6-4 - Added BinArr_ToFile() + +BinArr_FromString(str) { + oADO := ComObjCreate("ADODB.Stream") + + oADO.Type := 2 ; adTypeText + oADO.Mode := 3 ; adModeReadWrite + oADO.Open + oADO.Charset := "UTF-8" + oADO.WriteText(str) + + oADO.Position := 0 + oADO.Type := 1 ; adTypeBinary + oADO.Position := 3 ; Skip UTF-8 BOM + return oADO.Read, oADO.Close +} + +BinArr_FromFile(FileName) { + oADO := ComObjCreate("ADODB.Stream") + + oADO.Type := 1 ; adTypeBinary + oADO.Open + oADO.LoadFromFile(FileName) + return oADO.Read, oADO.Close +} + +BinArr_Join(Arrays*) { + oADO := ComObjCreate("ADODB.Stream") + + oADO.Type := 1 ; adTypeBinary + oADO.Mode := 3 ; adModeReadWrite + oADO.Open + For i, arr in Arrays + oADO.Write(arr) + oADO.Position := 0 + return oADO.Read, oADO.Close +} + +BinArr_ToString(BinArr, Encoding := "UTF-8") { + oADO := ComObjCreate("ADODB.Stream") + + oADO.Type := 1 ; adTypeBinary + oADO.Mode := 3 ; adModeReadWrite + oADO.Open + oADO.Write(BinArr) + + oADO.Position := 0 + oADO.Type := 2 ; adTypeText + oADO.Charset := Encoding + return oADO.ReadText, oADO.Close +} + +BinArr_ToFile(BinArr, FileName) { + oADO := ComObjCreate("ADODB.Stream") + + oADO.Type := 1 ; adTypeBinary + oADO.Open + oADO.Write(BinArr) + oADO.SaveToFile(FileName, 2) + oADO.Close +} +; -------------------------------/CreateFormData - Creates "multipart/form-data" for http post------------------------------- + +; -------------------------------CheckDirExistAndCreate------------------------------- +; Check if directory exists and if not, create it +CheckDirExistAndCreate(Path){ + if(!FileExist(Path)){ + FileCreateDir, %Path% + } +} +; -------------------------------/CheckDirExistAndCreate------------------------------- + + + +CheckIfUpdateAvailable(Filepath, CurrentVersion){ + FileRead, ScriptUpdateContents, %Filepath% + FileContents := StrSplit(ScriptUpdateContents, "ScriptVersion") + FileContents := FileContents[2] + FileContents := StrSplit(FileContents, "`n") + UpdateVersion := FileContents[1] + ; msgbox % UpdateVersion + + if(!InStr(UpdateVersion, CurrentVersion)){ ; Update found for file, write to settings.ini for next time script is run + Message = Update Available to Download + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + Return True + } + Return False +} + + + +FindUpdateChangeLog(Filepath){ + FileRead, ScriptUpdateContents, %Filepath% + + ; Set Variables + ChangelogStart =;---Changelog------------------------------------------------------ + ChangelogEnd =;---/Changelog------------------------------------------------------ + + ; Msgbox % "ScriptUpdateContents: " ScriptUpdateContents + ChangeLog := StrSplit(ScriptUpdateContents, ChangelogStart) + ChangeLog := ChangeLog[2] + ChangeLog := StrSplit(ChangeLog, ChangelogEnd) + ChangeLog := ChangeLog[1] + Return Changelog +} + + + + + + +CheckSeleniumDriver(){ + try Driver := SChrome_Get("", ChromeProfile := "") ; open new tab page with with specified profile + catch e { + ShowSeleniumErrorMsgbox() + ; Message = Failed to Make Connection to Chrome. Check for Any Open Dialogue Boxes or out of date ChromeDriver + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + Return "Failed" + } + ; Driver := SChrome_Get("https://www.bitchute.com/", ChromeProfile) ; open new tab page with with specified profile + ; driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + catch e { + ShowSeleniumErrorMsgbox() + ; Message = Failed to send command to Chrome. Check for an Open Dialogue Box. + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + Return "Failed" + } + DriverStatus := 1 +} + +SeleniumConnectToActiveTab(IP_Port := "127.0.0.1:9222"){ + Driver := ComObjCreate("Selenium.ChromeDriver") + Driver.SetCapability("debuggerAddress", IP_Port) + try Driver.Start() + catch e { + ShowSeleniumErrorMsgbox() + ; msgbox, failed to connect to Chrome for some reason. + ; Message = Failed to Connect to Chrome for some reason. + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + } + return Driver +} + +CreateArrayOfTabs() { + Message = Creating an Array of All Chrome Tabs + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + DriverTitleArray := [] ; Create an array + DriverURLArray := [] + + try TotalTabsFound := Driver.Windows.Count + + ; if only 1 tab exists, grab info, push to array and exit early + if(TotalTabsFound = 1){ + try Title := Driver.Title + try URL := Driver.URL + + if(Title != "") + DriverTitleArray.Push(Title) + if(URL != "") + DriverURLArray.Push(URL) + return + } + + ; Msgbox % "TotalTabsFound: " TotalTabsFound + ; if(DevMode) + ; Msgbox % "TotalTabsFound: " TotalTabsFound + ; msgbox % "total Tabs:" Driver.Windows.Count + ; Message = Creating an Array of Chrome Tabs + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + ; StartTime := A_TickCount + ; Sleep, 1000 + StartTime := A_TickCount + + Loop, { + Message = Creating an Array of All Chrome Tabs`nCurrent Loop: %A_index%/%TotalTabsFound% (Cannot loop through unloaded tabs)`nSometimes might get stuck for a short while if there is something loading in active tab + TooltipThis(Message) + + ; SaveOrPostProgress(Message:=URL,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar") + ; if(ArrayContainsURL = 3 AND A_index > TotalTabsFound) + ; Break + + + TabEndTime := A_TickCount - TabFoundStartTime + TabEndTimeArray .= TabEndTime . "," + + + ; Message = Time to switch to new tab: %TabEndTime%`nCurrent Loop: %A_index%/%TotalTabsFound% + ; SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging") + + TabFoundStartTime := A_TickCount + + + IndexMinus3 := A_index - 3 + ; if(FirstURLPosition AND SecondURLPosition AND ThirdURLPosition AND IndexPlus3 > TotalTabsFound OR A_index = 30) { + if(IndexMinus3 > TotalTabsFound) { + ; DevModeMsgBox("First 3 tabs found. Breaking") + ; Msgbox % "A_index: " A_index "`n" "IndexPlus3: " IndexPlus3 + break + + } + + if(TotalTabsFound < 4 AND A_index = 4) + break + ; TimeToGrabCurrentTab := A_TickCount - StartTime + ; Msgbox % "TimeToGrabCurrentTab: " TimeToGrabCurrentTab + + ; Stop page refresh if it's happening + ; try driver.executeScript("return window.stop") + + try Title := Driver.Title + try URL := Driver.URL + + ; TimeToGrabCurrentTab := A_TickCount - StartTime + ; Msgbox % "TimeToGrabCurrentTab: " TimeToGrabCurrentTab + ; VAR := HasVal(DriverURLArray, STRINGVAR) ; returns position of value in array + if(HasVal(DriverURLArray, URL)) ; returns position of value in array + { + URLPositionInArray := HasVal(DriverURLArray, URL) + if(URLPositionInArray = 1){ + FirstURLPosition := 1 + } + if(URLPositionInArray = 2){ + SecondURLPosition := 1 + } + if(URLPositionInArray = 3){ + ThirdURLPosition := 1 + } + if(URLPositionInArray = 4){ + FourthURLPosition := 1 + } + ; Msgbox % "PositionInArray: " PositionInArray + ; ArrayContainsURL += 1 + } + ; TimeToCheckArray := A_TickCount - StartTime + + ; Msgbox % "ArrayContainsURL: " ArrayContainsURL + + if(Title != "") + DriverTitleArray.Push(Title) + if(URL != "") + DriverURLArray.Push(URL) + +/* +if(TotalTabsFound = 1){ + TimeToKickOut := A_TickCount - StartTime + + ; Msgbox % "TimeToGrabCurrentTab: " TimeToGrabCurrentTab + ; Msgbox % "TimeToCheckArray: " TimeToCheckArray + ; Msgbox % "TimeToKickOut: " TimeToKickOut + ; MsgBox, %ElapsedTime% milliseconds have elapsed. + ; Msgbox % "A_index: " A_index + ; DevModeMsgBox("breaking early on loop 1?") + break + } ; if there is only 1 tab, then break out of loop and don't bother looping through same tab + + */ + try driver.SwitchToNextWindow ;Focuses Selenium on the newly opened/next window. + } ; end of loop + + ; Iterate from 1 to the end of the array: + Loop % DriverURLArray.Length() + { + ARRAYNAMEList .= DriverURLArray[A_Index] . "`n" + ; ArrayItem := DriverURLArray[A_Index] + ; MsgBox % DriverURLArray[A_Index] + + } + ; Msgbox % "ARRAYNAMEList: " ARRAYNAMEList + + TimeToLoopThroughAllTabs := A_TickCount - StartTime + Message = Time to Loop through all tabs: %TimeToLoopThroughAllTabs% + SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging") + ; DevModeMsgBox(Message) + return + } ; /FUNC + + InputFilePathIntoOpenWindow(Filepath){ + ; Msgbox % "Filepath: " Filepath + Message = Waiting for "Open" window to appear to input filepath into + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + ; Tooltip,Waiting for "Open" window to appear to input filepath into,850,0 + ; WinWait, Open + WinWait,Open,,5 ; Wait for 10 seconds for window + if(ErrorLevel) + { + ; msgbox, failed to find window. + Return "Failed" + } + WinActivate, Open + sleep, 1000 + ControlSetText, Edit1, %Filepath%, Open + sleep, 1000 + ControlSend, Edit1, {Enter}, Open + sleep, 1000 + + ; Do an extra check in case the Open window is still open. + OpenWindowExist := WinExist("Open") + if(OpenWindowExist) + ControlSend, Edit1, {Enter}, Open + ToolTip, + } + + ; -------------------------------NavigateFromBaseURLTo------------------------------- + NavigateFromBaseURLTo(URL,PageTitle := "New Tab"){ + if(!DriverStatus){ ; if not connected to selenium chrome, then re-connect + Status := CheckSeleniumDriver() + if(Status) + Return "Failed" + + CreateArrayOfTabs() + } + + + if(ReuseTabs){ + URLBase := StrReplace(URL,"https://","") + URLBase := StrSplit(URLBase, "/") + URLBase := URLBase[1] + URLBase := StrReplace(URLBase, "www.","") + } + + if(!HasSubstringVal(DriverURLArray, URLBase)) ; returns position of value in array + { + try, run "%ChromeFilepath%" "%URL%" + DriverURLArray.Push(URL) ; Append an item to the array + NewTabCreated := 1 + sleep, 1000 + } + ; msgbox, + + Message = Finding Tab + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + TabFoundSuccessfully := + + NumberOfTabLoops := DriverURLArray.Length() + + ; NumberOfTabLoops := Driver.Windows.Count + 2 + loop % NumberOfTabLoops { ; loop through tabs to find matching tab + try driver.SwitchToNextWindow() + + ; sleep, 1000 + ; msgbox, looping through tabs + try CurrentTabTitle := driver.window.title + try CurrentTabURL := driver.Url + + if(CurrentTabTitle = PageTitle OR InStr(CurrentTabURL, URLBase)){ + ; msgbox, found it.`n%CurrentTabTitle% = %PageTitle%`n%CurrentTabURL% = %URLBase% + TabFoundSuccessfully := 1 + ; msgbox %CurrentTabTitle% = %PageTitle% + ; msgbox %CurrentTabURL% = %URL% + Break + } + } + + if(!NewTabCreated){ ; if re-using a tab then we want to re-navigate to URL because it might be the wrong page + try driver.Get(URL) ;Open selected URL + try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + catch e { + ; msgbox, error caught. trying something + try driver.switchToalert().accept() + try driver.Get(URL) ;Open selected URL + catch e { + Message = Failed to Navigate to %URL%: Please Check for Any Open Dialogue Boxes + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return "Failed" + } + } + } + ; msgbox, no error caught + ; } + + + Return + } + ; End of Function + ; -------------------------------/NavigateFromBaseURL------------------------------- + + SaveDriverURL(){ ; save the url of the result page. That way if a tab is not found for a site, we can open up a tab from this tab instead of middle of nowhere. That way we can keep the tabs together + try LastWebsitePostURL := driver.URL + } + + + ; -------------------------------SChrome_Get------------------------------- + SChrome_Get(URL := "", Profile := "Profile 1", IP_Port := "127.0.0.1:9222"){ + IP_Port_Nr := RegExReplace(IP_Port, ".*:(\d*)", "$1") + if WinExist("ahk_exe Chrome.exe"){ + WinGet, pid, PID, ahk_exe chrome.exe + for item in ComObjGet("winmgmts:").ExecQuery("SELECT * FROM Win32_Process WHERE ProcessId='" pid "'"){ + if RegExMatch(item.CommandLine, "i)--remote-debugging-port=\K\d+", port){ + break + } + } + + if (Port=""){ + MsgBox, 36, ,Chrome Needs to be started in debugging mode in order for Autohotkey to connect to it.`nIs it ok to restart Chrome in debugmode to enable a connection? + IfMsgBox, Yes + { + Message = Restarting Chrome in Debug Mode + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + While(WinExist("ahk_exe chrome.exe")) { + WinClose, ahk_exe chrome.exe + } + Process, WaitClose, chrome.exe + } + Else{ + Msgbox, 4096, Error, Cannot connect to Chrome profile if it is Not running in debug mode. Script Terminating + ExitApp + ; @todo: Make this error out to the script result screen + } + } + } + + ; ; yuriy's settings + ; IniRead, ChromeFilepath, C:\Users\%A_username%\Documents\Autohotkey\Lib\ScriptSettings.ini, Selenium, %A_Computername%, %A_Space% + + ; ; Establish Variable with Filepath to be used throughout the script + ; if(ChromeFilepath = ""){ + if(FileExist("C:\Program Files\Google\Chrome\Application\chrome.exe")){ + ChromeFilepath = C:\Program Files\Google\Chrome\Application\chrome.exe + } + else if (FileExist("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe")){ + ChromeFilepath = C:\Program Files (x86)\Google\Chrome\Application\chrome.exe + } + + + if(ChromeFilepath = ""){ + Message = Failed to find chrome.exe in the usual locations. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + MsgBox 0x30, Error!, Unable to find Chrome.exe in the usual locations. `nScript Exiting. + ExitApp + } + + if(!winExist("ahk_exe chrome.exe")){ + message = %ChromeFilepath% --remote-debugging-port=%IP_Port_Nr% %URL% + Clipboard := Message + DevModeMsgBox(message) + run, %ChromeFilepath% --remote-debugging-port=%IP_Port_Nr% %URL% + } + + Driver := ComObjCreate("Selenium.ChromeDriver") + Driver.SetCapability("debuggerAddress", IP_Port) + try Driver.Start() + catch e { + + ShowSeleniumErrorMsgbox() + + } ; end of catch + + ; Save current chrome version to ini file + return Driver + } + ; -------------------------------/SChrome_Get------------------------------- + + ShowSeleniumErrorMsgbox(){ + GetChromeVersionCommand = powershell (Get-Item '%ChromeFilepath%').VersionInfo.ProductVersion + Chromeversion := RunCMD(GetChromeVersionCommand) + ChromeVersion := StrReplace(ChromeVersion, "`n", "") + + ; Clipboard := ChromeVersion + ; Msgbox % "Chromeversion: " Chromeversion + IniRead, PreviousWorkingChromeVersion, Settings.ini, Misc, ChromeVersion, %A_Space% + ; IniWrite, %ChromeVersion%, Settings.ini, Misc, ChromeVersion + ; msgbox, failed to connect to Chrome for some reason. + ; Message = Failed to Connect to Chrome. Most likely problem is either Chrome has some sort of dialogue box open or ChromeDriver needs to be updated. + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + + OnMessage(0x44, "OnMsgBoxChromeDriverFailed") + MsgBox 0x40043, Error, Failed to Connect to Chrome. `nMost likely issue is either Chrome has some sort of dialogue box open or ChromeDriver needs to be updated.`n`nClick "Reload" to reload the script to try again`nClick "ChromeDriver" to open up the ChromeDriver download page. `n`nClick "Instructions" to open up .pdf file with instructions for updating chromedriver.exe`n`nPossibly Helpful Info:`nCurrent Chrome Version: %Chromeversion%Chrome Version of Last Successfull Upload: %PreviousWorkingChromeVersion% + OnMessage(0x44, "") + + IfMsgBox Yes, { + ; Reload script + Reload + } Else IfMsgBox No, { + run, https://chromedriver.chromium.org/downloads + ExitApp + ; open chromedriver site + } Else IfMsgBox Cancel, { + URL = https://freedomainplaylists.com/wp-content/FreedomainScripts/Update`%20Selenium`%20ChromeDriver.pdf + Filepath = %A_ScriptDir%\Lib\Update Selenium ChromeDriver.pdf + if(!FileExist(Filepath)){ + UrlDownloadToFile, %URL%, %Filepath% + + run, %Filepath% + } + ExitApp + + } + } + + + ; -------------------------------HasVal------------------------------- + ; Function needed for finding a value in an array + HasVal(haystack, needle) + { + if !(IsObject(haystack)) || (haystack.Length() = 0) + return 0 + for index, value in haystack + if (value = needle) + return index + return 0 + } + ; -------------------------------/HasVal------------------------------- + + HasSubstringVal(haystack, needle) + { + if !(IsObject(haystack)) || (haystack.Length() = 0) + return 0 + for index, value in haystack + if (InStr(value, Needle)) + return index + return 0 + } + + ; SubStr(String, StartingPos [, Length]) + + ; InStr(value, Needle) + + + + + + + ; -------------------------------FileXPro Get File Attributes------------------------------- + ;https://www.autohotkey.com/boards/viewtopic.php?t=59882 + + Filexpro( sFile := "", Kind := "", P* ) { ; v.90 By SKAN on D1CC @ goo.gl/jyXFo9 + Local + Static xDetails + + If ( sFile = "" ) + { ; Deinit static variable + xDetails := "" + Return + } + + fex := {}, _FileExt := "" + + Loop, Files, % RTrim(sfile,"\*/."), DF + { + If not FileExist( sFile:=A_LoopFileLongPath ) + { + Return + } + + SplitPath, sFile, _FileExt, _Dir, _Ext, _File, _Drv + + If ( p[p.length()] = "xInfo" ) ; Last parameter is xInfo + { + p.Pop() ; Delete parameter + fex.SetCapacity(11) ; Make room for Extra info + fex["_Attrib"] := A_LoopFileAttrib + fex["_Dir"] := _Dir + fex["_Drv"] := _Drv + fex["_Ext"] := _Ext + fex["_File"] := _File + fex["_File.Ext"] := _FileExt + fex["_FilePath"] := sFile + fex["_FileSize"] := A_LoopFileSize + fex["_FileTimeA"] := A_LoopFileTimeAccessed + fex["_FileTimeC"] := A_LoopFileTimeCreated + fex["_FileTimeM"] := A_LoopFileTimeModified + } + Break + } + + If Not ( _FileExt ) ; Filepath not resolved + { + Return + } + + + objShl := ComObjCreate("Shell.Application") + objDir := objShl.NameSpace(_Dir) + objItm := objDir.ParseName(_FileExt) + + If ( VarSetCapacity(xDetails) = 0 ) ; Init static variable + { + i:=-1, xDetails:={}, xDetails.SetCapacity(309) + + While ( i++ < 309 ) + { + xDetails[ objDir.GetDetailsOf(0,i) ] := i + } + + xDetails.Delete("") + } + + If ( Kind and Kind <> objDir.GetDetailsOf(objItm,11) ) ; File isn't desired kind + { + Return + } + + i:=0, nParams:=p.Count(), fex.SetCapacity(nParams + 11) + + While ( i++ < nParams ) + { + Prop := p[i] + + If ( (Dot:=InStr(Prop,".")) and (Prop:=(Dot=1 ? "System":"") . Prop) ) + { + fex[Prop] := objItm.ExtendedProperty(Prop) + Continue + } + + If ( PropNum := xDetails[Prop] ) > -1 + { + fex[Prop] := ObjDir.GetDetailsOf(objItm,PropNum) + Continue + } + } + + fex.SetCapacity(-1) + Return fex + + } ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + ; GuiButtonIcon + ;------------------------------------------------ + GuiButtonIcon(Handle, File, Index := 1, Options := "") + { + RegExMatch(Options, "i)w\K\d+", W), (W="") ? W := 16 : + RegExMatch(Options, "i)h\K\d+", H), (H="") ? H := 16 : + RegExMatch(Options, "i)s\K\d+", S), S ? W := H := S : + RegExMatch(Options, "i)l\K\d+", L), (L="") ? L := 0 : + RegExMatch(Options, "i)t\K\d+", T), (T="") ? T := 0 : + RegExMatch(Options, "i)r\K\d+", R), (R="") ? R := 0 : + RegExMatch(Options, "i)b\K\d+", B), (B="") ? B := 0 : + RegExMatch(Options, "i)a\K\d+", A), (A="") ? A := 4 : + Psz := A_PtrSize = "" ? 4 : A_PtrSize, DW := "UInt", Ptr := A_PtrSize = "" ? DW : "Ptr" + VarSetCapacity( button_il, 20 + Psz, 0 ) + NumPut( normal_il := DllCall( "ImageList_Create", DW, W, DW, H, DW, 0x21, DW, 1, DW, 1 ), button_il, 0, Ptr ) ; Width & Height + NumPut( L, button_il, 0 + Psz, DW ) ; Left Margin + NumPut( T, button_il, 4 + Psz, DW ) ; Top Margin + NumPut( R, button_il, 8 + Psz, DW ) ; Right Margin + NumPut( B, button_il, 12 + Psz, DW ) ; Bottom Margin + NumPut( A, button_il, 16 + Psz, DW ) ; Alignment + SendMessage, BCM_SETIMAGELIST := 5634, 0, &button_il,, AHK_ID %Handle% + return IL_Add( normal_il, File, Index ) + } + + ; \GuiButtonIcon + ;------------------------------------------------ + + + ToggleTestingMode(){ + + IniRead, TestingMode, Settings.ini, General, TestingMode, 0 + ; Msgbox % "TestingMode: " TestingMode + if(TestingMode) + IniWrite, 0, Settings.ini, General, TestingMode + else, + IniWrite, 1, Settings.ini, General, TestingMode + } + + ToggleManualSubmit(){ + + IniRead, ManualSubmit, Settings.ini, General, ManualSubmit, 0 + ; Msgbox % "TestingMode: " TestingMode + if(ManualSubmit) + IniWrite, 0, Settings.ini, General, ManualSubmit + else, + IniWrite, 1, Settings.ini, General, ManualSubmit + } + + + ToggleDevMode(){ + + IniRead, DevMode, Settings.ini, General, DevMode, 0 + ; Msgbox % "TestingMode: " TestingMode + if(DevMode) + IniWrite, 0, Settings.ini, General, DevMode + else, + IniWrite, 1, Settings.ini, General, DevMode + } + + + FormatTextToJSText(Var){ ; Replaces AHK newline characters with javascript ones +/*\b Backspace +\f Form Feed +\n New Line - done +\r Carriage Return +\t Horizontal Tabulator +\v Vertical Tabulator +\' Single quote - done +\" Double quote - done +\\ Backslash - done +*/ + +SingleQuotationmark = " +; Variable of Escaped Symbols +EscapedSingleQuote = \' +EscapedDoubleQuote = \" +EscapedBackslash = \\ +EscapedNewLine = \n + +; Replace each character that needs replacing in the text string +Var := StrReplace(Var, "\", EscapedBackslash) ; needed otherwise selenium will error out +Var := StrReplace(Var, "`n", EscapedNewLine) ; needed otherwise selenium will error out +Var := StrReplace(Var, "`r", "") ; needed otherwise selenium will error out +Var := StrReplace(Var, SingleQuotationmark, EscapedDoubleQuote) ; needed otherwise selenium will error out +Var := StrReplace(Var, "'", EscapedSingleQuote) ; needed otherwise selenium will error out +; Var := StrReplace(Var, "`r", "") ; needed otherwise selenium will error out +Return Var +} + + + +; OnMsgbox Functions +;------------------------------------------------ +OnMsgBoxUpdateAvailable() { + DetectHiddenWindows, On + Process, Exist + If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) { + ControlSetText Button1, Cancel + ControlSetText Button2, Install + } +} + + +OnMsgBoxChromeDriverFailed() { + DetectHiddenWindows, On + Process, Exist + If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) { + WinMove,, 0 + ControlSetText Button1, Reload Script + ControlSetText Button2, ChromeDriver + ControlSetText Button3, Instructions + } +} + + +SaveCurrentChromeVersionToIniFile(){ + + ; Msgbox % "ChromeFilepath: " ChromeFilepath + GetChromeVersionCommand = powershell (Get-Item '%ChromeFilepath%').VersionInfo.ProductVersion + Chromeversion := RunCMD(GetChromeVersionCommand) + if(InStr(ChromeVersion, "scripts is disabled on this system")){ + ChromeVersion = Not Able to Grab Because: "scripts are disabled in powershell" + } + ; Msgbox % "Chromeversion: " Chromeversion + + ; Msgbox % "Chromeversion: " Chromeversion + + + if(ChromeFilepath = "") + return + + ; Chromeversion := StrSplit(Chromeversion, "`n") + ; Chromeversion := Chromeversion[4] + IniWrite, %ChromeVersion%, Settings.ini, Misc, ChromeVersion +} + + +SaveDriverURLOFErrorPage(){ ; save the url of the result page. That way if a tab is not found for a site, we can open up a tab from this tab instead of middle of nowhere. That way we can keep the tabs together + try URLOfLastErrorPage := driver.URL +} + + + +FindAndActivateTab(TabURL){ + + Loop, { + if(A_index = 30) + break + + try CurrentTabTitle := driver.window.title + try CurrentTabURL := driver.Url + + if(CurrentTabURL = TabURL) + Break + + try driver.SwitchToNextWindow() + + } + +} diff --git a/Lib/StdOutToVar.ahk b/Lib/StdOutToVar.ahk new file mode 100644 index 0000000..5525d35 --- /dev/null +++ b/Lib/StdOutToVar.ahk @@ -0,0 +1,56 @@ +; Edited by Masonjar13 to be compatible with 32 and 64-bit (2015) + +;msgbox % StdOutToVar("ipconfig") + +StdOutToVar( sCmd ) { ; GAHK32 ; Modified Version : SKAN 05-Jul-2013 http://goo.gl/j8XJXY + ; msgbox, getting stdout + Static StrGet := "StrGet" ; Original Author : Sean 20-Feb-2007 http://goo.gl/mxCdn + + DllCall( "CreatePipe", UIntP,hPipeRead, UIntP,hPipeWrite, UInt,0, UInt,0 ) + DllCall( "SetHandleInformation", UInt,hPipeWrite, UInt,1, UInt,1 ) + + if(a_ptrSize=8){ + VarSetCapacity( STARTUPINFO, 104, 0 ) ; STARTUPINFO ; http://goo.gl/fZf24 + NumPut( 104, STARTUPINFO, 0 ) ; cbSize + NumPut( 0x100, STARTUPINFO, 60 ) ; dwFlags => STARTF_USESTDHANDLES = 0x100 + NumPut( hPipeWrite, STARTUPINFO, 88 ) ; hStdOutput + NumPut( hPipeWrite, STARTUPINFO, 96 ) ; hStdError + VarSetCapacity( PROCESS_INFORMATION, 32 ) ; PROCESS_INFORMATION ; http://goo.gl/b9BaI + }else{ + VarSetCapacity( STARTUPINFO, 68, 0 ) ; STARTUPINFO ; http://goo.gl/fZf24 + NumPut( 68, STARTUPINFO, 0 ) ; cbSize + NumPut( 0x100, STARTUPINFO, 44 ) ; dwFlags => STARTF_USESTDHANDLES = 0x100 + NumPut( hPipeWrite, STARTUPINFO, 60 ) ; hStdOutput + NumPut( hPipeWrite, STARTUPINFO, 64 ) ; hStdError + VarSetCapacity( PROCESS_INFORMATION, 16 ) ; PROCESS_INFORMATION ; http://goo.gl/b9BaI + } + If ! DllCall( "CreateProcess", UInt,0, UInt,&sCmd, UInt,0, UInt,0 ; http://goo.gl/USC5a + , UInt,1, UInt,0x08000000, UInt,0, UInt,0 + , UInt,&STARTUPINFO, UInt,&PROCESS_INFORMATION ) + Return "" + , DllCall( "CloseHandle", UInt,hPipeWrite ) + , DllCall( "CloseHandle", UInt,hPipeRead ) + , DllCall( "SetLastError", Int,-1 ) + + hProcess := NumGet( PROCESS_INFORMATION, 0 ) + if(a_is64bitOS) + hThread := NumGet( PROCESS_INFORMATION, 8 ) + else + hThread := NumGet( PROCESS_INFORMATION, 4 ) + + DllCall( "CloseHandle", UInt,hPipeWrite ) + + AIC := ( SubStr( A_AhkVersion, 1, 3 ) = "1.0" ) ; A_IsClassic + VarSetCapacity( Buffer, 4096, 0 ), nSz := 0 + + While DllCall( "ReadFile", UInt,hPipeRead, UInt,&Buffer, UInt,4094, UIntP,nSz, UInt,0 ) + sOutput .= ( AIC && NumPut( 0, Buffer, nSz, "UChar" ) && VarSetCapacity( Buffer,-1 ) ) + ? Buffer : %StrGet%( &Buffer, nSz, "CP850" ) + + DllCall( "GetExitCodeProcess", UInt,hProcess, UIntP,ExitCode ) + DllCall( "CloseHandle", UInt,hProcess ) + DllCall( "CloseHandle", UInt,hThread ) + DllCall( "CloseHandle", UInt,hPipeRead ) + +Return sOutput, DllCall( "SetLastError", UInt,ExitCode ) +} diff --git a/README.md b/README.md index 65f20b3..fc6c02a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ -# Freedomain_Social_Media_Poster +# Freedomain Social Media Poster -Social Media Poster customized for the Freedomain Philosophy Show \ No newline at end of file +Social Media Poster created for the [Freedomain Philosophy Show](https://freedomain.com/) + + + +## Todo +- Convert .docx files to markdown + - Add note about pinning tool to taskbar +- Add Chromedriver auto updater functionality diff --git a/Tools/Auto Update Selenium Chromedriver.ahk b/Tools/Auto Update Selenium Chromedriver.ahk new file mode 100644 index 0000000..1f27641 --- /dev/null +++ b/Tools/Auto Update Selenium Chromedriver.ahk @@ -0,0 +1,174 @@ +; ENVIRONMENT +;------------------------------------------------ +#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. +;#Warn ; Enable warnings to assist with detecting common errors. +;DetectHiddenWindows, On +#SingleInstance, Force +SendMode Input ; Recommended for new scripts due to its superior speed and reliability. +SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. +;SetKeyDelay, 500 +CoordMode, ToolTip, Screen +CoordMode, Mouse, Screen +;#NoTrayIcon +;Menu, Tray, Icon, ..\Icons\ICONNAMEHERE + +; Notes/Extra Info/#Includes +;------------------------------------------------ +; https://old.reddit.com/r/PowerShell/comments/nksoh1/keeping_selenium_chromedriver_uptodate/ + + +; VARIABLES +;------------------------------------------------ + + + +; MAIN SCRIPT +;------------------------------------------------ +#Include C:\Users\%A_UserName%\Documents\Autohotkey\Lib\RunCMD.ahk +#include C:\Users\%A_username%\Documents\Autohotkey\Lib\URLDownloadToVar.ahk + + + +; MAIN SCRIPT +;------------------------------------------------ +; MsgBox A_IsAdmin: %A_IsAdmin%`nCommand line: %full_command_line% + + +; run as admin +full_command_line := DllCall("GetCommandLine", "str") +; Msgbox % "full_command_line: " full_command_line +if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)")) +{ + try + { + if A_IsCompiled + Run *RunAs "%A_ScriptFullPath%" /restart + else + Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%" + } + ; ExitApp +} + + +if(!A_IsAdmin){ + MsgBox 0x40040, Information, Failed to get Administrator Authentication which is only needed for copying the chromedriver.exe file into /Program Files/SeleniumBasic. `n`nPress OK to continue and to just download the chromedriver.exe file to the current folder. `n(You will have to move it manually into /Program Files/Selenium Basic) +} + + +ToolTip, Downloading Chromedriver for your installed chrome version, 850, 0 + +; ChromeFilepath = C:\Program Files\Chromium\Application\chrome.exe + +IniRead, ChromeFilepath, C:\Users\%A_username%\Documents\Autohotkey\Lib\ScriptSettings.ini, Selenium, %A_Computername%, %A_Space% +; Msgbox % "ChromeFilepath: " ChromeFilepath + +if(ChromeFilepath = ""){ + if(FileExist("C:\Program Files\Google\Chrome\Application\chrome.exe")){ + ChromeFilepath = C:\Program Files\Google\Chrome\Application\chrome.exe + } + else if (FileExist("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe")){ + ChromeFilepath = C:\Program Files (x86)\Google\Chrome\Application\chrome.exe + } + else, { + IniRead, ChromeFilepath, C:\Users\%A_username%\Documents\Autohotkey\Lib\ScriptSettings.ini, Selenium, %A_Computername%, "Filepath not found" + if(!FileExist(ChromeFilepath)){ + msgbox, Chrome.exe not found. Exiting + ExitApp + } + } +} +; Msgbox % "ChromeFilepath: " ChromeFilepath + + + /* IniRead, ChromeFilepath, C:\Users\%A_username%\Documents\Autohotkey\Lib\ScriptSettings.ini, Selenium, %A_Computername%, "Filepath not found" + if(!FileExist(ChromeFilepath)){ + msgbox, Chrome.exe not found. Exiting + ExitApp + } + + */ + ; ChromeFilepath = C:\Users\%A_username%\Downloads\chromedriver.exe + + ; VARIABLES + ;------------------------------------------------ + ChromeDriverZipSavePath = C:\Users\%A_username%\Downloads\chromedriver.zip + ChromeDriverExeExtractParentFolderPath = C:\Users\%A_username%\Downloads\ + ChromeDriverExeExtractedFilepath = %ChromeDriverExeExtractParentFolderPath%chromedriver.exe + ChromeDriverFinalDestination = C:\Program Files\SeleniumBasic\chromedriver.exe + ; Msgbox % "ChromeFilepath: " ChromeFilepath + + ; Check Chrome Version + ; ChromeFilepath = C:\Program Files\Chromium\Application\chrome.exe + Command = powershell (Get-Item '%ChromeFilepath%').VersionInfo.ProductVersion + ; Command := "powershell (Get-Item 'C:\Program Files\Chromium\Application\chrome.exe').VersionInfo | Select-Object ProductVersion" + + Chromeversion := RunCMD(Command) + Chromeversion := SubStr(Chromeversion, 1, 2) + ; Msgbox % "Chromeversion: " Chromeversion + + ; Chromeversion := + + if(Chromeversion = ""){ + MsgBox 0x40040, Information, Failed to grab chrome version.`n`nMost Likely reason is that the chrome filepath is incorrect: `nGiven Chrome Filepath:`n%ChromeFilepath% + ExitApp + } + + ; Msgbox % "Chromeversion: " Chromeversion + + ; Query what the latest release chromedriver for the current chrome version is + URL = https://chromedriver.storage.googleapis.com/LATEST_RELEASE_%Chromeversion% + URLContents := URLDownloadToVar(URL) + + ; Msgbox % "URLContents: " URLContents + + ; Chromedriver is always saved in the following format: + url = https://chromedriver.storage.googleapis.com/%URLContents%/chromedriver_win32.zip + + ; Donwload chromedriver + UrlDownloadToFile, %url%, %ChromeDriverZipSavePath% + + ChromeDriverZipSavePath = '%ChromeDriverZipSavePath%' + ChromeDriverExeExtractPath = '%ChromeDriverExeExtractPath%' + + + ; Extract the downloaded zip file using powershell + Command = powershell Expand-Archive -LiteralPath %ChromeDriverZipSavePath% -DestinationPath %ChromeDriverExeExtractParentFolderPath% -Force + ; Clipboard := Command + ; Msgbox % "Command: " Command + ; Command := "powershell (Get-Item 'C:\Program Files\Chromium\Application\chrome.exe').VersionInfo.ProductVersion" + ; Command := "powershell (Get-Item 'C:\Program Files\Chromium\Application\chrome.exe').VersionInfo | Select-Object ProductVersion" + + PowerShellReturn := RunCMD(Command) + Msgbox % "PowerShellReturn: " PowerShellReturn + + if(!FileExist(ChromeDriverExeExtractedFilepath)){ + Msgbox, Extracting failed for some reason. `nYou can find the downloaded .zip file in %ChromeDriverZipSavePath%`n`nClick OK to Exit + ExitApp + } + + if(!A_IsAdmin){ + Msgbox, Chromedriver was successfully downloaded to:`n %ChromeDriverExeExtractedFilepath%. `n`nPlease copy it over manually to:`n %ChromeDriverFinalDestination%`n`nClick OK to Exit + ExitApp + } + + ; If run as admin, copy over to Program FIles + if(A_IsAdmin){ + FileMove, %ChromeDriverExeExtractedFilepath%, %ChromeDriverFinalDestination%, 1 + if(ErrorLevel){ + msgbox, Failed to move chromedriver.exe to /Program Files/SeleniumBasic. `n`nMost Likely reason is that ChromeDriver is currently running in the background because of a recently run script. `nPlease Copy it over manually`n`nClick OK to exit. + ExitApp + } + } + + msgbox, Chromedriver.exe successfully copied to: `n%ChromeDriverFinalDestination% `n`nClick OK to Exit. + + + ExitApp + + + + + + + ; Functions +;------------------------------------------------ \ No newline at end of file diff --git a/Tools/Auto Update Selenium Chromedriver.exe b/Tools/Auto Update Selenium Chromedriver.exe new file mode 100644 index 0000000..383ce47 Binary files /dev/null and b/Tools/Auto Update Selenium Chromedriver.exe differ diff --git a/Tools/Compile Scripts to EXE.ahk b/Tools/Compile Scripts to EXE.ahk new file mode 100644 index 0000000..5995e86 --- /dev/null +++ b/Tools/Compile Scripts to EXE.ahk @@ -0,0 +1,92 @@ +;---ENVIRONMENT--------------------------------------------------------------------- +#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. +;#Warn ; Enable warnings to assist with detecting common errors. +;DetectHiddenWindows, On +#SingleInstance, Force +DetectHiddenWindows, ON +SendMode Input ; Recommended for new scripts due to its superior speed and reliability. +SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. +;SetKeyDelay, 500 +CoordMode, ToolTip, Screen +CoordMode, Mouse, Screen +; #NoTrayIcon +; Menu, Tray, Icon, RMScriptManager.ico + +;---Notes/Extra Info/#Includes------------------------------------------------------ + +; msgbox +;---VARIABLES----------------------------------------------------------------------- +/*ScriptToCompile = %1% +CompileType = %2% ; Testing OR Production +if(CompileType = "") +CompileType = Testing +; Msgbox % "CompileType: " CompileType +if(ScriptToCompile = "") +ExitApp + + +*/ + +; Msgbox % "ScriptToCompile: " ScriptToCompile +ScriptToCompile = SocialMediaPoster +; ScriptToCompile = ScriptUpdater +;---MAIN SCRIPT--------------------------------------------------------------------- +if(ScriptToCompile = "SocialMediaPoster"){ + AHKFilepath = %A_ScriptDir%\..\Freedomain Social Media Poster.ahk + Exefilepath = %A_ScriptDir%\..\Freedomain Social Media Poster.exe + icopath = %A_ScriptDir%\..\Assets\FreedomainSMP.ico +} + +if(ScriptToCompile = "ScriptUpdater"){ + AHKFilepath = %A_ScriptDir%\..\Tools\Freedomain Program Updater.ahk + Exefilepath = %A_ScriptDir%\..\Tools\Freedomain Program Updater.exe + icopath = %A_ScriptDir%\..\Assets\Update.ico +} + +; Kill any active intances of the uploaders so the .exe files can be overwriten by the compilation +run, %A_ScriptDir%\Kill Open Freedomain Programs.ahk + +sleep, 500 + +; Delete the .exe file so it can be repalced +if(FileExist(Exefilepath)){ + FileDelete, %Exefilepath% + if(ErrorLevel){ + msgbox, failed to delete Exe file. Please delete manually and re-run the compiler. + ExitApp + } +} + + +if(!FileExist(AHKFilepath)){ + msgbox, %AHKFilepath% does not exist`nExiting + ExitApp +} + + +if(!FileExist(icopath)){ + msgbox, %icopath% does not exist`nExiting + ExitApp +} + + +run, %comspec% /K ""C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe" /in "%AHKFilepath%" /out "%exefilepath%" /icon "%icopath%"" + + +; OldNotify(ScriptToCompile,"Compiled Successfully",5) +; sleep, 5000 +ExitApp + + + + + + + + + + + + + +;---FUNCTIONS----------------------------------------------------------------------- diff --git a/Tools/ConnecToActiveChromeTab.ahk b/Tools/ConnecToActiveChromeTab.ahk new file mode 100644 index 0000000..8e7d786 --- /dev/null +++ b/Tools/ConnecToActiveChromeTab.ahk @@ -0,0 +1,119 @@ +;---ENVIRONMENT--------------------------------------------------------------------- +#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. +#SingleInstance, Force +SendMode Input ; Recommended for new scripts due to its superior speed and reliability. +SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. +CoordMode, ToolTip, Screen +CoordMode, Mouse, Screen +FileEncoding, UTF-8-RAW ; Needed for special symbols that are used in video descritions +#Include %A_ScriptDir%\..\Lib\SharedFunctions.ahk +#Include %A_ScriptDir%\..\Lib\Json.ahk +; #Include %A_scriptdir%\RunCMD.ahk +;---VARIABLES----------------------------------------------------------------------- +global driver +; JSVideoDescription = hey there how goes it +WinActivate, ahk_class Chrome_WidgetWin_1 +WinGetTitle, Chrome_Window_Title, A +Chrome_Window_Title := StrSplit(Chrome_Window_Title, " - Google Chrome") +Chrome_Window_Title := Chrome_Window_Title[1] +Driver := ConnectToChrome("", ConnectActiveTab := 1, ActiveTabTitle := Chrome_Window_Title) ; open new tab page with with specified profile + + +;---MAIN SCRIPT--------------------------------------------------------------------- +js = return document.querySelector(".header__contain").innerText +try status := driver.executeScript(js) + +ExitApp + + + + + + +ConnectToChrome(URL := "", ConnectActiveTab := 0, WinGetActiveChromeTabTitle := ""){ + ; Msgbox % "WinGetActiveChromeTabTitle: " WinGetActiveChromeTabTitle + IP_Port := "127.0.0.1:9222" + IP_Port_Nr := RegExReplace(IP_Port, ".*:(\d*)", "$1") + if WinExist("ahk_exe Chrome.exe"){ + WinGet, pid, PID, ahk_exe chrome.exe + for item in ComObjGet("winmgmts:").ExecQuery("SELECT * FROM Win32_Process WHERE ProcessId='" pid "'"){ + if RegExMatch(item.CommandLine, "i)--remote-debugging-port=\K\d+", port){ + break + } + } + + if (Port=""){ + MsgBox, 36, ,Chrome Needs to be started in debugging mode in order for Autohotkey to connect to it.`nIs it ok to restart Chrome in debugmode to enable a connection? + IfMsgBox, Yes + { + Message = Restarting Chrome in Debug Mode + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + While(WinExist("ahk_exe chrome.exe")) { + WinClose, ahk_exe chrome.exe + } + Process, WaitClose, chrome.exe + } + Else{ + Msgbox, 4096, Error, Cannot connect to Chrome profile if it is Not running in debug mode. Script Terminating + ExitApp + ; @todo: Make this error out to the script result screen + } + } + } + + ; yuriy's settings + ; IniRead, ChromeFilepath, C:\Users\%A_username%\Documents\Autohotkey\Lib\ScriptSettings.ini, Selenium, %A_Computername%, %A_Space% + + ; Establish Variable with Filepath to be used throughout the script + if(ChromeFilepath = ""){ + if(FileExist("C:\Program Files\Google\Chrome\Application\chrome.exe")){ + ChromeFilepath = C:\Program Files\Google\Chrome\Application\chrome.exe + } + else if (FileExist("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe")){ + ChromeFilepath = C:\Program Files (x86)\Google\Chrome\Application\chrome.exe + } + } + + if(ChromeFilepath = ""){ + Message = Failed to find chrome.exe in the usual locations. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + MsgBox 0x30, Error!, Unable to find Chrome.exe in the usual locations. `nScript Exiting. + ExitApp + } + + if(!winExist("ahk_exe chrome.exe")){ + run, %ChromeFilepath% --remote-debugging-port=%IP_Port_Nr% %URL% + } + + Driver := ComObjCreate("Selenium.ChromeDriver") + Driver.SetCapability("debuggerAddress", IP_Port) + try Driver.Start() + catch e { + + ShowSeleniumErrorMsgbox() + + } ; end of catch + + if(ConnectActiveTab){ + try TotalTabsFound := Driver.Windows.Count + loop, %TotalTabsFound% { + try SeleniumActiveTabTitle := Driver.Title + + ; Msgbox % "Title: " Title + + if(InStr(WinGetActiveChromeTabTitle, SeleniumActiveTabTitle)){ + ; msgbox, window match found + break + } + try driver.SwitchToNextWindow ;Focuses Selenium on the newly opened/next window. + + + } + + } + + ; Save current chrome version to ini file + return Driver + } + ; -------------------------------/SChrome_Get------------------------------- diff --git a/Tools/ExampleThumbnail.png b/Tools/ExampleThumbnail.png new file mode 100644 index 0000000..e7702ab Binary files /dev/null and b/Tools/ExampleThumbnail.png differ diff --git a/Tools/Freedomain Program Updater.ahk b/Tools/Freedomain Program Updater.ahk new file mode 100644 index 0000000..2001dfe --- /dev/null +++ b/Tools/Freedomain Program Updater.ahk @@ -0,0 +1,153 @@ +; ENVIRONMENT +;------------------------------------------------ +#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. +;#Warn ; Enable warnings to assist with detecting common errors. +;DetectHiddenWindows, On +#SingleInstance, Force +SendMode Input ; Recommended for new scripts due to its superior speed and reliability. +SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. +;SetKeyDelay, 500 +CoordMode, ToolTip, Screen +CoordMode, Mouse, Screen +;#NoTrayIcon + +if(InStr(A_ScriptFullPath, ".ahk")) +Menu, Tray, Icon, %A_scriptdir%\Lib\Update.ico +DetectHiddenWindows, ON + + + +ScriptName = Freedomain Program Updater +ScriptVersion = 1.1 +FullScriptName := ScriptName . " " ScriptVersion + + +; Notes/Extra Info/#Includes +;------------------------------------------------ +#Include, %A_scriptdir%\Lib\SharedFunctions.ahk + +; Msgbox % "A_ScriptDir: " A_ScriptDir + +; VARIABLES +;------------------------------------------------ +SettingsIniFileLocation := A_ScriptDir . "\Settings.ini" +ChangelogIniFilepath := A_ScriptDir . "\Lib\FreedomScriptsChangelogINI" + +ScriptBackupFolder := A_ScriptDir . "\Lib\Backups" +FileCreateDir, %ScriptBackupFolder% +; FileCreateDir, %ScriptBackupFolder% + + +ScriptToUpdate = %1% ; script to update is passed through argument. + +; Msgbox % "ScriptToUpdate: " ScriptToUpdate + +if(ScriptToUpdate = ""){ + OnMessage(0x44, "OnMsgBoxSelectProgram") + MsgBox 0x23, %FullScriptName%, Which Program would you like to download an update for? + OnMessage(0x44, "") + + IfMsgBox Yes, { + ScriptToUpdate = VideoUploader + } Else IfMsgBox No, { + ScriptToUpdate = SocialMediaPoster + } Else IfMsgBox Cancel, { + ExitApp + } + } + + if(!FileExist(SettingsIniFileLocation)){ + MsgBox 0x30, , Failed to find Settings.ini file. `nExiting + ExitApp + } + + + ToolTip, Downloading Updates, 850, 0 + + ; MAIN SCRIPT + ;------------------------------------------------ + + ; Check what the current update + ; msgbox, here goes? + if(ScriptToUpdate = "VideoUploader"){ + ScriptSettingsSection := "VideoUploader" + } + if(ScriptToUpdate = "SocialMediaPoster"){ + ScriptSettingsSection := "SocialMediaPoster" + } + + ; Current Location of the calling script + IniRead, CallingScriptFilepath, %SettingsIniFileLocation%, %ScriptSettingsSection%, Filepath, %A_space% + if(CallingScriptFilepath = ""){ + Message = Update Failed`n "CallingScriptFilepath" is blank.`nPlease Submit Error to Yuriy + MsgBox 0x10,, %Message% + return + } + Iniread, CallingScriptUpdateURL, %ChangelogIniFilepath%, %ScriptSettingsSection%, UpdateURL, %A_space% + if(CallingScriptFilepath = ""){ + Message = Update Failed`n "ChangelogIniFilepath" is blank.`nPlease Submit Error to Yuriy + MsgBox 0x10,, %Message% + return + } + Iniread, LastPost, %SettingsIniFileLocation%, %ScriptSettingsSection%, LastPost, %A_space% + Iniread, ScriptVersion, %SettingsIniFileLocation%, %ScriptSettingsSection%, ScriptVersion, %A_space% + ; Msgbox % "ScriptVersion: " ScriptVersion + ; Msgbox % "CallingScriptFilepath: " CallingScriptFilepath + ; Msgbox % "CallingScriptUpdateURL: " CallingScriptUpdateURL + ; Msgbox % "LastPost: " LastPost + + + ; Kill the scrip if it is currently open, shouldn't be necessary, but just in case + SplitPath, CallingScriptFilepath, ProcessName, OutDir, OutExtension, OutNameNoExt, OutDrive + ; SplitPath, InputVar [, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive] + Process, Exist, %ProcessName% + if(ErrorLevel){ + Process, Close, %ProcessName% + } + + ; Msgbox % "CallingScriptFilepath: " CallingScriptFilepath + + + BackupLocation = %ScriptBackupFolder%\%OutNameNoExt%_%ScriptVersion%.%OutExtension% + FileMove, %CallingScriptFilepath%, %BackupLocation%, 1 + if(ErrorLevel){ + MsgBox 0x10, Failed To Delete, Failed to Delete:`n%ScriptFilepath%`n`nPlease delete it manually and re-run the updater and Select the Program You'd Like to Update. + ExitApp + } + + ToolTip, Backup Made to \Backups\ Successfully. `nDownloading New Version, 850, 0 + ; Download latest file + UrlDownloadToFile, %CallingScriptUpdateURL%, %CallingScriptFilepath% + + ; IniWrite, Value, Filename, Section, Key + ; Update the ini file with the update status + IniWrite, 0, %SettingsIniFileLocation%, %ScriptSettingsSection%, UpdateAvailable + + + ; MsgBox + + run, "%CallingScriptFilepath%" "LastPost" + ; ExitApp + ; MsgBox, done here! + + + ExitApp + ; Functions + ;------------------------------------------------ + URLDownloadToVar(url){ + hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1") + hObject.Open("GET",url) + hObject.Send() + return hObject.ResponseText + } + + + OnMsgBoxSelectProgram() { + DetectHiddenWindows, On + Process, Exist + If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) { + ControlSetText Button1, Video Uploader + ControlSetText Button2, Social Media + ControlSetText Button3, Cancel + } + } \ No newline at end of file diff --git a/Tools/Freedomain Program Updater.exe b/Tools/Freedomain Program Updater.exe new file mode 100644 index 0000000..ffef5eb Binary files /dev/null and b/Tools/Freedomain Program Updater.exe differ diff --git a/Tools/Kill Open Freedomain Programs.ahk b/Tools/Kill Open Freedomain Programs.ahk new file mode 100644 index 0000000..9990f4f --- /dev/null +++ b/Tools/Kill Open Freedomain Programs.ahk @@ -0,0 +1,39 @@ +; ENVIRONMENT +;------------------------------------------------ +#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. +;#Warn ; Enable warnings to assist with detecting common errors. +;DetectHiddenWindows, On +#SingleInstance, Force +SendMode Input ; Recommended for new scripts due to its superior speed and reliability. +SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. +;SetKeyDelay, 500 +CoordMode, ToolTip, Screen +CoordMode, Mouse, Screen +;#NoTrayIcon +;Menu, Tray, Icon, ..\Icons\ICONNAMEHERE + +; Notes/Extra Info/#Includes +;------------------------------------------------ + + + +; VARIABLES +;------------------------------------------------ + + + +; MAIN SCRIPT +;------------------------------------------------ +process, close, Freedomain Social Media Poster.exe +process, close, Freedomain Video Uploader.exe + +ExitApp + + + + + + + +; Functions +;------------------------------------------------ \ No newline at end of file diff --git a/Tools/Script Updater.ahk b/Tools/Script Updater.ahk new file mode 100644 index 0000000..c50fead --- /dev/null +++ b/Tools/Script Updater.ahk @@ -0,0 +1,106 @@ +; ENVIRONMENT +;------------------------------------------------ +#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. +;#Warn ; Enable warnings to assist with detecting common errors. +;DetectHiddenWindows, On +#SingleInstance, Force +SendMode Input ; Recommended for new scripts due to its superior speed and reliability. +SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. +;SetKeyDelay, 500 +CoordMode, ToolTip, Screen +CoordMode, Mouse, Screen +;#NoTrayIcon +Menu, Tray, Icon, Update.ico +DetectHiddenWindows, ON + + + +ScriptName = Script Updater +ScriptVersion = 1.0 +FullScriptName := ScriptName . " " ScriptVersion + + +;---Changelog------------------------------------------------------ +; Fixed Locals not saving successful upload status to correct file +; Added Locals Upload status to Upload Results screen +;---/Changelog------------------------------------------------------ + + + + + +; Notes/Extra Info/#Includes +;------------------------------------------------ +#Include, %A_scriptdir%\SharedFunctions.ahk + + +; VARIABLES +;------------------------------------------------ +SettingsIniFileLocation := A_ScriptDir . "\Settings.ini" +ScriptToUpdate = %1% +ScriptToUpdate = VideoUploader + + + +IniRead, DiscordErrorLoggingWebhookBotURL, %SettingsIniFileLocation%, SocialMediaPoster, DiscordErrorLoggingWebhookBotURL, %A_space% +SplitPath, A_scriptdir, OutFileName, ParentDirectory, OutExtension, OutNameNoExt, OutDrive + + + + +; MAIN SCRIPT +;------------------------------------------------ +; Check what the current update + +if(ScriptToUpdate = "VideoUploader"){ + ; Current Location of the calling script + IniRead, CallingScriptFilepath, %SettingsIniFileLocation%, General, VideoUploaderFilepath + Iniread, CallingScriptUpdateURL, %SettingsIniFilepath%, General, VideoUploaderURL + Iniread, CallingScriptChangelogURL, %SettingsIniFilepath%, General, VideoUploaderChangelogURL + Iniread, CallingScriptCurrentVersion, %SettingsIniFilepath%, General, ScriptVersion + ; Iniread, CallingScriptVersion, %SettingsIniFilepath%, General, ScriptVersion +} + +if(ScriptToUpdate = "SocialMediaPoster"){ + ; Current Location of the calling script + IniRead, CallingScriptFilepath, %SettingsIniFileLocation%, SocialMediaPoster, VideoUploaderFilepath + Iniread, CallingScriptUpdateURL, %SettingsIniFilepath%, SocialMediaPoster, VideoUploaderURL + Iniread, CallingScriptCurrentVersion, %SettingsIniFilepath%, SocialMediaPoster, ScriptVersion +} + + + +UpdateChangelog := URLDownloadToVar(CallingScriptChangelogURL) +Msgbox % "UpdateChangelog: " UpdateChangelog + + +Msgbox % "ScriptToUpdate: " ScriptToUpdate +Msgbox % "CallingScriptFilepath: " CallingScriptFilepath +Msgbox % "CallingScriptUpdateURL: " CallingScriptUpdateURL +Msgbox % "CallingScriptChangelogURL: " CallingScriptChangelogURL +Msgbox % "CallingScriptVersion: " CallingScriptVersion + + + + + +; Kill the Original Script in order to delete it +WinClose, %ScriptFilepath% ahk_class AutoHotkey +sleep, 500 +WinClose, %ScriptFilepath% ahk_class AutoHotkey + +; Delete the original file +FileDelete, %ScriptFilepath% + + + + + +; Functions +;------------------------------------------------ +URLDownloadToVar(url){ + hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1") + hObject.Open("GET",url) + hObject.Send() + return hObject.ResponseText +} \ No newline at end of file diff --git a/Tools/Script Updater.exe b/Tools/Script Updater.exe new file mode 100644 index 0000000..2e16d69 Binary files /dev/null and b/Tools/Script Updater.exe differ diff --git a/Tools/TestSeleniumInstall.ahk b/Tools/TestSeleniumInstall.ahk new file mode 100644 index 0000000..22a6390 --- /dev/null +++ b/Tools/TestSeleniumInstall.ahk @@ -0,0 +1,50 @@ +;---ENVIRONMENT--------------------------------------------------------------------- +#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. +;#Warn ; Enable warnings to assist with detecting common errors. +;DetectHiddenWindows, On +#SingleInstance, Force +SendMode Input ; Recommended for new scripts due to its superior speed and reliability. +SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. +;SetKeyDelay, 500 +CoordMode, ToolTip, Screen +CoordMode, Mouse, Screen +;#NoTrayIcon +;Menu, Tray, Icon, ..\Icons\ICONNAMEHERE + +;---Notes/Extra Info/#Includes------------------------------------------------------ +#include %A_ScriptDir%/../Lib/Schrome.ahk ; used for chrome debugging mode connection + + +;---VARIABLES----------------------------------------------------------------------- + + +;---MAIN SCRIPT--------------------------------------------------------------------- +driver:= ComObjCreate("Selenium.CHROMEDriver") ;Select and Create Chrome driver instance +driver.AddArgument("disable-infobars") ;Hides 'Chrome is being controlled by automated test software' message +driver.AddArgument("--start-maximized") ; Maximize Chrome Browser +driver.AddArgument("--disable-gpu") +;driver.AddArgument("--headless") +try driver.Get("https://freedomain.com/") ;Open selected URL +catch e { + Msgbox,4096,Error, Unable to connect to Chrome.`n`nPlease check the documentation for how to fix this. + ExitApp +} + +try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding +msgbox,4096,Success,If you installed Selenium correctly A chrome window should have opened up and navigated to freedomain.com.`nClick ok to close. + + +ExitApp + + + + + + + + + + + + +;---FUNCTIONS-----------------------------------------------------------------------