#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author: pat4005
Script Function:
Copying statistic Z_* files from PID-PC 2 USB-drive
#ce ----------------------------------------------------------------------------
; Script Start
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <Misc.au3>
#include <File.au3>
FileCreateShortcut(@ScriptFullPath, @StartupDir&"\CS.lnk")
HotKeySet("+!^{END}", "_Block")
HotKeySet("+!^{HOME}", "_UnBlock")
HotKeySet("+!^{INSERT}", "_CopyStat")
Global Const $WM_DEVICECHANGE = 0x0219
Global Const $DBT_DEVICEARRIVAL = 0x8000 ; Найдено новое устройство
Global Const $DBT_DEVICEREMOVECOMPLETE = 0x8004 ; Устройство отключено
Global Const $DBT_DEVTYP_VOLUME = 0x00000002 ; Логический диск
Global $iDrive
Global $disk
$Gui = GUICreate("WM_DEVICECHANGE", 370, 140)
GUIRegisterMsg($WM_DEVICECHANGE, "WM_DEVICECHANGE")
Do
Until GUIGetMsg() = -3
Func _CopyStat()
$kontur = _FileListToArray('C:', 'kontur*', 2)
$1=InputBox("Какова твоя станция?","Введите первые 3 лат. буквы названия станции, pls!")
If $1="3km" then
$success=FileCopy("C:\"&$kontur[1]&"\stat\Z*.*",$iDrive&"\6Statistika\1stat(3km)\*.*",8)
MsgBox(4128,"Мессага","Копирование ЗАВЕРШЕНО блеать! Результат is "&$success,2)
EndIf
If $1="5km" then
MsgBox(0,"",$iDrive)
$success=FileCopy("C:\"&$kontur[1]&"\stat\Z*.*",$iDrive&"\6Statistika\2stat(5km)\*.*",8)
MsgBox(4128,"Мессага","Копирование ЗАВЕРШЕНО блеать! Результат is "&$success,2)
EndIf
If $1="ino" then
$success=FileCopy("C:\"&$kontur[1]&"\stat\Z*.*",$iDrive&"\6Statistika\3stat(ino)\*.*",8)
MsgBox(4128,"Мессага","Копирование ЗАВЕРШЕНО блеать! Результат is "&$success,2)
EndIf
If $1="mas" then
$success=FileCopy("C:\"&$kontur[1]&"\stat\Z*.*",$iDrive&"\6Statistika\4stat(mas)\*.*",8)
MsgBox(4128,"Мессага","Копирование ЗАВЕРШЕНО блеать! Результат is "&$success,2)
EndIf
If $1="ler" then
$success=FileCopy("C:\"&$kontur[1]&"\stat\Z*.*",$iDrive&"\6Statistika\5stat(ler)\*.*",8)
MsgBox(4128,"Мессага","Копирование ЗАВЕРШЕНО блеать! Результат is "&$success,2)
EndIf
If $1="ska" then
$success=FileCopy("C:\"&$kontur[1]&"\stat\Z*.*",$iDrive&"\6Statistika\6stat(ska)\*.*",8)
MsgBox(4128,"Мессага","Копирование ЗАВЕРШЕНО блеать! Результат is "&$success,2)
EndIf
If $1="zol" then
$success=FileCopy("C:\"&$kontur[1]&"\stat\Z*.*",$iDrive&"\6Statistika\7stat(zol)\*.*",8)
MsgBox(4128,"Мессага","Копирование ЗАВЕРШЕНО блеать! Результат is "&$success,2)
EndIf
If $1="pod" then
$success=FileCopy("C:\"&$kontur[1]&"\stat\Z*.*",$iDrive&"\6Statistika\8stat(pod)\*.*",8)
MsgBox(4128,"Мессага","Копирование ЗАВЕРШЕНО блеать! Результат is "&$success,2)
EndIf
If $1="min" then
$success=FileCopy("C:\"&$kontur[1]&"\stat\Z*.*",$iDrive&"\6Statistika\9stat(min)\*.*",8)
MsgBox(4128,"Мессага","Копирование ЗАВЕРШЕНО блеать! Результат is "&$success,2)
EndIf
If $1="kis" then
$success=FileCopy("C:\"&$kontur[1]&"\stat\Z*.*",$iDrive&"\6Statistika\10stat(kis)\*.*",8)
MsgBox(4128,"Мессага","Копирование ЗАВЕРШЕНО блеать! Результат is "&$success,2)
EndIf
EndFunc
Func _Quit()
Exit
EndFunc
Func WM_DEVICECHANGE($hWnd, $Msg, $wParam, $lParam)
If ($wParam = $DBT_DEVICEARRIVAL) Or ($wParam = $DBT_DEVICEREMOVECOMPLETE) Then
Local $DEV_BROADCAST_VOLUME = DllStructCreate("int dbcvsize;int dbcvdevicetype;int dbcvreserved;int dbcvunitmask;" & _
"ushort dbcvflags", $lParam)
Local $iDriveType = DllStructGetData($DEV_BROADCAST_VOLUME, "dbcvdevicetype")
Else
Return $GUI_RUNDEFMSG
EndIf
; Если устройство не является логическим диском, то выход из функции
If $iDriveType <> $DBT_DEVTYP_VOLUME Then Return $GUI_RUNDEFMSG
Local $iMask = DllStructGetData($DEV_BROADCAST_VOLUME, "dbcvunitmask")
$iMask = Log($iMask) / Log(2)
Local $iDrive = Chr(65 + $iMask) & ":"
Switch $wParam
Case $DBT_DEVICEARRIVAL ; обнаружение устройства
TrayTip("WM_DEVICECHANGE", "Устройство подключено", 5, 1)
Case $DBT_DEVICEREMOVECOMPLETE ; отключение устройства
TrayTip("WM_DEVICECHANGE", "Устройство отключено", 5, 2)
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc