Автор: wicked_boy
Дата сообщения: 08.10.2007 11:18
Помогите разобраться
есть вот такой код:
Код: #include <GUIConstants.au3>
#include <file.au3>
AutoItSetOption ( "TrayIconHide", 1 )
dim $temp="C:\"
Dim $imagemagik
Dim $list
;---------------------------------------------------------------------------------------
;Поиск в Program Files папки imagemagik с возмложными вариациями
RunWait(@ComSpec & " /c "&"dir /B imagemagi* >"&$temp&"\temp.txt",@ProgramFilesDir,@SW_HIDE)
If Not _FileReadToArray($temp&"\temp.txt",$imagemagik) Then
MsgBox(4096,"Error", "Невозможно прочитать временный файл")
Exit
EndIf
$imagemagick=$imagemagik[1]
FileDelete($temp&"\temp.txt")
;---------------------------------------------------------------------------------------
GUICreate(" Перетащите папку для преобразования", 360,190, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, 0x00000018); WS_EX_ACCEPTFILES
GUICtrlCreateLabel ( "Папка - источник", 10, 10, 300, 20 )
$input_dir = GUICtrlCreateInput ( "", 10, 25, 300, 20)
GUICtrlSetState(-1,$GUI_DROPACCEPTED)
GUICtrlCreateLabel ( "Папка - получатель", 10, 55 , 300, 20 )
$output_dir = GUICtrlCreateInput ("", 10, 70, 300, 20)
GUICtrlSetState(-1,$GUI_DROPACCEPTED)
GUICtrlCreateLabel ( "Начальный индекс", 10, 100, 300, 20 )
$start_index=GUICtrlCreateInput ("", 10, 115, 100, 20)
$btn = GUICtrlCreateButton ("Поехали!", 160, 160, 60, 20)
GUISetState ()
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
Case $msg = $btn
exitloop
Case $msg = $GUI_EVENT_CLOSE
exit
EndSelect
Wend
list_of_files(GUICtrlRead($input_dir))
work(GUICtrlRead($input_dir), GUICtrlRead($output_dir), GUICtrlRead($start_index))
Exit
Func list_of_files($dir)
$string=$temp&"\temp.cmd"
FileDelete($string)
$file=FileOpen($string,1)
FileWriteLine($file,"dir /B /TC /OD "&$dir&"\*.jpg >"&$temp&"\temp.txt")
FileClose($file)
RunWait($temp&"\temp.cmd","",@SW_HIDE)
If Not _FileReadToArray($temp&"\temp.txt",$list) Then
MsgBox(4096,"Error", "Невозможно прочитать временный файл")
Exit
EndIf
FileClose($temp&"\temp.cmd")
FileClose($temp&"\temp.txt")
FileDelete($temp&"\temp.cmd")
FileDelete($temp&"\temp.txt")
EndFunc
func work($input, $output, $index)
$x=1
$y=1
$z=1
$number=1
$txt=$output&"\list.txt"
$list2 = FileOpen($txt, 1)
DirCreate($output&"\Fotki_big")
dim $counter=1
$files = FileFindFirstFile($input&"*.jpg")
while 1
$file2 = FileFindNextFile($files)
if @error Then ExitLoop
$counter=$counter+1
WEnd
$counter=$counter-1
;MsgBox("","",$list[1])
for $x=1 to $list[0]-1
$string=$temp&"\temp.cmd"
FileDelete($string)
$file=FileOpen($string,1)
FileWriteLine($file,"identify "&$input&"\"&$list[$z]& ">"&$temp&"temp.txt")
FileClose($file)
RunWait($temp&"\temp.cmd","",@SW_HIDE)
$file = FileOpen($temp&"\temp.txt", 0)
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
$line = FileReadLine($file, 1)
if $line =" " Then
MsgBox(0,"Error", "Файл параметров файла пуст")
Exit
EndIf
FileClose($file)
$array=StringSplit ( $line, " ")
$array=StringSplit ($array[3], "x")
$shirina = $array[1]
$visota = $array[2]
;MsgBox("","",$visota)
Select
Case $z >= 1 AND $z < 10
$filename="000"&$z&".jpg"
$number="000"&$z
Case $z >= 10 AND $z < 100
$filename="00"&$z&".jpg"
$number="00"&$z
Case $z >= 100
$filename="0"&$z&".jpg"
$number="0"&$z
EndSelect
FileDelete($string)
$file=FileOpen($string,1)
FileWriteLine($file,"convert "&$input&"\"&$list[$x]& " -resize 800 "&$output&"\Fotki_big\"&$filename)
FileClose($file)
RunWait($temp&"\temp.cmd","",@SW_HIDE)
$html=$output&"\"&$number&".html"
;MsgBox("","",$html)
$123 = FileOpen($html, 1)
FileWriteLine($123,Chr(60)&"HTML>")
FileWriteLine($123,Chr(60)&"HEAD>")
FileWriteLine($123,Chr(60)&"TITLE>Отдых в дельте Днестра</TITLE>")
FileWriteLine($123,Chr(60)&"/HEAD>")
FileWriteLine($123,Chr(60)&'BODY bgcolor="#cccc99" background="otdih_background.gif">')
FileWriteLine($123,Chr(60)&'P style="margin-left: 20px; font-weight: bold; font-style: italic">')
FileWriteLine($123,Chr(60)&'IMG src="Fotki_big/'&$filename&'">')
FileWriteLine($123,Chr(60)&"/BODY>")
FileWriteLine($123,Chr(60)&"/HTML>")
FileClose($123)
if $y=1 then
FileWriteLine($list,'<TR height="105"> ')
endif
FileWriteLine($list2,'<TD width="145" align="middle" valign="middle">')
if $visota>$shirina then
FileWriteLine($list2,'<A href='&$number&'.html target="_blank"><IMG src="Fotki_big/'&$filename&'" width="93" height="125" " alt="Закат на Днестре" border="0"></A>')
Else
FileWriteLine($list2,'<A href='&$number&'.html target="_blank"><IMG src="Fotki_big/'&$filename&'" width="125" height="93" " alt="Закат на Днестре" border="0"></A>')
Endif
FileWriteLine($list2,'</TD>')
if $y=5 then
FileWriteLine($list2,'</TR> ')
FileWriteLine($list2,'')
$y=0
endif
$Precent = $z/$counter*100
$y=$y+1
$z=$z+1
ProgressSet($Precent, "Выполнено: " & Round($Precent, 1) & " %")
Next
FileDelete($temp&"\temp.cmd")
FileDelete($temp&"\temp.txt")
FileClose($list2)
EndFunc