Object help

display folder contents

Thursday, October 12, 2006 by Chaos Ra | Discussion: DesktopX

I was wondering if anyone could help me out with creating an object that can do a couple of things:
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
c242
Reply #1 Thursday, October 12, 2006 6:23 AM
You need to write a script to do that.

Help : WWW Link
Murex
Reply #2 Thursday, October 12, 2006 7:08 AM
You can also do this with in DX it's self.. Go to properties of your button or object that you want the mouse to hover over.. go to the states tab, On mouse away go to messages click on add..In the next window check (object ID) then browse till you find the name of your object that you want to pop up (You did name your objects???).. then in message pick (HIDE ) now go to mouse over and do the same thing only now the message will be (SHOW) Make sure that you have checked "Object ID " and NOT BROADCAST Ok now go to the relations page and set Visible to (NO) click on apply now when you mouse over your object your bubble will appear.. hope this helps    

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...
c242
Reply #3 Thursday, October 12, 2006 7:44 AM
Code to list files :

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.
Chaos Ra
Reply #4 Thursday, October 12, 2006 3:34 PM
Murex, for your solution I would need a second object that pops up when I hover over the original one (the second object being a popup), correct?
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?
SirSmiley
Reply #5 Thursday, October 12, 2006 6:14 PM
Chaos, I believe you'll need to parse the list to get each filename.

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
Chaos Ra
Reply #6 Thursday, October 12, 2006 9:41 PM
hmmm, been trying out a few things but none are doing quite what I want...Think maybe I'll get one of my friends to give me a hand with the coding... What language does the script use?

Edit: nvm, uses VB or Java
c242
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.

c242
Reply #8 Friday, October 13, 2006 6:05 AM
Note Also, that it doesn't see Folders.

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.

SirSmiley
Reply #9 Friday, October 13, 2006 4:10 PM
If you want to add a drop file function to this then add the first part below and make the appropriate changes within the OnMouseEnter sub.

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!



web-wc01