Page 1 of 1

How do I store a LONG string as a variable?

Posted: 13 Dec 2017, 19:48
by omar
I'm trying to save a page of HTML text so I can output using a shortcut.
The text is 6000+ chars long.

I try this:

Code: Select all

myText=
(
; Looooong HTML text - all in one line! More than 6000 characters. It contains quote marks and others.
)
I cant do the above as there are quote marks and maybe some with characters.

When I try this:

Code: Select all

SendInput {raw} ; Looooong HTML text - all in one line! More than 6000 characters. It contains quote marks and others.
It doesnt output all characters - it stops somewhere - I guess there must be a limit?

What can I do?

Thanks.

Re: How do I store a LONG string as a variable?

Posted: 13 Dec 2017, 20:14
by Osprey
Change your Send mode. From the docs:

"Unlike the other sending modes, the operating system limits SendInput to about 5000 characters (this may vary depending on the operating system's version and performance settings). Characters and events beyond this limit are not sent."

Re: How do I store a LONG string as a variable?

Posted: 14 Dec 2017, 09:31
by omar
How do I change send mode?
Never heard of that.

But even then, how can I store a large amount of text in a variable (something that has quote characters and others in)?
The best way I find is to copy to clipboard and send a ctrl v to paste.

Let me know. Thanks

Re: How do I store a LONG string as a variable?

Posted: 14 Dec 2017, 09:43
by Delta Pythagorean
SendRaw, % Raw

Re: How do I store a LONG string as a variable?

Posted: 14 Dec 2017, 13:36
by jeeswg
I would suggest using FileRead, to put text into a variable.
You can store text verbatim in AutoHotkey using continuation sections, starting with:
(% ` Join`r`n or (% `
[See: ANSI (CP-1252) CHARACTERS (VERBATIM) (WYSIWYG) (CONTINUATION SECTIONS)]
jeeswg's characters tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=26486

[EDIT:] I posted some relevant code here:
How best to read in a whole file and output to clipboard? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 37#p188637

Re: How do I store a LONG string as a variable?

Posted: 24 Feb 2021, 07:46
by DRocks
Thanks @jeeswg reading a file to string is perfect and much easier to understand in the code.

Code: Select all

htmlString := getFileHtml("path/to/myFile.html")

getFileHtml(filePath) {
	FileRead, fileContentAsHtmlString, % filePath
	return fileContentAsHtmlString
}