CODICE
; #########################
; # Autorun Maker #
; # By FrontBack #
; # Under GNU/GPL License #
; # Version 2.0.0 #
; #########################
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
#cs
GNU/GPL License
Auutorun Maker Copyright (C) 2010 Nicolò Di Domenico
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#ce
Global $i
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Autorun Maker", 625, 445, 192, 124)
$Input1 = GUICtrlCreateInput("", 64, 24, 249, 21)
$Label1 = GUICtrlCreateLabel("File da aprire all'inserimento del CD o DVD (deve essere nella Root del supporto):", 64, 7, 505, 17)
$Button1 = GUICtrlCreateButton("Sfoglia...", 328, 24, 65, 25, $WS_GROUP)
$Label2 = GUICtrlCreateLabel("Icona che apparirà in Esplora Risorse: (deve essere nella Root del supporto):", 64, 56, 583, 17)
$Input2 = GUICtrlCreateInput("", 64, 75, 198, 21)
$Label2_2 = GUICtrlCreateLabel("\",262,77,5,17)
$Input2_2 = GUICtrlCreateInput("",267,75,51,21)
$Button2 = GUICtrlCreateButton("Sfoglia...", 328, 73, 65, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Estrai...", 400, 73, 65, 25, $WS_GROUP)
$Label3 = GUICtrlCreateLabel("Funzioni del Menù Contestuale:", 64, 144, 152, 17)
$Label4 = GUICtrlCreateLabel("NB: Inserire con questa sintassi: "&Chr(34)&"TestoDelTasto|FileAperto"&Chr(34)&". Per più funzioni andare a capo.", 64, 168, 452, 17)
$Edit1 = GUICtrlCreateEdit("", 64, 192, 257, 233)
$Button4 = GUICtrlCreateButton("Genera!", 424, 408, 97, 25, $WS_GROUP)
$Label5 = GUICtrlCreateLabel("Testo che apparirà quando si inserirà il CD o DVD:", 64, 97, 241, 17)
$Input3 = GUICtrlCreateInput("", 64, 120, 249, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$d = DriveGetDrive("CDROM")
$cd = $d[1]&"\"
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button3 ;===> NEW! 2.0.0
_ExploreIcons()
Case $Button2
$IconFile = FileOpenDialog("Seleziona una icona...",$cd,"Icone Windows (*.ico)",1+2)
GUICtrlSetData($Input2,$IconFile)
Case $Button1
$OpenFile = FileOpenDialog("Seleziona un file da aprire...",$cd,"Tutti i File (*.*)",1+2)
GUICtrlSetData($Input1,$OpenFile)
Case $Button4
$AutorunFile = FileSaveDialog("Salva file Autorun.inf",@ScriptDir,"File Autorun (autorun.inf)",2+16,"autorun.inf")
If GUICtrlRead($Input1) = "" Then
MsgBox(16,"Autorun Maker","Inserisci prima un file da aprire!")
Else
_GenerateOpen($AutorunFile)
EndIf
If Not GUICtrlRead($Input2) = "" Then
_GenerateIcon($AutorunFile)
EndIf
If Not GUICtrlRead($Input3) = "" Then
IniWrite($AutorunFile,"autorun","label",GUICtrlRead($Input3))
EndIf
If Not GUICtrlRead($Edit1) = "" Then
_GenerateContext($AutorunFile)
EndIf
MsgBox(64,"Autorun Maker","La generazione del file .inf è completata. Per vederlo in azione, è necessario inserire un CD o un DVD.")
Run("explorer.exe "&$cd)
Exit
EndSwitch
WEnd
; Actions compressed in functions! ===> NEW! 2.0.0
Func _GenerateOpen($oFile)
$OpenSplitted = StringSplit(GUICtrlRead($Input1),"\")
$Open = $OpenSplitted[$i]
$Open = $OpenSplitted[$Open]
$Ext = StringSplit($Open,".")
If $Ext[2] = "exe" Then
IniWrite($oFile,"autorun","Open",$Open)
Else
IniWrite($oFile,"autorun","ShellExecute",$Open)
EndIf
EndFunc
Func _GenerateIcon($iFile)
$IconSplitted = StringSplit(GUICtrlRead($Input2),"\")
$Icon = $IconSplitted[$i]
$AutorunIcon = $IconSplitted[$Icon - 1]
$AutorunIcon2 = $IconSplitted[$Icon]
$Ext2 = StringSplit($AutorunIcon,".")
If GUICtrlRead($Input2_2) = "" Then
IniWrite($iFile,"autorun","icon",$AutorunIcon)
Else
IniWrite($iFile,"autorun","icon",$AutorunIcon2&", "&GUICtrlRead($Input2_2))
EndIf
EndFunc
Func _GenerateContext($cFile)
$ContextLines = StringSplit(GUICtrlRead($Edit1),@CRLF)
$count2 = 1
$count3 = 1
For $count = 1 To $ContextLines[$i]-1
$ContextData = StringSplit($ContextLines[$count2],"|")
$ContextName = $ContextData[1]
IniWrite($AutorunFile,"autorun","shell\"&$count3,"&"&$ContextData[1])
IniWrite($AutorunFile,"autorun","shell\"&$count3&"\command",$ContextData[2])
$count2 = $count2 + 2
$count3 = $count3 + 1
Next
EndFunc
Func _ExploreIcons()
Local $FileName = @WindowsDir&"\System32\Shell32.dll"
Local $_Icon = DllStructCreate("int")
Local $String = DLLStructCreate("wchar[260]")
Local $Str = DllStructGetSize($String)/2
DllStructSetData($String, 1, $FileName)
DllCall("shell32.dll", "none", 62, "hwnd", 0, "ptr", DllStructGetPtr($String), "int", $Str, "ptr", DllStructGetPtr($_Icon))
Local $FileName = DllStructGetData($String, 1)
Local $IconIndex = DllStructGetData($_Icon, 1)
GUICtrlSetData($Input2,$FileName)
GUICtrlSetData($Input2_2,$IconIndex)
EndFunc