Hey,
ich bastle gerade eine Winamp Oberfläche, die mit der Fernbedienung bedient werden kann.
Das Bedienkonzept wollte ich es ganz einfach halten:
Pfeilstasten hoch/runter um die Items im Listview durchzugehen (Verzeichnisse bzw. Dateien);
rechte Pfeiltaste -> in einen Unterordner gehen oder die Datei zur Playliste hinzufügen;
linke Pfeiltaste -> wieder raus aus dem Unterordner bzw. ins übergeordnete Verzeichnis wechseln;
Enter -> Den ganzen Unterordner zu Playliste hinzufügen / die ausgewählte Datei zur Playliste hinzufügen
Für den Browser habe ich ein Beispiel von Progandy genommen (Achtung da hab ich schon drin rumgeschmiert, wer das Orginal haben will muss mal die Suchfunktion bemühen):
Spoiler anzeigen
;#BETA
#include <GuiImageList.au3>
#include <GUIListView.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
Global Const $tagSHFILEINFO = "dword hIcon; int iIcon; DWORD dwAttributes; CHAR szDisplayName[255]; CHAR szTypeName[80];"
Global Const $SHGFI_USEFILEATTRIBUTES = 0x10
Global Const $SHGFI_SYSICONINDEX = 0x4000
Global Const $FILE_ATTRIBUTE_NORMAL = 0x80
Global Const $SHGFI_SMALLICON = 0x1
Global Const $SHGFI_LARGEICON = 0x0
Global Const $FOLDERUP_ICON_INDEX = _GUIImageList_AddIcon(_GUIImageList_GetSystemImageList(), @SystemDir & "\shell32.dll", 132)
Global Const $FOLDER_ICON_INDEX = _GUIImageList_GetFileIconIndex(@SystemDir, 0, 1)
Global Const $NOICON_ICON_INDEX = _GUIImageList_GetFileIconIndex("nb lgl", 0, 0)
Global $path = "C:\Programme"
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=D:\Dokumente\Dateien von Andreas\AutoIt3\FTP\GUI_MAIN.kxf
Global $GUI_MAIN = GUICreate("Au3FTP", 882, 586, 193, 125)
GUISetOnEvent(-3, "GUI_Close")
Global $inpLocalDirectory = GUICtrlCreateInput("", 8, 28, 369, 20, $ES_READONLY)
Global $ListView1 = GUICtrlCreateListView("Name|Datum|Größe", 8, 48, 369, 489)
Global $SHELLLISTVIEWHANDLE = GUICtrlGetHandle($ListView1) ; Get the Handle
[/autoit] [autoit][/autoit] [autoit]GUICtrlSendMsg($ListView1, 0x101E, 0, 200)
GUICtrlSendMsg($ListView1, 0x101E, 1, 75)
GUICtrlSendMsg($ListView1, 0x101E, 2, 50)
GUIRegisterMsg($WM_NOTIFY, "_SHLV_WM_NOTIFY")
_GUICtrlListView_SetImageList($ListView1, _GUIImageList_GetSystemImageList(), 1)
Global $DIRECTORY_LOCAL = "" ; Start with Selection of drives (IMG:http://www.autoitscript.com/forum/style_em…utoit/smile.gif)
_SHLV_PopulateLocalListView($SHELLLISTVIEWHANDLE, $DIRECTORY_LOCAL)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(100)
WEnd
Func GUI_Close()
Exit
EndFunc ;==>GUI_Close
; Prog@ndy
Func _SHLV_PopulateLocalListView($hListView1, ByRef $DIRECTORY_LOCAL)
If Not IsHWnd($hListView1) Then $hListView1 = GUICtrlGetHandle($hListView1)
If $DIRECTORY_LOCAL = "" Then
Local $drives = DriveGetDrive("ALL")
GUICtrlSetData($inpLocalDirectory, "Pfad Auswahl")
_GUICtrlListView_BeginUpdate($hListView1)
_GUICtrlListView_DeleteAllItems($hListView1)
_GUICtrlListView_AddItem($hListView1, $path);, _GUIImageList_GetFileIconIndex($drives[$i] & "\"))
_GUICtrlListView_EndUpdate($hListView1)
Return
EndIf
If StringRight($DIRECTORY_LOCAL, 1) <> "\" Then $DIRECTORY_LOCAL &= "\"
If DriveStatus(StringLeft($DIRECTORY_LOCAL, 3)) <> "READY" Then Return 0 * MsgBox(16 + 8192, 'Error on Drive Access', "Drive " & StringLeft($DIRECTORY_LOCAL, 3) & " not ready!")
GUICtrlSetData($inpLocalDirectory, $DIRECTORY_LOCAL)
$files = _SHLV__FileListToArray2($DIRECTORY_LOCAL, "*.*", 2)
_GUICtrlListView_BeginUpdate($hListView1)
_GUICtrlListView_DeleteAllItems($hListView1)
Local $foldercount = 0
_GUICtrlListView_AddItem($hListView1, "< .. >", $FOLDERUP_ICON_INDEX)
If IsArray($files) Then
_GUICtrlListView_SetItemCount($hListView1, $files[0] + 1)
$foldercount = $files[0] + 1
For $i = 1 To $files[0]
$item = _GUICtrlListView_AddItem($hListView1, $files[$i], $FOLDER_ICON_INDEX)
_GUICtrlListView_AddSubItem($hListView1, $item, __SHLV_FormatFilesize(DirGetSize($DIRECTORY_LOCAL & $files[$i], 2)), 2)
Next
EndIf
$files = _SHLV__FileListToArray2($DIRECTORY_LOCAL, "*.*", 1)
_GUICtrlListView_EndUpdate($hListView1)
_GUICtrlListView_BeginUpdate($hListView1)
If IsArray($files) Then
_GUICtrlListView_SetItemCount($hListView1, $files[0] + $foldercount)
For $i = 1 To $files[0]
$item = _GUICtrlListView_AddItem($hListView1, $files[$i], _GUIImageList_GetFileIconIndex($files[$i]))
_GUICtrlListView_AddSubItem($hListView1, $item, __SHLV_FileDateString2Calc(FileGetTime($DIRECTORY_LOCAL & $files[$i], 0, 1)), 1)
_GUICtrlListView_AddSubItem($hListView1, $item, __SHLV_FormatFilesize(FileGetSize($DIRECTORY_LOCAL & $files[$i])), 2)
Next
EndIf
_GUICtrlListView_EndUpdate($hListView1)
EndFunc ;==>_SHLV_PopulateLocalListView
; Prog@ndy
Func __SHLV_FormatFilesize($size)
Select
Case $size > 1000
Return Round($size / 1024, 1) & " KB"
Case $size > 1048500
Return Round($size / 1048576, 1) & " MB"
Case Else
Return $size & " Byte"
EndSelect
EndFunc ;==>__SHLV_FormatFilesize
; Prog@ndy
Func _GUIImageList_GetSystemImageList($bLargeIcons = False)
Local $dwFlags, $hIml, $FileInfo = DllStructCreate($tagSHFILEINFO)
$dwFlags = BitOR($SHGFI_USEFILEATTRIBUTES, $SHGFI_SYSICONINDEX)
If Not ($bLargeIcons) Then
$dwFlags = BitOR($dwFlags, $SHGFI_SMALLICON)
EndIf
;~ '// Load the image list - use an arbitrary file extension for the
;~ '// call to SHGetFileInfo (we don't want to touch the disk, so use
;~ '// FILE_ATTRIBUTE_NORMAL && SHGFI_USEFILEATTRIBUTES).
$hIml = _WinAPI_SHGetFileInfo(".txt", $FILE_ATTRIBUTE_NORMAL, _
DllStructGetPtr($FileInfo), DllStructGetSize($FileInfo), $dwFlags)
Return $hIml
EndFunc ;==>_GUIImageList_GetSystemImageList
; Prog@ndy
Func _WinAPI_SHGetFileInfo($pszPath, $dwFileAttributes, $psfi, $cbFileInfo, $uFlags)
Local $return = DllCall("shell32.dll", "DWORD*", "SHGetFileInfo", "str", $pszPath, "DWORD", $dwFileAttributes, "ptr", $psfi, "UINT", $cbFileInfo, "UINT", $uFlags)
If @error Then Return SetError(@error, 0, 0)
Return $return[0]
EndFunc ;==>_WinAPI_SHGetFileInfo
; Prog@ndy
Func _GUIImageList_GetFileIconIndex($sFileSpec, $bLargeIcons = False, $bForceLoadFromDisk = False)
Local $dwFlags, $FileInfo = DllStructCreate($tagSHFILEINFO)
$dwFlags = $SHGFI_SYSICONINDEX
If $bLargeIcons Then
$dwFlags = BitOR($dwFlags, $SHGFI_LARGEICON)
Else
$dwFlags = BitOR($dwFlags, $SHGFI_SMALLICON)
EndIf
;~ ' We choose whether to access the disk or not. If you don't
;~ ' hit the disk, you may get the wrong icon if the icon is
;~ ' not cached. But the speed is very good!
If Not $bForceLoadFromDisk Then
$dwFlags = BitOR($dwFlags, $SHGFI_USEFILEATTRIBUTES)
EndIf
;~ ' sFileSpec can be any file. You can specify a
;~ ' file that does not exist and still get the
;~ ' icon, for example sFileSpec = "C:\PANTS.DOC"
Local $lR = _WinAPI_SHGetFileInfo( _
$sFileSpec, $FILE_ATTRIBUTE_NORMAL, DllStructGetPtr($FileInfo), DllStructGetSize($FileInfo), _
$dwFlags _
)
If ($lR = 0) Then
Return SetError(1, 0, -1)
Else
Return DllStructGetData($FileInfo, "iIcon")
EndIf
EndFunc ;==>_GUIImageList_GetFileIconIndex
; Author(s): Prog@ndy
Func __SHLV_FileDateString2Calc($filedate)
Return StringRegExpReplace($filedate, "(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", "$1/$2/$3 $4:$5:$6")
EndFunc ;==>__SHLV_FileDateString2Calc
; Author(s): Prog@ndy
Func __SHLV_CalcDate2FileDateString($calcdate)
Return StringRegExpReplace($calcdate, "(\d{4})/(\d{2})/(\d{2}) (\d{2})(IMG:http://www.autoitscript.com/forum/style_em…/autoit/sad.gif) \d{2})(IMG:http://www.autoitscript.com/forum/style_em…/autoit/sad.gif) \d{2})", "$1$2$3$4$5$6")
EndFunc ;==>__SHLV_CalcDate2FileDateString
; Prog@ndy
Func _SHLV_WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo, $hListView1 = $SHELLLISTVIEWHANDLE
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hListView1
;MsgBox(1, "", $iCode)
Switch $iCode
Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
Local $ItemText = _GUICtrlListView_GetItemText($hListView1, _GUICtrlListView_GetSelectedIndices($hListView1), 0)
_Browse($ItemText)
Case $LVN_KEYDOWN
Local $tagLVKEYDOWN = $tagNMHDR & "; USHORT wVKey; UINT flags;"
$tNMHDR = DllStructCreate($tagLVKEYDOWN, $ilParam)
;MsgBox(1, "", DllStructGetData($tNMHDR, "wVKey"))
Switch DllStructGetData($tNMHDR, "wVKey")
Case 0x27; rechte Pfeiltaste
Local $ItemText = _GUICtrlListView_GetItemText($hListView1, _GUICtrlListView_GetSelectedIndices($hListView1), 0)
_Browse($ItemText)
Case 0x25 ;linke Pfeiltaste
_Browseback()
EndSwitch
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>_SHLV_WM_NOTIFY
Func _Browseback()
If $DIRECTORY_LOCAL = $path & "\" then $DIRECTORY_LOCAL = ""
Local $slash = StringInStr($DIRECTORY_LOCAL, "\", 1, -2)
If $slash Then
$DIRECTORY_LOCAL = StringLeft($DIRECTORY_LOCAL, $slash)
;ElseIf StringRegExp($DIRECTORY_LOCAL, "\A[A-Za-z]:\\\Z") Then
; MsgBox(1, "", StringRegExp($DIRECTORY_LOCAL, "\A[A-Za-z]:\\\Z"))
; $DIRECTORY_LOCAL = ""
EndIf
_SHLV_PopulateLocalListView($ListView1, $DIRECTORY_LOCAL)
;No return value
EndFunc ;==>_Browseback
[/autoit] [autoit][/autoit] [autoit]Func _Browse($data)
If StringInStr(FileGetAttrib($DIRECTORY_LOCAL & $data), "D") Then
$DIRECTORY_LOCAL &= $data
_SHLV_PopulateLocalListView($ListView1, $DIRECTORY_LOCAL)
ElseIf StringRegExp($data, "\A[A-Za-z]:\\\Z") Then
$DIRECTORY_LOCAL = $data
_SHLV_PopulateLocalListView($ListView1, $DIRECTORY_LOCAL)
ElseIf $data = "< .. >" Then
#cs
Local $slash = StringInStr($DIRECTORY_LOCAL, "\", 1, -2)
If $slash Then
$DIRECTORY_LOCAL = StringLeft($DIRECTORY_LOCAL, $slash)
ElseIf StringRegExp($DIRECTORY_LOCAL, "\A[A-Za-z]:\\\Z") Then
$DIRECTORY_LOCAL = ""
EndIf
_SHLV_PopulateLocalListView($ListView1, $DIRECTORY_LOCAL)
#ce
Else
If MsgBox(36, "ShellListView", "Soll diese Datei geöffnet werden? " & @CRLF & $DIRECTORY_LOCAL & $data) = 6 Then
ShellExecute($DIRECTORY_LOCAL & $data, "", $DIRECTORY_LOCAL)
EndIf
EndIf
EndFunc ;==>_Browse
; Author ........: SolidSnake <MetalGX91 at GMail dot com>
; Modified by Prog@ndy
Func _SHLV__FileListToArray2($sPath, $sFilter = "*", $iFlag = 0)
Local $hSearch, $sFile, $asFileList
If Not FileExists($sPath) Then Return SetError(1, 1, "")
If (StringInStr($sFilter, "\")) Or (StringInStr($sFilter, "/")) Or (StringInStr($sFilter, ":")) Or (StringInStr($sFilter, ">")) Or (StringInStr($sFilter, "<")) Or (StringInStr($sFilter, "|")) Or (StringStripWS($sFilter, = "") Then Return SetError(2, 2, "")
If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "")
If (StringMid($sPath, StringLen($sPath), 1) = "\") Then $sPath = StringTrimRight($sPath, 1) ; needed for Win98 for x:\ root dir
$hSearch = FileFindFirstFile($sPath & "\" & $sFilter)
If $hSearch = -1 Then Return SetError(4, 4, "")
While 1
$sFile = FileFindNextFile($hSearch)
If @error Then
SetError(0)
ExitLoop
EndIf
If $iFlag = 1 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") <> 0 Then ContinueLoop
If $iFlag = 2 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") = 0 Then ContinueLoop
$asFileList &= $sFile & @CR
WEnd
FileClose($hSearch)
If Not $asFileList Then
Dim $asFileList[1] = [0]
Return SetError(1, 0, $asFileList)
EndIf
Return StringSplit(StringTrimRight($asFileList, 1), @CR)
EndFunc ;==>_SHLV__FileListToArray2
Nun zum Problem: Das Listview reagiert nicht auf die Enter Taste
Jede andere Taste scheint zu funktionieren
Zeile 188 bis 205 sind die enstprechenden Zeilen, $NM_Return funktioniert im Listview auch nicht.
Kann man diese Einschränkung irgendwie austricksen? Hotkeyset möchte ich ungern verwenden.
Gruß nuts
edit \
Theoretisch müsste es doch gehen.
http://msdn.microsoft.com/en-us/library/bb774879(VS.85).aspx