Code : Tout sélectionner
#include <File.au3>
#RequireAdmin
AutoItSetOption("WinDetectHiddenText", 1)
Opt("WinTitleMatchMode", 3)
Local $chemin = ""
Local $aArray1 = StringSplit(@ScriptDir, '\')
For $i = 1 To $aArray1[0] - 1
$chemin &= $aArray1[$i] & "\"
Next
;MsgBox(0,"",$chemin)
DirCreate($chemin & "Archives")
Local $TC_Container_Location = $chemin & "Archives\vol.tc"
Local $TC_Container_Encryption = "AES"
Local $TC_Container_Size = 10
Local $TC_Password = "motdepasse"
Local $TC_Format = "NTFS"
Local $TC_Dynamic = True
Local $TC_Keyfile = True
$PID_TC_Format = Run('"' & @ScriptDir & '\TrueCrypt7\TrueCrypt Format.exe"', @ScriptDir, @SW_SHOW)
ProcessWait($PID_TC_Format)
$hWnd_TC_Volume_Creation_Wizard = WinGetHandle("[TITLE:TrueCrypt Volume Creation Wizard; CLASS:CustomDlg]", "")
WinWait($hWnd_TC_Volume_Creation_Wizard,"TrueCrypt Volume Creation Wizard",1)
$TC_Timer = TimerInit()
ControlClick($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Button; INSTANCE:3]')
WinWait($hWnd_TC_Volume_Creation_Wizard,"Volume Type",1)
ControlClick($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Button; INSTANCE:3]')
WinWait($hWnd_TC_Volume_Creation_Wizard,"Volume Location",1)
ControlSetText($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Edit; INSTANCE:1]', $TC_Container_Location, 1)
If ControlGetText($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Edit; INSTANCE:1]') = $TC_Container_Location Then
ControlClick($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Button; INSTANCE:3]')
EndIf
WinWait($hWnd_TC_Volume_Creation_Wizard,"Encryption Options",1)
ControlCommand($hWnd_TC_Volume_Creation_Wizard, "", "[CLASS:ComboBox; INSTANCE:1]", "SelectString", $TC_Container_Encryption)
If ControlCommand($hWnd_TC_Volume_Creation_Wizard, "", "[CLASS:ComboBox; INSTANCE:1]", "GetCurrentSelection", "") = $TC_Container_Encryption Then
ControlClick($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Button; INSTANCE:3]')
EndIf
WinWait($hWnd_TC_Volume_Creation_Wizard,"Volume Size",1)
$Format_Size = "Button7";Button6 7 8 >> Kb Mb Gb
ControlFocus($hWnd_TC_Volume_Creation_Wizard,"",$Format_Size)
ControlSetText($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Edit; INSTANCE:1]', $TC_Container_Size, 1)
If ControlGetText($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Edit; INSTANCE:1]') = $TC_Container_Size Then
ControlClick($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Button; INSTANCE:3]')
EndIf
If $Format_Size = "Button7" Then $TC_Container_Size = $TC_Container_Size * 1024;en Mo >> Ko
If $Format_Size = "Button8" Then $TC_Container_Size = $TC_Container_Size * 1024 * 1024;en Go >> Ko
If $TC_Container_Size < 275 Then $TC_Container_Size = 275
If $TC_Container_Size < 2829 Then $TC_Format = "FAT"
WinWait($hWnd_TC_Volume_Creation_Wizard,"Volume Password",1)
;ControlClick($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Button; INSTANCE:6]');display password
If $TC_Keyfile = True Then
ControlClick($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Button; INSTANCE:7]') ;valide keyfile
If ControlEnable($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Button; INSTANCE:8]') Then
ControlClick($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Button; INSTANCE:8]');fenêtre TrueCrypt - Keyfiles
EndIf
ControlClick("TrueCrypt - Keyfiles", '', '[CLASS:Button; INSTANCE:1]');ouvre filedialog
WinWait("[Title: Select Keyfile]","",1);attente ouverture Fileopendialog
;entrer chemin keyfile
ControlSetText("[CLASS:#32770]", '&Nom du fichier :', '[CLASS:Edit; INSTANCE:1]', "C:\Users\Pc\Documents\AUTOIT\PROJET\TC\TC\Test.tc", 1)
;button "OK"
ControlClick("[CLASS:#32770]", '', '[CLASS:Button; INSTANCE:1]')
WinWait("TrueCrypt - Keyfiles","",1)
Local $aa1 = ControlListView("TrueCrypt - Keyfiles","",'SysListView321',"GetText", 0)
If $aa1 = "" Then
MsgBox(0,"ERROR","Erreur keyfile: Exit")
Exit
EndIf
ControlClick("TrueCrypt - Keyfiles", '', '[CLASS:Button; INSTANCE:8]');valide
WinWaitClose("TrueCrypt - Keyfiles","")
$cheminkey = StringSplit($aa1,"\")
$KeyFile = "\" & $cheminkey[$cheminkey[0]]
EndIf
ControlSetText($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Edit; INSTANCE:1]', $TC_Password, 1)
ControlSetText($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Edit; INSTANCE:2]', $TC_Password, 1)
If ControlEnable($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Button; INSTANCE:3]') Then
ControlClick($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Button; INSTANCE:3]')
EndIf
ControlClick("[TITLE:TrueCrypt Volume Creation Wizard; CLASS:#32770]", '', '[CLASS:Button; INSTANCE:1]');ferme alerte pour MP trop court
WinWait($hWnd_TC_Volume_Creation_Wizard,"Volume Format",1)
ControlCommand($hWnd_TC_Volume_Creation_Wizard, "", "[CLASS:ComboBox; INSTANCE:1]", "SelectString", $TC_Format)
If $TC_Format = "NTFS" And $TC_Dynamic = True Then
ControlClick($hWnd_TC_Volume_Creation_Wizard, '', "Button6");format dynamic
$fenetre = WinWait("[TITLE:TrueCrypt Volume Creation Wizard; CLASS:#32770]","")
WinSetState($fenetre,"",@SW_HIDE )
ControlClick($fenetre, '', "Button1")
EndIf
ControlClick($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Button; INSTANCE:3]')
$fenetre = WinWait("[TITLE:TrueCrypt Volume Creation Wizard; CLASS:#32770]","The TrueCrypt volume has been successfully created.")
ControlClick($fenetre, '', "Button1")
Sleep(1000)
ControlClick("[TITLE:TrueCrypt Volume Creation Wizard; CLASS:#32770]", '', '[CLASS:Button; INSTANCE:1]')
WinWait($hWnd_TC_Volume_Creation_Wizard,"Volume Created",1)
ControlClick($hWnd_TC_Volume_Creation_Wizard, '', '[CLASS:Button; INSTANCE:4]')
;MsgBox(0,"","bon " )
If ProcessExists($PID_TC_Format) Then ProcessClose($PID_TC_Format)