Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
Yuriy | e810133ff5 | 4 weeks ago |
Yuriy | 45420c0b7b | 2 months ago |
Yuriy | 7e8830b7d0 | 4 months ago |
Yuriy | 1874689568 | 4 months ago |
Before Width: | Height: | Size: 355 KiB After Width: | Height: | Size: 355 KiB |
@ -0,0 +1,155 @@
|
||||
;---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------------------------------------------------------
|
||||
#Include, %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\WindowCredentialManager.ahk
|
||||
|
||||
;---VARIABLES-----------------------------------------------------------------------
|
||||
ProgramName = Freedomain Social Media Poster
|
||||
ExeProgramName = %ProgramName%.exe
|
||||
AHKFilepath = %A_ScriptDir%\%ProgramName%.ahk
|
||||
Exefilepath = %A_ScriptDir%\%ProgramName%.exe
|
||||
icopath = %A_ScriptDir%\Assets\Icon.ico
|
||||
VersionIniFP = %A_ScriptDir%\Version.ini
|
||||
|
||||
; Generate a new errorlog text file each run
|
||||
FormatTime, TodayDate , YYYYMMDDHH24MISS, yyyyMMdd_hhmmss
|
||||
ErrorLogTextFile = %A_ScriptDir%\Lib\ErrorLogging\Compiler_%TodayDate%.txt
|
||||
|
||||
|
||||
; Read Credential token from Windows Credential Manager using WindowCredentialManager.ahk
|
||||
cred := CredRead("FDR-Gitea-Token")
|
||||
GiteaToken := Cred.Password
|
||||
|
||||
; Info for Creating the Release with Gitea-CreateRelease.ps1
|
||||
CreateReleasePS1Filepath = %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Gitea-CreateRelease.ps1
|
||||
CreateReleaseAPIURL = https://freedomain.dev/api/v1/repos/yuriy/social-media-poster/releases?token=%GiteaToken%
|
||||
|
||||
; Info for Attaching exe file to release using Gitea-AttachAssetToRelease.ps1
|
||||
AttachAssetToReleasePS1Filepath = %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Gitea-AttachAssetToRelease.ps1
|
||||
AttachAssetToReleaseAPIURL = https://freedomain.dev/api/v1/repos/yuriy/social-media-poster/releases
|
||||
|
||||
;---\VARIABLES-----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
; Compile to .exe
|
||||
; ------------------------------------------------
|
||||
; Bump the version number in the version.ini file
|
||||
IniRead, VersionNumber, %VersionIniFP%, Social-Media-Poster, Version, 0.0 ; , Filename, Section, Key [, Default]
|
||||
VersionNumber += .01
|
||||
VersionNumber := SubStr(VersionNumber, 1, 4)
|
||||
IniWrite, %VersionNumber%, %VersionIniFP%,Social-Media-Poster, Version
|
||||
|
||||
|
||||
|
||||
; Kill any active intances of the uploaders so the .exe file can be overwriten by the compilation
|
||||
process, close, %ExeProgramName%
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
; check if file exists and if not, give user error and stop
|
||||
if(!FileExist(AHKFilepath)){
|
||||
msgbox, %AHKFilepath% does not exist`nExiting
|
||||
ExitApp
|
||||
}
|
||||
|
||||
; check if file exists and if not, give user error and stop
|
||||
if(!FileExist(icopath)){
|
||||
msgbox, %icopath% does not exist`nExiting
|
||||
ExitApp
|
||||
}
|
||||
|
||||
; run, %comspec% /c ""C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe" /in "%AHKFilepath%" /out "%exefilepath%" /icon "%icopath%""
|
||||
Command = "C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe" /in "%AHKFilepath%" /out "%exefilepath%" /icon "%icopath%"
|
||||
Results := RunCMD(Command)
|
||||
LogToErrorLogFile(Results, ErrorLogTextFile)
|
||||
|
||||
if(!InStr(Results, "Successfully")){
|
||||
Msgbox, Error, Compilation failed with the following error:`n`n%Results%
|
||||
ExitApp
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
; Create new Release on Gitea using Gitea-CreateRelease.ps1
|
||||
; ------------------------------------------------
|
||||
InputBox, ReleaseBody, Release Body, Please Input Text to be used in the Release Body
|
||||
|
||||
ReleaseName := VersionNumber
|
||||
ReleaseTag := VersionNumber
|
||||
|
||||
; Strings with spaces in them need to be surrounted by a single quote and double quote, eg: "'spaced string'"
|
||||
Command = Powershell "%CreateReleasePS1Filepath%" "%CreateReleaseAPIURL%" "%ReleaseName%" "%ReleaseTag%" "'%ReleaseBody%'"
|
||||
|
||||
Message = PowerShell Command to Create Release:`n%Command%
|
||||
LogToErrorLogFile(Message, ErrorLogTextFile)
|
||||
|
||||
Results := RunCMD(Command)
|
||||
LogToErrorLogFile(Results, ErrorLogTextFile)
|
||||
|
||||
|
||||
; Pull out the release ID Number, needed for attaching a file to the release
|
||||
SplitText = @{id=
|
||||
SplitText2 = `;
|
||||
ReleaseID := StrSplit(Results, SplitText)[2]
|
||||
ReleaseID := StrSplit(ReleaseID, SplitText2)[1]
|
||||
|
||||
Message = ReleaseID: %ReleaseID%
|
||||
LogToErrorLogFile(Message, ErrorLogTextFile)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; Attach .exe File to Release using Gitea-AttachAssetToRelease.ps1
|
||||
; ------------------------------------------------
|
||||
AttachAssetToReleaseAPIURL = %AttachAssetToReleaseAPIURL%/%ReleaseID%/assets
|
||||
|
||||
; Strings with spaces in them need to be surrounted by a single quote and double quote, eg: "'spaced string'"
|
||||
Command = Powershell "%AttachAssetToReleasePS1Filepath%" "%AttachAssetToReleaseAPIURL%" "%GiteaToken%" "'%ExeProgramName%'" "'%Exefilepath%'"
|
||||
LogToErrorLogFile(Command, ErrorLogTextFile)
|
||||
|
||||
Results := RunCMD(Command)
|
||||
LogToErrorLogFile(Results, ErrorLogTextFile)
|
||||
|
||||
|
||||
ExitApp
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;---FUNCTIONS-----------------------------------------------------------------------
|
||||
LogToErrorLogFile(Text, TextFileFilepath){
|
||||
FileAppend, %Text%`n, %TextFileFilepath%
|
||||
}
|
@ -1 +1 @@
|
||||
Subproject commit 6bf72336d0af0aa57064fc40c267677bb27577f3
|
||||
Subproject commit 4a1d2a5d9d95d06567e84f4128f02b1a233d53df
|
@ -0,0 +1,165 @@
|
||||
|
||||
; -------------------------------Minds-------------------------------
|
||||
PostToTumblr:
|
||||
CurrentSite := "Tumblr"
|
||||
Message = Navigating to Post Creationg Page
|
||||
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
|
||||
URLAttempt := NavigateFromBaseURLTo("https://www.tumblr.com/")
|
||||
if(URLAttempt = "Failed")
|
||||
Return
|
||||
|
||||
Status := CheckCurrentTabForCurrentSite()
|
||||
if(Status){
|
||||
Return
|
||||
}
|
||||
|
||||
; Check Login Status
|
||||
; ------------------------------------------------
|
||||
Message = Checking Login Status
|
||||
SaveOrPostProgress(Message,PostType:="Tooltip")
|
||||
|
||||
Xpath = (//button[normalize-space()='Photo'])[1]
|
||||
try ElementInnerText := driver.findelementbyxpath(Xpath).Attribute("innerText") ;XPATH Inner Text
|
||||
if(ElementInnerText != "Photo"){
|
||||
Message = Site is Logged out. Please log back in.
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
Return
|
||||
}
|
||||
|
||||
; Start Text Post
|
||||
; ------------------------------------------------
|
||||
Message = Creating New Post
|
||||
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
|
||||
Xpath = (//button[normalize-space()='Text'])[1]
|
||||
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
||||
if(status){
|
||||
Message = Failed to Start Post. Check Login Status
|
||||
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
Return
|
||||
}
|
||||
|
||||
|
||||
Xpath = (//span[@data-rich-text-placeholder='Title'])[1]
|
||||
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitle, ClearElement:=0)
|
||||
if(status){
|
||||
Message = Failed to Input Post Title
|
||||
SaveOrPostProgress(Message,PostType:=",ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
Return
|
||||
}
|
||||
|
||||
|
||||
Xpath = (//span[@data-rich-text-placeholder='Go ahead, put anything.'])[1]
|
||||
; newline is needed so the "attach image" to post option appears in the next line down
|
||||
PostBodyWithNewLine = %PostBody%`n
|
||||
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=1000,StringTextContent:=PostBodyWithNewLine, ClearElement:=0)
|
||||
if(status){
|
||||
Message = Failed To Input Post Body
|
||||
SaveOrPostProgress(Message,PostType:=",ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
Return
|
||||
}
|
||||
|
||||
|
||||
if(ImageAttachmentFilepath){
|
||||
; Click into space below the preview image so the "add photo" button shows up
|
||||
Xpath = (//div[@class='block-list-appender wp-block'])[1]
|
||||
try, driver.FindElementByXPath(Xpath).click()
|
||||
|
||||
; Xpath = (//button[@title='Add photo'])[1]
|
||||
; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
||||
|
||||
|
||||
; Click the Photo Icon on the next line down to attach an image
|
||||
Xpath = (//button[@title='Add photo'])[1]
|
||||
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
||||
if(status){
|
||||
Message = Failed to Click Attach Image Button
|
||||
SaveOrPostProgress(Message,PostType:=",ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
Return
|
||||
}
|
||||
|
||||
; send image filepath to element to attach picture
|
||||
Xpath = (//input[@role='button'])[1]
|
||||
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath, ClearElement:=0)
|
||||
if(status){
|
||||
Message = Failed to Attach Image to Post
|
||||
SaveOrPostProgress(Message,PostType:=",ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
Return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
; Input Tags
|
||||
Xpath = (//textarea[@placeholder='#add tags to help people find your post'])[1]
|
||||
|
||||
try, driver.FindElementByXPath(Xpath).SendKeys(PostTags)
|
||||
try, driver.SendKeys(driver.Keys.Enter)
|
||||
|
||||
|
||||
|
||||
|
||||
sleep, 1000
|
||||
|
||||
|
||||
if (ConfirmBeforeSubmit && ConfirmBeforeSubmitMsgboxFunc() != true) {
|
||||
Message = User Selected STOP button when asked for confirmation. Cancelling Rest of Site Upload.
|
||||
SaveOrPostProgress(Message:=Message, PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
|
||||
Xpath = (//span[normalize-space()='Post now'])[1]
|
||||
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
||||
if(status){
|
||||
Message = Failed to Click Post Now Button
|
||||
SaveOrPostProgress(Message,PostType:=",ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
Return
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*; start photo post button
|
||||
Xpath = (//button[normalize-space()='Photo'])[1]
|
||||
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
||||
if(status){
|
||||
Message = Failed to Start Post
|
||||
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
}
|
||||
|
||||
if(ImageAttachmentFilepath){
|
||||
; Attach Image
|
||||
Xpath = (//input[@role='button'])[1]
|
||||
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath, ClearElement:=0)
|
||||
if(status){
|
||||
Message = Failed to Attach Image
|
||||
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
}
|
||||
}
|
||||
|
||||
; input Text Post
|
||||
Xpath = (//span[@data-rich-text-placeholder='Go ahead, put anything.'])[1]
|
||||
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=)
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
IniWrite, Successful, %StatusFileFilePath%, Status, %CurrentSite%
|
||||
AddToTotalPostsPostedCount()
|
||||
|
||||
PauseBetweenPosts()
|
||||
DevModeMsgBox("done!")
|
||||
|
||||
Message = Post Publish Successful
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
|
||||
|
||||
Return
|
||||
; -------------------------------/Minds-------------------------------
|
@ -1,2 +1,2 @@
|
||||
[Social-Media-Poster]
|
||||
Version=2.92
|
||||
Version=2.96
|
||||
|
Loading…
Reference in New Issue