topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Tuesday March 19, 2024, 3:39 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: IDEA: Dynamic shortcuts  (Read 31793 times)

Josh

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Points: 45
  • Posts: 3,411
    • View Profile
    • Donate to Member
IDEA: Dynamic shortcuts
« on: May 25, 2008, 09:28 AM »
Here is an idea that I have had for a bit now. What if you could create a shortcut on your desktop that is updated, automatically, each time a thumb drive is put into the PC? That way, you can have a shortcut to firefox portable (FOR EXAMPLE), which points to D:\Apps\PortableFirefox.exe. Then, if you were to insert another thumb drive prior to inserting the one with FF Port on it, the shortcut would be updated to point to an updated path when the proper drive is inserted. Basically, you have a smart shortcut that can detect when you put the right drive in and have it change the shortcuts properties accordingly.

Is this a possibility?

SirSmiley

  • Member
  • Joined in 2007
  • **
  • Posts: 64
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #1 on: May 25, 2008, 10:20 AM »
Is this what you mean DiskMounter
Or DeskDrive via FreewareGenius.

Have tried the first one but, not the second.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #2 on: May 25, 2008, 01:45 PM »
you can try Launcher programs that specialize in portable apps such as PStart or UBSpawn.

Ampa

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 592
  • I am cute ;)
    • View Profile
    • MonkeyDash - 2 Player strategy boardgame
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #3 on: May 25, 2008, 04:43 PM »
Also DeskDrive (via LifeHacker)

Josh

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Points: 45
  • Posts: 3,411
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #4 on: May 25, 2008, 11:26 PM »
Actually, I am looking more for something that doesnt display an icon on the desktop for the thumb drive, but more updates an existing icon to point to a proper path for an application on a removable drive.

Say I have inserted a drive for the first time and made a shortcut on the desktop to D:\Apps\FirefoxPortable.exe

Now. I remove this drive and insert another which then becomes D:\. Now I reinsert the original drive at the same time as the other and now the original D:\ is now E:\.

I want a program that will change the properties of the existing shortcut to point from D:\Apps\FirefoxPortable.exe to E:\Apps\FirefoxPortable.exe

Is this possible?

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #5 on: May 25, 2008, 11:36 PM »
I want a program that will change the properties of the existing shortcut to point from D:\Apps\FirefoxPortable.exe

i'm not sure that this is possible but i've been in situations that you had mentioned and now i'm using USB drive letter manager to avoid this by assigning a fixed drive letter for flash drives. also check out this thread.

Josh

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Points: 45
  • Posts: 3,411
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #6 on: May 25, 2008, 11:46 PM »
I dont see why it shouldnt be possible. All that should be required is a program which monitors new drive letters, scans the drive for a given shortcut on the desktop's path, and then updates the shortcut accordingly.

justice

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,898
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #7 on: May 26, 2008, 06:02 AM »
I'd create a coding snack in AHK but actually you don't even have to do that. The easiest option is to overwrite shortcuts instead of updating them.
Create a file called Autorun.inf with the following contents:
[autorun]
open=LnkSwitch\LnkSwitchThumb.bat
Keep copies of shotcuts on the drive in the LnkSwitch folder
Then create the LnkSwitch\LnkSwitchThumb.bat file and have it copy the right shortcut to the right folder using a copy command such as
copy *.lnk c:\users\Josh\Desktop /y


lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #8 on: May 26, 2008, 10:59 AM »
The easiest option is to overwrite shortcuts instead of updating them.

good call, justice. :Thmbsup: i hadn't thought of that.

Josh

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Points: 45
  • Posts: 3,411
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #9 on: May 26, 2008, 10:38 PM »
The problem with this is I would like to be able to run this on multiple PC's. This would require me have a batch file for every conceivable PC I use this on as path's change from PC to PC. I could use the %USERPROFILE% environment variable, however, some PC's I have access to do not allow those variables.

steeladept

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,061
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #10 on: May 26, 2008, 10:50 PM »
If it just places the Shortcut on the desktop upon load, then it wouldn't matter if you never used the USB device on that pc before or not.  If you have, it would just update the link, if not, it would create it.

EDIT - Hmm, maybe not.  Sometimes it will create <ShortcutName>(2) instead.  That might be a problem...

SirSmiley

  • Member
  • Joined in 2007
  • **
  • Posts: 64
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #11 on: May 26, 2008, 10:51 PM »
Don't think you would need a batch for every individual PC just a loop that iterates through various desktop path options until it finds the correct one.

A monitoring type app might be some what over kill for something as simple as this? Guess it would depend on how frequently you are polling the drives, etc.

Josh

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Points: 45
  • Posts: 3,411
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #12 on: May 26, 2008, 10:52 PM »
That would be an option I would like. A way to say "Poll for updated shortcuts every 30 minutes". Or even a program which sits idly waiting for a new drive to be inserted. Then, upon insertion, it scans that drive to see if said path exists and updated the shortcut accordingly.

mikiem

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 99
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #13 on: June 17, 2008, 09:35 PM »
Ummm... not a coder (that part of my brain died long ago) so this is probably a stupid idea, but what popped into my head was why have an app constantly watching &/or polling when it could be activated by an autorun association? Also, instead of a shortcut, updating or otherwise, would a constant sized/placed window work containing your shortcuts? That way you could have several sticks with the icons or shortcuts varying by content?

nite_monkey

  • Member
  • Joined in 2006
  • **
  • Posts: 753
    • View Profile
    • Just Plain Super
    • Read more about this member.
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #14 on: July 10, 2008, 07:40 PM »
I have created a very basic AHK script that should work
FileCreateShortcut, %A_WorkingDir%\test\test.exe, %A_Desktop%\test.lnk
just make a new ahk script in the root of the usb drive, and put that in it.
replace test\test.exe with the program you want to make a shortcut to
replace test.lnk with the name of the program
compile the script, and you are good to go.
you can also copy that code several times in the same ahk script for multiple shortcuts

then just create an autorun file that will run the ahk script when you stick in the usb drive, when you are done, unplug the drive, and delete the shortcut from the desktop.

example: FileCreateShortcut, %A_WorkingDir%\Apps\PortableFirefox.exe, %A_Desktop%\Portable FireFox.lnk
[Insert really cool signature here]

belkira

  • Member
  • Joined in 2006
  • **
  • Posts: 52
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #15 on: July 14, 2008, 12:02 AM »
Try this out and let me know what you think. I have attached both the source (ahk) and a compiled version.

Edit:
See posts below for latest version
« Last Edit: July 15, 2008, 10:12 AM by belkira »

belkira

  • Member
  • Joined in 2006
  • **
  • Posts: 52
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #16 on: July 14, 2008, 09:46 PM »
Updated it to keep track of the lnk files already on the desktop,
and replace them if they got overwritten when the new shortcuts
were created. (Once the removable drive gets removed)

Edit:
See posts below for latest version
« Last Edit: July 15, 2008, 10:12 AM by belkira »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #17 on: July 14, 2008, 10:35 PM »
what a cool idea.. i'd love to see a demo movie of some of this in action, i think it would help people understand what it's for.

nogojoe

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 169
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #18 on: July 15, 2008, 02:06 AM »
tried this out and it worked OK  except it removed the icons to the shortcuts of my drives C D E F G H I J K that I have on my desktop.
Also removed a icon from shortcut that was already on the desktop that was of the same program that was also on the usb drive. (the drive had a backup of that program although the icons were different it removed both at the finish just leaving the shortcut itself that was already on the desktop.

Left all the other shortcuts and their icons alone.

I can see some promise in the program but for the above.

a possibility would be to have the  shortcuts be delivered to a place on the tray  (something similar to DESKonTOP) as in the finish you have to access the "Safely Remove Hardware" from there.
Often the most convincing people are those who have lost the plot so much they don't recognize the difference between fact and fantasy

belkira

  • Member
  • Joined in 2006
  • **
  • Posts: 52
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #19 on: July 15, 2008, 10:10 AM »
nogojoe,

Which version did you try? The original did delete shortcuts if they were the same name as a shortcut being created, but the second version doesn't(shouldn't).

As for the deleting of the Drive letter shortcuts I will look into that. I dont keep shortcuts to the drives on my desktop so that issue didn't come up for me.
Also I have attached a new version which recurses only 1 level (easily changed) looking for exe files.

This version does not remove any drive icons or other existing icons from my desktop. Let me know if you experience something different.
;
; Program Version: 1.3
; Language:       English
; Author:         belkira
;
; Script Function:
; Script to create shortcuts on Desktop for exe files on a removable drive
;   and then to remove those shortcuts when the removable drive has been removed.
;Script Usage:
; Launch script on whatever computer(s) you want to have the shortcuts updated on.
; When a new removable drive is inserted, this script will scan for all exe files on the
; removable device, and create shortcuts for them on the users Desktop.
;
; Once removed the script will cleanup any shortcuts that were created.
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
;SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#Persistent
First = 0
DriveGET, USB, List, REMOVABLE
settimer, check, 500
return

check:
ret := scan4newDrives(USB)
If (First = 0)
{
; Copy current shortcuts
Loop, %A_Desktop%\*.lnk
{
FileGetShortcut, %A_LoopFileName%, Target
ShortCutTarget = %ShortCutTarget%%Target%\\%A_LoopFileName%`n
;ShortCutName = %ShortCutName%%A_LoopFileName%`n
;MsgBox %ShortCutTarget%`n%ShortCutName%
}
}
First = 1
if (!ret)
{
UsbDirList :=
ShortcutList :=
;nothing here
}
else
{
; Scan usb drive for applications
Usb_Folders = %ret%:\
Loop, %Usb_folders%*.exe, 0, 1
{
   StringReplace, dummy, A_LoopFileFullPath, \, \, UseErrorLevel
   If (ErrorLevel > 2) ; ex: "C:\folder1\folder2\folder3\file.ext"
      continue ; skip files that are 1 or more folders deep
    UsbDirList = %UsbDirList%%A_LoopFileFullPath%`n
}

{

}
Sort UsbDirList, UD`n ;Remove duplicate entries, just in case
; create shortcuts
Loop, Parse, UsbDirList, `n
{
If !A_LoopField
Break
SplitPath, A_LoopField, Name, Dir, Extension, NameNoExt, OutDrive
FileCreateShortcut, %Dir%\%Name%, %A_Desktop%\%NameNoExt%.lnk
CreatedShortcuts = %CreatedShortcuts%%A_Desktop%\%NameNoExt%.lnk`n
}
}
; remove shortcuts if drive removed
IfNotExist %OutDrive%
If CreatedShortcuts >= 1
{
Loop, Parse, CreatedShortcuts, `n
{
FileDelete, %A_LoopField%
CreatedShortcuts =
}
Loop, Parse, ShortCutTarget, `n
{
If A_LoopField =
Continue
SplitPath, A_LoopField, Name, Old_Target
StringTrimRight, Target, Old_Target, 1
FileCreateShortcut, %Target%, %A_Desktop%\%Name%
;MsgBox Name=%Name%`nTarget=%Target%
}
}
return

scan4newDrives(byref olddrives)
{
DriveGET, NewUSB, List, REMOVABLE
Loop, parse, NewUSB
{
if InStr(olddrives, a_loopfield)
{
   ;still here
}
else
{
   ;found new device!
   olddrives := NewUSB ;update
   return, % a_loopfield
}
}
olddrives := NewUSB ;update
return, 0 ;no new devices found.
}


belkira

  • Member
  • Joined in 2006
  • **
  • Posts: 52
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #20 on: August 08, 2008, 09:19 PM »
what a cool idea.. i'd love to see a demo movie of some of this in action, i think it would help people understand what it's for.

Per mousers request...

Let me know how this works, its my first screen capture.
« Last Edit: August 08, 2008, 10:09 PM by belkira »

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #21 on: August 12, 2008, 02:37 AM »
what a cool idea.. i'd love to see a demo movie of some of this in action, i think it would help people understand what it's for.

Per mousers request...

Let me know how this works, its my first screen capture.

wow! i didn't know much about your program's feature until i saw the demo video. :up:

P.S. could have used a more decent codec, though. :)

belkira

  • Member
  • Joined in 2006
  • **
  • Posts: 52
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #22 on: August 13, 2008, 03:54 PM »

wow! i didn't know much about your program's feature until i saw the demo video. :up:

P.S. could have used a more decent codec, though. :)

Like??

As I said I have never done a screen capture before so I just used what I found. It was either avi or swf and the swf file looked pretty crappy and had a huge file size.....

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #23 on: August 13, 2008, 08:51 PM »
i'm no expert myself but i believe that DC 's Best Screencasting Tool review might help. btw, when the need arises, I normally use Camtasia Studio 3. :)

belkira

  • Member
  • Joined in 2006
  • **
  • Posts: 52
    • View Profile
    • Donate to Member
Re: IDEA: Dynamic shortcuts
« Reply #24 on: August 20, 2008, 02:33 AM »
Thanks, I'll give that a read. I used Camstudio, but will definitely look into camtasia.