求救 怎么使用复选框 来执行复制多个已经勾选的文件?
本帖最后由 pzypdl2006 于 2017-9-16 12:37 编辑窗口的代码如下:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("COPY选择", 615, 437, 195, 130)
$Button_COPY = GUICtrlCreateButton("COPY", 152, 335, 113, 57)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
$Group_SOFT = GUICtrlCreateGroup("SOFT", 40, 32, 129, 209)
$QQ = GUICtrlCreateCheckbox("QQ", 64, 56, 75, 18)
$WINRAR = GUICtrlCreateCheckbox("解压缩", 64, 80, 75, 17)
$OFFICE07 = GUICtrlCreateCheckbox("OFFICE07", 64, 104, 75, 17)
$ALLINONE = GUICtrlCreateCheckbox("ALLINONE", 64, 128, 75, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group_TOOL = GUICtrlCreateGroup("TOOL", 200, 32, 169, 209)
$IObitU = GUICtrlCreateCheckbox("IObitU", 224, 56, 75, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button_OPEN = GUICtrlCreateButton("OPEN", 311, 335, 113, 57)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
$Group1 = GUICtrlCreateGroup("Group1", 400, 32, 169, 209)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
如何做到勾选QQ、解压缩包后,点击COPY按钮,就可以将勾选的软件安装包拷贝到电脑的C盘1这个文件夹?
已经知道“创建文件夹”和“复制文件到某位置”的命令。
流程是:
打开窗口界面——>勾选所需的软件名——>点击COPY按钮——>程序执行拷贝所选文件到指定的文件夹中
哪位大神可以提供个思路? 想到的思路是
①先声明变量每个软件包所在的路径
②点击COPY按钮时候,获取已经勾选的软件名
③根据第二步获取到的软件名对应的路径,然后依次执行每个文件拷贝命令 就是不知道具体的代码怎么写,特别是让程序获取已经勾选的软件名对应的路径
Local $idQQ = GUICtrlCreateCheckbox("QQ", 10, 10, 185, 25)
;====中略
if BitAND(GUICtrlRead($idQQ ), $GUI_CHECKED) = $GUI_CHECKED Then
;===略
把软件路径等等对应信息存储在配置文件里.
...
与其花心思自己空想,还不如直接在论坛里搜索现在的源码例子? #include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("COPY选择", 615, 437, 195, 130)
$Button_COPY = GUICtrlCreateButton("COPY", 152, 335, 113, 57)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
$Group_SOFT = GUICtrlCreateGroup("SOFT", 40, 32, 129, 209)
$QQ = GUICtrlCreateCheckbox("QQ", 64, 56, 75, 18)
$WINRAR = GUICtrlCreateCheckbox("解压缩", 64, 80, 75, 17)
$OFFICE07 = GUICtrlCreateCheckbox("OFFICE07", 64, 104, 75, 17)
$ALLINONE = GUICtrlCreateCheckbox("ALLINONE", 64, 128, 75, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group_TOOL = GUICtrlCreateGroup("TOOL", 200, 32, 169, 209)
$IObitU = GUICtrlCreateCheckbox("IObitU", 224, 56, 75, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button_OPEN = GUICtrlCreateButton("OPEN", 311, 335, 113, 57)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
$Group1 = GUICtrlCreateGroup("Group1", 400, 32, 169, 209)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button_COPY
_Copy()
EndSwitch
WEnd
Func _Copy()
Local $aAry = ['QQ','WINRAR','OFFICE07','ALLINONE','IObitU']
For $i = 0 To UBound($aAry) - 1
If GUICtrlRead(Eval($aAry[$i])) = 1 Then MsgBox(512,'','选择安装 ' & $aAry[$i],1,$Form1)
Next
EndFunc看看这样是否符合你的需求 回复 6# zghwelcome
你的代码可以达到效果,自己根据实际需要修改了下,就不行了
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button_COPY
$NON_DIR =IniRead("NON_CORY.INI","main_ini","NON_DIR","ERROR")
DirCreate(@DesktopDir & $NON_DIR)
_Copy()
EndSwitch
WEnd
Func _Copy()
Local $aAry =
;Local $aAry = ['QQ','WINRAR','OFFICE07','ALLINONE','IObitU']
For $i = 0 To UBound($aAry) - 1
If GUICtrlRead(Eval($aAry[$i])) = 1 Then Run($aAry[$i])
Next
EndFunc
Func _QQ()
FileCopy(IniRead("NON_CORY.ini","soft","QQ","ERROR"),@DesktopDir & $NON_DIR)
EndFunc
Func _WINRAR()
FileCopy(IniRead("NON_CORY.ini","soft","WINRAR","ERROR"),@DesktopDir & $NON_DIR)
EndFunc
Func _OFFICE07()
FileCopy(IniRead("NON_CORY.ini","soft","OFFICE07","ERROR"),@DesktopDir & $NON_DIR)
EndFunc
Func _ALLINONE()
FileCopy(IniRead("NON_CORY.ini","soft","集合包","ERROR"),@DesktopDir & $NON_DIR)
EndFunc
Func _IOBITU()
FileCopy(IniRead("NON_CORY.ini","soft","IOBITU","ERROR"),@DesktopDir & $NON_DIR)
EndFuncini的配置文件是
NON_DIR="\NON"
WINRAR=c:\1\WINRAR.txt
QQ=c:\1\QQ.txt
OFFICE03=c:\1\OFFICE03.txt
OFFICE07=c:\1\OFFICE07.txt
WPS=c:\1\WPS.txt
集合包=c:\1\2345.txt
IOBITU=c:\1\IOBITU.txt
WINXP=
WIN7_32=
WIN7_64=
WIN10_64= {:face (356):}run???建议楼主多学学基础 学习 学习 谢谢楼主分享 回复 8# yamakawa
是啊需要多学习学习基础,~~~~(>_<)~~~~ 回复 8# yamakawa
是啊需要多学习学习基础,~~~~(>_<)~~~~
望指点下^_^ 回复 11# pzypdl2006
随便写的,未做详细测试,仅供参考#cs
ACN论坛 Yamakawa涂鸦之作,仅供参考,贻笑方家了!
#ce
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
Local $softArray = IniReadSection(@ScriptDir & "\NON_CORY.ini", "soft")
Local $idArray[$softArray + 1]
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("COPY选择", 615, 437, 195, 130)
$Button_COPY = GUICtrlCreateButton("COPY", 152, 335, 113, 57)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
$Group_SOFT = GUICtrlCreateGroup("SOFT", 40, 32, 129, 209)
For $i = 1 To $softArray
$idArray[$i] = GUICtrlCreateCheckbox($softArray[$i], 64, 56 + ($i - 1) * 24, 75, 18)
Next
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button_COPY
For $i = 1 To $softArray
If BitAND(GUICtrlRead($idArray[$i]), $GUI_CHECKED) = $GUI_CHECKED Then MsgBox(0, "", "你选择了 " & $softArray[$i])
Next
EndSwitch
WEnd
页:
[1]