如何执行Send(“ Send(” $ readme 1“)”)?

时间:2019-01-31 12:56:02

标签: autoit

如何正确执行此命令Send(“ Send(” $ readme 1“)”)?

Send("Send("$readme 1")")

因此,在脚本运行时键入以下内容:

发送(“ $ readme 1上的所有内容”)

3 个答案:

答案 0 :(得分:0)

根据the AutoIt manual,您可以将字符串括在单引号和双引号中。那是

Send('Send("$readme 1")')

应该做你想要的。

另一种选择是使用双引号将双引号字符串(phew!)中的文字双引号标记为:

Send("Send(""$readme 1"")")

答案 1 :(得分:0)

Send('Send("$readme 1")', 1)输出Send( "$readme 1" )。注意, 1为原料键(使用特殊字符或保留的关键字)。

写入文件的示例:

; variant one: create new file and write into
Global $sYourFile    = @DesktopDir & '\myNewFile.txt'
Global $sFileContent = 'Line 1' & @CRLF & 'Line 2' & @CRLF

Func _writeFile($sFile, $sText)
    Local $hFile = FileOpen($sFile, 2 + 8 + 256)
    FileWrite($hFile, $sText)
    FileClose($hFile)
EndFunc

_writeFile($sYourFile, $sFileContent)

MsgBox(64, 'Information', 'Variant one was executed. Please check your new file on the Desktop.'

; variant two: create new file and append text line by line
Global $sYourFile = @DesktopDir & '\myNewFile.txt'

Func _appendLineToFile($sFile, $sLineText)
    Local $hFile = FileOpen($sFile, 1 + 8 + 256)
    FileWriteLine($hFile, $sLineText)
    FileClose($hFile)
EndFunc

_appendLineToFile($sYourFile, 'Line 3')
_appendLineToFile($sYourFile, 'Line 4')
_appendLineToFile($sYourFile, 'Line 5')
_appendLineToFile($sYourFile, 'Line 6')

MsgBox(64, 'Information', 'Variant two was executed. Please check your new file on the Desktop.')

; variant three: replace text in file on specific line
#include-once
#include <File.au3>

Global $sYourFile = @DesktopDir & '\myNewFile.txt'

_FileWriteToLine($sYourFile, 2, 'New line 2', True)
_FileWriteToLine($sYourFile, 4, 'New line 4', True)

MsgBox(64, 'Information', 'Variant three was executed. Please check your new file on the Desktop.')

答案 2 :(得分:0)

如前所述,在AutoIt中,变量不能包含空格(如果尝试,应该会出现编译器错误)
另外(如前所述),您只需写入文件即可,而不必“使用编辑器”进行模拟。

可悲的是,您的问题不是很清楚,但是以下其中一项应该符合您的需求:

要将send("Hello")之类的行写入文件,请使用:

$readme1 = "Hello"
FileWriteLine("C:\tmp\test.txt", 'send("' & $readme1 & '")')

如果您想写send("$readme1")

FileWriteLine("C:\tmp\test.txt", 'send("$readme1")')

两种情况下的关键是正确使用引号(AutoIt使用两种引号样式:"'