#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
; 创建GUI
$Form1 = GUICreate("AutoIt GUI Example", 400, 200)
$Label1 = GUICtrlCreateLabel("选择目标文件夹:", 10, 10, 120, 20)
$Input1 = GUICtrlCreateInput("", 140, 10, 200, 20)
$Browse1 = GUICtrlCreateButton("浏览...", 350, 10, 40, 20)
$Label2 = GUICtrlCreateLabel("创建新文件夹:", 10, 50, 120, 20)
$Input2 = GUICtrlCreateInput("", 140, 50, 200, 20)
$Browse2 = GUICtrlCreateButton("浏览...", 350, 50, 40, 20)
$StartButton = GUICtrlCreateButton("开始", 150, 100, 100, 30)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit`
Case $Browse1
$source_folder = FileSelectFolder("选择目标文件夹", "")
If Not @error Then
GUICtrlSetData($Input1, $source_folder)
EndIf
Case $Browse2
$destination_folder = FileSelectFolder("选择新文件夹位置", "")
If Not @error Then
$new_folder = InputBox("创建新文件夹", "请输入新文件夹名称", "")
If $new_folder <> "" Then
$destination_folder &= "\" & $new_folder
DirCreate($destination_folder)
GUICtrlSetData($Input2, $destination_folder)
EndIf
EndIf
Case $StartButton
$source_folder = GUICtrlRead($Input1)
$destination_folder = GUICtrlRead($Input2)
If $source_folder <> "" And $destination_folder <> "" Then
; 复制EXE和DLL文件
FileCopy($source_folder & "\*.exe", $destination_folder)
FileCopy($source_folder & "\*.dll", $destination_folder)
; 打开目标程序并自动化操作
Run("C:\path\to\target_program.exe")
WinWaitActive("目标程序窗口标题")
; 模拟操作,具体操作视实际应用而定
; 例如:选择文件、勾选选项、保存
Send("!f") ; 打开文件菜单
Send("a") ; 选择添加文件
WinWaitActive("打开")
Send($destination_folder & "\*.exe{ENTER}")
Send($destination_folder & "\*.dll{ENTER}")
ControlClick("目标程序窗口标题", "", "复选框ID")
Send("!f") ; 打开文件菜单
Send("s") ; 保存
Sleep(5000) ; 等待保存完成
WinClose("目标程序窗口标题")
WinWaitClose("目标程序窗口标题")
MsgBox($MB_OK, "完成", "操作已完成")
Else
MsgBox($MB_OK, "错误", "请选择目标文件夹和创建新文件夹")
EndIf
EndSwitch
WEnd
标签:20,demo,destination,source,文件夹,folder,include
From: https://www.cnblogs.com/LoveForeverIT/p/18278441