Random Musings from the Intellectually Gifted. How's that for no ego? :pfft
Published on April 29, 2007 By SirSmiley In DesktopX
Ok. First, I'd like to say sorry to sviz as I sent this to him & it was probably discombobulated. Create a new object & drop this whole script in it. Then drag one (only one) shortcut on to it to see how the FSO parses it.

Code: vbscript
  1. Sub Object_OnDropFiles(files)
  2. '--Call shell & FSO object
  3. Set WshShell = CreateObject("WScript.Shell")
  4. Set objFSO = CreateObject("Scripting.FileSystemObject")
  5. '--Uses the CreateShortcut Method to retrieve the target Path(s) of the the shortcut
  6. '--eg. The actual file/folder or application the shortcut points to
  7. Set oShellLink = WshShell.CreateShortcut(files)
  8. '--Echos back the full path to respective Target
  9. msgbox "Path to Application: " & oShellLink.TargetPath
  10. objFile = oShellLink.TargetPath
  11. '--Using the comment field as temp storage for file target path
  12. Object.Comments = objFSO.GetAbsolutePathName(objFile)
  13. '-- Updates Tooltip & Text Label to Application Name
  14. Object.ToolTipText = objFSO.GetBaseName(objFile)
  15. '--Parses Paths using FSO & echoes back
  16. msgbox "Absolute path: " & objFSO.GetAbsolutePathName(objFile)
  17. msgbox "Parent folder: " & objFSO.GetParentFolderName(objFile)
  18. msgbox "File name: " & objFSO.GetFileName(objFile)
  19. msgbox "Base name: " & objFSO.GetBaseName(objFile)
  20. msgbox "Extension name: " & objFSO.GetExtensionName(objFile)
  21. '--Echos back path to Icon
  22. msgbox "Path to Icon: " & oShellLink.IconLocation
  23. End Sub
  24. '--Go to selected target on L-click
  25. Sub Object_OnLbuttonUp(x,y,dragged)
  26. Dim appPath
  27. appPath=object.Comments
  28. If Not dragged Then
  29. On Error Resume Next
  30. Set Sh = CreateObject("WScript.Shell")
  31. Sh.Run (Chr(34)& appPath & Chr(34))
  32. Set Sh = Nothing
  33. End If
  34. End Sub


Comments
on Apr 30, 2007
Just a suggestion on the following code:

'--Parses Paths using FSO & echoes back
msgbox "Absolute path: " & objFSO.GetAbsolutePathName(objFile)
msgbox "Parent folder: " & objFSO.GetParentFolderName(objFile)
msgbox "File name: " & objFSO.GetFileName(objFile)
msgbox "Base name: " & objFSO.GetBaseName(objFile)
msgbox "Extension name: " & objFSO.GetExtensionName(objFile)
msgbox "Path to Icon: " & oShellLink.IconLocation

When i make a "TEST" object i always send the output to:
object.text

The reason for not wanting to use msgbox is that it can get into loops at places, and really mess you up.

My suggestion for the above code:

'--Parses Paths using FSO & echoes back
object.text = "Absolute path: " & objFSO.GetAbsolutePathName(objFile)
object.text = object.text & vbnewline & msgbox "Parent folder: " & objFSO.GetParentFolderName(objFile)
object.text = object.text & vbnewline & "File name: " & objFSO.GetFileName(objFile)
object.text = object.text & vbnewline & "Base name: " & objFSO.GetBaseName(objFile)
object.text = object.text & vbnewline & "Extension name: " & objFSO.GetExtensionName(objFile)
object.text = object.text & vbnewline & "Path to Icon: " & oShellLink.IconLocation

This gives you one text string with all the info above. the vbnewline just puts a line break in there.

Just my ideas. Take 'em or leave 'em
on Apr 30, 2007
That makes perfect sense. Really I should be using msgbox constants then that would eliminate potential looping issues. I like your idea better because it is more for a demo purpose anyway. Thanks.
on May 01, 2007
no problem.

You should see my desktop, its a mess of test text objects, each running its own script trying to find different things.

I like it cause i can leave them all out there, different colors, fonts, sizes, just to see what works.

I use a lot of TEST text objects when im debugging code, make test1.text test2.text etc.. and put them on the desktop and pass things like "made it this far, var1=.." so i can see what DX is doing.
on May 01, 2007
Quick Q,
I love the formatting above, how did you do that in html?
on May 01, 2007
I love the formatting above, how did you do that in html?

There is a button on the toolbar with two brackets and text between them.
Click that box and choose your format.  Paste your code in between
Like this:
Code: html
  1. <html>
  2. <body>
  3. The content of the body element is displayed in your browser.
  4. </body>
  5. </html>

on May 01, 2007
verrry nice Zu.. thanks.
on May 01, 2007
I use a lot of TEST text objects when im debugging code, make test1.text test2.text etc.. and put them on the desktop and pass things like "made it this far, var1=.." so i can see what DX is doing.


Yeah, things do tend to get a little messy when you get going on a project. I added an addin folder under my object development folder which has helped considerably.

I'm tracking some of my projects from start to finish using Todolist which has lead to another object idea of plotting projects to the desktop using the bar charts. Funny how that happens.

Just a note on the code tags when you go to edit it, your code still gets screwed up but usually I'm posting from the object so, it's an easy work-a-round.
on May 01, 2007
The reason for not wanting to use msgbox is that it can get into loops at places, and really mess you up.

yea, Evil Msgbox Loop of Doom!
on May 01, 2007
yea, Evil Msgbox Loop of Doom!


why isnt there a CTRL+C to kill the script?


I have lost more code that way, its why i HATE using them now, i put things into text objects, so that even if there is a loop, who the heck cares. I can still STOP the script.

I had spent close to 3 hrs on a gadget, it was doing something stupid "somewhere" so i put in a "msgbox stringhere" into the place where i wanted to see the stringhere var, well crap, it was in the middle of a 100 ms loop.. in about 3 seconds i had 300 msgbox windows all over my screen. NOT GOOD!!

So.. no more msgbox! LOL
on May 01, 2007
I think I've got the answer to that somewhere in my script library. It halts the script until the message box is dealt with. ie. ok/close/cancel,etc.
on May 01, 2007
yeah you can do that..
but its result = MsgBox(prompt[, buttons][, title][, helpfile, context])

But when you just want something to show up on the screen as feedback.. thats how you get in trouble.

but that is a good idea.
on May 03, 2007
This is a very nice script. I see what you meant about the icon location. Some work some don't. I'll definitely put this in the updated version of the script helper.


Oh, yeah and it's...

First, I'd like to say sorry to sviz as I sent this to her & it was probably discombobulated


No worries, though. Thanks again, SirS.

on May 03, 2007
Oops! Sorry about that. Guess I should read people's profiles instead of just looking at their galleries.