I figured out the passing a variable bit:
Code: Select all
FileEncoding, UTF-8-RAW ; Needed for special symbols
FileRead, Var, C:\Software\Syncthing\AutoHotKey\testing\description.txt
; File Contents are 2 lines:
; 🔴 Bitchute: bitchute.com/
; 🔴 LBRY: lbry.tv
; Msgbox % "Var: " Var
sleep 100
js =
(
document.getElementsByClassName('textarea -form js-paste-code')[0].value = "%Var%";
)
Msgbox % "js: " js
driver:= ComObjCreate("Selenium.CHROMEDriver") ;Select and Create Chrome driver instance
; driver.setbinary("C:\Software\Chromium\chrome.exe") ;Sets path to custom Binary
driver.Get("https://pastebin.com/") ;Open selected URL
driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
driver.executeScript(js)
sleep, 1000
Send, {Enter}
msgbox stop
This works just fine if the text file has only 1 line. But if it has 2 lines the script errors out.
I'm thinking I need to replace the newline character with something javascripty.