Object help
display folder contents
Thursday, October 12, 2006 by Chaos Ra | Discussion: DesktopX
1) On mouse hover, a "speech bubble" appears listing the contents of a specified folder without actually giving the user access to that folder
2) On click, open a drop-down menu that will give access to all the files w/in the folder.
I already know how to make it so on clicking, it will open up the dropdown menu for access to the folder (very simple), but I can't for the life of me get a way to make a speech bubble type popup to appear on hover that simply lists the contents of the linked folder... Any help would be appreciated
Reply #2 Thursday, October 12, 2006 7:08 AM
This will only make your object show or hide you will still have to fill in the information in your bubble and make the shortcuts to the files...
Reply #3 Thursday, October 12, 2006 7:44 AM
Sub Object_OnScriptEnter
Object.ToolTipText = ListDir ("C:\")
End Sub
'Called when the script is terminated
Sub Object_OnScriptExit
End Sub
Function ListDir (Path)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim Folder: Set Folder = fso.GetFolder(Path)
Dim Files: Set Files = Folder.Files
Dim File
For Each File In Files
ListDir = ListDir & File & vbcrlf
Next
End Function
Problem ist, that the DX-Tooltext only holds a certain amount of lines.
Reply #4 Thursday, October 12, 2006 3:34 PM
Alright, created a second object - the speechbubble, and it appears whenever I hover over the original one...now I just have to make the speechbubble list all the files in the folder by file name, not path...
Carl, when I tried to use your code, it displayed the entire path name of each file - thus limiting how much it could show (in fact, it only showed one full file path, and then the fist few letters of the next file). Is there a way to make it only display the file name w/o the full path?
Reply #5 Thursday, October 12, 2006 6:14 PM
Nice script Carl[c242]. You could eliminate the OnScriptEnter sub & update the tooltip text using GetFolder("foldername") or GetParent? within the function. I think something like this: Dim fName: Set fName = fso.GetFolder(foldername) DesktopX.Object("myobject").Tooltip Text = "ListDir" & fName
Reply #6 Thursday, October 12, 2006 9:41 PM
Edit: nvm, uses VB or Java
Reply #7 Friday, October 13, 2006 5:48 AM
| Carl, when I tried to use your code, it displayed the entire path name of each file - thus limiting how much it could show (in fact, it only showed one full file path, and then the fist few letters of the next file). Is there a way to make it only display the file name w/o the full path? |
You will have to use some string coding :
Dim PathLenghth
PathLength = Len(Path) + 1 '(+1 because we don't want to see the backslash)
...
ListDir = ListDir & Mid(File, PathLength, 255) & vbcrlf
All VBScript.
Reply #8 Friday, October 13, 2006 6:05 AM
A better way : Create 2 Objects (here : DirObject1 and DirObject2), DirObject2 as a brief text object and be sure to group them ! Than assign this Script to DirObject1 :
Sub Object_OnScriptEnter
End Sub
Sub Object_OnMouseEnter
DesktopX.Object("DirObject2").Text = ListFolders ("C:\")& vbcrlf & ListDir ("C:\")
End Sub
Sub Object_OnMouseLeave
DesktopX.Object("DirObject2").Text = ""
End Sub
'Called when the script is terminated
Sub Object_OnScriptExit
End Sub
Function ListDir (Path)
Dim fso
Dim PathLenghth
PathLength = Len(Path) + 1
Set fso = CreateObject("Scripting.FileSystemObject")
Dim Folder: Set Folder = fso.GetFolder(Path)
Dim Files: Set Files = Folder.Files
Dim File
For Each File In Files
ListDir = ListDir & Mid(File, PathLength, 255) & vbcrlf
Next
End Function
Function ListFolders (Path)
Dim fso
Dim PathLenghth
PathLength = Len(Path) + 1
Set fso = CreateObject("Scripting.FileSystemObject")
Dim Folder: Set Folder = fso.GetFolder(Path)
Dim Folders: Set Folders = Folder.SubFolders
Dim Folder1
For Each Folder1 In Folders
ListFolders = ListFolders & "[" & Mid(Folder1, PathLength, 255) & "]" & vbcrlf
Next
End Function
That way You don't have to fiddle with show or hide events.
Reply #9 Friday, October 13, 2006 4:10 PM
Dim myDirectory
Sub Object_OnDropFiles(files)
Set objFSO = CreateObject("Scripting.FileSystemObject")
folderpath = objFSO.GetFolder(files)
myDirectory = folderpath
End Sub
Sub Object_OnMouseEnter
DesktopX.Object("DirObject2").Text = ListFolders (myDirectory & "\")& vbcrlf & ListDir (myDirectory & "\")
End Sub
Please login to comment and/or vote for this skin.
Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:
- Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
- Access to a great community, with a massive database of many, many areas of interest.
- Access to contests & subscription offers like exclusive emails.
- It's simple, and FREE!







Reply #1 Thursday, October 12, 2006 6:23 AM
Help : WWW Link