Sowas suche ich. Ich habe keine ahnung wie ich sowas realisieren soll. Viel Programe fragen nach einer Datei x. Dan kan man sich yu der durchhangeln (Durchsuchen) und ok druecken. Sowas moechte ich auch.
Phatangeaben Program soll wie Explorer zu Datei fuehren
-
- [ offen ]
-
Skar -
1. Oktober 2009 um 08:50 -
Geschlossen -
Erledigt
-
-
- Offizieller Beitrag
Also einen einfachen Datei-Explorer.
Hatte ich vor Urzeiten mal gemacht.
Inklusive Doppelklick zum Ausführen der Dateien und Kontextmenü (Ausführen, Kopieren, Einfügen, Umbenennen, Löschen).Spoiler anzeigen
[autoit]#include<GUIConstantsEx.au3>
[/autoit] [autoit][/autoit] [autoit]
#include<ListBoxConstants.au3>
#include<WindowsConstants.au3>
#include <GuiListBox.au3>
#include <File.au3>Global $aFile, $aFolder, $aPath[1] = [@HomeDrive & '\'], $currPath, $sUp = '[ EBENE HÖHER ]'
[/autoit] [autoit][/autoit] [autoit]
Global $Safed = '[SHOC]' ; mit diesen Attributen gesperrt für: Ausführen, Umbenennen, Löschen$GUI = GUICreate("Simple Explorer",400,300)
[/autoit] [autoit][/autoit] [autoit]
$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
[/autoit] [autoit][/autoit] [autoit]
$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
WendFunc _WriteList($PATH)
[/autoit] [autoit][/autoit] [autoit]
_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)
EndFuncFunc _ListDblClick()
[/autoit] [autoit][/autoit] [autoit]
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
EndFuncFunc _RunFile()
[/autoit] [autoit][/autoit] [autoit]
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)
EndFuncFunc _CopyFile()
[/autoit] [autoit][/autoit] [autoit]
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)
EndFuncFunc _PasteFile()
[/autoit] [autoit][/autoit] [autoit]
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)
EndFuncFunc _RenFile()
[/autoit] [autoit][/autoit] [autoit]
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])
EndFuncFunc _DelFile()
[/autoit] [autoit][/autoit] [autoit]
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])
EndFuncFunc WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
[/autoit]
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_COMMANDOder meinst du evtl. einfach nur: FileOpenDialog() ?
-
Der kleine unscheinbare Tipp @FileOpenDialog@ hat mich zum Ziel gefuert. Danke. Juhu >< Freu
Spoiler anzeigen
[autoit]
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
#include <GUIConstants.au3>GUICreate("Phat", 500, 400)
[/autoit] [autoit][/autoit] [autoit]GUICtrlCreateGroup("Datei öffnen", 10, 10, 480, 60)
[/autoit] [autoit][/autoit] [autoit]
$button = GUICtrlCreateButton("Durchsuchen...", 370, 30, 100, 25)
$input = GUICtrlCreateInput("", 30, 30, 320, 25)
GUISetState()While 1
[/autoit]
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $button
$re = FileOpenDialog("Datei öffnen", @DesktopDir, "Alle Dateien (*.*)")
If @error Then
MsgBox(16, Default, "FOD", 5)
EndIf
GUICtrlSetData($input, $re)
EndSwitch
WEnd -
Ich wei- jetyt nicht wo das noch muckt. Case $Button1S Funzt gut. Doch warum wird jetzt die SkriptPathangaben.txt in den Ordner gespeicher wo der Phad liegt? Die Datei existiert in dem Ordner wo die .au3 ist. Also mein Naviigations Datenbank programm xD.
Spoiler anzeigen
[autoit]
[/autoit]
Case $Button1S
$re = FileOpenDialog("Datei öffnen", @DesktopDir, "Alle Dateien (*.*)")
If @error Then
MsgBox(16, Default, "FOD", 5)
EndIf
GUICtrlSetData($Input1S, $re)
Case $Button2S
$Path = GuiCtrlRead($Input1S)
If FileExists(@ScriptDir & '\SkriptPathangaben.txt') Then
$file = FileOpen ( "SkriptPathangaben.txt", 1 )
If $file = -1 Then
MsgBox(0, "Error", "Kann Datei nicht Öffnen!")
Exit
EndIf
FileWrite($file, @CRLF)
FileWrite($file, $Path )
FileClose($file)
Else
MsgBox(4096,"Warnung" , "SkriptPathangaben.txt does NOT exists")
EndIf
msgbox(0, "INFO", "Phad gespeichert")PS> Hab den Fehler gefunden $file = FileOpen (@ScriptDir & "\SkriptPathangaben.txt", 1 ) so mus es sein.
-
- Offizieller Beitrag
Zitat aus der Hilfe:
Zitat@WorkingDir is changed on successful return.
Bei FileOpen musst Du also auch den ganzen Pfad angeben (@ScriptDir hinzufügen).