topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Friday December 13, 2024, 11:59 pm
  • 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

Author Topic: IDEA: port-apps launcher (auto-create shortcuts to exe's within a directory)  (Read 37806 times)

suleika

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 117
    • View Profile
    • Read more about this member.
    • Donate to Member
I run quite a lot of portable apps, although mostly from a folder on my hard drive.  I like to back them up onto usb drives and also copy them directly between my two laptops. 

I'd like a program that would create a folder full of nothing but shortcuts pointing to the various apps in my portable folder.  This way, if I move the apps around, create directories, rename things etc, I could easily auto-generate the shortcuts again.  The shortcut folder could then be added onto my desktop or as a taskbar toolbar in an instant.

Here's how I imagine it working (slightly inspired by the recent IconAnyFolder coding snack):  The shortcut creator would allow me to designate the top level directory, and then it would create shortcuts to any .exe file in that folder, and then search recursively one level down and add shortcuts to any .exe files it found there.  Any folders not including an .exe file would be searched further, and so on.

Well, that's what would work for me, since occasionally I have older versions and messy stuff like that stored within the folders of newer versions, and so I wouldn't want the shortcut creator to find them.  Also, many of the portable apps have executable plugins within their directories, which I wouldn't want shortcuts to.  But I imagine it could be configurable to either find all .exe's or to stop searching recursively at each found .exe as I suggest above.

Does anything like this exist already?  If not, any takers?
« Last Edit: February 10, 2008, 12:29 PM by suleika »

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
 :) Try ShortcutFolder!

Creates and collects shortcuts to programs in a folder named Shortcuts.

2008.2.11: Added depth limit, and only makes a shortcut to the first exe in every folder.
Skrommel

;ShortcutFolder.ahk
; Creates and collects shortcuts to programs in a folder
;Skrommel @ 2008

depth=2

#SingleInstance,Ignore
#NoEnv
SetBatchLines,-1

If 0=0
{
  FileSelectFolder,start,,3,Select a folder to search for programs
  If start=
  {
    MsgBox,0,TheDIZs,You didn't select a folder.
    ExitApp
  }
}   
Else
  start=%1%

StringSplit,startdepth,start,\

FileCreateDir,%A_WorkingDir%\Shortcuts

TrayTip,%ShortcutFolder%,Searching %start%...
Loop,%start%\*.exe,0,1
{
  olddir:=dir
  dir:=A_LoopFileDir
  StringSplit,dirdepth,dir,\
  If (dir<>olddir And dirdepth0-startdepth0<=depth)
  {
    SplitPath,A_LoopFileLongPath,name,dir,ext,name_no_ext,drive
    FileCreateShortcut,%A_LoopFileLongPath%,%A_WorkingDir%\Shortcuts\%name_no_ext%.lnk,,,,%A_LoopFileLongPath%,,1,
  }
}
TrayTip,%ShortcutFolder%,Shortcuts stored in %start%
Sleep,3000
« Last Edit: February 11, 2008, 04:35 PM by skrommel »

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
 :) And I believe you can use my tool ShortCutter

Skrommel


suleika

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 117
    • View Profile
    • Read more about this member.
    • Donate to Member
Thank you, Skrommel.   :)

ShortcutFolder successfully generated a load of shortcuts but unfortunately it's not really usable because there are shortcuts to over 150 Portable Gimp plug ins, various uninstall exe's, and some extra exe's with deceivingly similar names inside "App" folders.

If it's not possible to stop the search loop in any given path once an exe has been found (as per my description below) then could it be an option to select how many levels of subdirectory to search?  That would pretty much solve this for me.

By the way, I couldn't get Shortcutter to work.  I tried to insert or edit but clicking on "browse" gave me the message "Press OK to continue".


skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
 :) Try the changed version of ShortcutFolder above!

Skrommel

suleika

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 117
    • View Profile
    • Read more about this member.
    • Donate to Member
Thank you!  That is a tremendous help for my navigation and laptop syncing.  It's great.  :)

app103

  • That scary taskbar girl
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 5,885
    • View Profile
    • Donate to Member
It doesn't auto-create shortcuts, but my ClutterBuster app can handle relative paths. (requires a bit of editing of the ini file, in a text editor though)

Put it at the root of your USB drive and run it.

Right click a button, select an .exe file to associate with it. (it only works with .exe files) The exe file must contain an icon or the button will look blank. Once you have all the buttons set, close it and it will save the settings to an .ini file. Open the .ini file in notepad and edit the entries so they are relative paths.

It has 100 buttons, so it can hold quite a bit.

If you copy the entire contents of your usb drive to another folder, like on your laptop, you can create a shortcut to ClutterBuster on your desktop or taskbar's quicklaunch and the relative paths will still work. (I have used a smaller version of this to bundle collections of small apps with a preconfigured toolbar for launching)


phillfri

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 41
    • View Profile
    • Donate to Member
suleika - I have the same problem with shortcutter. Pressing the Browse button gives the message "Press OK to continue". (running WinXPSP2). Too bad. This is exactly what I need to manage a wiki "master links" folder. Anyone know of an updated version?

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
 :) Here's version 1.1 of ShortCutter!

20080223: Added browse functionality, changed the text of the settings dialog.

Skrommel

;ShortCutter.ahk
; Make autoupdating collections of shortcuts to certain filetypes
;Skrommel @ 2006

#Persistent
#SingleInstance,Force

applicationname=ShortCutter
open=0
Gosub,INIREAD
Gosub,TRAYMENU
If enabled=1
  enabled=0
Else
  enabled=1
Gosub,TOGGLE

Process,Priority,,Low
Gosub,TIMER
Return


TIMER:
If enabled=0
  Return
SetTimer,TIMER,%timer%,Off
Loop,%rules%
{
  active:=%A_Index%active
  If active=0
    Continue
  source:=%A_Index%source
  target:=%A_Index%target
  files:=%A_Index%files
  ignore:=%A_Index%ignore
  recurse:=%A_Index%recurse
  If (source="" Or target="")
    Continue
  Menu,Tray,Tip,%applicationname% - %files%
  FileCreateDir,%target%
  FileSetAttrib,-A,%target%\*.lnk,0,0
  Gosub,FIND
  Loop,%target%\*.lnk,0,0
  {
    Sleep,%delay%
    FileGetAttrib,attrib,%A_LoopFileLongPath%
    IfNotInString,attrib,A
    {
      FileGetShortcut,%A_LoopFileLongPath%,linktarget
      IfNotExist,%linktarget%
        FileDelete,%A_LoopFileLongPath%
    }
  }
}
SetTimer,TIMER,%timer%,On
Return


FIND:
Loop,%source%\*.*,2,% (recurse="Yes")
{
  Sleep,%delay%
  If enabled=0
    Return
  folderpath:=A_LoopFileLongPath
  If status=1
    TrayTip,%applicationname%,%folderpath%
  Loop,Parse,files,`,
  {
    type:=A_LoopField
    Loop,%folderpath%\%type%,0,0
    {
      path:=A_LoopFileLongPath
      name:=A_LoopFileName
      If path Contains %ignore%
        Continue
      exist=0
      counter=0
      version=
      Loop
      {
        Sleep,%delay%
        If counter>0
          version=-%counter%
        IfExist,%target%\%A_LoopFileName%%version%.lnk
        {
          FileGetShortcut,%target%\%A_LoopFileName%%version%.lnk,linktarget
          If (linktarget=path)
          {
            exist=1
            Break
          }
          counter+=1
        }
        Else
          Break
      }
      If exist=0
      {
        FileCreateShortcut,%path%,%target%\%A_LoopFileName%%version%.lnk,%folderpath%,,%path%
        FileGetTime,date,%path%,M
        FileSetTime,%date%,%target%\%A_LoopFileName%%version%.lnk
      }
      Else
      {
        FileSetAttrib,+A,%target%\%A_LoopFileName%%version%.lnk
        FileGetTime,date,%path%,M
        FileSetTime,%date%,%target%\%A_LoopFileName%%version%.lnk
      }
    }
  }
}
Return


INIREAD:
IfNotExist,%applicationname%.ini
{
  start=1
  delay=5
  timer=60000
  status=0

  1active=1
  1source=C:\
  1target=%A_Desktop%\Images
  1files=*.jpg,*.jpeg
  1ignore=Recycled,Temporary
  1recurse=Yes

  2active=1
  2source=C:\
  2target=%A_Desktop%\Music
  2files=*.mp3
  2ignore=Recycled,Temporary
  2recurse=Yes
 
  rules=2
  Gosub,INIWRITE
}
Else
{
  IniRead,start,%applicationname%.ini,Settings,start
  If start=1
    enabled=1
  Else
    enabled=0
  IniRead,delay,%applicationname%.ini,Settings,delay
  IniRead,timer,%applicationname%.ini,Settings,timer
  IniRead,status,%applicationname%.ini,Settings,status
  rules=1
  Loop
  {
    IniRead,active,%applicationname%.ini,%A_Index%,active
    IniRead,source,%applicationname%.ini,%A_Index%,source
    IniRead,target,%applicationname%.ini,%A_Index%,target
    IniRead,files,%applicationname%.ini,%A_Index%,files
    IniRead,ignore,%applicationname%.ini,%A_Index%,ignore
    IniRead,recurse,%applicationname%.ini,%A_Index%,recurse
    If (source="ERROR" And target="ERROR" And files="ERROR")
      Break
    If (source="" And target="" And files="")
      Break
    %rules%active:=active
    %rules%source:=source
    %rules%target:=target
    %rules%files:=files
    %rules%ignore:=ignore
    %rules%recurse:=recurse
    rules+=1
  }
  rules-=1
}
Return


INIWRITE:
Iniwrite,%start%,%applicationname%.ini,Settings,start
Iniwrite,%delay%,%applicationname%.ini,Settings,delay
Iniwrite,%timer%,%applicationname%.ini,Settings,timer
Iniwrite,%status%,%applicationname%.ini,Settings,status
count=1
Loop,%rules%
{
  If (%A_Index%source="" And %A_Index%target="" And %A_Index%files="" And %A_Index%ignore="" And %A_Index%recurse="")
  {
    IniDelete,%applicationname%.ini,%A_Index%,
    Continue
  }
  active:=%A_Index%active
  source:=%A_Index%source
  target:=%A_Index%target
  files:=%A_Index%files
  ignore:=%A_Index%ignore
  recurse:=%A_Index%recurse
  Iniwrite,%active%,%applicationname%.ini,%count%,active
  Iniwrite,%source%,%applicationname%.ini,%count%,source
  Iniwrite,%target%,%applicationname%.ini,%count%,target
  Iniwrite,%files%,%applicationname%.ini,%count%,files
  Iniwrite,%ignore%,%applicationname%.ini,%count%,ignore
  Iniwrite,%recurse%,%applicationname%.ini,%count%,recurse
  count+=1
}
count-=1
rules:=count
Gosub,INIREAD
Return


SETTINGS:
oldenabled:=enabled
enabled=0
insert=0
Gui,99:Destroy
Gui,99:Add,Tab,w580 h370,Rules|Options
Gui,99:Tab,1
Gui,99:Add,ListView,w560 h300 GLISTVIEW NoSort -Multi Checked,Active|Source|Target|Files|Ignore|Recurse?
Gui,99:Default

Loop,%rules%
{
  If (%A_Index%source="" And %A_Index%target="" And %A_Index%files="" And %A_Index%ignore="" And %A_Index%recurse="")
    Continue
  LV_ADD("","",%A_Index%source,%A_Index%target,%A_Index%files,%A_Index%ignore,%A_Index%recurse)
  If %A_Index%active=1
    LV_Modify(LV_GetCount(),"Check")
}
LV_ADD("","","","","","","")

Gui,99:Tab,1
Gui,99:Add,Button,w75 x20 y340 GSETTINGSEDIT,&Edit
Gui,99:Add,Button,w75 x+5 GSETTINGSINSERT,&Insert
Gui,99:Add,Button,w75 x+5 GSETTINGSDELETE,&Delete

Gui,99:Add,Button,w75 x+5 GSETTINGSMOVEUP,Move &Up
Gui,99:Add,Button,w75 x+5 GSETTINGSMOVEDOWN,Move &Down

Gui,99:Tab,2
Gui,99:Add,GroupBox,x20 y50 w300,Timer - How often to check for new files?
Gui,99:Add,Edit,x30 yp+20 w75 votimer,% Floor(timer/1000)
Gui,99:Add,Text,x+5 yp+5,seconds

Gui,99:Add,GroupBox,x20 y+30 w300,Delay - How long to wait between file operations (0-100)?
Gui,99:Add,Edit,x30 yp+20 w75 vodelay,%delay%
Gui,99:Add,Text,x+5 yp+5,ms

Gui,99:Add,GroupBox,x20 y+30 w300,Status
If status=1
  Gui,99:Add,CheckBox,xp+10 yp+20 vostatus Checked,Show status in the tray
Else
  Gui,99:Add,CheckBox,xp+10 yp+20 vostatus,Show status in the tray
Gui,99:Add,GroupBox,x20 y+30 w300,Startup
If start=1
  Gui,99:Add,CheckBox,xp+10 yp+20 vostart Checked,Start enabled
Else
  Gui,99:Add,CheckBox,xp+10 yp+20 vostart,Start enabled
Gui,99:Tab
Gui,99:Add,Button,x425 y340 w75 Default GSETTINGSOK,&OK
Gui,99:Add,Button,x+5 w75 GSETTINGSCANCEL,&Cancel

Gui,99:Show,w600 h390,%Applicationname% Settings
Return


LISTVIEW:
If A_GuiEvent=DoubleClick
  Gosub,SETTINGSEDIT
Return


SETTINGSINSERT:
row:=LV_GetNext(0,"Focused")
insert=1
Gosub,SETTINGSEDIT
Return


SETTINGSDELETE:
row:=LV_GetNext(0,"Focused")
If (row=LV_GetCount())
  Return
LV_Delete(row)
LV_Modify(row,"Select")
LV_Modify(row,"Focus")
Return


SETTINGSEDIT:
row:=LV_GetNext(0,"Focused")
If row=0
  Return
LV_GetText(source,row,2)
LV_GetText(target,row,3)
LV_GetText(files,row,4)
LV_GetText(ignore,row,5)
LV_GetText(recurse,row,6)

Gui,98:Destroy
Gui,98:+ToolWindow

Gui,98:Add,GroupBox,x10 w560 h50,&Source - Where to look for files
Gui,98:Add,Edit,xp+10 yp+20 w460 vosource,%source%
Gui,98:Add,Button,x+5 yp w75 GBROWSESOURCE,&Browse...

Gui,98:Add,GroupBox,x10 y+20 w560 h50,&Target - Where to store the shortcuts
Gui,98:Add,Edit,xp+10 yp+20 w460 votarget,%target%
Gui,98:Add,Button,x+5 yp w75 GBROWSETARGET,B&rowse...

Gui,98:Add,GroupBox,x10 y+20 w480 h70,&Files - What files to create shortcuts to
Gui,98:Add,Edit,xp+10 yp+20 w460 vofiles,%files%
Gui,98:Add,Text,y+5 300,Supports wildcards * ?. Example: *.jp*g

Gui,98:Add,GroupBox,x10 y+20 w480 h70,&Ignore - What (parts of) filenames to ignore
Gui,98:Add,Edit,xp+10 yp+20 w460 voignore,%ignore%
Gui,98:Add,Text,y+5 300,No wildcards. Example: jpg,jpeg,C:\Boot.ini

options=No|Yes|
StringReplace,options,options,%recurse%,%recurse%|
Gui,98:Add,GroupBox,x10 y+20 w300 h70,&Recurse - Search subfolders?
Gui,98:Add,DropDownList,xp+10 yp+20 w150 vorecurse,%options%
Gui,98:Add,Text,y+5 300,No, Yes

Gui,98:Add,Button,x420 y340 w75 Default GEDITOK,&OK
Gui,98:Add,Button,x+5 w75 GEDITCANCEL,&Cancel

Gui,98:Show,w580 h370,%applicationname% Edit
Return


BROWSESOURCE:
Gui,98:+LastFound
guiid:=WinExist("A")
ControlGetText,sourcefolder,Edit1,ahk_id %guiid%
FileSelectFolder,chosenfolder,*%sourcefolder%,3,Select a source folder
If chosenfolder=
  chosenfolder:=sourcefolder
ControlSetText,Edit1,%chosenfolder%,ahk_id %guiid%
Return


BROWSETARGET:
Gui,98:+LastFound
guiid:=WinExist("A")
ControlGetText,targetfolder,Edit2,ahk_id %guiid%
FileSelectFolder,chosenfolder,*%targetfolder%,3,Select a target folder
If chosenfolder=
  chosenfolder:=targetfolder
ControlSetText,Edit2,%targetfolder%,ahk_id %guiid%
Return


EDITOK:
Gui,98:Submit,NoHide
If (osource="" Or otarget="" Or ofiles="")
  MsgBox,0,%applicationname% - Error,Please fill inn Source, Target and Files
Else
{
  Gui,99:Default
  If insert=1
    LV_Insert(row,"Focus","",osource,otarget,ofiles,oignore,orecurse)
  Else
  {   
    LV_Modify(row,"Focus","",osource,otarget,ofiles,oignore,orecurse)
    If (row=LV_GetCount())
      LV_ADD("","","","","","","")
  }
  Gosub,EDITCANCEL
}
Return


EDITCANCEL:
Gui,98:Destroy
insert=0
Return


SETTINGSMOVEUP:
row:=LV_GetNext(0,"Focused")
If row=1
  Return
If (row=LV_GetCount())
  Return
LV_GetText(source2,row,2)
LV_GetText(target2,row,3)
LV_GetText(files2,row,4)
LV_GetText(ignore2,row,5)
LV_GetText(recurse2,row,6)

row-=1
LV_GetText(source1,row,2)
LV_GetText(target1,row,3)
LV_GetText(files1,row,4)
LV_GetText(ignore1,row,5)
LV_GetText(recurse1,row,6)

LV_Modify(row,"Select","",source2,target2,files2,ignore2,recurse2)
LV_Modify(row,"Focus")

row+=1
LV_Modify(row,"","",source1,target1,files1,ignore1,recurse1)
Return


SETTINGSMOVEDOWN:
row:=LV_GetNext(0,"Focused")
If (row>=LV_GetCount()-1)
  Return
LV_GetText(source2,row,2)
LV_GetText(target2,row,3)
LV_GetText(files2,row,4)
LV_GetText(ignore2,row,5)
LV_GetText(recurse2,row,6)

row+=1
LV_GetText(source1,row,2)
LV_GetText(target1,row,3)
LV_GetText(files1,row,4)
LV_GetText(ignore1,row,5)
LV_GetText(recurse1,row,6)

LV_Modify(row,"Select","",source2,target2,files2,ignore2,recurse2)
LV_Modify(row,"Focus")

row-=1
LV_Modify(row,"","",source1,target1,files1,ignore1,recurse1)
Return


SETTINGSOK:
Gui,99:Submit,NoHide
If otimer>0
  timer:=otimer*1000
If odelay>0
  delay:=odelay
status:=ostatus
start:=ostart
count=1
Loop % LV_GetCount()
{
  checked:=LV_GetNext(count-1,"Checked")
  If (checked=count)
    %count%active=1
  Else
    %count%active=0
  LV_GetText(%count%source,A_Index,2)
  LV_GetText(%count%target,A_Index,3)
  LV_GetText(%count%files,A_Index,4)
  LV_GetText(%count%ignore,A_Index,5)
  LV_GetText(%count%recurse,A_Index,6)
  If (%count%source="" And %count%target="" And %count%files="" And %count%ignore="" And %count%recurse="")
    Continue
  count+=1
}
rules:=count
Gosub,INIWRITE
Gosub,SETTINGSCANCEL
Return


SETTINGSCANCEL:
Gui,98:Destroy
Gui,99:Destroy
enabled:=oldenabled
Gosub,TIMER
Return


TRAYMENU:
Menu,Tray,NoStandard
Menu,Tray,DeleteAll
Menu,Tray,Add,%applicationname%,SETTINGS
Menu,Tray,Add
Menu,Tray,Add,&Settings,SETTINGS
Menu,Tray,Add,&Enabled,TOGGLE
Menu,Tray,Add
Menu,Tray,Add,&About,ABOUT
Menu,Tray,Add,E&xit,EXIT
Menu,Tray,Default,%applicationname%
Menu,Tray,Tip,%applicationname%
Return


TOGGLE:
If enabled=1
{
  enabled=0
  Menu,Tray,UnCheck,&Enabled
  ;Menu,Tray,Icon,%applicationname%.exe,3
}
Else
{
  enabled=1
  Menu,Tray,Check,&Enabled
  ;Menu,Tray,Icon,%applicationname%.exe,1

Return


ABOUT:
Gui,97:Destroy
Gui,97:Add,Picture,Icon1,%applicationname%.exe
Gui,97:Font,Bold
Gui,97:Add,Text,x+10 yp+10,%applicationname% v1.1
Gui,97:Font
Gui,97:Add,Text,xm,Make autoupdating collections of shortcuts to certain filetypes.
Gui,97:Add,Text,xm,- Rightclick the tray icon to configure
Gui,97:Add,Text,xm,- Choose Settings to change rules and options
Gui,97:Add,Text,xm,- Choose Enable to Start or Stop all the rules
Gui,97:Add,Text,y+0,`t

Gui,97:Add,Picture,xm Icon2,%applicationname%.exe
Gui,97:Font,Bold
Gui,97:Add,Text,x+10 yp+10,1 Hour Software by Skrommel
Gui,97:Font
Gui,97:Add,Text,xm,For more tools, information and donations, visit
Gui,97:Font,CBlue Underline
Gui,97:Add,Text,xm G1HOURSOFTWARE,www.1HourSoftware.com
Gui,97:Font
Gui,97:Add,Text,y+0,`t

Gui,97:Add,Picture,xm Icon5,%applicationname%.exe
Gui,97:Font,Bold
Gui,97:Add,Text,x+10 yp+10,DonationCoder
Gui,97:Font
Gui,97:Add,Text,xm,Please support the DonationCoder community
Gui,97:Font,CBlue Underline
Gui,97:Add,Text,xm GDONATIONCODER,www.DonationCoder.com
Gui,97:Font
Gui,97:Add,Text,y+0,`t

Gui,97:Add,Picture,xm Icon6,%applicationname%.exe
Gui,97:Font,Bold
Gui,97:Add,Text,x+10 yp+10,AutoHotkey
Gui,97:Font
Gui,97:Add,Text,xm,This program was made using AutoHotkey
Gui,97:Font,CBlue Underline
Gui,97:Add,Text,xm GAUTOHOTKEY,www.AutoHotkey.com
Gui,97:Font
Gui,97:Add,Text,y+0,`t

Gui,97:Add,Button,GABOUTOK Default w75,&OK
Gui,97:Show,,%applicationname% About

hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
OnMessage(0x200,"WM_MOUSEMOVE")
Return

1HOURSOFTWARE:
Run,http://www.1hoursoftware.com,,UseErrorLevel
Return

DONATIONCODER:
Run,https://www.donationcoder.com,,UseErrorLevel
Return

AUTOHOTKEY:
Run,http://www.autohotkey.com,,UseErrorLevel
Return

ABOUTOK:
Gui,97:Destroy
OnMessage(0x200,"")
DllCall("DestroyCursor","Uint",hCurs)
Return

WM_MOUSEMOVE(wParam,lParam)
{
  Global hCurs
  MouseGetPos,,,winid,ctrl
  If ctrl in Static12,Static17,Static22
    DllCall("SetCursor","UInt",hCurs)
}

EXIT:
ExitApp
« Last Edit: February 22, 2008, 05:40 PM by skrommel »

vixay

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 140
  • ViXaY
    • View Profile
    • Donate to Member
This is related to this idea, so i figured i'd post it here in case somebody might find it useful. It is related in that it does the opposite of what you want.

It takes a folder of shortucts and copies the actual files over to a destination of your choice. :P

' Purpose: A simple Synchronization/Multiple Folder to One Folder
' script.
' Create a directory full of shortcuts to programs/files/folders
' that you want to copy to a destination folder
' Run this script either
' a) from that directory with the destination folder as a parameter
' b) from anywhere with the destination folder as the 1st parameter
'       and the source folder (with the shortcuts in it) as the second
'       parameter
'
' Notes: WARNING - Will overwrite files without prompting!
'  If you make changes please send me email, might go to spam, so
'  be careful :)

here's the code for it, it's a vb script. so save it as .vbs and pass it the correct parameters to run it.

'
' CopyShortcutTargets.vbs
'
' Purpose: A simple Synchronization/Multiple Folder to One Folder
' script.
' Create a directory full of shortcuts to programs/files/folders
' that you want to copy to a destination folder
' Run this script either
' a) from that directory with the destination folder as a parameter
' b) from anywhere with the destination folder as the 1st parameter
' and the source folder (with the shortcuts in it) as the second
' parameter
'
' Notes: WARNING - Will overwrite files without prompting!
'  If you make changes please send me email, might go to spam, so
'  be careful :)
'
' Written by Vixay Xavier,
' Version 1.0 - [email protected]
' Remove IGNORE THIS from email address before mailing it out
' Don't know how effective this is but eh, it's worth a shot :)
'
' Source/Help taken from:
' === "bertha_index.vbs"
' Keep Bertha Surfin Heavy Industries,
' a division of Keep Bertha Surfin Electrical Concern
' Version 1.0 - [email protected]
' === "LogToFile.vbs"
' http://www.naterice.com/blog/template_permalink.asp?id=43

'TODO
' Add better error handling/notification
' - for overwriting scenario
' - when logfile doesn't exist/ can't create
' Keep statistics?
'DONE
' Add Logging to Source Directory of Files Copied and all - Done
' Notification to user while running - changed method to windows
'   copy box, and added a done dialog box at end. This makes the script
'   unusable in automated fashion, but easy enough to fix by
'   removing/commenting out the "msgbox" line


Option Explicit

'---------LogToFile Configuration---------
'NOTE: Copy the configuration section To
'the beginning of an existing script. The
'values specified here must be set before
'calling the LogToFile sub.
Dim bEnableLogging
Dim bIncludeDateStamp
Dim bPrependDateStampInLogFileName
Dim sLogFileLocation
Dim sLogFileName
Dim sOverWriteORAppend
'You can disable logging globally by
'setting the bEnableLogging option to false.
bEnableLogging = True

'Setting this to true will time stamp Each
'message that is logged to the log file
'with the current date and time.
bIncludeDateStamp = True

'This will set the log file name to the
'current date and time. You can use this
'option to create incremental log files.
bPrependDateStampInLogFileName = True

'Specify the log file location here. Path
'must contain a trailing backslash. If you
'would like to log to the same location as
'the currently running script, set this
'value to "relative" or uncomment out the
'line below.
'sLogFileLocation = "C:\LogFiles\"
sLogFileLocation = "relative"

'Specify the log file name here.
sLogFileName = "CopyTargets.log"

'You can set whether or not you would like
'the script to append to an existing file,
'or if you would like it to overwrite
'existing copies. To overwrite set the
'sOverWriteORAppend variable to "overwrite"
sOverWriteORAppend = "append"
'-------END LogToFile Configuration-------

' Run the Function :)
Call CheckParameters

Sub CheckParameters()
' First thing, check the argument list for a directory.
' If they didn't specIfy one, use the current directory.

Dim fso
Set fso = createobject("scripting.filesystemobject")

Dim destF
Dim sourceF
If WScript.Arguments.Count = 0 Then
WScript.Echo "Error: No Destination folder provided!" & vbcrlf _
& "Usage: Scriptname DestFolder [SourceFolder]" & vbcrlf _
& " SourceFolder is assumed to be current directory when ommitted"
'If not Destination is provided quit
WScript.Quit
ElseIf Wscript.Arguments.Count = 1 Then
' if 1 argument is provided ASSUME it's destination folder
destF = WScript.Arguments(0)
sourceF = fso.GetAbsolutePathName(".")
ElseIf Wscript.Arguments.Count = 2 Then
' if 2 arguments are provided ASSUME 1st is destination folder
' and 2nds is source folder
destF = WScript.Arguments(0)
sourceF = WScript.Arguments(1)
End If

GetWorkingFolder destF, sourceF

Set fso = nothing

End Sub

Function GetWorkingFolder(targetF, originF)

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

Dim sourceF
Set sourceF = fso.GetFolder(originF)
Dim destF
If Not fso.FolderExists(targetF) Then
fso.CreateFolder(targetF)
End If
Set destF = fso.GetFolder(targetF)

Dim sourceFiles
Set sourceFiles = sourceF.Files

Dim remaincount
remaincount = sourceFiles.count

LogToFile("Process Started" & vbcrlf _
& "Source: " & sourceF & vbcrlf _
& "Destination: " & destF & vbcrlf _
& "# of Files in Source:" & remaincount)
Dim file_in_f
Dim ftemp
Dim targt
Dim fsCopyObj
'***Code to test windows animated copying method
Dim shAppObj, nmSpObj
Set shAppObj = CreateObject("Shell.Application")
Set nmSpObj = shAppObj.NameSpace(destF.Path)
'***End test code setup

For each file_in_f in sourceFiles
Set ftemp = fso.GetFile(file_in_f.Name)
'If file is a shortcut
If fso.GetExtensionName(ftemp) = "lnk" Then
'This is where the magic happens
' 1) we get the target path
' 2) check what it is
' 3) copy it to destination
'Find it's target
targt = FindTarget(file_in_f.Name)
'Check if it's a folder/file
If (fso.FolderExists(targt)) Then
LogToFile(" Copying directory- " & targt)
Set fsCopyObj = fso.GetFolder(targt)
'fso.CopyFolder targt, destF
ElseIf (fso.FileExists(targt)) Then
LogToFile(" Copying file     - " & targt)
Set fsCopyObj = fso.GetFile(targt)
'fso.CopyFile targt, destF
Else
LogToFile(" ERROR: Cannot determine targets type - " & targt)
End If
'And Copy the target to destination
If Not fsCopyObj is Nothing Then
'Wscript.Echo "Copying to " & destF.Path
          'fsCopyObj.Copy destF.Path & "\"
          '*** Alternative Windows animated method
          'See http://www.tek-tips.com/viewthread.cfm?qid=831585
          nmSpObj.CopyHere fsCopyObj.Path,16
          '*** End alternative method
          Set fsCopyObj = Nothing 
          End If
        End If
        Set ftemp = Nothing
Next
LogToFile("Done copying files/folders")
If MsgBox("Done copying files/folders." & vbcrlf _
& "Log Filename: " & sLogFileName & vbcrlf _
& "Open Log?", vbYesNo + vbQuestion, "Done, Open Log?") = vbYes Then
Set shAppObj = nothing
Set shAppObj = CreateObject("WScript.Shell")
shAppObj.Run "notepad " & sLogFileLocation & sLogFileName
End If
Set shAppObj = nothing
Set nmSpObj = nothing
Set fso = nothing
Set sourceF = nothing
Set destF = nothing
Set sourceFiles = nothing
Exit Function
errHandler:

End Function

Function FindTarget(filenam)
Dim shortct, WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Set shortct = WshShell.CreateShortcut(filenam)
FindTarget = shortct.TargetPath
Set WshShell = nothing
Set shortct = nothing
End Function

Sub LogToFile(sMessage)
    'LogToFile.vbs 12-15-06
    'This script is provided under the Creative Commons license located
    'at http://creativecommons.org/licenses/by-nc/2.5/ . It may not
    'be used for commercial purposes with out the expressed written consent
    'of NateRice.com

    If bEnableLogging = False Then Exit Sub

Dim oLogFSO
Dim oLogShell
Dim oLogFile
Dim sNow, sLogFile

    Const ForWriting = 2
    Const ForAppending = 8

    Set oLogFSO = CreateObject("Scripting.FileSystemObject")
   
    If sLogFileLocation = "relative" Then
        Set oLogShell = CreateObject("Wscript.Shell")
        sLogFileLocation = oLogShell.CurrentDirectory & "\"
        Set oLogShell = Nothing
    End If
   
    If bPrependDateStampInLogFileName Then
        sNow = Replace(Replace(Now(),"/","-"),":",".")
        sLogFileName = sNow & " - " & sLogFileName
        'Disable generation of another logfilename for subsequent calls
        bPrependDateStampInLogFileName = False
    End If
   
    sLogFile = sLogFileLocation & sLogFileName
   
    If sOverWriteORAppend = "overwrite" Then
        Set oLogFile = oLogFSO.OpenTextFile(sLogFile, ForWriting, True)
        sOverWriteORAppend = "append"
    Else
        Set oLogFile = oLogFSO.OpenTextFile(sLogFile, ForAppending, True)
    End If

    If bIncludeDateStamp Then
        sMessage = Now & "   " & sMessage
    End If

    oLogFile.WriteLine(sMessage)
   
    oLogFile.Close
    oLogFSO = Null
End Sub
"Drunk on the Nectar of Life!" -me

phillfri

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 41
    • View Profile
    • Donate to Member
Vixay - Thanks for the CopyShortcutTargets script. I can see making good use of this for creating documentation directories containing only documents referenced by a wiki and backing them up.


phillfri

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 41
    • View Profile
    • Donate to Member
skrommel - The updated shortcutter program doesn't work. The target browse button doesn't load the directory selected and the program never actually runs when one adds a new entry into the rules table.

update: Actually the program will run the example rules that it comes with, but it appears not to work with mapped drives? Was it perhaps designed that way?
« Last Edit: February 25, 2008, 12:46 PM by phillfri »

phillfri

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 41
    • View Profile
    • Donate to Member
To fix Shortcutter v1.1 target directory input problem, find the following code in what was posted earlier in this thread.

BROWSETARGET:
Gui,98:+LastFound
guiid:=WinExist("A")
ControlGetText,targetfolder,Edit2,ahk_id %guiid%
FileSelectFolder,chosenfolder,*%targetfolder%,3,Select a target folder
If chosenfolder=
  chosenfolder:=targetfolder
ControlSetText,Edit2,%targetfolder%,ahk_id %guiid%
Return

Change the line:

ControlSetText,Edit2,%targetfolder%,ahk_id %guiid%

to read

ControlSetText,Edit2,%chosenfolder%,ahk_id %guiid%


Ehtyar

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,237
    • View Profile
    • Donate to Member
PStart has an option to scan any directory for executables and will automatically add them to the menu. I use it to manage my portable drive, very good software.

Ehtyar.

phillfri

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 41
    • View Profile
    • Donate to Member
Shortcutter v1.1 as posted earlier in this thread had 3 problems for what I was seeking to accomplish.

[1] The target directory input browse dialog wouldn't work properly, failing to actually record the selected target directory
[2] The recurse option would create shortcuts for files found in the subdirectories ONLY, skipping the files in the root source directory
[3] Without the recurse option, no shortcuts were created for files in the root source directory

The attached code changes the logic of the program. When the recurse option is selected, shortcuts are created for files in the source root directory and files in all the subdirectories. When the recurse option s not selected, shortcuts are created for all the files in the source root directory only. And the target directory browse button problem is fixed.

This code has not been extensively tested, and being brand new to AutoHotKey my code changes surely are a bit of a cludge :D  This could be coded better by someone more familiar with AutoHotKey. In any event, it appears to work on my short tests, so I pass it along for anyone who wishes to use it.

kartal

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 1,529
    • View Profile
    • Donate to Member
This was the exact same thing I was looking for!!!!!!!!!!!! GREAT WORK!!!!!  Now I can speed up FARR by directing Farr to this particular shortcuts folder for app search.

« Last Edit: October 30, 2008, 09:13 PM by kartal »

kartal

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 1,529
    • View Profile
    • Donate to Member
I am also testing shortcutter, I am guessing that they are similar in nature?

phillfri,

Shall I go forward with you version? Have you had any failures so far?



thanks again