Parsing Shortcut using Script
Sunday, April 29, 2007 by SirSmiley | Discussion: DesktopX
- Sub Object_OnDropFiles(files)
- '--Call shell & FSO object
- Set WshShell = CreateObject("WScript.Shell")
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- '--Uses the CreateShortcut Method to retrieve the target Path(s) of the the shortcut
- '--eg. The actual file/folder or application the shortcut points to
- Set oShellLink = WshShell.CreateShortcut(files)
- '--Echos back the full path to respective Target
- msgbox "Path to Application: " & oShellLink.TargetPath
- objFile = oShellLink.TargetPath
- '--Using the comment field as temp storage for file target path
- Object.Comments = objFSO.GetAbsolutePathName(objFile)
- '-- Updates Tooltip & Text Label to Application Name
- Object.ToolTipText = objFSO.GetBaseName(objFile)
- '--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)
- '--Echos back path to Icon
- msgbox "Path to Icon: " & oShellLink.IconLocation
- End Sub
- '--Go to selected target on L-click
- Sub Object_OnLbuttonUp(x,y,dragged)
- Dim appPath
- appPath=object.Comments
- If Not dragged Then
- On Error Resume Next
- Set Sh = CreateObject("WScript.Shell")
- Sh.Run (Chr(34)& appPath & Chr(34))
- Set Sh = Nothing
- End If
- End Sub
Reply #2 Monday, April 30, 2007 6:35 PM
Reply #3 Tuesday, May 1, 2007 9:42 AM
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.
Reply #4 Tuesday, May 1, 2007 9:46 AM
I love the formatting above, how did you do that in html?
Reply #5 Tuesday, May 1, 2007 9:57 AM
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:
- <html>
- <body>
- The content of the body element is displayed in your browser.
- </body>
- </html>
Reply #7 Tuesday, May 1, 2007 10:52 AM
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.
Reply #8 Tuesday, May 1, 2007 1:48 PM
yea, Evil Msgbox Loop of Doom!
Reply #9 Tuesday, May 1, 2007 2:06 PM
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
Reply #10 Tuesday, May 1, 2007 4:03 PM
Reply #11 Tuesday, May 1, 2007 4:14 PM
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.
Reply #12 Thursday, May 3, 2007 7:30 AM
Oh, yeah and it's...
No worries, though. Thanks again, SirS.
Reply #13 Thursday, May 3, 2007 11:19 AM
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 Monday, April 30, 2007 9:39 AM
'--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