How do I store a LONG string as a variable?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
omar
Posts: 540
Joined: 22 Oct 2015, 17:56

How do I store a LONG string as a variable?

13 Dec 2017, 19:48

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.
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

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

13 Dec 2017, 20:14

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."
omar
Posts: 540
Joined: 22 Oct 2015, 17:56

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

14 Dec 2017, 09:31

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
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

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

14 Dec 2017, 09:43

SendRaw, % Raw

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

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

14 Dec 2017, 13:36

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
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
DRocks
Posts: 565
Joined: 08 May 2018, 10:20

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

24 Feb 2021, 07:46

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
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], RandomBoy, Rohwedder, ruespe and 375 guests