Jason Berger
Jason Berger

Reputation: 303

"Send %variable%" evals my variable before sending it

I have an autohotkey script(A) that write another script(B).

The important line in my script(A):

InputBox variable, Variable
Send %variable%

Then, if i input:

helloworld{enter}

it will write "helloworld" and insert a new line in my script(B) instead of just writing "{enter}"

How do I force it to write %variable% without interpreting it beforehand ?

Upvotes: 0

Views: 942

Answers (2)

S. User18
S. User18

Reputation: 712

I agree with the other answer that using FileAppend would be a better method. However, if you truly want to accomplish this using the send command, then you need to use {raw} mode. You can read about {raw} in the documentation: https://autohotkey.com/docs/commands/Send.htm

InputBox variable, Variable
Send, {raw}%variable%

Upvotes: 3

Relax
Relax

Reputation: 10543

The simplest way to write another script (scriptB) from scriptA is to use FileAppend:

variable = helloworld

FileAppend,
(
; a line of code
Send %variable%{enter}
; another line of code
)
,C:\scriptB.ahk

Run, edit "C:\scriptB.ahk"
; or:
; Run, C:\scriptB.ahk

or

InputBox variable, Variable, Enter a variable:
if not ErrorLevel
{
FileAppend,
(
; a line of code
Send %variable%{enter}
; another line of code
)
,C:\scriptB.ahk
Run, edit "C:\scriptB.ahk"
; or:
; Run C:\scriptB.ahk
}
return

Upvotes: 2

Related Questions