Что нового

[Элементы GUI] Связка Button1 и DirCopy

Arbios

Новичок
Сообщения
18
Репутация
0
Всем привет! Решил написать программку которая бы копировала директории из одной в другую.
Сделал элементы GUI через Koda, с DirCopy и DirMove разобрался с горем пополам, а теперь возник вопрос как связать функции и кнопки. Например по нажатии Button1 делать DirCopy, по нажатии Button2 - DirMove и т.д..


Код:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$GUI = GUICreate("Проба", 288, 130, 309, 283)
$Input1 = GUICtrlCreateInput("", 40, 16, 209, 21)
$Button1 = GUICtrlCreateButton("Резервировать", 42, 48, 98, 25)
$Button2 = GUICtrlCreateButton("Удалить", 42, 80, 98, 25)
$Button3 = GUICtrlCreateButton("Восстановить", 150, 48, 98, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ##

If $Button1 = 'Резервировать' Then DirCopy ( "C:\Dest", "C:\Folder", 1)
If $Button2 = 'Удалить' Then DirMove ( "Dest", "C:\Removed", 1)
If $Button3 = 'Восстановить' Then DirCopy ( "C:\Folder", "C:\Dest", 1)

Заранее спасибо!)
 

WSWR

AutoIT Гуру
Сообщения
941
Репутация
363
Arbios

Код:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#region ### START Koda GUI section ### Form=
$GUI = GUICreate("Проба", 288, 130, 309, 283)
$Input1 = GUICtrlCreateInput("", 40, 16, 209, 21)
$Button1 = GUICtrlCreateButton("Резервировать", 42, 48, 98, 25)
$Button2 = GUICtrlCreateButton("Удалить", 42, 80, 98, 25)
$Button3 = GUICtrlCreateButton("Восстановить", 150, 48, 98, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ##

While 1

	Switch GUIGetMsg()
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			DirCopy("C:\Dest", "C:\Folder", 1)
		Case $Button2
			DirMove("Dest", "C:\Removed", 1)
		Case $Button3
			DirCopy("C:\Folder", "C:\Dest", 1)
	EndSwitch

WEnd



В Koda Tools - Generate Form Code... или нажать F9, будет сгенерирован код с событиями
 
Автор
Arbios

Arbios

Новичок
Сообщения
18
Репутация
0
Большое спасибо, очень помог. То, что надо. )) ;) :IL_AutoIt_2:
 
Верх