Sign in to follow this  
Followers 0
Javik

Windows Explorer view, but with my own coded file actions?

3 posts in this topic

Is there a simple way to display a list of icons in a folder, but assign my own menu and mouse context menus for the folder list?

I have seen the posts about embedding Windows Explorer icon lists into an AutoIt parent window, but when the mouse is right-clicked in the list, it acts like a normal Explorer shell with options for delete, renamed, new, etc.

I would like to display the contents of a folder and just have context/menu options for Open?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include<File.au3>

Opt('GUIOnEventMode', 1)

Global $aFileArray, $sFolder = @DesktopDir ;Folder to browse.
Global $hGui, $hList, $hListItems[1] = [1]

$hGui = GUICreate('Custom Explorer', 420, 420)
GUISetOnEvent(-3, '_Exit')
GUISetBkColor(0x515151)

$hList = GUICtrlCreateListView('Files', 10, 10, 400, 400)

$hContextMenu = GUICtrlCreateContextMenu($hList)

GUICtrlCreateMenuItem('Open', $hContextMenu)
GUICtrlSetOnEvent(-3, '_Open')

GUICtrlCreateMenuItem('Open with Notepad', $hContextMenu)
GUICtrlSetOnEvent(-3, '_OpenWithNotepad')

GUISetState()

$aFileArray = _FileListToArray($sFolder)
For $i = 1 To $aFileArray[0]
    $hListItems[0] += 1
    ReDim $hListItems[$hListItems[0]]
    $hListItems[$hListItems[0] - 1] = GUICtrlCreateListViewItem($aFileArray[$i], $hList)
Next

ControlClick('Custom Explorer', '', 'SysHeader321', 'Primary', 2, 45, 10)

While 1
    Sleep(10)
WEnd

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func _Open()
    $Active = StringTrimRight(GUICtrlRead(GUICtrlRead($hList)), 1)
    ShellExecute($sFolder & $Active)
EndFunc   ;==>_Open

Func _OpenWithNotepad()
    $Active = StringTrimRight(GUICtrlRead(GUICtrlRead($hList)), 1)
    ShellExecute(@SystemDir & '\notepad.exe', $sFolder & $Active)
EndFunc   ;==>_OpenWithNotepad

Edited by BitByteBit

Share this post


Link to post
Share on other sites

Thanks for this code example.

,

Small correction to your code, need a backslash in the path:

Func _Open()
    $Active = StringTrimRight(GUICtrlRead(GUICtrlRead($hList)), 1)
    ShellExecute($sFolder & $Active)
EndFunc   ;==>_Open

should be:

Func _Open()
    $Active = StringTrimRight(GUICtrlRead(GUICtrlRead($hList)), 1)
    ShellExecute($sFolder & "\" & $Active)
EndFunc   ;==>_Open

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0