使用autoIT调用bat文件的问题
本帖最后由 xavier880819 于 2009-7-27 09:07 编辑小弟有个bat的文件,每次都要进去dos调用,请问是否可以直接用autoIT写一个程序直接调用呢?这样就可以有用户控制面板,就人人都可以使用我这个bat的文件了。
谢谢大家 批量创建文件夹
用au3自己的命令写都很方便啦 2# lynfr8
请问怎么样可以做到呢??能不能教教我呢??
能够不调用BAT也最好啊。
谢谢 DirCreate
--------------------------------------------------------------------------------
新建一个目录/文件夹.
DirCreate ( "路径" )
批量创建自己写个数组+循环就可以了 DirCreate 创建目录 =Md
DirCopy 复制目录 =Xcopy
DirMove 移动目录 =Move
DirRemove 删除目录=Rd 谢谢各位
但是可不可以帮我说得详细点的呢??因为我刚刚才开始上手AutoIT,很多东西都还不懂。现在都才开始从最基本的教程开始学。希望能够得到大家的帮助。 我的目的主要是要创建多层的文件夹
打个比方来说是这样的,第一层有4个文件夹就是f1,f2,f3,f4.第二层(在每个文件夹下都)有5个文件夹就是f1-1,f1-2,f1-3,f1-4,f1-5.然后是f2-1,f2-2,f2-3,f2-4,f2-5. f3-1,f3-2,f3-3,f3-4,f3-5. f4-1,f4-2,f4-3,f4-4,f4-5.
以此类推可以一层一层可以批量建立多层的文件夹。
我目前只能用bat做到,但是那样就是每次都需要用DOS调用,很麻烦。而AUTOIT是有用户界面的,使用起来应该也方便很多很多。是不是也可以做到这样批量创建文件夹呢??
谢谢大家的不吝赐教。 本帖最后由 afan 于 2009-7-21 00:56 编辑
我是新手,试试~
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#NoTrayIcon
$Form1 = GUICreate('多层文件夹生成工具', 370, 108)
Dim $l, $s
For $n = 1 To 9
$l[$n] = GUICtrlCreateLabel("第" & $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
$Button = GUICtrlCreateButton("生成文件夹(&G)", 80, 65, 190, 25)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
exit
Case $Button
jc()
scml()
msgbox(0, '完成', '创建完成! ')
EndSwitch
WEnd
Func jc()
For $i = 9 To 1 Step -1
$sl = GUICtrlRead($s[$i])
If $sl > 0 then
For $i1 = 1 To $i
If GUICtrlRead($s[$i1]) = 0 then GUICtrlSetData($s[$i1], 1)
Next
ExitLoop
Endif
Next
EndFunc ;==>jc
Func scml()
$sl1 = GUICtrlRead($s)
For $i1 = 1 To $sl1
$fn1 = 'F'
DirCreate($fn1 & $i1)
$sl2 = GUICtrlRead($s)
For $i2 = 1 To $sl2
$fn2 = $fn1 & $i1
DirCreate($fn2 & '\' & $fn2 & '-' & $i2)
$sl3 = GUICtrlRead($s)
For $i3 = 1 To $sl3
$fn3 = $fn2 & '-' & $i2
DirCreate($fn2 & '\' & $fn3 & '\' & $fn3 & '-' & $i3)
$sl4 = GUICtrlRead($s)
For $i4 = 1 To $sl4
$fn4 = $fn3 & '-' & $i3
DirCreate($fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn4 & '-' & $i4)
$sl5 = GUICtrlRead($s)
For $i5 = 1 To $sl5
$fn5 = $fn4 & '-' & $i4
DirCreate($fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn5 & '-' & $i5)
$sl6 = GUICtrlRead($s)
For $i6 = 1 To $sl6
$fn6 = $fn5 & '-' & $i5
DirCreate($fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn6 & '-' & $i6)
$sl7 = GUICtrlRead($s)
For $i7 = 1 To $sl7
$fn7 = $fn6 & '-' & $i6
DirCreate($fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn7 & '-' & $i7)
$sl8 = GUICtrlRead($s)
For $i8 = 1 To $sl8
$fn8 = $fn7 & '-' & $i7
DirCreate($fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn8 & '-' & $i8)
$sl9 = GUICtrlRead($s)
For $i9 = 1 To $sl9
$fn9 = $fn8 & '-' & $i8
DirCreate($fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn9 & '-' & $i9)
Next
Next
Next
Next
Next
Next
Next
Next
Next
Endfunc ;==>scml 楼上高手啊!!你都不是初学者了,对于我来说,你很强了!!非常感谢您!!
不过我还想知道,如果继续加多层数是不是直接加就可以了呢??
还有就是能不能在建立文件夹的时候显示进度条呢??
谢谢您的赐教!! 我是菜鸟…… 呵呵,略知一二~~
可以继续添加层数,在界面处稍加调整,然后增加添加层数的循环就行了~
显示进度条也可以,不过我是新手,没玩过~ 想了想,先计算总数,然后每生成一个文件夹传递一次变量,用AdlibEnable() 调用进度条,应该就 OK 了~ 你先试试吧,我也试试~ 好的,我也尝试一下,再次谢谢你! 本帖最后由 afan 于 2009-7-21 01:06 编辑
头大了一圈……
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#NoTrayIcon
$Form1 = GUICreate('多层文件夹生成工具', 385, 125)
Dim $n = 1, $l, $s
For $n = 1 To 10
$l[$n] = GUICtrlCreateLabel("第" & $n & "层", 12 + 74 * ($n - (Int(($n - 1) / 5)) * 5 - 1), 23 + 20 * (Int(($n - 1) / 5)), 37, 16)
$s[$n] = GUICtrlCreateInput("0", 46 + 74 * ($n - (Int(($n - 1) / 5)) * 5 - 1), 20 + 20 * (Int(($n - 1) / 5)), 30, 16, $ES_NUMBER)
GUICtrlSetLimit(-1, 4)
Next
$Button = GUICtrlCreateButton("生成文件夹(&G)", 80, 70, 190, 25)
$xs = GUICtrlCreateLabel("0/0", 290, 83, 80, 15)
GUICtrlSetColor(-1, 0x0000FF)
$jdt = GUICtrlCreateProgress(10, 100, 365, 12)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
exit
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 & ' 个文件夹完成! ')
endif
GUICtrlSetState($Button, $GUI_ENABLE)
EndSwitch
WEnd
Func jc()
For $i = 10 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 scml()
$sl1 = GUICtrlRead($s)
For $i1 = 1 To $sl1
$fn1 = 'F'
DirCreate($fn1 & $i1)
$ywc = $ywc + 1
$sl2 = GUICtrlRead($s)
For $i2 = 1 To $sl2
$fn2 = $fn1 & $i1
DirCreate($fn2 & '\' & $fn2 & '-' & $i2)
$ywc = $ywc + 1
$sl3 = GUICtrlRead($s)
For $i3 = 1 To $sl3
$fn3 = $fn2 & '-' & $i2
DirCreate($fn2 & '\' & $fn3 & '\' & $fn3 & '-' & $i3)
$ywc = $ywc + 1
$sl4 = GUICtrlRead($s)
For $i4 = 1 To $sl4
$fn4 = $fn3 & '-' & $i3
DirCreate($fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn4 & '-' & $i4)
$ywc = $ywc + 1
$sl5 = GUICtrlRead($s)
For $i5 = 1 To $sl5
$fn5 = $fn4 & '-' & $i4
DirCreate($fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn5 & '-' & $i5)
$ywc = $ywc + 1
$sl6 = GUICtrlRead($s)
For $i6 = 1 To $sl6
$fn6 = $fn5 & '-' & $i5
DirCreate($fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn6 & '-' & $i6)
$ywc = $ywc + 1
$sl7 = GUICtrlRead($s)
For $i7 = 1 To $sl7
$fn7 = $fn6 & '-' & $i6
DirCreate($fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn7 & '-' & $i7)
$ywc = $ywc + 1
$sl8 = GUICtrlRead($s)
For $i8 = 1 To $sl8
$fn8 = $fn7 & '-' & $i7
DirCreate($fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn8 & '-' & $i8)
$ywc = $ywc + 1
$sl9 = GUICtrlRead($s)
For $i9 = 1 To $sl9
$fn9 = $fn8 & '-' & $i8
DirCreate($fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn9 & '-' & $i9)
$ywc = $ywc + 1
$sl10 = GUICtrlRead($s)
For $i10 = 1 To $sl10
$fn10 = $fn9 & '-' & $i9
DirCreate($fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\' & $fn10 & '-' & $i10)
$ywc = $ywc + 1
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
呵呵,谢谢加分的大虾们~ 修改了下进度条显示,现在更精确 很好,可以当成一个实用工具了