AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

list files in folder
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Deller



Joined: 21 Nov 2007
Posts: 202
Location: 0x01101110

PostPosted: Fri Jul 18, 2008 3:58 am    Post subject: list files in folder Reply with quote

I swear i found something like this a while ago on these forums but i cant find it again so here it goes.

I need to:
1: make as many variables as there are files in a folder.
2: put the filenames of each file in one of those variables
3 make a button linking every one of those files to the file.


The purpose for this:

It will serve as a pop up menu that can be triggered by a hotkey and can launch any program you want with putting links in that folder.

Add ons:
If someone is interested you could list the folders in that folder and an "up" button.
You could also choose to list only files with a certain extension with *.anyextension.

This can be a primative, pop up file explorer used to launch programs and files.
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Fri Jul 18, 2008 4:09 am    Post subject: Reply with quote

Using a ComboBox would make things more elegant Smile
_________________
SKAN - Suresh Kumar A N
Back to top
View user's profile Send private message
Deller



Joined: 21 Nov 2007
Posts: 202
Location: 0x01101110

PostPosted: Fri Jul 18, 2008 4:40 am    Post subject: Reply with quote

thats for the buttons but how about the listing of files?
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Fri Jul 18, 2008 5:40 am    Post subject: Reply with quote

Here is a simple version of my Combo-Box Launcher:

Code:
SetBatchLines -1
VarSetCapacity( Sps, 100, Asc( A_Space) )                ; Sps var will contain 100 spaces

Loop %A_AppData%\Microsoft\Internet Explorer\Quick Launch\*.lnk
  fList .= (A_Index=1 ? "" : "`n") SubStr(A_LoopFileName Sps,1,100) "|" A_LoopFileLongPath

Sort, fList, D`n   
Loop, Parse, fList, `n,`r
 {
   StringSplit,F, A_LoopField, |, %A_Space%
   LNK%A_Index%:=F2, List.=((A_Index=1) ? "" : "|") F1
 }

Gui +AlwaysOnTop +Owner +LastFound
Gui1 := WinExist()
Gui, Add, ComboBox, w285 vCB r10 Simple AltSubmit vNum +Border, %List%
Gui, Show,, Launch It
Gui, Add, Button, w100 h25 +Default gRun, Launch it
Return

Run:
  GuiControlGet, Num
  If Num is Not Integer
     Return
  Run, % """" ( Link := Lnk%Num% ) """",, UseErrorLevel
Return

^Space::
GuiHideShow:
 If DllCall( "IsWindowVisible", UInt,Gui1 )
      Gui Hide
 Else Gui Show
 Return


Smile
_________________
SKAN - Suresh Kumar A N
Back to top
View user's profile Send private message
Deller



Joined: 21 Nov 2007
Posts: 202
Location: 0x01101110

PostPosted: Fri Jul 18, 2008 8:19 pm    Post subject: Reply with quote

perfect
One more thing; how would i list all the folders?
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Fri Jul 18, 2008 8:32 pm    Post subject: Reply with quote

Code:
SetBatchLines -1
VarSetCapacity( Sps, 100, Asc( A_Space) )                ; Sps var will contain 100 spaces

Folders=
(
%A_AppData%\Microsoft\Internet Explorer\Quick Launch\*.lnk
%A_MyDocuments%\*.*
%AppData%\..\Favorites\*.url

; add more entries as you please
)

Loop, Parse, Folders, `n, `r
{
 IfNotExist, % ( Folder:=A_LoopField ), Continue 
 Loop %A_LoopField%,0,1
  fList .= (A_Index=1 ? "" : "`n") SubStr(A_LoopFileName Sps,1,100) "|" A_LoopFileLongPath
}

Sort, fList, D`n
Loop, Parse, fList, `n,`r
 {
   StringSplit,F, A_LoopField, |, %A_Space%
   LNK%A_Index%:=F2, List.=((A_Index=1) ? "" : "|") F1
 }

Gui +AlwaysOnTop +Owner +LastFound
Gui1 := WinExist()
Gui, Add, ComboBox, w285 vCB r10 Simple AltSubmit vNum +Border, %List%
Gui, Show,, Launch It
Gui, Add, Button, w100 h25 +Default gRun, Launch it
Return

Run:
  GuiControlGet, Num
  If Num is Not Integer
     Return
  Run, % """" ( Link := Lnk%Num% ) """",, UseErrorLevel
Return

^Space::
GuiHideShow:
 If DllCall( "IsWindowVisible", UInt,Gui1 )
      Gui Hide
 Else Gui Show
 Return

_________________
SKAN - Suresh Kumar A N
Back to top
View user's profile Send private message
Deller



Joined: 21 Nov 2007
Posts: 202
Location: 0x01101110

PostPosted: Fri Jul 18, 2008 8:44 pm    Post subject: Reply with quote

no i meant not list the files in the folders but the folders themselves
as in list everything in the folder including all files and all subfolders but not the files in those subfolders
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Fri Jul 18, 2008 8:49 pm    Post subject: Reply with quote

Deller wrote:
no i meant not list the files in the folders but the folders themselves


Like this ?

Code:
SetBatchLines -1
VarSetCapacity( Sps, 100, Asc( A_Space) )                ; Sps var will contain 100 spaces

Loop %A_ProgramFiles%\*.*,2,1
  fList .= (A_Index=1 ? "" : "`n") SubStr(A_LoopFileName Sps,1,100) "|" A_LoopFileLongPath

Sort, fList, D`n   
MsgBox, % fList
Loop, Parse, fList, `n,`r
 {
   StringSplit,F, A_LoopField, |, %A_Space%
   LNK%A_Index%:=F2, List.=((A_Index=1) ? "" : "|") F1
 }

Gui +AlwaysOnTop +Owner +LastFound
Gui1 := WinExist()
Gui, Add, ComboBox, w285 vCB r10 Simple AltSubmit vNum +Border, %List%
Gui, Show,, Launch It
Gui, Add, Button, w100 h25 +Default gRun, Launch it
Return

Run:
  GuiControlGet, Num
  If Num is Not Integer
     Return
  Run, % """" ( Link := Lnk%Num% ) """",, UseErrorLevel
Return

^Space::
GuiHideShow:
 If DllCall( "IsWindowVisible", UInt,Gui1 )
      Gui Hide
 Else Gui Show
 Return

_________________
SKAN - Suresh Kumar A N
Back to top
View user's profile Send private message
Deller



Joined: 21 Nov 2007
Posts: 202
Location: 0x01101110

PostPosted: Fri Jul 18, 2008 8:53 pm    Post subject: Reply with quote

it still doesnt list folders just files inside folders
btw do you know how to make a mouseclick launch them instead of an enter?
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Fri Jul 18, 2008 8:58 pm    Post subject: Reply with quote

Deller wrote:
it still doesnt list folders just files inside folders


I have posted tested code.. try it afresh.

Quote:
btw do you know how to make a mouseclick launch them instead of an enter?


combobox does not generate a doubleclick event, however we can always use ugly workaournds.. I will give it a try and let you know.

Smile
_________________
SKAN - Suresh Kumar A N


Last edited by SKAN on Fri Jul 18, 2008 9:03 pm; edited 1 time in total
Back to top
View user's profile Send private message
Deller



Joined: 21 Nov 2007
Posts: 202
Location: 0x01101110

PostPosted: Fri Jul 18, 2008 8:59 pm    Post subject: Reply with quote

i thought of something like while a window with a certain title is active doubleclick can be set to a hotkey to press enter

the code on the other hand doesnt list the folders in a combo box, just a msgbox
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Fri Jul 18, 2008 9:06 pm    Post subject: Reply with quote

Deller wrote:
the code on the other hand doesnt list the folders in a combo box, just a msgbox


Dismiss the MsgBox to let the code continue.. Surprised
_________________
SKAN - Suresh Kumar A N
Back to top
View user's profile Send private message
Deller



Joined: 21 Nov 2007
Posts: 202
Location: 0x01101110

PostPosted: Fri Jul 18, 2008 9:12 pm    Post subject: Reply with quote

oh thanks it works great
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Fri Jul 18, 2008 9:28 pm    Post subject: Reply with quote

Here is a workaround to detect double click:

Code:
SetBatchLines -1
VarSetCapacity( Sps, 100, Asc( A_Space) )                ; Sps var will contain 100 spaces

Loop %A_ProgramFiles%\*.*,2,1
  fList .= (A_Index=1 ? "" : "`n") SubStr(A_LoopFileName Sps,1,100) "|" A_LoopFileLongPath

Sort, fList, D`n   
Loop, Parse, fList, `n,`r
 {
   StringSplit,F, A_LoopField, |, %A_Space%
   LNK%A_Index%:=F2, List.=((A_Index=1) ? "" : "|") F1
 }

Gui +AlwaysOnTop +Owner +LastFound
Gui1 := WinExist()
Gui, Add, ComboBox, w285 vCB r10 Simple AltSubmit vNum +Border, %List%
Gui, Show,,Launch It
Gui, Add, Button, w100 h25 +Default gRun, Launch it
Count := 0
Return

#IfWinActive Launch It ahk_class AutoHotkeyGUI
~LButton::
  MouseGetPos,,,,Ctrl
  IfNotEqual,Ctrl,ComboLBox1, Return
  If (A_ThisHotkey=A_PriorHotkey && A_TimeSincePriorHotkey<DllCall("GetDoubleClickTime"))
       Count += 1
  Else
       Count = 1
  IfGreater,Count,1,GoSub,Run
  Return
#IfWinActive


Run:
  GuiControlGet, Num
  If Num is Not Integer
     Return
  Run, % """" ( Link := Lnk%Num% ) """",, UseErrorLevel
Return

^Space::
GuiHideShow:
 If DllCall( "IsWindowVisible", UInt,Gui1 )
      Gui Hide
 Else Gui Show
 Return

_________________
SKAN - Suresh Kumar A N
Back to top
View user's profile Send private message
Deller



Joined: 21 Nov 2007
Posts: 202
Location: 0x01101110

PostPosted: Fri Jul 18, 2008 9:57 pm    Post subject: Reply with quote

perfect
one last thing; i cant figure out how to hide the combo box after something launches
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group