autoit 创建发送 ' type o.txt | clip ' 的批处理不起作用

autoit 创建发送 ' type o.txt | clip ' 的批处理不起作用

我花了几个小时查阅文档和论坛来尝试解决这个问题。

代码运行时没有错误,但批处理脚本没有执行。

我没有向读者展示该#include<*>部分,因为它太冗长了。

oToClip()
Func oToClip()
    Local $sleep = 250
    Sleep($sleep)
    Local $sFilePath = "%userprofile%\oToClip.bat"
    Sleep($sleep)
    Local $hFileOpen = FileOpen($sFilePath, $FO_APPEND + $FO_CREATEPATH)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when opening the file.")
    EndIf
    Sleep($sleep)
    FileWriteLine($hFileOpen, "type %userprofile%\o.txt | clip")
    Sleep($sleep)
    FileClose($hFileOpen)
    Sleep($sleep)
    RunWait(@ComSpec & " /c " & $sFilePath)
EndFunc   ;==>oToClip

答案1

如果你使用' "command" | clip'

 类型%userprofile%\o.txt"|剪辑


oToClip()
Func oToClip()
    Local $sleep = 250
    Sleep($sleep)
    Local $sFilePath = "%userprofile%\oToClip.bat"
    Sleep($sleep)
    Local $hFileOpen = FileOpen($sFilePath, $FO_APPEND + $FO_CREATEPATH)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when opening the file.")
    EndIf
    Sleep($sleep)
    FileWriteLine($hFileOpen, 'type "%userprofile%\o.txt"|clip')
    Sleep($sleep)
    FileClose($hFileOpen)
    Sleep($sleep)
    RunWait(@ComSpec & " /c " & $sFilePath)
EndFunc   ;==>oToClip

相关内容