Page 1 of 1
How to Send text as one string?
Posted: 11 May 2024, 19:10
by slishnevsky
Hello.
I was playing with the Send command.
It seems it can only send text character by character, like typing.
I was wondering if it is possible to send a text as a whole string?
Thanks.
Re: How to Send text as one string?
Posted: 12 May 2024, 00:24
by Rohwedder
Re: How to Send text as one string?
Posted: 12 May 2024, 09:23
by kunkel321
Code: Select all
#SingleInstance
#Requires AutoHotkey v2+
^+p:: ; Ctrl+Shift+P, save to clipboard, then simulate paste.
{
A_Clipboard := "I was playing with the Send command.`nIt seems it can only send text character by character, like typing.`nI was wondering if it is possible to send a text as a whole string?`n`nI was playing with the Send command.`nIt seems it can only send text character by character, like typing.`nI was wondering if it is possible to send a text as a whole string?`n`nI was playing with the Send command.`nIt seems it can only send text character by character, like typing.`nI was wondering if it is possible to send a text as a whole string?`n`nI was playing with the Send command.`nIt seems it can only send text character by character, like typing.`nI was wondering if it is possible to send a text as a whole string?`n`nI was playing with the Send command.`nIt seems it can only send text character by character, like typing.`nI was wondering if it is possible to send a text as a whole string?"
Send "^{v}" ; Ctrl+V tells Windows to paste content of clipboard.
}
Re: How to Send text as one string?
Posted: 12 May 2024, 10:15
by mikeyww
I would use
ClipWait.
Code: Select all
#Requires AutoHotkey v2.0
str := 'I was playing with the Send command.`nIt seems it can only send text character by character,'
. ' like typing.`nI was wondering if it is possible to send a text as a whole string?`n`n'
str .= str str str
^+p::paste(str)
paste(str) {
A_Clipboard := ''
A_Clipboard := str
If ClipWait(1)
Send '^v'
Else MsgBox 'An error occurred while waiting for the clipboard.', 'Error', 'Icon!'
}
Re: How to Send text as one string?
Posted: 12 May 2024, 10:30
by kunkel321
Yeah, good call.
I guess it's also worth mentioning that if you are pasting multiple paragraphs, you can have the variable assignment with a multiline
continuation section.
This takes more lines of code, but it is easier to understand.
Code: Select all
A_Clipboard := "
(
I was playing with the Send command.
It seems it can only send text character by character, like typing.
I was wondering if it is possible to send a text as a whole string?
I was playing with the Send command.
It seems it can only send text character by character, like typing.
I was wondering if it is possible to send a text as a whole string?
I was playing with the Send command.
It seems it can only send text character by character, like typing.
I was wondering if it is possible to send a text as a whole string?
I was playing with the Send command.
It seems it can only send text charater by character, like typing.
I was wondering if it is possible to send a text as a whole string?
I was playing with the Send command.
It seems it can only send text character by character, like typing.
I was wondering if it is possible to send a text as a whole string?
)"
Re: How to Send text as one string?
Posted: 12 May 2024, 13:09
by ntepa
Re: How to Send text as one string?
Posted: 12 May 2024, 13:30
by mikeyww
That is what I thought for a while, but I had an instance where I thought that the ClipWait made a difference. I might have been mistaken and defer to lexikos's expertise. If I encounter the problem again, I will post.