Aide et conseils concernant AutoIt et ses outils.
Boulanza
Niveau 9
Messages : 697 Enregistré le : mer. 31 juil. 2013 15:49
Status :
Hors ligne
#1
Message
par Boulanza » mer. 10 avr. 2019 14:32
Bonjour,
Je suis incapable de trouver la solution pour intégrer
$sFileOpenDialog = FileOpenDialog("", "", "All(*.*)" , BitOr($FD_FILEMUSTEXIST, $FD_MULTISELECT))
à la place de Dim $Path = @ScriptDir du code ci-joint. Car Dim $Path = @ScriptDir fige la recherche vers une seule direction.
Merci d’avance pour votre aide.
Cordialement.
#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <File.au3> #include <GuiListBox.au3> #include <ListBoxConstants.au3> ;https://www.autoitscript.fr/forum/viewtopic.php?t=7111 Exemple003suite
( ) Func Exemple003suite
( ) ;Dim $PaintEditor = "mspaint.exe" Dim $PaintEditor = "D:\Program Files\Paint.NET\PaintDotNet.exe" ;Dim $Path = "D:\Program Files\TipTop software\iCar DS\skins\CFStyle" Dim $Path = @ScriptDir ;Gui All skin files $AllSkinFilesGUI = GUICreate ( "" , 490 , 350 , - 1 ,- 1 ) GUICtrlCreateLabel ( "Select the file that you want to edit !!!" , 100 , 5 , 300 , 20 ) GUICtrlSetFont ( - 1 , 8 , 800 , 0 , "MS Sans Serif" ) $AllSkinList = GUICtrlCreateList ( "" , 2 , 22 , 488 , 300 , BitOR ( $LBS_STANDARD , $LBS_EXTENDEDSEL ) ) GUICtrlSetFont ( - 1 , 10 , 450 , 0 , "MS Sans Serif" ) $PaintEditorPic = GUICtrlCreateButton ( "Paint" , 2 , 325 , 25 , 25 , $BS_ICON ) GUICtrlSetTip ( - 1 , "Paint editor" ) GUICtrlSetImage ( - 1 , @SystemDir & '\mspaint.exe' , 1 , 0 ) $PaintEditorName = GUICtrlCreateLabel ( "MsPaint" , 35 , 329 , 100 , 25 ) GUICtrlSetFont ( - 1 , 8 , 800 , 0 , "MS Sans Serif" ) $EditSelectedFile = GUICtrlCreateButton ( "Edit" , 150 , 325 , 168 , 25 ) GUICtrlCreateLabel ( "Filter :" , 370 , 327 , 45 , 25 ) GUICtrlSetFont ( - 1 , 10 , 800 , 0 , "MS Sans Serif" ) $EditSelectedFilter = GUICtrlCreateCombo ( "" , 420 , 325 , 60 , 25 ) Opt ( "GUIDataSeparatorChar" , "|" ) GUICtrlSetData ( - 1 , "*.skin|*.txt|*.ini|*.bmp|*.gif|*.jpg|*.png|*.*" , "*.jpg" ) GUICtrlSetFont ( - 1 , 10 , 450 , 0 , "MS Sans Serif" ) GUISetState ( ) $AllSkinFilesGUIStatus = False _GUICtrlListBox_Dir ( $AllSkinList , $Path & "\" & GUICtrlRead ( $EditSelectedFilter ) ) While 1 $nMsg = GUIGetMsg ( ) Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $EditSelectedFile ;edition du fichier choisi $testthis = _GUICtrlListBox_GetSelItems ( $AllSkinList ) $sItems = '' For $iI = 1 To $testthis [ 0 ] $sItems &= _GUICtrlListBox_GetText ( $AllSkinList , $testthis [ $iI ] ) Next Local $szDrive , $szDir , $szFName , $szExt $Ext = _PathSplit ( $Path & "\" & $sItems , $szDrive , $szDir , $szFName , $szExt ) If $sItems <> '' Then Switch $szExt Case ".txt" ShellExecute ( $sItems , "" , $Path & "\" , "edit" ) Case ".ini" , ".skin" Run ( "notepad.exe " & $Path & "\" & $sItems ) Case ".bmp" , ".gif" , ".jpg" , ".png" $sItems = StringSplit ( $sItems , $szExt , 1 ) For $i = 1 to UBound ( $sItems ) - 2 run ( $PaintEditor & " " "" & $Path & "\" & $sItems [ $i ] & $szExt & "" "" , "" , @SW_MAXIMIZE ) ; msgbox(0,"",$sItems[$i]) Next EndSwitch Else SplashTextOn ( "Info" , "Choose a file please !" , 200 , 40 ,- 1 , - 1 , 32 , "" , 10 , 800 ) sleep ( 2000 ) SplashOff ( ) EndIf Case $EditSelectedFilter ;filtrage selon l'extension du fichier _GUICtrlListBox_ResetContent ( $AllSkinList ) _GUICtrlListBox_BeginUpdate ( $AllSkinList ) _GUICtrlListBox_Dir ( $AllSkinList , $Path & "\" & GUICtrlRead ( $EditSelectedFilter ) ) _GUICtrlListBox_EndUpdate ( $AllSkinList ) EndSwitch wend EndFunc
Modifié en dernier par
Boulanza le jeu. 11 avr. 2019 16:49, modifié 1 fois.
walkson
Modérateur
Messages : 1020 Enregistré le : ven. 12 août 2011 19:49
Localisation : Hurepoix
Status :
Hors ligne
#2
Message
par walkson » mer. 10 avr. 2019 21:02
Bonjour,
Je n'ai pas testé mais cette ligne me parait bizarre
run($PaintEditor&" """&$Path & "\"&$sItems[$i]&$szExt & """","",@SW_MAXIMIZE)
Ce ne serait pas comme ceci ?
run ( $PaintEditor & '" ' & $Path & "\" & $sItems [ $i ] & $szExt & '"' , "" , @SW_MAXIMIZE )
un ' puis un " puis un ' => '"'
Cordialement,
Walkson
"Horas non numero nisi serenas " Le canon de midi
(Je ne compte que les heures heureuses)
Boulanza
Niveau 9
Messages : 697 Enregistré le : mer. 31 juil. 2013 15:49
Status :
Hors ligne
#3
Message
par Boulanza » mer. 10 avr. 2019 21:18
Bonsoir monsieur walkson,
Merci pour votre aimable réponse.
Le code en question, marche sans aucun problème. Ma demande c'est de faire la recherche ("Select") de fichiers à traiter en utilisant la fonction AutoIt "FileOpenDialog" à la place de "Dim $Path = @ScriptDir" du code :
#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <File.au3> #include <GuiListBox.au3> #include <ListBoxConstants.au3> ;https://www.autoitscript.fr/forum/viewtopic.php?t=7111 Exemple003suite
( ) Func Exemple003suite
( ) ;Dim $PaintEditor = "mspaint.exe" Dim $PaintEditor = "D:\Program Files\Paint.NET\PaintDotNet.exe" ;Dim $Path = "D:\Program Files\TipTop software\iCar DS\skins\CFStyle" Dim $Path = @ScriptDir ;Gui All skin files $AllSkinFilesGUI = GUICreate ( "" , 490 , 350 , - 1 ,- 1 ) GUICtrlCreateLabel ( "Select the file that you want to edit !!!" , 100 , 5 , 300 , 20 ) GUICtrlSetFont ( - 1 , 8 , 800 , 0 , "MS Sans Serif" ) $AllSkinList = GUICtrlCreateList ( "" , 2 , 22 , 488 , 300 , BitOR ( $LBS_STANDARD , $LBS_EXTENDEDSEL ) ) GUICtrlSetFont ( - 1 , 10 , 450 , 0 , "MS Sans Serif" ) $PaintEditorPic = GUICtrlCreateButton ( "Paint" , 2 , 325 , 25 , 25 , $BS_ICON ) GUICtrlSetTip ( - 1 , "Paint editor" ) GUICtrlSetImage ( - 1 , @SystemDir & '\mspaint.exe' , 1 , 0 ) $PaintEditorName = GUICtrlCreateLabel ( "MsPaint" , 35 , 329 , 100 , 25 ) GUICtrlSetFont ( - 1 , 8 , 800 , 0 , "MS Sans Serif" ) $EditSelectedFile = GUICtrlCreateButton ( "Edit" , 150 , 325 , 168 , 25 ) GUICtrlCreateLabel ( "Filter :" , 370 , 327 , 45 , 25 ) GUICtrlSetFont ( - 1 , 10 , 800 , 0 , "MS Sans Serif" ) $EditSelectedFilter = GUICtrlCreateCombo ( "" , 420 , 325 , 60 , 25 ) Opt ( "GUIDataSeparatorChar" , "|" ) GUICtrlSetData ( - 1 , "*.skin|*.txt|*.ini|*.bmp|*.gif|*.jpg|*.png|*.*" , "*.jpg" ) GUICtrlSetFont ( - 1 , 10 , 450 , 0 , "MS Sans Serif" ) GUISetState ( ) $AllSkinFilesGUIStatus = False _GUICtrlListBox_Dir ( $AllSkinList , $Path & "\" & GUICtrlRead ( $EditSelectedFilter ) ) While 1 $nMsg = GUIGetMsg ( ) Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $EditSelectedFile ;edition du fichier choisi $testthis = _GUICtrlListBox_GetSelItems ( $AllSkinList ) $sItems = '' For $iI = 1 To $testthis [ 0 ] $sItems &= _GUICtrlListBox_GetText ( $AllSkinList , $testthis [ $iI ] ) Next Local $szDrive , $szDir , $szFName , $szExt $Ext = _PathSplit ( $Path & "\" & $sItems , $szDrive , $szDir , $szFName , $szExt ) If $sItems <> '' Then Switch $szExt Case ".txt" ShellExecute ( $sItems , "" , $Path & "\" , "edit" ) Case ".ini" , ".skin" Run ( "notepad.exe " & $Path & "\" & $sItems ) Case ".bmp" , ".gif" , ".jpg" , ".png" $sItems = StringSplit ( $sItems , $szExt , 1 ) For $i = 1 to UBound ( $sItems ) - 2 run ( $PaintEditor & " " "" & $Path & "\" & $sItems [ $i ] & $szExt & "" "" , "" , @SW_MAXIMIZE ) ; msgbox(0,"",$sItems[$i]) Next EndSwitch Else SplashTextOn ( "Info" , "Choose a file please !" , 200 , 40 ,- 1 , - 1 , 32 , "" , 10 , 800 ) sleep ( 2000 ) SplashOff ( ) EndIf Case $EditSelectedFilter ;filtrage selon l'extension du fichier _GUICtrlListBox_ResetContent ( $AllSkinList ) _GUICtrlListBox_BeginUpdate ( $AllSkinList ) _GUICtrlListBox_Dir ( $AllSkinList , $Path & "\" & GUICtrlRead ( $EditSelectedFilter ) ) _GUICtrlListBox_EndUpdate ( $AllSkinList ) EndSwitch wend EndFunc
Cordialement.
walkson
Modérateur
Messages : 1020 Enregistré le : ven. 12 août 2011 19:49
Localisation : Hurepoix
Status :
Hors ligne
#4
Message
par walkson » mer. 10 avr. 2019 21:23
Bonsoir Monsieur Boulanza
En effet ça marche, je n'ai rien dit
Cordialement,
Walkson
"Horas non numero nisi serenas " Le canon de midi
(Je ne compte que les heures heureuses)
walkson
Modérateur
Messages : 1020 Enregistré le : ven. 12 août 2011 19:49
Localisation : Hurepoix
Status :
Hors ligne
#5
Message
par walkson » mer. 10 avr. 2019 21:51
Comme ça ?
#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <File.au3> #include <GuiListBox.au3> #include <ListBoxConstants.au3> #include <Array.au3> ;https://www.autoitscript.fr/forum/viewtopic.php?t=7111 Exemple003suite
( ) Func Exemple003suite
( ) ;Dim $PaintEditor = "mspaint.exe" Dim $PaintEditor = "C:\Program Files\Paint.NET\PaintDotNet.exe" ;Dim $Path = "D:\Program Files\TipTop software\iCar DS\skins\CFStyle" Dim $Path = @ScriptDir ;Gui All skin files $AllSkinFilesGUI = GUICreate ( "" , 490 , 350 , - 1 ,- 1 ) GUICtrlCreateLabel ( "Select the file that you want to edit !!!" , 100 , 5 , 300 , 20 ) GUICtrlSetFont ( - 1 , 8 , 800 , 0 , "MS Sans Serif" ) $AllSkinList = GUICtrlCreateList ( "" , 2 , 22 , 488 , 300 , BitOR ( $LBS_STANDARD , $LBS_EXTENDEDSEL ) ) GUICtrlSetFont ( - 1 , 10 , 450 , 0 , "MS Sans Serif" ) $PaintEditorPic = GUICtrlCreateButton ( "Paint" , 2 , 325 , 25 , 25 , $BS_ICON ) GUICtrlSetTip ( - 1 , "Paint editor" ) GUICtrlSetImage ( - 1 , @SystemDir & '\mspaint.exe' , 1 , 0 ) $PaintEditorName = GUICtrlCreateLabel ( "MsPaint" , 35 , 329 , 100 , 25 ) GUICtrlSetFont ( - 1 , 8 , 800 , 0 , "MS Sans Serif" ) $EditSelectedFile = GUICtrlCreateButton ( "Edit" , 150 , 325 , 168 , 25 ) GUICtrlCreateLabel ( "Filter :" , 370 , 327 , 45 , 25 ) GUICtrlSetFont ( - 1 , 10 , 800 , 0 , "MS Sans Serif" ) $EditSelectedFilter = GUICtrlCreateCombo ( "" , 420 , 325 , 60 , 25 ) Opt ( "GUIDataSeparatorChar" , "|" ) GUICtrlSetData ( - 1 , "*.skin|*.txt|*.ini|*.bmp|*.gif|*.jpg|*.png|*.*" , "*.png" ) GUICtrlSetFont ( - 1 , 10 , 450 , 0 , "MS Sans Serif" ) GUISetState ( ) $AllSkinFilesGUIStatus = False Local $array [ 0 ] $sFileOpenDialog = FileOpenDialog ( "" , "" , "All(*.*)" , BitOr ( $FD_FILEMUSTEXIST , $FD_MULTISELECT ) ) ;renvoie chemin|fichier1|fichier2|etc... If StringInStr ( $sFileOpenDialog , "|" ) > 0 Then _ArrayAdd ( $array , $sFileOpenDialog ) _ArrayDisplay ( $array ) ; pour voir $path = $array [ 0 ] For $i = 1 To UBound ( $array ) - 1 $chemin = $path & "\" & $array [ $i ] _GUICtrlListBox_Dir ( $AllSkinList , $chemin ) Next Else _GUICtrlListBox_Dir ( $AllSkinList , $sFileOpenDialog ) EndIf While 1 $nMsg = GUIGetMsg ( ) Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $EditSelectedFile ;edition du fichier choisi $testthis = _GUICtrlListBox_GetSelItems ( $AllSkinList ) $sItems = '' For $iI = 1 To $testthis [ 0 ] $sItems &= _GUICtrlListBox_GetText ( $AllSkinList , $testthis [ $iI ] ) Next Local $szDrive , $szDir , $szFName , $szExt $Ext = _PathSplit ( $Path & "\" & $sItems , $szDrive , $szDir , $szFName , $szExt ) If $sItems <> '' Then Switch $szExt Case ".txt" ShellExecute ( $sItems , "" , $Path & "\" , "edit" ) Case ".ini" , ".skin" Run ( "notepad.exe " & $Path & "\" & $sItems ) Case ".bmp" , ".gif" , ".jpg" , ".png" $sItems = StringSplit ( $sItems , $szExt , 1 ) For $i = 1 to UBound ( $sItems ) - 2 run ( $PaintEditor & " " "" & $Path & "\" & $sItems [ $i ] & $szExt & "" "" , "" , @SW_MAXIMIZE ) ; msgbox(0,"",$sItems[$i]) Next EndSwitch Else SplashTextOn ( "Info" , "Choose a file please !" , 200 , 40 ,- 1 , - 1 , 32 , "" , 10 , 800 ) sleep ( 2000 ) SplashOff ( ) EndIf Case $EditSelectedFilter ;filtrage selon l'extension du fichier _GUICtrlListBox_ResetContent ( $AllSkinList ) _GUICtrlListBox_BeginUpdate ( $AllSkinList ) _GUICtrlListBox_Dir ( $AllSkinList , $Path & "\" & GUICtrlRead ( $EditSelectedFilter ) ) _GUICtrlListBox_EndUpdate ( $AllSkinList ) EndSwitch wend EndFunc
Mais dans ce cas, le combo est inutile....
Cordialement,
Walkson
"Horas non numero nisi serenas " Le canon de midi
(Je ne compte que les heures heureuses)
Boulanza
Niveau 9
Messages : 697 Enregistré le : mer. 31 juil. 2013 15:49
Status :
Hors ligne
#6
Message
par Boulanza » mer. 10 avr. 2019 22:49
Bonsoir monsieur walkson,
Merci infiniment pour votre aide, ça marche parfaitement.
Cordialement.
walkson
Modérateur
Messages : 1020 Enregistré le : ven. 12 août 2011 19:49
Localisation : Hurepoix
Status :
Hors ligne
#7
Message
par walkson » mer. 10 avr. 2019 23:53
Non, le code fonctionne mal quand on choisit un seul fichier. L'erreur vient de Dim $Path = @ScriptDir qui renvoie une mauvaise adresse
Voilà le code corrigé pour cette erreur. Le reste je vous le laisse
#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <File.au3> #include <GuiListBox.au3> #include <ListBoxConstants.au3> #include <Array.au3> #include <WinAPIShPath.au3> ;https://www.autoitscript.fr/forum/viewtopic.php?t=7111 Exemple003suite
( ) Func Exemple003suite
( ) ;Dim $PaintEditor = "mspaint.exe" Dim $PaintEditor = "C:\Program Files\Paint.NET\PaintDotNet.exe" ;Dim $Path = "D:\Program Files\TipTop software\iCar DS\skins\CFStyle" ;Gui All skin files $AllSkinFilesGUI = GUICreate ( "" , 490 , 350 , - 1 ,- 1 ) GUICtrlCreateLabel ( "Select the file that you want to edit !!!" , 100 , 5 , 300 , 20 ) GUICtrlSetFont ( - 1 , 8 , 800 , 0 , "MS Sans Serif" ) $AllSkinList = GUICtrlCreateList ( "" , 2 , 22 , 488 , 300 , BitOR ( $LBS_STANDARD , $LBS_EXTENDEDSEL ) ) GUICtrlSetFont ( - 1 , 10 , 450 , 0 , "MS Sans Serif" ) $PaintEditorPic = GUICtrlCreateButton ( "Paint" , 2 , 325 , 25 , 25 , $BS_ICON ) GUICtrlSetTip ( - 1 , "Paint editor" ) GUICtrlSetImage ( - 1 , @SystemDir & '\mspaint.exe' , 1 , 0 ) $PaintEditorName = GUICtrlCreateLabel ( "MsPaint" , 35 , 329 , 100 , 25 ) GUICtrlSetFont ( - 1 , 8 , 800 , 0 , "MS Sans Serif" ) $EditSelectedFile = GUICtrlCreateButton ( "Edit" , 150 , 325 , 168 , 25 ) GUICtrlCreateLabel ( "Filter :" , 370 , 327 , 45 , 25 ) GUICtrlSetFont ( - 1 , 10 , 800 , 0 , "MS Sans Serif" ) $EditSelectedFilter = GUICtrlCreateCombo ( "" , 420 , 325 , 60 , 25 ) Opt ( "GUIDataSeparatorChar" , "|" ) GUICtrlSetData ( - 1 , "*.skin|*.txt|*.ini|*.bmp|*.gif|*.jpg|*.png|*.*" , "*.png" ) GUICtrlSetFont ( - 1 , 10 , 450 , 0 , "MS Sans Serif" ) GUISetState ( ) $AllSkinFilesGUIStatus = False Local $array [ 0 ] , $path Local $sFileOpenDialog = FileOpenDialog ( "" , @DesktopDir , "All(*.*)" , BitOr ( $FD_FILEMUSTEXIST , $FD_MULTISELECT ) ) ;renvoie chemin|fichier1|fichier2|etc... If StringInStr ( $sFileOpenDialog , "|" ) > 0 Then _ArrayAdd ( $array , $sFileOpenDialog ) ;_ArrayDisplay($array); pour voir $path = $array [ 0 ] _GUICtrlListBox_BeginUpdate ( $AllSkinList ) _GUICtrlListBox_InitStorage ( $AllSkinList , 100 , 4096 ) For $i = 1 To UBound ( $array ) - 1 $chemin = $path & "\" & $array [ $i ] _GUICtrlListBox_Dir ( $AllSkinList , $chemin ) Next Else _GUICtrlListBox_Dir ( $AllSkinList , $sFileOpenDialog ) $path = _WinAPI_PathRemoveFileSpec ( $sFileOpenDialog ) EndIf _GUICtrlListBox_EndUpdate ( $AllSkinList ) While 1 $nMsg = GUIGetMsg ( ) Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $EditSelectedFile ;edition du fichier choisi $testthis = _GUICtrlListBox_GetSelItems ( $AllSkinList ) $sItems = '' For $iI = 1 To $testthis [ 0 ] $sItems &= _GUICtrlListBox_GetText ( $AllSkinList , $testthis [ $iI ] ) Next Local $szDrive , $szDir , $szFName , $szExt $Ext = _PathSplit ( $Path & "\" & $sItems , $szDrive , $szDir , $szFName , $szExt ) If $sItems <> '' Then Switch $szExt Case ".txt" ShellExecute ( $sItems , "" , $Path & "\" , "edit" ) Case ".ini" , ".skin" Run ( "notepad.exe " & $Path & "\" & $sItems ) Case ".bmp" , ".gif" , ".jpg" , ".png" $sItems = StringSplit ( $sItems , $szExt , 1 ) For $i = 1 to UBound ( $sItems ) - 2 run ( $PaintEditor & " " "" & $Path & "\" & $sItems [ $i ] & $szExt & "" "" , "" , @SW_MAXIMIZE ) Next EndSwitch Else SplashTextOn ( "Info" , "Choose a file please !" , 200 , 40 ,- 1 , - 1 , 32 , "" , 10 , 800 ) sleep ( 2000 ) SplashOff ( ) EndIf Case $EditSelectedFilter ;filtrage selon l'extension du fichier _GUICtrlListBox_ResetContent ( $AllSkinList ) _GUICtrlListBox_BeginUpdate ( $AllSkinList ) _GUICtrlListBox_Dir ( $AllSkinList , $Path & "\" & GUICtrlRead ( $EditSelectedFilter ) ) _GUICtrlListBox_EndUpdate ( $AllSkinList ) EndSwitch wend EndFunc
Cordialement,
Walkson
"Horas non numero nisi serenas " Le canon de midi
(Je ne compte que les heures heureuses)
Boulanza
Niveau 9
Messages : 697 Enregistré le : mer. 31 juil. 2013 15:49
Status :
Hors ligne
#8
Message
par Boulanza » jeu. 11 avr. 2019 10:54
Bonjour monsieur Walkson,
C'est bien vu, merci pour la correction, ce script servira pour tous les utilisateurs de AutoIt.
Cordialement.