Initial Commit of V2.7

main
Yuriy 2 years ago
parent 66c93e4d01
commit 27d556eb0c

8
.gitignore vendored

@ -0,0 +1,8 @@
Settings.ini
VideoLinks.ini
body.txt
**/ErrorLogging
**/Backups
**/Debug
**/Templates
**/Testing

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 317 KiB

File diff suppressed because it is too large Load Diff

@ -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---
;------------------------------------------------

@ -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 <JSON>
* Links:
* GitHub: - https://github.com/cocobelgica/AutoHotkey-JSON
* Forum Topic - http://goo.gl/r0zI8t
* Email: - cocobelgica <at> gmail <dot> 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*)
}
}
}

@ -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
}

@ -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
}

File diff suppressed because it is too large Load Diff

@ -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 )
}

@ -1,3 +1,10 @@
# Freedomain_Social_Media_Poster # Freedomain Social Media Poster
Social Media Poster customized for the Freedomain Philosophy Show 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

@ -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
;------------------------------------------------

@ -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-----------------------------------------------------------------------

@ -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-------------------------------

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 KiB

@ -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
}
}

@ -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
;------------------------------------------------

@ -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
}

Binary file not shown.

@ -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-----------------------------------------------------------------------
Loading…
Cancel
Save