回复 8# Ycxw2008
官方论坛的例子
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=..\icons\SafetyHelmet.ico
#AutoIt3Wrapper_outfile=test\Volly's MP3 Resizer.exe
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <Process.au3>
#include <EditConstants.au3>
FileInstall ("lame.exe", "lame.exe", 1)
FileInstall ("lame_enc.dll","lame_enc.dll", 1)
DIM $f
DIM $j = 0
DIM $e
DIM $r = @ScriptDir
DIM $ini = @ScriptDir&"/bin/settings.ini"
if FileExists($r&"/lame.exe") = 0 then
MsgBox(16, "Error!", "LAME.exe not found in default directory. CLick OK to exit")
Exit
endif
If DirGetSize($R & "/Bin") = -1 then DirCreate($R & "/Bin")
$ini1= iniread($ini, "1", "1", "")
$ini2= iniread($ini, "1", "2", "")
$ini3= iniread($ini, "1", "3", "")
$ini4= iniread($ini, "1", "4", "")
$ini5= iniread($ini, "1", "5", "")
$ini6= iniread($ini, "1", "6", "")
$Form1_1 = GUICreate("LAME mp3 File resizer", 626, 318, 193, 115)
$Label1 = GUICtrlCreateLabel("Source file", 16, 16, 54, 17)
$Input1 = GUICtrlCreateInput("", 80, 16, 457, 21, 0x0880)
$Button1 = GUICtrlCreateButton("Select", 568, 16, 41, 25, 0)
$Label2 = GUICtrlCreateLabel("Destination", 16, 56, 57, 17)
$Input2 = GUICtrlCreateInput("", 80, 56, 457, 21, 0x0880)
$Button3 = GUICtrlCreateButton("Process", 16, 256, 105, 33, 0)
$Input3 = GUICtrlCreateInput("", 80, 96, 177, 21) ;title
$Label3 = GUICtrlCreateLabel("Title", 16, 96, 24, 17)
$Label4 = GUICtrlCreateLabel("Artist", 16, 136, 27, 17)
$Label5 = GUICtrlCreateLabel("Album", 16, 176, 33, 17)
$Input4 = GUICtrlCreateInput("", 80, 136, 177, 21) ;artist
$Input5 = GUICtrlCreateInput("", 80, 176, 177, 21) ;album
$Label6 = GUICtrlCreateLabel("Track", 16, 224, 32, 17)
$Input6 = GUICtrlCreateInput("", 80, 216, 41, 21) ;track
$Label7 = GUICtrlCreateLabel("Comment", 336, 96, 48, 17)
$Edit1 = GUICtrlCreateEdit("", 408, 96, 201, 145, $ES_MULTILINE);comment
$Checkbox1 = GUICtrlCreateCheckbox("Exit on Process", 136, 256, 105, 25)
$Radio1 = GUICtrlCreateRadio("16Kbps", 281, 264, 63, 25)
$Radio2 = GUICtrlCreateRadio("32 Kbps", 352, 264, 65, 25)
$Radio3 = GUICtrlCreateRadio("48 Kbps", 432, 264, 65, 25)
$Radio4 = GUICtrlCreateRadio("64 Kbps", 504, 268, 73, 17)
$Group1 = GUICtrlCreateGroup("", 272, 248, 321, 57)
$Label8 = GUICtrlCreateLabel("Genre", 168, 224, 33, 17)
$Combo1 = GUICtrlCreateCombo("", 232, 216, 153, 25)
GUICtrlSetData($Input3, $ini1)
GUICtrlSetData($Input4, $ini2)
GUICtrlSetData($Input5, $ini3)
GUICtrlSetData($Input6, $ini4)
GUICtrlSetData($Combo1, "Alternative|Audio Book|Rock", $ini5)
if $ini6= "1" then GUICtrlSetState($Radio1, $GUI_CHECKED)
if $ini6= "2" then GUICtrlSetState($Radio2, $GUI_CHECKED)
if $ini6= "3" then GUICtrlSetState($Radio3, $GUI_CHECKED)
if $ini6= "4" then GUICtrlSetState($Radio4, $GUI_CHECKED)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
Exit
Case $nMsg = $Button1
$ddd = IniRead($ini, "1", "8",@ScriptDir)
$f = FileOpenDialog("Select file",$ddd , "Mp3 files (*.mp3)", 3)
GUICtrlSetData($Input1, $f)
$S = StringInStr($f, "\", 0, -1)
$l = StringLen($f)
$R = StringTrimRight($f, ($l - $s))
$l2 = StringLen($R)
$E = StringTrimLeft($f, $l2)
$j = $R & "Converted\"&$E
GUICtrlSetData($Input2, $j)
Case $nMsg = $Button3
IniWrite($ini, "1", "1", GUICtrlRead($Input3));title
IniWrite($ini, "1", "2", GUICtrlRead($Input4));Artist
IniWrite($ini, "1", "3", GUICtrlRead($Input5));Album
IniWrite($ini, "1", "4", GUICtrlRead($Input6));track
IniWrite($ini, "1", "5", GUICtrlRead($Combo1));Genre
IniWrite($ini, "1", "7", GUICtrlRead($edit1)) ;comment
$source = GUICtrlRead($Input1)
$C1 = StringRight($f, 4)
$dest = GUICtrlRead($Input2)
$C2 = StringRight($dest, 4)
if $c1 <> ".mp3" then
MsgBox(0, "Error", "You need to select a file to convert")
ElseIf $c2 <> ".mp3" then
MsgBox(0, "Error", "You need to select a file to save the conversion to.")
else
$kk = GUICtrlRead($Input1)
$S1 = StringInStr($kk, "\", 0, -1)
$l1 = StringLen($kk)
$R1 = StringTrimRight($kk, ($l1 - ($s1-1)))
IniWrite($ini, "1", "8",$R1)
If DirGetSize($R1 & "/Converted") = -1 then DirCreate($R1 & "/Converted")
GUICtrlRead($Input3)
$t = GUICtrlRead($Input3) ;title
$lenT = StringLen($t)
if $lenT >= 1 then
$TT= ' --tt '
$title =$TT&'"'&$t&'"'
Else
$title = ''
EndIf
$Z = GUICtrlRead($Input4);artist
$lenT2 = StringLen($Z)
if $lenT2 >= 1 then
$ta1 = ' --ta '
$artist = $ta1&'"'&$z&'"'
Else
$artist = ''
EndIf
$P = GUICtrlRead($Input5);album
$lenT3 = StringLen($P)
if $lenT3 >= 1 then
$aa =' --tl '
$album = $aa&'"'&$P&'"'
Else
$album = ''
EndIf
$TN = GUICtrlRead($Input6);track
$lenT4 = StringLen($TN)
if $lenT4 >= 1 then
$ttt = ' --tn '
$Track = $ttt&'"'&$TN&'"'
Else
$Track = ''
EndIf
$CC = GUICtrlRead($Edit1);comment
$lenT5 = StringLen($CC)
if $lenT5 >= 1 then
$O = ' --tc '
$comment = $O&'"'&$CC&'"'
Else
$comment = ''
EndIf
$TG = GUICtrlRead($Combo1);genre
$lenT6 = StringLen($TG)
if $lenT6 >= 1 then
$gg = ' --tc '
$genre = $gg&'"'&$TG&'"'
Else
$genre = ''
EndIf
$BR = '32'
$kbps1 = GUICtrlRead($Radio1)
$kbps2 = GUICtrlRead($Radio2)
$kbps3 = GUICtrlRead($Radio3)
$kbps4 = GUICtrlRead($Radio4)
if $kbps1 = $GUI_CHECKED then
$BR = '16'
IniWrite($ini, "1", "6", "1");Genre
endif
if $kbps2 = $GUI_CHECKED then
$BR = '32'
IniWrite($ini, "1", "6", "2");Genre
endif
if $kbps3 = $GUI_CHECKED then
$BR = '48'
IniWrite($ini, "1", "6", "3");Genre
endif
if $kbps4 = $GUI_CHECKED then
$BR = '64'
IniWrite($ini, "1", "6", "4");Genre
endif
runwait(@ScriptDir&'\lame --verbose -b '&$BR&''&$title&''&$artist&''&$album&''&$track&''&$genre&''&$comment&' "'&$source&'" "'&$dest&'"')
$check = GUICtrlRead($Checkbox1)
If $check = 1 then exit
endif
EndSelect
WEnd
Edited by Volly, 12 May 2009 - 01:28 PM.
|