找回密码
 加入
搜索
查看: 4219|回复: 4

[AU3基础] 后台复制文件如何让界面不卡死 ?

  [复制链接]
发表于 2014-11-22 16:36:57 | 显示全部楼层 |阅读模式
在复制过程中,拖动边框 在win7下 非常容易出现  程序无响应 。试了 论坛上面的 多任务处理方式 也不行
各位老大 看下,谢谢啊。
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 442, 192, 124)
$Button1 = GUICtrlCreateButton("copy", 224, 240, 75, 25)
$Label1 = GUICtrlCreateLabel("复制文件过程中,如何让界面不卡死", 144, 104, 196, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        ;DirCopy ("d:\XXX","e:\xxx",1)
        EndSwitch
WEnd


        
        
发表于 2014-11-22 17:01:52 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 442, 192, 124)
$Button1 = GUICtrlCreateButton("copy", 224, 240, 75, 25)
$Label1 = GUICtrlCreateLabel("复制文件过程中,如何让界面不卡死", 144, 104, 196, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
sleep(100)
WEnd

$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
;DirCopy ("d:\XXX","e:\xxx",1)
EndSwitch





 楼主| 发表于 2014-11-22 17:09:55 | 显示全部楼层
回复 2# Huiseyu


    这个无法复制哟
发表于 2014-11-22 18:21:15 | 显示全部楼层
回复 3# laomeng
如果是复制量较大,花时多,单进程的AU3程序当然无法再响应你的其它操作.
考虑把复制功能做成独立的EXE,要复制时调用它.

主程序里:
ShellExecute('_copy.exe', $dir1 & ' ' & $dir2)
;ShellExecute('_copy.exe', "d:\XXX e:\xxx")
_copy.exe代码可以这样:
#NoTrayIcon
If $cmdline[0] <> 2 Then Exit 
If Not FileExists($cmdline[1]) Then Exit MsgBox(16, 'Err', '源目录不存在!')
If Not FileExists($cmdline[2]) Then
        If DirCreate($cmdline[2]) = 0 Then Exit MsgBox(16, 'Err', '无法创建目标目录!')
EndIf
DirCopy($cmdline[1], $cmdline[2], 1)
Msgbox(64, '信息提示', '完成 ' & $cmdline[1] & ' 的复制!')
 楼主| 发表于 2014-11-22 19:38:11 | 显示全部楼层
回复 4# user3000


    多谢!那 这个可以用 ShellExecutewait 的吗 ? 因为需要 主程序等待   等复制完 然后再执行里 里面的程序。 之前试了很多方法 在等待的过程中 不敢托 一拖 就提示停止响应  win7最敏感!!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-28 06:22 , Processed in 0.099581 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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