后台复制文件如何让界面不卡死 ?
在复制过程中,拖动边框 在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
#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
{:face (303):} 回复 2# Huiseyu
这个无法复制哟 回复 3# laomeng
如果是复制量较大,花时多,单进程的AU3程序当然无法再响应你的其它操作.
考虑把复制功能做成独立的EXE,要复制时调用它.
主程序里:ShellExecute('_copy.exe', $dir1 & ' ' & $dir2)
;ShellExecute('_copy.exe', "d:\XXX e:\xxx")_copy.exe代码可以这样:#NoTrayIcon
If $cmdline <> 2 Then Exit
If Not FileExists($cmdline) Then Exit MsgBox(16, 'Err', '源目录不存在!')
If Not FileExists($cmdline) Then
If DirCreate($cmdline) = 0 Then Exit MsgBox(16, 'Err', '无法创建目标目录!')
EndIf
DirCopy($cmdline, $cmdline, 1)
Msgbox(64, '信息提示', '完成 ' & $cmdline & ' 的复制!')
回复 4# user3000
多谢!那 这个可以用 ShellExecutewait 的吗 ? 因为需要 主程序等待 等复制完 然后再执行里 里面的程序。 之前试了很多方法 在等待的过程中 不敢托 一拖 就提示停止响应win7最敏感!!
页:
[1]