Compare commits

..

No commits in common. 'main' and '1.0' have entirely different histories.
main ... 1.0

@ -1,13 +1,10 @@
;---FUNCTIONS-----------------------------------------------------------------------
; Misc Functions that are called by both the Video and Social Media poster
; -------------------------------Discord-------------------------------
PostToDiscordChannel(Message,WebhookChannel){
; Don't try to post a message if there is no webhook url
if(WebhookChannel = "")
Return
; -------------------------------Discord-------------------------------
PostToDiscordChannel(Message,WebhookChannel){
; Msgbox % "Message: " Message
; Msgbox % "WebhookChannel: " WebhookChannel
@ -31,6 +28,8 @@ PostToDiscordChannel(Message,WebhookChannel){
}
)
; Msgbox % "JsonString: " JsonString
;
try WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
try WebRequest.Open("POST", WebhookChannel, false)
try WebRequest.SetRequestHeader("Content-Type", "application/json")
@ -51,14 +50,14 @@ TelegramMsgBox(Text:="", TelegramBotToken := "", TelegramBotChatID :=""){
; 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
; Text := StrReplace(Text, "`%", "%25") ; percent with
; Msgbox % "Text: " Text
ErrorLoggingPath = %A_ScriptDir%\Lib\ErrorLogging\check.rups
@ -94,7 +93,6 @@ TelegramMsgBox(Text:="", TelegramBotToken := "", TelegramBotChatID :=""){
; -------------------------------/TelegramAPI-------------------------------
; Telegram Message API
; https://core.telegram.org/bots/api
;------------------------------------------------
SendTelegramMessage(token, chatID, text := "", ParseMode := "MarkdownV2") ; you could add more options; compare the Telegram API docs
{
@ -117,7 +115,7 @@ SendTelegramMessage(token, chatID, text := "", ParseMode := "MarkdownV2")
json_resp := whr.ResponseText
whr := ; free COM object
; Msgbox % "json_resp: " json_resp
; if(InStr(json_resp, "error_code"))
if(InStr(json_resp, "error_code"))
Return json_resp
}
@ -144,7 +142,6 @@ pre-formatted fixed-width code block written in the Python programming language
; -------------------------------Telegram Image Sending-------------------------------
; https://www.autohotkey.com/boards/viewtopic.php?t=68417
; https://core.telegram.org/bots/api
SendTelegramPhoto(token, chatID, file, caption := "", ParseMode := "MarkdownV2") ; you could add more options; compare the Telegram API docs
{
@ -167,7 +164,7 @@ SendTelegramPhoto(token, chatID, file, caption := "", ParseMode := "MarkdownV2")
whr := ; free COM object
; Msgbox % "json_resp: " json_resp
; if(InStr(json_resp, "error_code"))
if(InStr(json_resp, "error_code"))
Return json_resp
}
@ -195,7 +192,7 @@ SendTelegramVideo(token, chatID, file, caption := "", ParseMode := "MarkdownV2")
whr := ; free COM object
; Msgbox % "json_resp: " json_resp
; if(InStr(json_resp, "error_code"))
if(InStr(json_resp, "error_code"))
Return json_resp
}
@ -224,7 +221,7 @@ SendTelegramFile(token, chatID, file, caption := "", ParseMode := "MarkdownV2")
whr := ; free COM object
; Msgbox % "json_resp: " json_resp
; if(InStr(json_resp, "error_code"))
if(InStr(json_resp, "error_code"))
Return json_resp
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

@ -21,9 +21,6 @@ global InstalledChromeVersion
; Chrome Related Functions
;------------------------------------------------
DownloadLatestChromium(){
Message = Checking Variables for Downloading Newest Chrome
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
if(ChromeFilepath = "")
ChromeFilepath := GetInstalledChromeFilepath()
@ -43,7 +40,7 @@ DownloadLatestChromium(){
ChromeExtractedDirectory = %A_ScriptDir%\Lib\chrome-win64
ChromeDriverMoverEXEFilepath = %A_ScriptDir%\Lib\Chromedriver-Mover.exe
ChromeDriverMoverURL = https://freedomain.dev/attachments/b7b608b6-379a-42bb-a7c4-23fd67a05bb3
ChromeDriverMoverURL = https://git.freedomainplaylists.com/yuriy/Chromedriver-Mover/releases/download/1.1/Chromedriver-Mover.exe
ChromeDriverProgramFilesExeFilepath = C:\Program Files\SeleniumBasic\chromedriver.exe
@ -93,9 +90,9 @@ DownloadLatestChromium(){
; close any open instances of Chromium
; SetTitleMatchMode, 2 ; substring
SetTitleMatchMode, 2 ; substring
/*
if(WinExist(" - Chromium")){
Message = Trying to close any open Chromium Windows
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
@ -114,66 +111,19 @@ DownloadLatestChromium(){
MsgBox 0x10,, %Message%
return
}
*/
; make sure all instances of chrome are closed
Loop, {
ChromeOpen := WinExist("ahk_exe chrome.exe")
if(ChromeOpen) {
Message = Chrome is Open. Asking user to close instances before continuing.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
MsgBox 0x41, Chrome is Open, Please close all instances of Chrome and then click OK to continue with replacing Chrome with the newest version.
IfMsgBox OK, {
} Else IfMsgBox Cancel, {
ToolTip
return
}
}
else,
break
}
; make sure all instances of chromedriver.exe are closed
Message = Checking and killing any instances of the chromedriver.exe process
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Loop, 5 {
Process, Exist, chromedriver.exe
ChromedriverExists := ErrorLevel
if(ChromedriverExists){
Message = Chromedriver Exists on check number %A_Index%
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging")
Process, Close, chromedriver.exe
sleep, 5000 ; wait 5 seconds before checking again
continue
}
else,
break
Message = Chrome Update Failed. Unable to kill background chromedriver.exe process
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
return
}
; msgbox
FileGetTime, ChromeDriverExeOldCreationTime, %ChromeDriverProgramFilesExeFilepath%, C
Message = Downloading Chromedriver v%ChromeStableLatestVersion% `nFrom: %chromedriverDLURL64%`nTo: %ChromeDriverDownloadZipFilepath%
Message = Downloading Chromedriver v%ChromeStableLatestVersion% to:`n%ChromeDriverDownloadZipFilepath%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
UrlDownloadToFile, %chromedriverDLURL64%, %ChromeDriverDownloadZipFilepath%
Message = Downloading Chromium v%ChromeStableLatestVersion% `nfrom: %chromeDLURL64% to:`n%ChromeDownloadZipFilepath%`n(This might take 1-2 minutes)
Message = Downloading Chromium v%ChromeStableLatestVersion% to:`n%ChromeDownloadZipFilepath%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
UrlDownloadToFile, %chromeDLURL64%, %ChromeDownloadZipFilepath%
@ -182,8 +132,6 @@ DownloadLatestChromium(){
Message = Deleting Old Chromium Directory
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
FileRemoveDir, %ChromeExtractedDirectory%, 1
if(FileExist(ChromeExtractedDirectory)){
Message = Failed to delete the old Chromium. `nPlease manually delete the following directory and then run the Chrome Update again.`n`n %ChromeExtractedDirectory%
@ -230,7 +178,7 @@ DownloadLatestChromium(){
; Check if the Copy-ChromeDriver-To-Program-Files.exe file exists
; @todo, remove later. this is temporary to fix chromedriver-mover being broken and needing to be replaced
; FileDelete, %ChromeDriverMoverEXEFilepath%
FileDelete, %ChromeDriverMoverEXEFilepath%
Message = Checking Chromedriver-Mover.exe exists
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
@ -311,13 +259,10 @@ DownloadLatestChromium(){
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
MsgBox 0x40,, %Message%
ChromeFilepath := ; clear out chromefilepath variable in case the path changed
ToolTip
return
}
/*
*/
CheckForChromeUpdates(ChromeFilepath := ""){
@ -339,6 +284,7 @@ CheckForChromeUpdates(ChromeFilepath := ""){
GetInstalledChromeFilepath(){
; ChromeFilepath is global variable
if(ChromeFilepath = ""){
ChromePortableFilepath = %A_ScriptDir%\Lib\chrome-win64\chrome.exe
@ -351,14 +297,19 @@ GetInstalledChromeFilepath(){
if(FileExist(ChromePortableFilepath))
ChromeFilepath := ChromePortableFilepath
; Message = Using Chromium Portable for Upload
; SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging")
Message = Using Chromium Portable for Upload
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging")
}
else {
Message = Chrome.exe not found in \Lib\
SaveOrPostProgress(Message,PostType:=",ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
MsgBox 0x10, Chromium Portable not Found, Chromium Portable not found. `nPlease make sure it's located at one of the following paths and then try again.`n`n%ChromePortableFilepath% `nOR`n%ChromePortableFilepath2%
; Leave this in for now, but i don't think we will be going to using the system Chrome in the future.
; if(FileExist("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"))
; ChromeFilepath = C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
MsgBox 0x10, Chrome Not Found, Chrome for Testing not found.`nIf this is your first time running on this computer, please click the "Chrome Up-To-Date" button to download the latest chrome binaries.
; if(FileExist("C:\Program Files\Google\Chrome\Application\chrome.exe"))
; ChromeFilepath = C:\Program Files\Google\Chrome\Application\chrome.exe
}
}
ToolTip

@ -35,9 +35,10 @@ SaveOrPostProgress(Message:="",PostType:=""){
if(InStr(PostType, "Tooltip")){
TooltipThis(Message)
}
if(InStr(PostType, "ErrorLoggingTextFile")){
/* if(InStr(PostType, "ErrorLoggingTextFile")){
Func_LogErrorsToTextFile(Message)
}
*/
if(InStr(PostType, "ErrorSummaryVar")){
Func_LogErrorsToVar(Message)
}
@ -102,16 +103,15 @@ TimedToolTip(Text, x="", y="",RemoveAfterTime:=2000, SetWhichToolTip="") {
; -------------------------------LogErrorsToTextFile-------------------------------
Func_LogErrorsToTextFile(Text){
; Do not log if we do not have an errorlog filepath
if(ErrorLoggingFilePath = "")
return
; ErrorLoggingFile := Filepath
FormatTime, TodayDate , YYYYMMDDHH24MISS, yyyyMMdd_hhmmss
text =
(
text =`n`n---------------%TodayDate%---------------`n%Text%
---------------%TodayDate%---------------
%Text%
)
FileAppend, %Text%, %ErrorLoggingFilePath%
}
; -------------------------------/LogErrorsToTextFile-------------------------------
@ -133,10 +133,6 @@ CheckDirExistAndCreate(Path){
; -------------------------------/CheckDirExistAndCreate-------------------------------
; Script Updates
; ------------------------------------------------
CheckIfUpdateAvailable(Filepath, CurrentVersion){
FileRead, ScriptUpdateContents, %Filepath%
@ -375,6 +371,19 @@ Return Var
}
; OnMsgbox Functions
;------------------------------------------------
OnMsgBoxUpdateAvailable() {
DetectHiddenWindows, On
Process, Exist
If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) {
ControlSetText Button1, Cancel
ControlSetText Button2, Install
}
}
SaveCurrentChromeVersionToIniFile(){
if(InstalledChromeVersion = "")
@ -412,286 +421,3 @@ HasSubstringVal(haystack, needle)
; -------------------------------Functions-------------------------------
; https://www.autohotkey.com/docs/v2/Functions.htm#Variadic
Join(sep, params*) {
For index, param in params
str .= param . sep
return SubStr(str, 1, -StrLen(sep))
}
LogErrorToTextFile(Error){
/* if(LogErrorsToTextFile != 1)
Return
*/
ErrorLoggingFile := VideoFolderDir . "\" . "ErrorLogging.txt"
FormatTime, TodayDate , YYYYMMDDHH24MISS, yyyyMMdd_hhmmss
text =
(
---------------%TodayDate%---------------
%CurrentSite%: %Error%
)
if(LogErrorsToMsgbox)
Msgbox % "Text: " Text
FileAppend, %Text%, %ErrorLoggingFile%
} ; End of Function
/*
*/
AddToTotalVideosUploadedCount(){
; IniRead, TotalVideosUploaded, %SettingsIniFilepath%, General, TotalVideosUploaded, %A_Space%
TotalVideosUploaded += 1
; IniWrite, %TotalVideosUploaded%, %SettingsIniFilepath%, General, TotalVideosUploaded
}
Check_For_Stuck_Video_Upload(Index_Number, Upload_Status){
if(A_index = 1){ ; Create a blank array
ProgressStatusArray := []
Return
}
Message = Upload Status: %Upload_Status%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
; if we reached the last loop number:
if(A_index = %Number_of_loops_to_Check_Upload_status%){
Message = Upload Most Likely Failed: Video Hasn't Finished Uploading after 1 hour.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return "Failed"
}
; If progress is still the same after a ten minute interval then error out
if(HasVal(Array_Index_Num_of_Upload_StatusChecks, A_index)){ ; if current index is in Array of index numbers to check status during
; Send a notification message of upload status
Message = Upload Status: %Upload_Status%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; if current upload_status is in the array of values that are updated every 10 mins
if(HasVal(ProgressStatusArray, Upload_Status)){
Message = Upload Failed (E#4508)`nUpload Stuck at same point for 10 minutes. Stuck Status: %ProgressStatus%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return "Failed"
}
ProgressStatusArray.Push(Upload_Status) ; append current status to array
}
} ; end of func
/*
*/
; Find the longest word in a string of words
FindLongestWordInString(m, calloutNumber, pos, haystack, pattern){
Global wordLength, longestWord
len := StrLen(m)
If ( len > wordLength )
{
wordLength := len
longestWord := m
; MsgBox, %m%
}
}
/*
*/
; Split a long string into multiple pieces based on the string lengtht you want and return an array with all strings
SplitStringWithSentences(text, maxChunkSize) {
sentences := StrSplit(text, "\. ") ; split at period with space after it
currentChunk := ""
chunks := []
Loop, % sentences.Length()
{
sentence := sentences[A_Index]
CurrentChunkAndSentence := currentChunk . sentence
; Msgbox % "CurrentChunkAndSentence: " CurrentChunkAndSentence
; msgbox % StrLen(CurrentChunkAndSentence)
if (StrLen(CurrentChunkAndSentence) <= maxChunkSize)
{
currentChunk .= sentence . "\. "
}
else
{
chunks.Push(currentChunk)
currentChunk := sentence . "\. "
}
}
if (currentChunk != "")
chunks.Push(currentChunk)
return chunks
}
CreateErrorLoggingFiles(Directory := ""){
FormatTime, TodayDate, YYYYMMDDHH24MISS, yyyyMMdd_hhmmss
ErrorLoggingDirectory := Directory
if(ErrorLoggingDirectory = ""){
ErrorLoggingDirectory := A_ScriptDir . "\Lib\ErrorLogging"
; If directory for error logging doesn't exist, create it
if(!FileExist(ErrorLoggingDirectory))
FileCreateDir, %ErrorLoggingDirectory%
ErrorLoggingDirectory := ErrorLoggingDirectory . "\" . TodayDate . "_" . ScriptAbbreviatedName
}
; Msgbox % "ErrorLoggingDirectory: " ErrorLoggingDirectory
FileCreateDir, %ErrorLoggingDirectory%
; Create variables with filepaths that content will be saved to.
global ErrorLoggingFilePath := ErrorLoggingDirectory . "\" . "ErrorLogging.txt"
global StatusFileFilePath := ErrorLoggingDirectory . "\" . "PostStatus.ini"
global PostTitleFilePath := ErrorLoggingDirectory . "\" . "PostTitle.txt"
global PostBodyFilePath := ErrorLoggingDirectory . "\" . "PostBody.txt"
global PostTagsFilePath := ErrorLoggingDirectory . "\" . "PostTags.txt"
PostStatusesFilepath := ErrorLoggingDirectory . "\" . "Status.ini"
; Msgbox % "ErrorLoggingDirectory: " ErrorLoggingDirectory
Return
}
; if passed argument is .exe file, then script has just been updated and we need to delete the old .exe file
CheckIfUpdateInstalled(PassedInArgument :=""){
if(InStr(PassedInArgument,".exe")){
FileDelete, %PassedInArgument%
if(ErrorLevel){ ; most likely because the old version hasn't finished exiting yet
Message = Failed to Delete Old .exe file after Updating
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar")
}
}
}
; https://www.autohotkey.com/boards/viewtopic.php?t=59936
GetDateOrdinalSuffix(D) {
Static Special := {1: "st", 2: "nd", 3: "rd", 21: "st", 22: "nd", 23: "rd", 31: "st"}
Return D . ((S := Special[D]) ? S : "th")
}
; Calculate the aspect ratio of a video/image using the width + height
getAspectRatio(width, height) {
gcd := gcdFunc(width, height)
return round(width/gcd) ":" round(height/gcd)
}
; The gcdFunc() is a helper function that calculates the GCD (greatest common divisor) of two numbers using the Euclidean algorithm.
; Used for calculating aspect ratio of Videos
gcdFunc(a, b) {
while b
t := b, b := Mod(a, b), a := t
return a
}
; OnMsgbox - Custom Msgbox Screens
;------------------------------------------------
ConfirmBeforeSubmitMsgboxFunc(){
/*
; Snippet to for check:
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
}
*/
OnMessage(0x44, "OnMsgBoxUserConfirmation")
MsgBox 0x21, User Confirmation, Please check that all data was input correctly and fix any mistakes and then click PROCEED to finalize the Upload.`n`nClick STOP to cancel the rest of this Upload and move on to the next website.
OnMessage(0x44, "")
IfMsgBox OK, {
return true
} Else IfMsgBox Cancel, {
Message = User Selected STOP button when asked for confirmation. Cancelling Rest of Site Upload.
Return %Message%
}
}
OnMsgBoxUpdateAvailable() {
DetectHiddenWindows, On
Process, Exist
If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) {
ControlSetText Button1, Cancel
ControlSetText Button2, Install
}
}
; Show a user confirmation msgbox with a PROCEED and STOP buttons
; Used by the "Confirm before Submit" checkbox
OnMsgBoxUserConfirmation() {
DetectHiddenWindows, On
Process, Exist
If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) {
ControlSetText Button1, PROCEED
ControlSetText Button2, STOP
}
}
OnMsgBoxConfirmChromiumOverwrite() {
DetectHiddenWindows, On
Process, Exist
If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) {
ControlSetText Button1, Cancel
ControlSetText Button2, Yes
}
}
OnMsgBoxPodcastFinish() {
DetectHiddenWindows, On
Process, Exist
If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) {
WinMove,, 0
}
}
OnMsgBoxSocialMediaPoster() {
DetectHiddenWindows, On
Process, Exist
If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) {
ControlSetText Button1, Yes
ControlSetText Button2, Not Now
}
}

@ -1,47 +0,0 @@
$apiurl=$args[0]
$apitoken=$args[1]
$filename=$args[2]
$filepath=$args[3]
Write-Host "apiurl: $apiurl"
Write-Host "apitoken: $apitoken"
Write-Host "filename: $filename"
Write-Host "filepath: $filepath"
# Load the required .NET assemblies
Add-Type -AssemblyName System.Net.Http
# Create Object and Load the required .NET assemblies
$httpClient = New-Object System.Net.Http.HttpClient
# $url = 'https://git.zinchuk.xyz/api/v1/repos/yuriy/TestRepo/releases/22/assets'
# $fileName = 'TestFile58.exe'
# $token = '2cf4a54d941'
$headers = @{
'accept' = 'application/json'
'Content-Type' = 'multipart/form-data'
}
# $filePath = "C:\Users\yuriy\Syncthing\Git\TestREpo\test.exe"
$fileBytes = [System.IO.File]::ReadAllBytes($filePath)
$fileStream = [System.IO.MemoryStream]::new($fileBytes)
$httpClient = [System.Net.Http.HttpClient]::new()
$httpClient.DefaultRequestHeaders.Add('Authorization', "Bearer $apitoken")
$multipartFormData = New-Object System.Net.Http.MultipartFormDataContent
$fileContent = New-Object System.Net.Http.StreamContent -ArgumentList $fileStream
$fileContent.Headers.ContentDisposition = New-Object System.Net.Http.Headers.ContentDispositionHeaderValue -ArgumentList "form-data"
$fileContent.Headers.ContentDisposition.Name = "attachment"
$fileContent.Headers.ContentDisposition.FileName = $fileName
# $fileContent.Headers.ContentType = [System.Net.Http.Headers.MediaTypeHeaderValue]::Parse("text/plain")
$fileContent.Headers.ContentType = [System.Net.Http.Headers.MediaTypeHeaderValue]::Parse("application/x-msdownload")
$multipartFormData.Add($fileContent)
$response = $httpClient.PostAsync($apiurl, $multipartFormData).Result
$responseContent = $response.Content.ReadAsStringAsync().Result
Write-Output $responseContent

@ -1,62 +0,0 @@
<#
.SYNOPSIS
Create a new release on on a Gitea site using the Gitea API
.DESCRIPTION
The Add-Numbers function takes two integer parameters, $Number1 and $Number2,
and returns the sum of those two numbers.
.PARAMETER APIURL
The Repo Releases API URL of the Gitea site, including the API Key.
Example: "https://gitea.example.com/api/v1/repos/yuriy/TESTREPO/releases?token=aaabbbcccdd"
.PARAMETER ReleaseName
Name for the release that will be created
.PARAMETER ReleaseTag
Tag for the release that will be created
.PARAMETER ReleaseBody
Body Text for the release that will be created
.EXAMPLE
Gitea-CreateRelease.ps1 "https://gitea.example.com/api/v1/repos/yuriy/TESTREPO/releases?token=aaabbbcccdd" "1.0" "1.0" "Initial Release"
.NOTES
This function was created as an example for a PowerShell documentation demonstration.
.LINK
https://example.com/powershell-functions
#>
$APIURL=$args[0]
$ReleaseName=$args[1]
$ReleaseTag=$args[2]
$ReleaseBody=$args[3]
<#
Write-Host "APIURL: $APIURL"
Write-Host "ReleaseTag: $ReleaseTag"
Write-Host "ReleaseName: $ReleaseName"
Write-Host "ReleaseBody: $ReleaseBody"
#>
$headers = @{
"accept" = "application/json"
"Content-Type" = "application/json"
}
$body = @{
"body" = "${ReleaseBody}"
"draft" = $false
"name" = "${ReleaseTag}"
"prerelease" = $false
"tag_name" = "${ReleaseTag}"
# "target_commitish" = "string"
} | ConvertTo-Json
# Write-Host "body: " $body
$Result = Invoke-RestMethod -Uri $APIURL -Method Post -Headers $headers -Body $body
Write-Host $Result

@ -1,7 +1,8 @@
; GITEA Functions
;------------------------------------------------
CheckForUpdates(GitReleasesAPIURL, CurrentVersionNumber := 0){
Message = Checking For Updates at %GitReleasesAPIURL%
CheckForUpdates(GitReleasesAPIURL){
; msgbox, checking for updates
Message = Checking For Updates
SaveOrPostProgress(Message,PostType:="ErrorLoggingTextFile")
data := URLDownloadToVar(GitReleasesAPIURL)
@ -14,15 +15,25 @@ CheckForUpdates(GitReleasesAPIURL, CurrentVersionNumber := 0){
Return
}
LatestReleaseVersionNumber := parsed.1.name
UpdateVersionNumber := parsed.1.name
; Message = UpdateVersionNumber: %UpdateVersionNumber%
; DevModeMsgBox(Message)
if(CurrentVersionNumber >= LatestReleaseVersionNumber)
UpdateAvailable := 0
else,
UpdateAvailable := 1
if(ScriptVersion = UpdateVersionNumber OR ScriptVersion > UpdateVersionNumber){
ToolTip
return UpdateAvailable
return 0
}
else, {
UpdateAvailable := 1
; msgbox, update found!
Message = Program Update Found
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile")
; IniWrite, 1, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable
; ToolTip
return 1
}
}
@ -42,13 +53,19 @@ UpdateScript(){
exename := parsed.1.assets.1.name
exeURL := parsed.1.assets.1.browser_download_url
; Msgbox % "UpdateVersionNumber: " UpdateVersionNumber
; msgbox, Version: %Version%
; Msgbox % "ChangeLog: " ChangeLog
; Msgbox % "exeURL: " exeURL
; Msgbox % "exename: " exename
ExeName := StrReplace(exename, ".exe", "")
UpdateExeName = %exename% %UpdateVersionNumber%.exe
UpdateExeFilepath = %A_ScriptDir%\%UpdateExeName%
if(ScriptVersion =< UpdateVersionNumber){
if(ScriptVersion = UpdateVersionNumber){
; IniWrite, 0, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable
MsgBox, You are Up-To-Date, There are no new updates to download.
MsgBox, You are Up-To-Date
; IniRead, UpdateAvailable, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable, 0
return
}
@ -64,12 +81,10 @@ UpdateScript(){
}
Else IfMsgBox No, {
SaveOrPostProgress(Message:="Downloading Update",PostType:="Tooltip,ErrorLoggingTextFile")
; Msgbox, downloading to: %A_ScriptDir%\%UpdateExeName%
UrlDownloadToFile, %exeURL%, %UpdateExeFilepath%
run, "%UpdateExeFilepath%" "%A_ScriptFullPath%"
ExitApp
}
return
}

@ -1,63 +0,0 @@
<#
.SYNOPSIS
Adds two numbers and returns the result.
.DESCRIPTION
The Add-Numbers function takes two integer parameters, $Number1 and $Number2,
and returns the sum of those two numbers.
.PARAMETER Number1
The first number to add.
.PARAMETER Number2
The second number to add.
.EXAMPLE
$sum = Add-Numbers -Number1 5 -Number2 10
Write-Host "The sum is: $sum"
.NOTES
This function was created as an example for a PowerShell documentation demonstration.
.LINK
https://example.com/powershell-functions
#>
$APIURL=$args[0]
$ReleaseName=$args[1]
$ReleaseTag=$args[2]
$ReleaseBody=$args[3]
function CreateRelease {
param (
[string]$APIURL,
[string]$ReleaseName,
[string]$ReleaseID,
[string]$ReleaseBody,
)
$headers = @{
"accept" = "application/json"
"Content-Type" = "application/json"
}
$body = @{
"body" = "${ReleaseBody}"
"draft" = $false
"name" = "${ReleaseTag}"
"prerelease" = $false
"tag_name" = "${ReleaseTag}"
"target_commitish" = "string"
} | ConvertTo-Json
# Write-Host "body: " $body
$Result = Invoke-RestMethod -Uri $APIURL -Method Post -Headers $headers -Body $body
Write-Host $Result
}
Write-FullName -FirstName "John" -LastName "Doe"

@ -1,149 +0,0 @@
CheckLBRYProcess(){
; Check if LBRY Process exists
Process, Exist,LBRY.exe
if(ErrorLevel = 0) ; if doesn't exist
{
Message = Not Running. Starting up LBRY.exe
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
LBRYExeFilepath = C:\Program Files\LBRY\LBRY.exe
if(!FileExist(LBRYExeFilepath)){
Message = Failed to Find LBRY.exe executable. LBRY not installed?
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
Message = Checking LBRY daemon_settings.yml file for Odysee Wallet Servers
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordErrorLogging")
; FileRead, daemon_settingsFileContent, C:\Users\%A_UserName%\AppData\Local\lbry\lbrynet\daemon_settings.yml
; if(!InStr(daemon_settingsFileContent, "a-hub1.odysee.com")){
; Message = Odysee wallet server is not in daemon_settings.yml. Replacing File with required settings.
; SaveOrPostProgress(Message:=Message,PostType:=",DiscordErrorLogging")
; LBRYDaemonSettingsFP = C:\Users\%A_UserName%\AppData\Local\lbry\lbrynet\daemon_settings.yml
; LBRYDaemonSettingsBackupFP = C:\Users\%A_UserName%\AppData\Local\lbry\lbrynet\daemon_settings_BU.yml
; ; Msgbox % "daemon_settingsText: " daemon_settingsText
; FileMove, %LBRYDaemonSettingsFP%, %LBRYDaemonSettingsBackupFP%, 1 ; Dest [, Flag (1 = overwrite)]
; UrlDownloadToFile, https://freedomain.dev/yuriy/video-uploader/raw/branch/main/Assets/daemon_settings.yml , %LBRYDaemonSettingsFP%
; sleep, 1000
; if(!FileExist(LBRYDaemonSettingsFP)){
; Message = Failed to download the custom daemon_settings.yml file from git. Restoring Original File
; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordErrorLogging")
; FileMove,%LBRYDaemonSettingsBackupFP%,%LBRYDaemonSettingsFP%, 1
; }
; }
try run, "%LBRYExeFilepath%"
Message = Waiting 1 Minute for LBRY to start up
SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
Sleep, 60000 ; 1 minute
Process, Exist,LBRY.exe
if(ErrorLevel = 0) ; if doesn't exist
{
Message = Failed to Start LBRY.exe after 60 seconds of waiting
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
WinMinimize, LBRY
}
Return
}
GetPermanentLBRYURL(UploadResult){
SingleQuotationmark = "
UploadResult := StrSplit(UploadResult, "`n") ; split results by new line
; Iterate through the array of the results
Loop % UploadResult.Length() {
PermanentURL := UploadResult[A_Index]
if(InStr(PermanentURL, "permanent_url"))
Break
}
; Starting Result: "permanent_url": "lbry://Test-Video-161-Numbered#c9ad9afe54c7178d6f870b59bbe129aef8efc3ff",
PermanentURL := StrSplit(PermanentURL, "lbry:")
PermanentURL := "lbry:" . PermanentURL[2]
PermanentURL := StrReplace(PermanentURL, ",", "")
PermanentURL := StrReplace(PermanentURL, SingleQuotationmark, "")
PermanentURL := StrReplace(PermanentURL, "`n", "")
PermanentURL := StrReplace(PermanentURL, "`r", "")
; End Result lbry://Test-Video-161-Numbered#c9ad9afe54c7178d6f870b59bbe129aef8efc3ff
Return PermanentURL
}
GetLBRYCanonicalURL(LBRYJSONObject){ ; input json string
; ResolveURL := StrSplit(LBRYResolveAPICommand, "lbry://")
; ResolveURL := "lbry://" . ResolveURL[2]
; StrReplace(Haystack, SearchText [, ReplaceText, OutputVarCount, Limit := -1])
LBRYPermanentURLJsonOBJ := StrReplace(LBRYJSONObject, LBRYPermanentURL, "LBRYPermanentURL")
; clipboard := LBRYPermanentURLJsonOBJ
; DevModeMsgBox(LBRYPermanentURLJsonOBJ)
try parsed := JSON.Load(LBRYPermanentURLJsonOBJ)
try LBRYCanonicalURL := parsed.LBRYPermanentURL.canonical_url
; DevModeMsgBox(LBRYCanonicalURL)
if(LBRYCanonicalURL = ""){
Return "" ; return blank
}
; otherwise return the LBRY url
LBRYCanonicalURL := StrReplace(LBRYCanonicalURL, "lbry://", "https://lbry.tv/")
Return LBRYCanonicalURL
}
LBRYCMDTextReplacement(LBRYURLSlug){
SingleQUote = "
LBRYURLSlug := StrReplace(LBRYURLSlug, " ", "_") ; replace all spaces with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, ":", "_") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, ",", "_") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "?", "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "!", "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "`;", "_") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "/", "_") ; replace all colons with dashes
; LBRYURLSlug := StrReplace(LBRYURLSlug, "?", "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "<", "_") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, ">", "_") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, SingleQUote, "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "'", "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "=", "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, ";", "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, ")", "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "(", "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "___", "_") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "__", "_") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "__", "_") ; replace all colons with dashes
Return LBRYURLSlug
}
GetLBRYAPIErrorFromString(UploadResult){
UploadResultArray := StrSplit(UploadResult, "message")
LBRYAPIError := UploadResultArray[2]
; LBRYAPIErrorStrLen := StrLen(LBRYAPIError)
; LBRYAPIErrorStrToTrim := LBRYAPIErrorStrLen - 3
; Msgbox % "LBRYAPIErrorStrToTrim: " LBRYAPIErrorStrToTrim
LBRYAPIError := SubStr(LBRYAPIError, 4)
LBRYAPIError := StrReplace(LBRYAPIError, "}", "")
; Msgbox % "LBRYAPIError: " LBRYAPIError
Return LBRYAPIError
}

@ -1,54 +0,0 @@
; Iterate over Locals posts on the home page until found post with title
; ------------------------------------------------
GrabLocalsPostURLUsingTitle(PostTitle){
Loop, 10 {
Message = Checking Post %A_index% on page for Post Titled`n%PostTitle%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
ToolTip, %A_Index%
; first two items can be skipped.
; new Post box and Create other forms of posts box
if(A_index < 3)
Continue
; Xpath for each post box on the main page
Xpath = //body/div/div/div/div/div/div[1]/div[%A_Index%]
try ElementInnerText := driver.findelementbyxpath(Xpath).Attribute("innerText") ;XPATH Inner Text
Try ElementOuterHTML := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag
if(Devmode){
Msgbox % "ElementInnerText: " ElementInnerText "`n" "ElementOuterHTML: " ElementOuterHTML
}
if(InStr(ElementInnerText, PostTitle)){
Message = Found Post Title in Element Number: %A_index%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; Pull Out the Post URL from the OuterHTML using RegEx
regexMatch := RegExMatch(ElementOuterHTML, "data-post-url=""([^""]+)""", match)
if (regexMatch)
{
PostURL := match1
Message = URL Pulled out from OuterHTML: %PostURL%
Return PostURL
}
else {
Message = Failed to Pull out URL from OuterHTML
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return "Failed"
}
}
}
Message = Failed to find New Post in the first 10 posts
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return "Failed"
}

@ -1,5 +1,4 @@
Function Libraries used in the following Projects:
- [Freedomain Social Media Poster](https://freedomain.dev/yuriy/social-media-poster)
- [Freedomain Video Uploader](https://freedomain.dev/yuriy/video-uploader)
- [Freedomain Clips Uploader](https://freedomain.dev/yuriy/clips-uploader)
- [Freedomain Livestream Scheduler](https://freedomain.dev/yuriy/livestream-scheduler)
- [Freedomain Social Media Poster](https://git.freedomainplaylists.com/yuriy/Freedomain-Social-Media-Poster)
- [Freedomain Video Uploader](https://git.freedomainplaylists.com/yuriy/Freedomain-Video-Uploader)
- [Freedomain Reposter](https://git.freedomainplaylists.com/yuriy/Freedomain-Reposter)

@ -73,6 +73,7 @@ CheckSeleniumDriver(){
}
DriverStatus := 1
if(ReuseTabs)
CreateArrayOfChromeTabs()
@ -720,28 +721,10 @@ Selenium_LoopToSendValueByName(ElementName,NumOfLoops:=1,SleepLength:=1000,Strin
}
}
Selenium_LoopToSendValueToXpath(Xpath,NumOfLoops:=1,SleepLength:=1000,StringTextContent:="",ClearElement:=0){
Selenium_LoopToSendValueToXpath(Xpath,NumOfLoops:=1,SleepLength:=1000,StringTextContent:=""){
loop, %NumOfLoops% {
if(ClearElement){
Loop, 3 { ; sometimes have to do it multiple times to make it trigger properly
Try PreviousValue := driver.findelementbyxpath(Xpath).Attribute("value") ;Xpath Value
try, driver.FindElementByXPath(Xpath).clear()
Try CurrentValue := driver.findelementbyxpath(Xpath).Attribute("value") ;Xpath Value
if(PreviousValue != CurrentValue){
break
}
sleep, 1000
; msgbox
}
}
try driver.FindElementByXPath(Xpath).sendKeys(StringTextContent) ; Input Text
; ToolTip, Loop attempt: %A_index%
try driver.FindElementByXPath(Xpath).sendKeys(StringTextContent) ; Click on "upload image" button
catch e {
if(A_index = NumOfLoops){
Return "Failed"
@ -796,27 +779,17 @@ Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath,NumOfLoops:=1,SleepLength:=1
}
Selenium_LoopToClearXpath(Xpath,NumberOfAttemps:=1,SleepLength:=1000){
loop, %NumberOfAttemps% {
Selenium_LoopToClearXpath(Xpath,NumOfLoops:=1,SleepLength:=1000){
loop, %NumOfLoops% {
try driver.FindElementByXPath(Xpath).clear()
catch e {
if(A_index = NumOfLoops){
Return "Failed"
}
sleep, %SleepLength%
try, InerText := driver.findelementbyxpath(Xpath).Attribute("value")
; Msgbox % "InerText: " InerText
if(InerText = "")
return
if(A_index = NumberOfAttemps){
return "Failed after %NumberOfAttemps"
}
Continue
; Return
}
Return
}
}
@ -848,38 +821,6 @@ SaveDriverURLOFErrorPage(){ ; save the url of the result page. That way if a tab
}
GetHTMLValueFromXpathOuterHTML(XPATH, HTMLElementName){
Try ElementOuterHTML := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag
; try Clipboard := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag
; Try MsgBox,,Element OuterHTML: `n, % driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag
; Match string between quotes following the HTMLELEMENTNAME
RegexStatement = %HTMLElementName%="([^"]+)"
; regexMatch := RegExMatch(ElementOuterHTML, "value=""([^""]+)""", match)
regexMatch := RegExMatch(ElementOuterHTML, RegexStatement, match)
if (regexMatch)
{
ElementValue := match1
; Msgbox % "PostURL: " PostURL
; Message = URL Pulled out from OuterHTML: %PostURL%
Return ElementValue
}
else {
Message = Failed to Pull out value from OuterHTML
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return "Failed"
}
}
;---\Selenium---
;------------------------------------------------

@ -1,197 +0,0 @@
; This #include needs to be at the bottom of the parent script
CheckForUpdates:
UpdateStartTime := A_TickCount ; start time
; The GUI buttons must have variable set to vUpdateAvailable and vChromeUpdateAvailable for button to get updated
; The following variables need to be set in the parent script
; GitReleasesAPIURL
; ChromeFilepath
Message = Checking for Updates
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
if(CheckForUpdates(GitReleasesAPIURL, ScriptVersion)){
GuiControl,,UpdateAvailable, Update Available!
}
; check for Post Scheduler Update
if(ScriptNameAcronym = "FVU"){
if(CheckForUpdates(PostSchedulerGitReleasesAPIURL, PostSchedulerVersion)){
GuiControl,,PostSchedulerUpdateAvailable, FPS Update Available!
}
}
if(CheckForChromeUpdates(ChromeFilepath)){
GuiControl,,ChromeUpdateAvailable, Chrome Update Available!
ChromeUpdateAvailable := 1
}
; calculate run time and convert to seconds
TimeToCheckforUpdates := round(((A_TickCount - UpdateStartTime) / 1000), 2)
Message = Update Check took %TimeToCheckforUpdates% seconds to complete
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; Msgbox % "TimeToCheckforUpdates: " TimeToCheckforUpdates
; Msgbox % "URunTime: " URunTime
ToolTip
Return
; UpdatePostScheduler:
Return
UpdateChrome:
; if chroem doesn't exist, download it
if(ChromeFilepath = ""){
Status := DownloadLatestChromium()
if(Status)
GuiControl,,ChromeUpdateAvailable, Chrome Up-To-Date
Return
}
if(CheckForChromeUpdates = "")
Status := CheckForChromeUpdates(ChromeFilepath)
if(!status){
OnMessage(0x44, "OnMsgBoxConfirmChromiumOverwrite")
MsgBox 0x41, Already Up-to-Date, Yor current Chromium version is already up to date. `nDo you want to download and overwrite it?
OnMessage(0x44, "")
IfMsgBox OK, {
Return
} Else IfMsgBox Cancel, {
ToolTip
}
}
Status := DownloadLatestChromium()
if(Status)
GuiControl,,ChromeUpdateAvailable, Chrome Up-To-Date
Return
/*
*/
PasteClipboardToEditBox:
if(A_GuiControl = "PasteClipboardToSMPBody"){
GuiControl,,PostBody, %Clipboard%
}
if(A_GuiControl = "PasteClipboardToSMPTitle"){
GuiControl,,PostTitle, %Clipboard%
}
if(A_GuiControl = "PasteClipboardToFLSTitle"){
GuiControl,,LivestreamTitle, %Clipboard%
}
if(A_GuiControl = "PasteClipboardToFLSDescription"){
GuiControl,,LivestreamDescription, %Clipboard%
}
if(A_GuiControl = "PasteClipboardToFLSTags"){
GuiControl,,LivestreamTags, %Clipboard%
}
Return
OpenErrorLog:
run, %ErrorLoggingFilePath%
Return
OpenGiteaPage:
if(ScriptAbbreviatedName = "FLS")
URL = https://freedomain.dev/yuriy/livestream-scheduler
if(ScriptAbbreviatedName = "FVU")
URL = https://freedomain.dev/yuriy/video-uploader
if(ScriptAbbreviatedName = "FSMP")
URL = https://freedomain.dev/yuriy/social-media-poster
run, %URL%
Return
UpdatePostScheduler:
; Close any existing instances of the Post Scheduler
; Kill any active intances of the Post Scheduler so the .exe file can be overwriten
process, close, Freedomain Post Scheduler.exe
; Msgbox % "PostSchedulerGitReleasesAPIURL: " PostSchedulerGitReleasesAPIURL
data := URLDownloadToVar(PostSchedulerGitReleasesAPIURL)
try parsed := JSON.Load(data)
catch e {
Message = Failed to check for updates. Gitea Releases API returned blank or malformed data.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return
}
UpdateVersionNumber := parsed.1.name
ChangeLog := parsed.1.body
exename := parsed.1.assets.1.name
exeURL := parsed.1.assets.1.browser_download_url
; Msgbox % "exename: " exename
; ExeName := StrReplace(exename, ".exe", "")
; UpdateExeName = %exename%.exe
UpdateExeFilepath = %A_ScriptDir%\%ExeName%
if(PostSchedulerVersion =< UpdateVersionNumber){
; IniWrite, 0, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable
MsgBox, You are Up-To-Date, There are no new updates to download.
; IniRead, UpdateAvailable, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable, 0
return
}
Changelog = %PostSchedulerVersion% --> %UpdateVersionNumber%`n`nChangelog:`n%Changelog%
OnMessage(0x44, "OnMsgBoxUpdateAvailable")
MsgBox 0x44, Update Available For %exename%, %Changelog%
OnMessage(0x44, "")
IfMsgBox Yes, {
Return
}
Else IfMsgBox No, {
SaveOrPostProgress(Message:="Downloading Update",PostType:="Tooltip,ErrorLoggingTextFile")
if(FileExist(UpdateExeFilepath)){
FileDelete, %UpdateExeFilepath%
if(ErrorLevel){
Message = Failed to Delete %UpdateExeFilepath%. `nPlease Close the process manually and try the update again.
MsgBox 0x10,, %Message%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
}
UrlDownloadToFile, %exeURL%, %UpdateExeFilepath%
run, "%UpdateExeFilepath%" "%A_ScriptFullPath%"
ToolTip
; ExitApp
}
return

@ -1,20 +1,11 @@
URLDownloadToVar(url){
hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
Try, hObject.Open("GET",url)
catch e {
Message = Error Ocurred when trying to do GET Request using URLDownloadToVar to`n: %URL%
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,ErrorSummaryVar")
}
hObject.Open("GET",url)
try {
hObject.Send()
}
try hObject.Send()
catch e {
Message = Error Ocurred when trying to hObject.Send() with URLDownloadToVar Function
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,ErrorSummaryVar")
; MsgBox, 4096, Error, Failed to connect to:`n`n%url%`n`nAre you connected to the internet? Or is the website down?`n`nDisable Auto Update Check to disable this message.
return ""
; msgbox, failed!
}
return hObject.ResponseText

@ -1 +0,0 @@
; Code migrated to Shared-GoTo's

@ -1,98 +0,0 @@
; https://www.autohotkey.com/boards/viewtopic.php?t=112391
; Usage:
; cred := CredRead("CREDENTIALNAME", NewlineInPassword := 1)
; Username := cred.username
; Password := cred.password
; msgbox % cred.username
; msgbox % cred.password
; Functions
;------------------------------------------------
CredWrite(name, username, password)
{
VarSetCapacity(cred, 24 + A_PtrSize * 7, 0)
cbPassword := StrLen(password)*2
NumPut(1 , cred, 4+A_PtrSize*0, "UInt") ; Type = CRED_TYPE_GENERIC
NumPut(&name , cred, 8+A_PtrSize*0, "Ptr") ; TargetName = name
NumPut(cbPassword, cred, 16+A_PtrSize*2, "UInt") ; CredentialBlobSize
NumPut(&password , cred, 16+A_PtrSize*3, "UInt") ; CredentialBlob
NumPut(3 , cred, 16+A_PtrSize*4, "UInt") ; Persist = CRED_PERSIST_ENTERPRISE (roam across domain)
NumPut(&username , cred, 24+A_PtrSize*6, "Ptr") ; UserName
return DllCall("Advapi32.dll\CredWriteW"
, "Ptr", &cred ; [in] PCREDENTIALW Credential
, "UInt", 0 ; [in] DWORD Flags
, "UInt") ; BOOL
}
CredDelete(name)
{
return DllCall("Advapi32.dll\CredDeleteW"
, "WStr", name ; [in] LPCWSTR TargetName
, "UInt", 1 ; [in] DWORD Type,
, "UInt", 0 ; [in] DWORD Flags
, "UInt") ; BOOL
}
CredRead(name,NewlineInUsername:=0, NewlineInPassword:=0)
{
DllCall("Advapi32.dll\CredReadW"
, "Str", name ; [in] LPCWSTR TargetName
, "UInt", 1 ; [in] DWORD Type = CRED_TYPE_GENERIC (https://learn.microsoft.com/en-us/windows/win32/api/wincred/ns-wincred-credentiala)
, "UInt", 0 ; [in] DWORD Flags
, "Ptr*", pCred ; [out] PCREDENTIALW *Credential
, "UInt") ; BOOL
if !pCred{
; Username
InputBox, Username, Input Username, Username not found. `nPlease Input Username for: `n--%name%--,,,,,,,,%Clipboard% ; , Prompt, HIDE, Width, Height, X, Y, Font, Timeout, Default]
if(ErrorLevel)
return
InputBox, Password, Input Password, Password not found. `nPlease Input Password for: `n--%name%--,,,,,,,,%Clipboard% ; , Prompt, HIDE, Width, Height, X, Y, Font, Timeout, Default]
if(ErrorLevel)
return
if !CredWrite(name, Username, Password)
MsgBox failed to write cred
else, { ; try reading the credential that was just saved
DllCall("Advapi32.dll\CredReadW"
, "Str", name ; [in] LPCWSTR TargetName
, "UInt", 1 ; [in] DWORD Type = CRED_TYPE_GENERIC (https://learn.microsoft.com/en-us/windows/win32/api/wincred/ns-wincred-credentiala)
, "UInt", 0 ; [in] DWORD Flags
, "Ptr*", pCred ; [out] PCREDENTIALW *Credential
, "UInt") ; BOOL
}
if !pCred{
msgbox, Failed to read cred. after writing it to Credential Manager.
return
}
}
name := StrGet(NumGet(pCred + 8 + A_PtrSize * 0, "UPtr"), 256, "UTF-16")
; append new line to end if requested
if(NewlineInUsername)
username := StrGet(NumGet(pCred + 24 + A_PtrSize * 6, "UPtr"), 256, "UTF-16") . "`n"
else,
username := StrGet(NumGet(pCred + 24 + A_PtrSize * 6, "UPtr"), 256, "UTF-16")
len := NumGet(pCred + 16 + A_PtrSize * 2, "UInt")
; append new line to end if requested
if(NewlineInPassword)
password := StrGet(NumGet(pCred + 16 + A_PtrSize * 3, "UPtr"), len/2, "UTF-16") . "`n"
else,
password := StrGet(NumGet(pCred + 16 + A_PtrSize * 3, "UPtr"), len/2, "UTF-16")
DllCall("Advapi32.dll\CredFree", "Ptr", pCred)
return {"name": name, "username": username, "password": password}
}
; Misc
;------------------------------------------------
; Escape::ExitApp
Loading…
Cancel
Save