hi,
gibt es eine Möglichkeit einen "OpenFileDialog" in eine GUI einzubetten oder hat vielleicht jemand sowas schonmal gemacht ?
markus
hi,
gibt es eine Möglichkeit einen "OpenFileDialog" in eine GUI einzubetten oder hat vielleicht jemand sowas schonmal gemacht ?
markus
Ist doch als native Funktion in AutoIt enthalten:
[autoit]FileOpenDialog() ; == Datei-Öffnen
FileSelectFolder() ; == Ordner wählen
Soweit ich das verstanden hab, möchte er es in die GUI einbetten, so das kein neues Fenster auftaucht, mir fällt keine Möglichkeit ein (gibt bestimmt UDF und das passende Objekt dazu) außer das selber zu basteln.
Ja genau, das es die Funktion gibt weiß ich ja. Ich wollte es wie schon gesagt in die GUI einbetten ...
Vielleicht hat ja jemand sowas schonmal realisiert ...
Welchen Sinn soll das Einbetten haben? Stehe da voll auf der Leitung.
Wenn der Anwender eine Datei wählen soll, erscheint die Datei/der Dateipfad nach der Auswahl in einem Input. Wozu willst du Platz verschwenden und ein Tree/Listview zur Auswahl ständig anzeigen, wenn nur einmalig darauf zugegriffen wird?
Es geht mir hier eher um die Optik, Bedienbarkeit. Ich möchte ein kleines Tool realsieren und fand es einfach
von meiner Überlegung her besser / schöner wenn praktisch ein kleines Explorer Fenster in der GUI eingebettet wäre anstatt
sich immer wieder ein neues Fenster öffnet...
Dann suchst du wohl eher einen SimpleExplorer um zu navigieren und auszuwählen.
Sowas hab ich vor Jahren mal gemacht. Kannst du ja als Basis nehmen:
#include <GUIConstantsEx.au3>
#include <ListBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListBox.au3>
#include <File.au3>
Global $aFile, $aFolder, $aPath[1] = [@HomeDrive & '\'], $currPath, $sUp = '[ EBENE HÖHER ]'
Global $Safed = '[SHOC]' ; mit diesen Attributen gesperrt für: Ausführen, Umbenennen, Löschen
$GUI = GUICreate("Simple Explorer",400,300)
$label = GUICtrlCreateLabel('', 5, 5, 390, 53)
$List = GUICtrlCreateList( '', 2, 65, 396, 230, BitOR($WS_HSCROLL, $WS_VSCROLL, $WS_BORDER))
$hList = GUICtrlGetHandle($List)
$menu = GUICtrlCreateContextMenu($List)
$itemRun = GUICtrlCreateMenuItem('Ausführen', $menu)
$itemShape = GUICtrlCreateMenuItem('', $menu)
$itemCopy = GUICtrlCreateMenuItem('Kopieren', $menu)
$itemPaste = GUICtrlCreateMenuItem('Einfügen', $menu)
GUICtrlSetState(-1, $GUI_DISABLE)
$itemRen = GUICtrlCreateMenuItem('Umbenennen', $menu)
$itemShape = GUICtrlCreateMenuItem('', $menu)
$itemDel = GUICtrlCreateMenuItem('Löschen', $menu)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
[/autoit] [autoit][/autoit] [autoit]_WriteList($aPath[0])
[/autoit] [autoit][/autoit] [autoit]While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $itemRun
_RunFile()
Case $itemCopy
_CopyFile()
Case $itemPaste
_PasteFile()
Case $itemRen
_RenFile()
Case $itemDel
_DelFile()
EndSwitch
Wend
Func _WriteList($PATH)
_GUICtrlListBox_ResetContent($hList) ; alte Inhalte löschen
$aFolder = _FileListToArray($PATH, '*', 2)
$aFile = _FileListToArray($PATH, '*', 1)
If UBound($aPath) > 1 Then _GUICtrlListBox_AddString($hList, $sUp)
If IsArray($aFolder) Then
_GUICtrlListBox_AddString($hList, '--------------- ORDNER ---------------')
For $i = 1 To UBound($aFolder) -1
_GUICtrlListBox_AddString($hList, $aFolder[$i])
Next
EndIf
If IsArray($aFile) Then
_GUICtrlListBox_AddString($hList, '--------------- DATEIEN ---------------')
For $i = 1 To UBound($aFile) -1
_GUICtrlListBox_AddString($hList, $aFile[$i])
Next
EndIf
GUICtrlSetData($label, $PATH)
EndFunc
Func _ListDblClick()
Local $str = _GUICtrlListBox_GetText($hList, _GUICtrlListBox_GetCurSel($hList))
Local $tmpPath = ''
If $str = $sUp Then
ReDim $aPath[UBound($aPath)-1]
$currPath = $aPath[UBound($aPath)-1]
_WriteList($currPath)
Else
$currPath = $aPath[UBound($aPath)-1] & $str & '\' ; neuer Pfad = letzter Pfad + geklickter Pfad
If Not StringRegExp(FileGetAttrib($currPath), 'D') Then ; ist es kein Ordner ?
_RunFile()
Else
ReDim $aPath[UBound($aPath)+1]
$aPath[UBound($aPath)-1] = $currPath ; neuen Pfad hinzufügen
_WriteList($currPath)
EndIf
EndIf
EndFunc
Func _RunFile()
Local $str = _GUICtrlListBox_GetText($hList, _GUICtrlListBox_GetCurSel($hList))
If $str = '' Then Return
Local $attrib = FileGetAttrib($aPath[UBound($aPath)-1] & $str)
If StringRegExp($attrib, $Safed) Then Return MsgBox(0, 'Geschützt!', $str & ' - Attribut: ' & $attrib)
ShellExecuteWait($aPath[UBound($aPath)-1] & $str)
EndFunc
Func _CopyFile()
Local $str = _GUICtrlListBox_GetText($hList, _GUICtrlListBox_GetCurSel($hList))
If $str = '' Then Return
Local $attrib = FileGetAttrib($aPath[UBound($aPath)-1] & $str)
If StringRegExp($attrib, 'D') Then Return MsgBox(0, 'Achtung', $str & ' ist keine Datei')
ClipPut($aPath[UBound($aPath)-1] & $str)
GUICtrlSetState($itemPaste, $GUI_ENABLE)
EndFunc
Func _PasteFile()
Local $str = _GUICtrlListBox_GetText($hList, _GUICtrlListBox_GetCurSel($hList))
If $str = '' Then Return
Local $attrib = FileGetAttrib($aPath[UBound($aPath)-1] & $str)
If Not StringRegExp($attrib, 'D') Then Return MsgBox(0, 'Achtung', $str & ' - ist kein Ordner')
Local $tmp = ClipGet(), $pos = StringInStr($tmp, '\', -1)
Local $file = StringRight($tmp, StringLen($tmp)-$pos)
If FileExists($aPath[UBound($aPath)-1] & $str & '\' & $file) Then $file = 'Kopie von ' & $file
FileCopy($tmp, $aPath[UBound($aPath)-1] & $str & '\' & $file)
_WriteList($aPath[UBound($aPath)-1])
GUICtrlSetState($itemPaste, $GUI_DISABLE)
EndFunc
Func _RenFile()
Local $str = _GUICtrlListBox_GetText($hList, _GUICtrlListBox_GetCurSel($hList))
If $str = '' Then Return
Local $attrib = FileGetAttrib($aPath[UBound($aPath)-1] & $str)
If StringRegExp($attrib, $Safed) Then Return MsgBox(0, 'Geschützt!', $str & ' - Attribut: ' & $attrib)
Local $tmp = InputBox('Umbenennen', 'Neuer Name:' & @LF & @LF & $aPath[UBound($aPath)-1], $str)
If $tmp <> '' Then FileMove($aPath[UBound($aPath)-1] & $str, $aPath[UBound($aPath)-1] & $tmp)
_WriteList($aPath[UBound($aPath)-1])
EndFunc
Func _DelFile()
Local $str = _GUICtrlListBox_GetText($hList, _GUICtrlListBox_GetCurSel($hList))
If $str = '' Then Return
Local $attrib = FileGetAttrib($aPath[UBound($aPath)-1] & $str)
If StringRegExp($attrib, $Safed) Then Return MsgBox(0, 'Geschützt!', $str & ' - Attribut: ' & $attrib)
FileDelete($aPath[UBound($aPath)-1] & $str)
_WriteList($aPath[UBound($aPath)-1])
EndFunc
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox
If Not IsHWnd($hList) Then $hWndListBox = GUICtrlGetHandle($hList)
$hWndFrom = $ilParam
$iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
$iCode = BitShift($iwParam, 16) ; Hi Word
Switch $hWndFrom
Case $hList, $hWndListBox
Switch $iCode
Case $LBN_DBLCLK ; Sent when the user double-clicks a string in a list box
_ListDblClick()
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND
Ja genau, hab ich mich wohl etwas falsch ausgedrückt ... sorry
Schau mir Dein Script gleich mal an, Danke !