找回密码
 加入
搜索
查看: 3225|回复: 3

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

[复制链接]
发表于 2010-3-29 19:52:03 | 显示全部楼层 |阅读模式
脚本比较写的乱,作用是自动监控 剪贴板 ,把复制的文本保存到指定文本文件中(在网页上复制小说),
现在出现个问题 : 指定文本文件 只能保存  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
发表于 2010-3-29 20:24:51 | 显示全部楼层
去掉主循环里的Do...Until循环
发表于 2010-3-29 21:48:19 | 显示全部楼层
谢谢分享!!
 楼主| 发表于 2010-3-30 16:10:04 | 显示全部楼层
本帖最后由 maxkingmax 于 2010-3-30 16:11 编辑
去掉主循环里的Do...Until循环
afan 发表于 2010-3-29 20:24



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

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

While 1
Sleep(100)
If  $stop=1  Then
        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
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-20 16:21 , Processed in 0.074475 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表