maxkingmax 发表于 2010-3-29 19:52:03

AU3 的写入文本文件和获取剪切板文本 是否都有 128KB 的大小限制?!

脚本比较写的乱,作用是自动监控 剪贴板 ,把复制的文本保存到指定文本文件中(在网页上复制小说),
现在出现个问题 : 指定文本文件 只能保存128KB 的内容,如果复制较多的文本 >128KB 无法自动粘贴!
恳请高手指教Dim $file,$hfile,$stop
HotKeySet("{F7}","start")
HotKeySet("{F8}","copytxt")
While 1
Sleep(100)
Do
        If $hfile <>'' And $file <> ''Then
                $txt=ClipGet ( )
                If Not @error Then
                ClipPut ( '')
                FileWrite($hfile,$txt)
                $txt=''
                EndIf
        EndIf
Until $stop=''
WEnd

Func start()
       
        FileClose($hfile)
        $file=''
        $file=FileSaveDialog("保存文件名称及位置",@DesktopDir,"文本文档(*.txt)",16,"小说.TXT")
        If $file <> '' Then
        $hfile=FileOpen($file,1)
        $stop=1
        Else
        $hfile=''
        EndIf
EndFunc

Func copytxt()
$stop=0
FileClose($hfile)
EndFunc

afan 发表于 2010-3-29 20:24:51

去掉主循环里的Do...Until循环

masterpcc 发表于 2010-3-29 21:48:19

谢谢分享!!

maxkingmax 发表于 2010-3-30 16:10:04

本帖最后由 maxkingmax 于 2010-3-30 16:11 编辑

去掉主循环里的Do...Until循环
afan 发表于 2010-3-29 20:24 http://www.autoitx.com/images/common/back.gif


    谢谢 Afan
重新整理了一下:
功能:
F7,新建文件并保存
F8,暂停或继续自动保存功能
F9,继续使用上次打开过的文件(新建的文件)或打开其它文件用于保存
Dim $file,$hfile,$stop,$lastfile

HotKeySet("{F7}","start")
HotKeySet("{F8}","copytxt")
HotKeySet("{F9}","opentxt")

While 1
Sleep(100)
If$stop=1Then
      If $hfile <>'' And $file <> '' Then
                $txt=ClipGet ( )
                If Not @error Then
                ClipPut ( '')
                FileWrite($hfile,$txt)
                $txt=''
                EndIf
      EndIf
EndIf
WEnd

Func start()
      ClipPut ( '')
      FileClose($hfile)
      $file=''
      $file=FileSaveDialog("保存文件名称及位置",@DesktopDir,"文本文档(*.txt)",16,"小说.TXT")
      If $file <> '' Then
                        $lastfile=$file
      $hfile=FileOpen($file,1)
                TrayTip("文件保存位置:",$lastfile,3)
      $stop=1
      Else
      $hfile=''
      EndIf
EndFunc

Func copytxt()
       
If $stop Then
        $stop=0
                TrayTip("已经停止保存",$lastfile,3)
Else
        $stop=1
        TrayTip("继续保存",$lastfile,3)
EndIf
EndFunc

Func opentxt()
        ClipPut ( '')
If $lastfile<>'' Then
                $hfile=FileOpen($lastfile,1)
                        TrayTip("文件保存位置:",$lastfile,3)
      $stop=1
        Else
                startopen()
        EndIf
       
EndFunc

Func startopen()
      
      FileClose($hfile)
      $file=''
      $file=FileOpenDialog("要继续的文件名称及位置",@DesktopDir,"文本文档(*.txt)",1+2+8,"小说.TXT")
      If $file <> '' Then
                        $lastfile=$file
      $hfile=FileOpen($file,1)
                TrayTip("文件保存位置:",$lastfile,3)
      $stop=1
      Else
      $hfile=''
      EndIf
EndFunc
页: [1]
查看完整版本: AU3 的写入文本文件和获取剪切板文本 是否都有 128KB 的大小限制?!