RDSchaefer Posted April 24, 2009 Share Posted April 24, 2009 (edited) This is what I have so far. It mostly works except that I want to be able to use the keyboard. I'd like to use the cursor keys to move down the list (which works) and then press the Enter key to select an item. Please help expandcollapse popupConst $VERSION = "MyMenu v0.0.1" Global $g_hList Global $g_hWin Global $g_lWidth = 1 Global $g_lHeight = 1 Global $g_sTitle = "MyMenu" Global $g_aList[2][2] Global $g_aItem[2] Global $g_aTitle[100] #include <guiconstants.au3> #include <windowsconstants.au3> Func Quit($bNow = 0) Local $iTitle GUISetState(@SW_SHOW, $g_hWin) $g_aTitle[0] -= 1 If $g_aTitle[0] = 0 _ Or $bNow = 1 then FileDelete(@ScriptDir & "MyMenu.ico") Exit EndIf $iTitle = $g_aTitle[0] $g_sTitle = $g_aTitle[$iTitle] NewWindow() EndFunc Func Init() If Not FileExists(@ScriptDir & "\MyMenu.INI") then MsgBox(16, $VERSION, "Specified menu file 'MyMenu.INI' not found") Exit EndIf FileInstall("D:\Code\Files\MyMenu.ico", @ScriptDir, 1) $g_aTitle[0] = 1 $g_aTitle[1] = "MyMenu" Endfunc Func PushTitle($sTitle) Local $iTitle $iTitle = $g_aTitle[0] + 1 If $iTitle > UBound($g_aTitle) then ReDim $g_aTitle[$iTitle] EndIf $g_aTitle[0] = $iTitle $g_aTitle[$iTitle] = $sTitle $g_sTitle = $sTitle EndFunc Func ListClick() Local $hID Local $iList $hID = @GUI_CTRLID For $iList = 1 to $g_aList[0][0] If $hID = $g_aItem[$iList] then ExitLoop EndIf Next If $iList > $g_aList[0][0] then MsgBox(16, $VERSION, "Unknown Control Event") Quit(1) EndIf If Stringright($g_aList[$iList][0], 3) <> "..." then Opt("ExpandEnvStrings", 1) ShellExecute($g_aList[$iList][1]) Quit(1) EndIf PushTitle(StringReplace($g_aList[$iList][0], "...", "")) NewWindow() EndFunc Func NewWindow() Local $g_hWin Local $iList Local $iWidth Local $sTitle $g_aList = IniReadSection(@ScriptDir & "\MyMenu.INI", $g_sTitle) $g_lHeight = $g_aList[0][0] * 17 ReDim $g_aItem[$g_lHeight + 1] For $iList = 1 to $g_aList[0][0] $iWidth = StringLen($g_aList[$iList][0]) If $iWidth > $g_lWidth then $g_lWidth = $iWidth EndIf Next $sTitle = StringLeft($g_sTitle & " ", $g_lWidth) $g_hWin = GUICreate($VERSION & " - " & $sTitle, $g_lWidth * 5, $g_lHeight, -1, -1, $WS_POPUP) GUISetIcon(@ScriptDir & "MyMenu.ico") GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") $g_hList = GUICtrlCreateListView($sTitle, 0, 0, $g_lWidth * 10, $g_lHeight * 20) For $iList = 1 to $g_aList[0][0] $g_aItem[$iList] = GUICtrlCreateListViewItem($g_aList[$iList][0], $g_hList) GUICtrlSetOnEvent(-1, "ListClick") Next GUISetState(@SW_SHOW) EndFunc ;*============================================================================* Opt("GUIOnEventMode", 1) Opt("MustDeclareVars", 1) HotKeySet("^{F12}", "Quit") Init() NewWindow() While 1 Sleep(250) WEnd Exit Edited April 29, 2009 by RDSchaefer Link to comment Share on other sites More sharing options...
BinaryBrother Posted April 24, 2009 Share Posted April 24, 2009 If WinActive("YOUR-GUI") And _Ispressed() Then <--- look up the usage, I think thats what you need... _etc() EndIf SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
water Posted April 24, 2009 Share Posted April 24, 2009 I bookmarked this topic as a starting point on how to handle the enter key "problem". My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
RDSchaefer Posted April 24, 2009 Author Share Posted April 24, 2009 If WinActive("YOUR-GUI") And _Ispressed() Then <--- look up the usage, I think thats what you need... _etc() EndIf I'm sorry, I have no idea how this applies to my question. This is a totally standalone app. BTW - I forgot to post the ini file expandcollapse popup<MyMenu> Apps...=Apps Graphics...=Graphics NCC...=NCC Programming...=Programming SchaeferConsulting...=SchaeferConsulting Security...=Security Tickets...=Tickets Utils...=Utils ConTEXT="%MyUSB%\Program Files\ConTEXT\ConTEXT.exe" MyTime="%MyUSB%\Program Files\NCC\MyTime.exe" Salamander="%MyUSB%\Program Files\AltapSalamander\SALAMAND.exe" <Apps> Tiny Office...=Tiny Office CCleaner="%MyUSB%\Program Files\CCleaner\CCleaner.exe" Cd2ISO="%MyUSB%\Program Files\cd2iso\cd2iso.exe" CSVed="%MyUSB%\Program Files\CSVed\CSVed.exe" ExamDiff="%MyUSB%\Program Files\ExamDiff\ExamDiff.exe" FBZip="%MyUSB%\Program Files\FBZip\FBZip.exe" FontMagic="%MyUSB%\Program Files\FontMagic\FontMagic.exe" Foxit Reader="%MyUSB%\Program Files\Foxit\Foxit Reader.exe" FTPEdit="%MyUSB%\Program Files\FTP Edit\FTPEdit.exe" Maxthon="%MyUSB%\Program Files\Maxthon\Maxthon.exe" NotePad2="%MyUSB%\Program Files\Notepad2\Notepad2.exe" NotePadSX="%MyUSB%\Program Files\NotepadSX\NotepadSX.exe" OutPort="%MyUSB%\Program Files\OutPort\outport.exe" PFE32="%MyUSB%\Program Files\PFE\PFE32.exe" PGS="%MyUSB%\Program Files\PGS\Pgs.exe" PPF="%MyUSB%\Program Files\Misc\Ppf.exe" PTE="%MyUSB%\Program Files\PTE\pte.exe" SPFPC="%MyUSB%\Program Files\SPF\SPFPC.exe" Tinyspell="%MyUSB%\Program Files\Tinyspell\tinyspell.exe" Treecopy="%MyUSB%\Program Files\TreeCopy\treecopy.exe" Treepad="%MyUSB%\Program Files\Treepad\Treepad.exe" WavTrim="%MyUSB%\Program Files\Misc\WavTrim.exe" <Graphics> BASIC Draw="%MyUSB%\Program Files\Graphics\BASICdraw.exe" FxIcon32="%MyUSB%\Program Files\Icon Maker\FxIcon32.exe" Gentex="%MyUSB%\Program Files\Graphics\gentex.exe" GIF Animator="%MyUSB%\Program Files\Graphics\GIFAnimator.exe" Gradiator="%MyUSB%\Program Files\Graphics\Gradiator.exe" IcoFX="%MyUSB%\Program Files\IcoFX\IcoFX.exe" IcoLib2Dir="%MyUSB%\Program Files\Graphics\IcoLib2Dir.exe" Icons Extract="%MyUSB%\Program Files\IconsExtract\iconsext.exe" IrfanView="%MyUSB%\Program Files\IrfanView\i_view32.exe" Paint Shop Pro="%MyUSB%\Program Files\Paint Shop Pro\Psp.exe" Rockin' Text="%MyUSB%\Program Files\Misc\Rockin' Text.exe" <NCC> AS400...=AS400 DX...=DX Mainframe...=Mainframe Midrange...=Midrange Network...=Network Alert="%MyUSB%\Program Files\NCC\Alert.exe" Avaya="%MyUSB%\Program Files\NCC\Avaya.exe" CCC="%MyUSB%\Program Files\NCC\CCC.exe" CleanInboxPC="%MyUSB%\Program Files\NCC\CleanInboxPC.exe" FDR="%MyUSB%\Program Files\NCC\FDR.exe" SC="%MyUSB%\Program Files\NCC\SC.exe" <Programming> AutoIt...=AutoIt ApiViewer="%MyUSB%\Program Files\ApiViewer 2004\ApiViewer2004.exe" BatchRun="%MyUSB%\Program Files\BatchRun\Batchrun.exe" BinText="%MyUSB%\Program Files\BinText\bintext.exe" Bits="%MyUSB%\Program Files\Bits\BITS.exe" Button Artist Wizard="%MyUSB%\Program Files\ButtonArtistWizard\ButtonArtistWiz.exe" Button Maker="%MyUSB%\Program Files\Button Maker v1.0\ButtonMaker V1.exe" CHM Decoder="%MyUSB%\Program Files\CHM Decoder\chmdecoder.exe" CHM Encoder="%MyUSB%\Program Files\CHM Decoder\chmencoder.exe" JFE="%MyUSB%\Program Files\JFE\jfe.exe" OleView="%MyUSB%\Program Files\OleView\oleview.exe" ProgFont="%MyUSB%\Program Files\ProgFont\progfont.exe" RegExBuilder="%MyUSB%\Program Files\RegExBuilder\RegExBuilder.exe" Relo="%MyUSB%\Program Files\Relo\Relo.exe" <Security> AutoRuns="%MyUSB%\Program Files\AutoRuns\autoruns.exe" ClamWin Plus="%MyUSB%\Program Files\ClamWin Plus\App\ClamWin\bin\ClamWin.exe" PST Password="%MyUSB%\Program Files\PstPassword\PstPassword.exe" <SchaeferConsulting> AddSeqNbrs="%MyUSB%\Program Files\SchaeferConsulting\AddSeqNbrs.exe" AttachmentExtract="%MyUSB%\Program Files\SchaeferConsulting\AttachmentExtract.exe" DirDateFromExe="%MyUSB%\Program Files\SchaeferConsulting\DirDateFromExe.exe" DrvLtrPos="%MyUSB%\Program Files\SchaeferConsulting\DrvLtrPos.exe" IniSort="%MyUSB%\Program Files\SchaeferConsulting\IniSort.exe" Janitor="%MyUSB%\Program Files\SchaeferConsulting\Janitor.exe" LookUpExt="%MyUSB%\Program Files\SchaeferConsulting\LookUpExt.exe" MakeLinks="%MyUSB%\Program Files\SchaeferConsulting\MakeLinks.exe" MakePlayList="%MyUSB%\Program Files\SchaeferConsulting\MakePlayList.exe" MaxLinks="%MyUSB%\Program Files\SchaeferConsulting\MaxLinks.exe" MonCal="%MyUSB%\Program Files\SchaeferConsulting\MonCal.exe" MyMail="%MyUSB%\Program Files\SchaeferConsulting\MyMail.exe" MySS="%MyUSB%\Program Files\SchaeferConsulting\MySS.exe" Name2IP="%MyUSB%\Program Files\SchaeferConsulting\Name2IP.exe" NewName="%MyUSB%\Program Files\SchaeferConsulting\NewName.exe" Noansi="%MyUSB%\Program Files\SchaeferConsulting\Noansi.exe" NoRemoteSchedTasks="%MyUSB%\Program Files\SchaeferConsulting\NoRemoteSchedTasks.exe" OlNotes2Txt="%MyUSB%\Program Files\SchaeferConsulting\OlNotes2Txt.exe" RenLinks="%MyUSB%\Program Files\SchaeferConsulting\RenLinks.exe" SetTimeSync="%MyUSB%\Program Files\SchaeferConsulting\SetTimeSync.exe" ShowIP="%MyUSB%\Program Files\SchaeferConsulting\ShowIP.exe" Twitch="%MyUSB%\Program Files\SchaeferConsulting\Twitch.exe" Unlock="%MyUSB%\Program Files\SchaeferConsulting\Unlock.exe" uuenview="%MyUSB%\Program Files\SchaeferConsulting\uuenview.exe" WallCalendar="%MyUSB%\Program Files\SchaeferConsulting\WallCalendar.exe" YearCalendar="%MyUSB%\Program Files\SchaeferConsulting\YearCalendar.exe" Z2R="%MyUSB%\Program Files\SchaeferConsulting\Z2R.exe" Zip="%MyUSB%\Program Files\SchaeferConsulting\zip.exe" <Tickets> Ack="%MyUSB%\Program Files\NCC\MRTA.exe" Cls="%MyUSB%\Program Files\NCC\MRTC.exe" <Utils> abclit="%MyUSB%\Program Files\abclit\abclit.exe" Aida32="%MyUSB%\Program Files\Aida32\aida32.exe" CloneSpy="%MyUSB%\Program Files\CloneSpy\CloneSpy.exe" COA2="%MyUSB%\Program Files\COA2\!COA.exe" DataRecovery="%MyUSB%\Program Files\DataRecovery\DataRecovery.exe" Defrag&Restart="%MyUSB%\Program Files\JK Defrag\D&R_NT.exe" DLLArchive="%MyUSB%\Program Files\DLLArchive\dllarch.exe" DOSPrint="%MyUSB%\Program Files\DOSPrint\DOSPrintUI.exe" DoubleKiller="%MyUSB%\Program Files\Misc\DoubleKiller.exe" DriverBackup!="%MyUSB%\Program Files\DriverBackup!\DriverBackup!.exe" DTaskManager="%MyUSB%\Program Files\DTaskManager\DTaskManager.exe" EasyCleaner="%MyUSB%\Program Files\EasyCleaner\EasyClea.exe" HijackThis="%MyUSB%\Program Files\HijackThis\HijackThis.exe" InCtrl5="%MyUSB%\Program Files\InCtrl5\InCtrl5.exe" Mirror="%MyUSB%\Program Files\Mirror\Mirror.exe" MultiRes="%MyUSB%\Program Files\MultiRes\MultiRes.exe" OpenedFilesView="%MyUSB%\Program Files\OpenedFilesView\OpenedFilesView.exe" OpenWithView="%MyUSB%\Program Files\OpenWithView\OpenWithView.exe" PrintKey2K="%MyUSB%\Program Files\PrintKey2K\Printkey2000.exe" ProduKey="%MyUSB%\Program Files\ProduKey\ProduKey.exe" RegCleaner="%MyUSB%\Program Files\RegCleaner\RegCleanr.exe" RegCleaner="%MyUSB%\Program Files\TweakNow RegCleaner Std\RegCleaner.exe" RegDelNull="%MyUSB%\Program Files\RegDelNull\RegDelNull.exe" RenameMaster="%MyUSB%\Program Files\RenameMaster\RenameMaster.exe" ReNamer="%MyUSB%\Program Files\ReNamer\ReNamer.exe" ReplacEm="%MyUSB%\Program Files\ReplacEm\replacem.exe" Securable="%MyUSB%\Program Files\Misc\securable.exe" SetAutochk="%MyUSB%\Program Files\Misc\SetAutochk.exe" SSC="%MyUSB%\Program Files\SSC\Ssc.exe" SysExp="%MyUSB%\Program Files\SysExp\sysexp.exe" Text2HTML="%MyUSB%\Program Files\Txt2Html\Text2Html.exe" Textractor="%MyUSB%\Program Files\Textractor\Textractor.exe" TinyDesk="%MyUSB%\Program Files\TinyDesk\tinydesk.exe" TreeSize="%MyUSB%\Program Files\TreeSize\TreeSizeFree.exe" TurnItOn="%MyUSB%\Program Files\Misc\TurnItOn.exe" UnstopableCopier="%MyUSB%\Program Files\Misc\UnstopableCopier.exe" XVI32="%MyUSB%\Program Files\XVI32\XVI32.exe" ZipRepair="%MyUSB%\Program Files\Misc\ZipRepair.exe" <Tiny Office> 100ziper="%MyUSB%\Program Files\TinyOffice\100zipper\100ziper.exe" CSVed="%MyUSB%\Program Files\TinyOffice\CSVed\CSVed.exe" dscrypt="%MyUSB%\Program Files\TinyOffice\dscrypt\dscrypt.exe" dsdel="%MyUSB%\Program Files\TinyOffice\dsdel\dsdel.exe" Eve="%MyUSB%\Program Files\TinyOffice\Eve\eve.exe" FTP Wanderer="%MyUSB%\Program Files\TinyOffice\FTPWanderer\FTPWanderer.exe" HFS="%MyUSB%\Program Files\TinyOffice\HFS\hfs.exe" kPad="%MyUSB%\Program Files\TinyOffice\kPad\kPad.exe" Mempad="%MyUSB%\Program Files\TinyOffice\mempad\Mempad.exe" nPOPuk="%MyUSB%\Program Files\TinyOffice\NPopUK\nPOPuk.exe" PDF Producer="%MyUSB%\Program Files\TinyOffice\PDFproducer\PDFproducer.exe" PixaMSN="%MyUSB%\Program Files\TinyOffice\PixaMSN\PixaMSN.exe" Qsel="%MyUSB%\Program Files\TinyOffice\Qsel.exe" Spread32="%MyUSB%\Program Files\TinyOffice\Spread32\Spread32.exe" TedNotepad="%MyUSB%\Program Files\TinyOffice\TedNotepad\TedNPad.exe" xpass="%MyUSB%\Program Files\TinyOffice\Xpass\bin\xpass.exe" <AS400> AS400="%MyUSB%\Program Files\NCC\AS400.exe" CL Browser="%MyUSB%\Program Files\CL Browser\CLBrowse.exe" <DX> ActivityLog="%MyUSB%\Program Files\NCC\DX\ActivityLog.exe" Cancel="%MyUSB%\Program Files\NCC\DX\Cancel.exe" DropRequest="%MyUSB%\Program Files\NCC\DX\DropRequest.exe" InitiateDrop="%MyUSB%\Program Files\NCC\DX\InitiateDrop.exe" LogIt="%MyUSB%\Program Files\NCC\DX\LogIt.exe" OV="%MyUSB%\Program Files\NCC\DX\OV.exe" SC06="%MyUSB%\Program Files\NCC\DX\SC06.exe" WebCmdr="%MyUSB%\Program Files\NCC\DX\WebCmdr.exe" <Mainframe> 3270="%MyUSB%\Program Files\NCC\3270.exe" CPM="%MyUSB%\Program Files\NCC\CPM.exe" EMC="%MyUSB%\Program Files\NCC\EMC.exe" <Midrange> AutoSys="%MyUSB%\Program Files\NCC\AutoSys.exe" FixAMW="%MyUSB%\Program Files\NCC\FixAMW.exe" Patrol="%MyUSB%\Program Files\NCC\Patrol.exe" PermissionCalculator\PermissionCalculator="%MyUSB%\Program Files\PermissionCalculator\PermissionCalculator.exe" Putty!="%MyUSB%\Program Files\NCC\Putty!.exe" <Network> AD Explorer="%MyUSB%\Program Files\AD Explorer\ADExplorer.exe" DeadLink="%MyUSB%\Program Files\DeadLink\deadlink.exe" DNS NameD="%MyUSB%\Program Files\NCC\DNSNameD.exe" DNS="%MyUSB%\Program Files\NCC\NCC_DNS.exe" InfoDB="%MyUSB%\Program Files\NCC\InfoDB.exe" MicroNet="%MyUSB%\Program Files\MicroNet\MNU.exe" NetPW="%MyUSB%\Program Files\NCC\NetPW.exe" NetScan="%MyUSB%\Program Files\Misc\netscan.exe" PingW="%MyUSB%\Program Files\PingW\pingw.exe" <AutoIt> Aut2Exe="%MyUSB%\Program Files\AutoIt3\Aut2exe.exe" AutoIt3="%MyUSB%\Program Files\AutoIt3\AutoIt3.exe" Check="%MyUSB%\Program Files\AutoIt3\AutoIt Check.exe" Exe2Aut="%MyUSB%\Program Files\AutoIt3\Exe2Aut.exe" FD="%MyUSB%\Program Files\KodaFormDesigner\FD.exe" Help="%MyUSB%\Program Files\AutoIt3\AutoIt.chm" Info="%MyUSB%\Program Files\AutoIt3\AutoIt Info.exe" MD="%MyUSB%\Program Files\KodaFormDesigner\MD.exe" Link to comment Share on other sites More sharing options...
BinaryBrother Posted April 26, 2009 Share Posted April 26, 2009 I guess I'll write it out a bit plainer... Looks like being lazy bit me in the .... nvm... #include <Misc.au3> ;Required Include $DLL = DllOpen("user32.dll") ; This will highly improve performance of the IsPressed() function While 1 If WinActive($g_sTitle) And _Ispressed("0D",$DLL) Then ;Beginning of an "If Statement"... ;;;;;;;;;; READ NOTES Bottom of my post EndIf WEndoÝ÷ Ù.Êz+!j·_¢¹¶ÞiÛ(#fë-§Ú,k$áy¦è½ç(uéÞyÛ-¡·¦¡Øçm¡øjZ(§br޶׫~+lÊ«ç³*.Â¥v벶§X¤y«¢+Ù]¡¥±9½Ð]¥¹Ñ¥Ù ÀÌØí}ÍQ¥Ñ±¤¹}%ÍÁÉÍÍ ÅÕ½ÐìÁÅÕ½Ðì°ÀÌØí10¤(M½µÑ¡¥¹Q¡Ñ1½½ÁÌ ¤)]¹)}½¹ÑÈ ¤ì½¹Ñ¡ÅÕ½Ðí¹ÑÈÅÕ½Ðìä¡Ì¸Õ͸ This will allow you to "Select" an item on a list using your Arrow keys, (Which you already have working), and use the "ENTER" key to do something once that item has been .. err... "Entered Upon".... ... But seriously... SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
rover Posted April 26, 2009 Share Posted April 26, 2009 (edited) @RDSchaefer you can get the enter key by subclassing the listview control look at last example in thread posted by Rasim Trapping $NM_RETURN in a ListView via WM_NOTIFY http://www.autoitscript.com/forum/index.php?showtopic=83621 Edited April 26, 2009 by rover I see fascists... Link to comment Share on other sites More sharing options...
picea892 Posted April 28, 2009 Share Posted April 28, 2009 I tried and tried and for the life of me couldn't get the Rasim technique to work. It took me a while but found a work around. It sets a flag when the listview is focused and then uses an _ispressed to determine keypress. The enter and backspace now works on this listview file explorer. expandcollapse popup#include <GuiImageList.au3> #include <GUIListView.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include<Misc.au3> $dll = DllOpen("user32.dll") 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 $listison=1, $hListView1 Global Const $FOLDER_ICON_INDEX = _GUIImageList_GetFileIconIndex(@SystemDir, 0, 1) Global Const $NOICON_ICON_INDEX = _GUIImageList_GetFileIconIndex("nb lgl", 0, 0) Opt("GUIOnEventMode", 1) Global $GUI_MAIN = GUICreate("File Manager", 388, 520, 193, 125) GUISetOnEvent(-3,"GUI_Close") ;GUISetBkColor(0xABCDEF,$GUI_MAIN) Global $inpLocalDirectory = GUICtrlCreateInput("", 8, 0, 370, 20,$ES_READONLY) ;GUIctrlSetBkColor($inpLocalDirectory,0xABCDEF) Global $hListView1 = GUICtrlCreateListView("Name|Date|Size", 8, 20, 370, 489,$GUI_WS_EX_PARENTDRAG) ;GUIctrlSetBkColor($hListView1,0xABCDEF) Global $SHELLLISTVIEWHANDLE = GUICtrlGetHandle($hListView1); Get the Handle GUICtrlSendMsg($hListView1, 0x101E, 0, 200) GUICtrlSendMsg($hListView1, 0x101E, 1, 75) GUICtrlSendMsg($hListView1, 0x101E, 2, 50) GUIRegisterMsg($WM_NOTIFY, "_SHLV_WM_NOTIFY") _GUICtrlListView_SetImageList($hListView1, _GUIImageList_GetSystemImageList(), 1) Global $DIRECTORY_LOCAL = ""; Start with Selection of drives smile.gif _SHLV_PopulateLocalListView($SHELLLISTVIEWHANDLE,$DIRECTORY_LOCAL) ;_WinAPI_SetLayeredWindowAttributes($GUI_MAIN, 0xABCDEF, 250) GUISetState(@SW_SHOW) While 1 Sleep(100) If _IsPressed("0D", $dll) and $listison=1 Then;enter pressed _GUICtrlListView_ClickItem($hListView1,_GUICtrlListView_GetNextItem($hListView1,-1,0,8),"left",False,2) ElseIf _IsPressed("08", $dll) and $listison=1 Then;backspace pressed _GUICtrlListView_ClickItem($hListView1,0,"left",False,2) EndIf WEnd Func GUI_Close() Exit EndFunc ; Prog@ndy Func _SHLV_PopulateLocalListView($hListView1,ByRef $DIRECTORY_LOCAL) If $DIRECTORY_LOCAL = "" Then Local $drives = DriveGetDrive("ALL") GUICtrlSetData($inpLocalDirectory, "Drive Selection") _GUICtrlListView_BeginUpdate($hListView1) _GUICtrlListView_DeleteAllItems($hListView1) For $i = 1 To $drives[0] _GUICtrlListView_AddItem($hListView1, StringUpper($drives[$i]) & "\", _GUIImageList_GetFileIconIndex($drives[$i] & "\")) Next _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) If UBound($files)==0 Then Return _GUICtrlListView_BeginUpdate($hListView1) _GUICtrlListView_DeleteAllItems($hListView1) _GUICtrlListView_SetItemCount($hListView1,$files[0]) _GUICtrlListView_AddItem($hListView1, "[..]", 1) If IsArray($files) Then 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 Local $foldercount $files = _SHLV__FileListToArray2($DIRECTORY_LOCAL, "*", 1) _GUICtrlListView_EndUpdate($hListView1) _GUICtrlListView_BeginUpdate($hListView1) _GUICtrlListView_SetItemCount($hListView1,$files[0]+$foldercount) If IsArray($files) Then 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 ;==>_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 $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 If Not $bForceLoadFromDisk Then $dwFlags = BitOR($dwFlags, $SHGFI_USEFILEATTRIBUTES) EndIf 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 ;==>_FileDateString2Calc ; Author(s): Prog@ndy Func __SHLV_CalcDate2FileDateString($calcdate) Return StringRegExpReplace($calcdate, "(\d{4})/(\d{2})/(\d{2}) (\d{2})sad.gif\d{2})sad.gif\d{2})", "$1$2$3$4$5$6") EndFunc ;==>_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 Switch $iCode Case $NM_DBLCLK; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) If _GUICtrlListView_GetItemText($hListView1, DllStructGetData($tInfo, "Index")) = "[..]" Then 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($hListView1,$DIRECTORY_LOCAL) ElseIf _GUICtrlListView_GetItemImage($hListView1, DllStructGetData($tInfo, "Index")) = $FOLDER_ICON_INDEX Then $DIRECTORY_LOCAL &= _GUICtrlListView_GetItemText($hListView1, DllStructGetData($tInfo, "Index")) _SHLV_PopulateLocalListView($hListView1,$DIRECTORY_LOCAL) ElseIf StringRegExp(_GUICtrlListView_GetItemText($hListView1, DllStructGetData($tInfo, "Index"), 0), "\A[A-Za-z]:\\\Z") Then $DIRECTORY_LOCAL = _GUICtrlListView_GetItemText($hListView1, DllStructGetData($tInfo, "Index")) _SHLV_PopulateLocalListView($hListView1,$DIRECTORY_LOCAL) else ShellExecute($DIRECTORY_LOCAL&"\"&_GUICtrlListView_GetItemText($hListView1, DllStructGetData($tInfo, "Index"))) EndIf ; No return value Case $NM_KILLFOCUS $listison=0 Case $NM_SETFOCUS; The control has received the input focus $listison=1 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY ; 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, 8) = "") 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 ;~ ReDim $asFileList[UBound($asFileList) + 1] ;~ $asFileList[0] = $asFileList[0] + 1 ;~ $asFileList[UBound($asFileList) - 1] = $sFile WEnd FileClose($hSearch) Return StringSplit(StringTrimRight($asFileList,1),@CR) EndFunc ;==>_SHLV__FileListToArray2 Link to comment Share on other sites More sharing options...
BinaryBrother Posted April 29, 2009 Share Posted April 29, 2009 Good work... I was just about to tell you that was all wrong, but I missed the fact you were using the GUI in OnEventMode... Good idea... SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
RDSchaefer Posted April 29, 2009 Author Share Posted April 29, 2009 I tried and tried and for the life of me couldn't get the Rasim technique to work. It took me a while but found a work around.It sets a flag when the listview is focused and then uses an _ispressed to determine keypress. The enter and backspace now works on this listview file explorer.Thank you so much. I knew there had to be a way to do it, just couldn't figure it out. Link to comment Share on other sites More sharing options...
RDSchaefer Posted April 29, 2009 Author Share Posted April 29, 2009 you can get the enter key by subclassing the listview control look at last example in thread posted by Rasim Trapping $NM_RETURN in a ListView via WM_NOTIFY http://www.autoitscript.com/forum/index.php?showtopic=83621 Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now