xavier880819
发表于 2009-7-22 16:36:36
30# afan
原来是这样的,看了你的程序有一种茅舍顿开的感觉!
我现在有遇到一个新问题,不知道你遇到过没有,就是如果文件夹创建太多了,想终止就只能去任务管理器那边终止了,有没有可以直接停止的呢??
afan
发表于 2009-7-22 16:38:48
可以加一个终止的热键吧~
afan
发表于 2009-7-22 16:42:51
HotKeySet()
xavier880819
发表于 2009-7-22 17:08:34
33# afan
好的,谢谢,我尝试一下
llssky2003
发表于 2009-7-23 10:35:26
一起学习,一起探讨,一起提高!~
xavier880819
发表于 2009-7-23 12:02:40
再次来求教afan,
现在有个很棘手的问题,我头都想大了一圈,也想不到解决的方法。
举个例子:
第一层我们创建了F1,F2,F3,F4,F5这5个文件夹,然后在这个5个文件夹往下还有很多层子文件夹。
现在需要复制某一种文件只到F1及其子文件夹,然后另外一种到F2和子文件夹,又是一种到F3和子文件夹等等F4,F5也同样。
这样看起来是可以做,但是实际操作起来,我换了很多方法都不行。
lynfr8
发表于 2009-7-23 12:08:27
楼上的
其实解决思路已经有人指点过了
万变不离其宗
自己想要什么效果自己是最清楚的了
建议还是自己再琢磨下
afan
发表于 2009-7-23 12:09:17
本帖最后由 afan 于 2009-7-23 12:13 编辑
36# xavier880819
不一定非得一次完成吧...
你不能先生成F1这一系列,然后f1改名,重新选择新文件,再来个F1系列吗 ... 呵呵
xavier880819
发表于 2009-7-23 13:51:12
37# lynfr8
所以说你的意思就是直接在第一层创建1个文件夹,子文件夹不管,可以随便多少。然后导入文件了,改个名字,再来一次。
明白!!谢谢你,我怎么就一心想到去改程序没有想到这个呢。看来和你们的差距还是很大!!
afan
发表于 2009-7-23 14:18:50
本帖最后由 afan 于 2009-7-23 14:24 编辑
是的,第一层只填写'1',后面其它层的随便,有时候程序还是简单点好,不容易出错,呵呵~~
29#代码第6行加一个变量改为: Dim $n = 1, $l, $s, $xh = 1
然后 Case $Button 改为:
Case $Button
GUICtrlSetData($jdt, 0)
GUICtrlSetState($Button, $GUI_DISABLE)
Dim $ywc = 0, $zs = 0, $sc = 1
jc()
AdlibEnable("jdt")
If GUICtrlRead($s) = 0 then
msgbox(48, '问题', '未设置文件夹数量? 请返回设置。 ')
Else
scml()
sleep(250)
AdlibDisable()
msgbox(64, '完成', '创建 ' & $zs & ' 个文件夹完成! ')
DirMove('f1', 'f' & '-' & $xh, 1)
$xh += 1
endif
GUICtrlSetState($Button, $GUI_ENABLE)
这样每次生成 f1后会自动更名为f-1,f-2,f-3,... 当然,中间不要重启程序,不然又会重新从 f-1 开始覆盖重命名~
xavier880819
发表于 2009-7-23 15:24:50
40# afan
对,这样自动改名确实是一个很好的办法,我甚至可以放一个INPUTBOX在那边,叫别人自己输入要创建的名字
xavier880819
发表于 2009-7-24 11:44:01
请教一下afan,
我把整个大程序作为一个子程序了,然后想用call来实现运行这个程序,但是我每次运行的时候就出问题,我把源码贴上来,请帮我看看哪里出了问题。谢谢~
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
$FormM=GUICreate('Select Call Function',200,100,-1,-1)
$ButtonM=GUICtrlCreateButton('Call MP3',10,20,80,30)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $ButtonM
Call('MP3')
EndSwitch
WEnd
FuncMP3()
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
$Form1 = GUICreate('Muti-Level Folder Creator', 400, 190,-1,-1)
Dim $n = 1, $l, $s
For $n = 1 To 14
$l[$n] = GUICtrlCreateLabel("Lv" & $n, 12 + 70 * ($n - (Int(($n - 1) / 5)) * 5 - 1), 20 + 20 * (Int(($n - 1) / 5)), 30, 18)
$s[$n] = GUICtrlCreateInput("0", 45 + 70 * ($n - (Int(($n - 1) / 5)) * 5 - 1), 17 + 20 * (Int(($n - 1) / 5)), 30, 16, $ES_NUMBER)
GUICtrlSetLimit(-1, 4)
Next
$yml = GUICtrlCreateInput("", 11, 85, 290, 20)
$Button = GUICtrlCreateButton("Create Folder / Copy File", 10, 115, 220, 25)
$Button1 = GUICtrlCreateButton("Remove All", 240, 115, 134, 25)
$Button2 = GUICtrlCreateButton("Select Folder", 305, 84, 80, 22)
$Button3 = HotKeySet("{ESC}", "Terminate")
$xs = GUICtrlCreateLabel("0/0 ", 175, 170, 300, 15)
GUICtrlSetColor(-1, 0xff0000)
$jdt = GUICtrlCreateProgress(10, 150, 365, 12,$PBS_SMOOTH)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
exit
Case $Button
GUICtrlSetData($jdt, 0)
GUICtrlSetState($Button, $GUI_ENABLE)
Dim $ywc = 0, $zs = 0, $sc = 1,$f,$h
jc()
AdlibEnable("jdt")
If GUICtrlRead($s) = 0 then
msgbox(16, 'Error', 'Please set the number of folders')
Else
$f=MsgBox(1+48,'Attention','You will create ' & $zs & ' folders.' &@CRLF& 'Do you wish to continue?')
Select
Case $f=1
scml()
sleep(300)
AdlibDisable()
msgbox(64, 'Finish', 'Created' & $zs & 'Folders! ')
Case $f=2
ContinueLoop
EndSelect
DirMove('f1','.MP3', 1)
EndIf
GUICtrlSetState($Button,$GUI_ENABLE)
Case $Button1
$h=MsgBox(1+48,'Attention','Are you suren you want to Delete all the folders ?')
Select
Case $h=1
Del()
Case $h=2
ContinueLoop
EndSelect
Case $Button2
$ywjj = FileSelectFolder("Choose The Folder", "", 4)
If @error Then ContinueLoop
GUICtrlSetData($yml, $ywjj)
Case $Button3
Terminate()
EndSwitch
WEnd
Func Del()
DirRemove('.MP3',1)
EndFunc
Func jc()
For $i = 14 To 1 Step -1
$sl = GUICtrlRead($s[$i])
If $sl > 0 then
For $i1 = 1 To $i
$sl1 = GUICtrlRead($s[$i1])
If $sl1 = 0 then
GUICtrlSetData($s[$i1], 1)
$sl1 = 1
endif
$zs = $zs + ($sc * $sl1)
$sc = $sc * $sl1
Next
ExitLoop
Endif
Next
EndFunc ;==>jc
Func Terminate()
Exit 0
EndFunc
Func scml()
$ymlr = GUICtrlRead($yml)
$sl1 = GUICtrlRead($s)
For $i1 = 1 To $sl1
$fn1 = 'F'
$xml1 = $fn1 & $i1
DirCreate($xml1)
if $ymlr <> '' then DirCopy($ymlr, $xml1, 1)
$ywc = $ywc + 1
$sl2 = GUICtrlRead($s)
For $i2 = 1 To $sl2
$fn2 = $fn1 & $i1
$xml2 = $fn2 & '\' & $fn2 & '-' & $i2
DirCreate($xml2)
if $ymlr <> '' then DirCopy($ymlr, $xml2, 1)
$ywc = $ywc + 1
$sl3 = GUICtrlRead($s)
For $i3 = 1 To $sl3
$fn3 = $fn2 & '-' & $i2
$xml3 = $fn2 & '\' & $fn3 & '\' & $fn3 & '-' & $i3
DirCreate($xml3)
if $ymlr <> '' then DirCopy($ymlr, $xml3, 1)
$ywc = $ywc + 1
$sl4 = GUICtrlRead($s)
For $i4 = 1 To $sl4
$fn4 = $fn3 & '-' & $i3
$xml4 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn4 & '-' & $i4
DirCreate($xml4)
if $ymlr <> '' then DirCopy($ymlr, $xml4, 1)
$ywc = $ywc + 1
$sl5 = GUICtrlRead($s)
For $i5 = 1 To $sl5
$fn5 = $fn4 & '-' & $i4
$xml5 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn5 & '-' & $i5
DirCreate($xml5)
if $ymlr <> '' then DirCopy($ymlr, $xml5, 1)
$ywc = $ywc + 1
$sl6 = GUICtrlRead($s)
For $i6 = 1 To $sl6
$fn6 = $fn5 & '-' & $i5
$xml6 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn6 & '-' & $i6
DirCreate($xml6)
if $ymlr <> '' then DirCopy($ymlr, $xml6, 1)
$ywc = $ywc + 1
$sl7 = GUICtrlRead($s)
For $i7 = 1 To $sl7
$fn7 = $fn6 & '-' & $i6
$xml7 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn7 & '-' & $i7
DirCreate($xml7)
if $ymlr <> '' then DirCopy($ymlr, $xml7, 1)
$ywc = $ywc + 1
$sl8 = GUICtrlRead($s)
For $i8 = 1 To $sl8
$fn8 = $fn7 & '-' & $i7
$xml8 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn8 & '-' & $i8
DirCreate($xml8)
if $ymlr <> '' then DirCopy($ymlr, $xml8, 1)
$ywc = $ywc + 1
$sl9 = GUICtrlRead($s)
For $i9 = 1 To $sl9
$fn9 = $fn8 & '-' & $i8
$xml9 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn9 & '-' & $i9
DirCreate($xml9)
if $ymlr <> '' then DirCopy($ymlr, $xml9, 1)
$ywc = $ywc + 1
$sl10 = GUICtrlRead($s)
For $i10 = 1 To $sl10
$fn10 = $fn9 & '-' & $i9
$xml10 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\' & $fn10 & '-' & $i10
DirCreate($xml10)
if $ymlr <> '' then DirCopy($ymlr, $xml10, 1)
$ywc = $ywc + 1
$sl11 = GUICtrlRead($s)
For $i11 = 1 To $sl11
$fn11 = $fn10 & '-' & $i10
$xml11 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\'& $fn11 & '\' & $fn11 & '-' & $i11
DirCreate($xml11)
if $ymlr <> '' then DirCopy($ymlr, $xml11, 1)
$ywc = $ywc + 1
$sl12 = GUICtrlRead($s)
For $i12 = 1 To $sl12
$fn12 = $fn11 & '-' & $i11
$xml12 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\'& $fn11 & '\'& $fn12 & '\' & $fn12 & '-' & $i12
DirCreate($xml12)
if $ymlr <> '' then DirCopy($ymlr, $xml12, 1)
$ywc = $ywc + 1
$sl13 = GUICtrlRead($s)
For $i13 = 1 To $sl13
$fn13 = $fn12 & '-' & $i12
$xml13 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\'& $fn11 & '\'& $fn12 & '\'& $fn13 & '\' & $fn13 & '-' & $i13
DirCreate($xml13)
if $ymlr <> '' then DirCopy($ymlr, $xml13, 1)
$ywc = $ywc + 1
$sl14 = GUICtrlRead($s)
For $i14 = 1 To $sl14
$fn14 = $fn13 & '-' & $i13
$xml14 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\'& $fn11 & '\'& $fn12 & '\'& $fn13 & '\'& $fn14 & '\' & $fn14 & '-' & $i14
DirCreate($xml14)
if $ymlr <> '' then DirCopy($ymlr, $xml14, 1)
$ywc = $ywc + 1
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Endfunc ;==>scml
Func jdt()
GUICtrlSetData($jdt, $ywc / $zs * 100)
GUICtrlSetData($xs, $ywc & '/' & $zs)
EndFunc ;==>jdt
EndFunc ;==> MP3
afan
发表于 2009-7-24 12:35:19
你是想将其作为子窗口弹出? 代码肯定有问题~
xavier880819
发表于 2009-7-24 13:00:37
43# afan
对,就是想按下那个键,就可以作为子窗口弹出。我试过,就是在func mp3()里面的代码都没有问题,就是加了那个Call作为主程序以后,就提示错误了,但是我又看不出错在哪里。
afan
发表于 2009-7-24 13:08:20
Func应该是不能嵌套使用的吧~~ 整个函数嵌套在func mp3()里面应该不行