topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Monday December 16, 2024, 4:11 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: Create shortcuts from a list  (Read 22219 times)

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #25 on: December 20, 2006, 09:13 PM »
ok, progress report.. :)
double-clicking on the box for output path works fine, regardless of the spaces within the path. :up:

however from the text file, the output path containing spaces doesn't work. here are a few formats i tried:
• ABC.exe,C:\A AA\BBB - creates BBB.lnk in A AA folder instead of ABC.exe in BBB
• ABC.exe,C:\A AA\BBB, - doesn't work
• ABC.exe,"C:\A AA\BBB" - doesn't work

btw, an option to ignore entries starting with a semi-colons for commenting purposes would be nice plus the implementation of <shortcut name> as part of the syntax..

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #26 on: December 21, 2006, 04:05 AM »
 :) Here's one I've actually tested!

Text2Shortcut

Drop a textfile with filenames on it to create shortcuts in the folder of the dropped textfile.
DoubleClick the drop window to select another target folder.
RightClick the drop window to edit the settings.

Syntax of dropped text file:
 <path to source file>
 <path to source file>,<target folder>\   <--- a \ must be added to a folder
 <path to source file>,<target folder>\<name of shortcut>
 <path to source file>,<name of shortcut>
;<path to source file> ;=line is ignored

Skrommel

Spoiler
;Text2Shortcut.ahk
; Drop a textfile with filenames on it to create shortcuts in the folder of the dropped textfile.
; DoubleClick the drop window to select another target folder.
; RightClick the drop window to edit the settings.
;Syntax of dropped text file:
; <path to source file>
; <path to source file>,<target folder>\    <--- a \ must be added to a folder
; <path to source file>,<target folder>\<name of shortcut>.lnk
; <path to source file>,<name of shortcut>.lnk
;;<path to source file> ;=line is ignored
;Skrommel @2006

#SingleInstance,Force
#NoEnv
applicationname=TS
Gosub,INIREAD
If target=
  TrayTip,%applicationname%,Target set to the folder of the dropped file
Else
  TrayTip,%applicationname%,Target set to the folder %target%
Gosub,GUI
Return

GuiDropFiles:
Loop,Read,%A_GuiControlEvent%
{
  SplitPath,A_GuiControlEvent,,dropdir,,,
  dir:=dropdir
  If target<>
    dir:=target
  StringSplit,part_,A_LoopReadLine,`,
  IfInString,part_1,`;
    Continue
  If part_0=1
  {
    SplitPath,part_1,name,,ext,name_no_ext,
    If ext In %noext%
      name:=name_no_ext
    FileCreateShortCut,%part_1%,%dir%\%name%.lnk
    TrayTip,%applicationname%,Created shortcut to %part_1% in %dir%\%name%.lnk
  }
  Else
  If part_0=2
  {
    SplitPath,part_2,name,dir,ext,name_no_ext,
    If dir=
      dir:=dropdir
    If name=
      SplitPath,part_1,name,,ext,name_no_ext,
    If ext In %noext%
      name:=name_no_ext
    FileCreateShortCut,%part_1%,%dir%\%name%.lnk
    TrayTip,%applicationname%,Created shortcut to %part_1% in %dir%\%name%.lnk
  }
}
Return

GUI:
Gui,Destroy
Gui,+ToolWindow +DropFiles +AlwaysOnTop -Border +Caption +Resize
Gui,Add,ListView,X0 Y0 W%w% H%h% GGUICLICK AltSubmit Icon
Gui,Show,X%x% Y%y% W%w% H%h%,%applicationname%
Gui,+LastFound
guiid:=WinExist("A")
WinMove,ahk_id %guiid%,,%x%,%y%,%w%,%h%
Return


GUICLICK:
If A_GuiControlEvent=DoubleClick
{
  FileSelectFolder,target,%target%,3,Select target folder
  If ErroLevel=1
    target=
  If target=
    TrayTip,%applicationname%,Target set to the folder of the dropped file
  Else
    TrayTip,%applicationname%,Target set to the folder %target%
}
Else
If A_GuiControlEvent=RightClick
{
  RunWait,%applicationname%.ini
  Reload
}
Else
  PostMessage,0xA1,2,,,A
Return

GuiEscape:
GuiClose:
WinGetPos,x,y,w,h,ahk_id %guiid%
IniWrite,%x%,%applicationname%.ini,Settings,x
IniWrite,%y%,%applicationname%.ini,Settings,y
IniWrite,%w%,%applicationname%.ini,Settings,w
IniWrite,%h%,%applicationname%.ini,Settings,h
IniWrite,%target%,%applicationname%.ini,Settings,target
ExitApp

INIREAD:
IfNotExist,%applicationname%.ini
{
  IniWrite,% A_ScreenWidth-140,%applicationname%.ini,Settings,x
  IniWrite,0,%applicationname%.ini,Settings,y
  IniWrite,37,%applicationname%.ini,Settings,w
  IniWrite,37,%applicationname%.ini,Settings,h
  IniWrite,%A_Space%,%applicationname%.ini,Settings,target
  IniWrite,exe`,com`,cmd`,bat,%applicationname%.ini,Settings,noext
}
IniRead,x,%applicationname%.ini,Settings,x
IniRead,y,%applicationname%.ini,Settings,y
IniRead,w,%applicationname%.ini,Settings,w
IniRead,h,%applicationname%.ini,Settings,h
IniRead,target,%applicationname%.ini,Settings,target
If (target="" Or target=" " Or target="ERROR")
  target=
IniRead,noext,%applicationname%.ini,Settings,noext
Return

« Last Edit: December 26, 2006, 01:26 PM by skrommel »

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #27 on: December 21, 2006, 10:00 PM »
sorry but the results are erratic.. btw, nice touch with the msg-box, i can monitor what's going on..
anyway, here is my text file with results. so that you can have a better picture..

My List
C:\My Tools\bintext.exe --> ok
;C:\My Tools\cpuz.exe --> this line is not ignored
C:\My Tools\DAMN NFO Viewer.ico --> ok
C:\My Tools\Dr.exe,C:\My Downloads\Test --> created as Test.lnk in 'My Downloads'
C:\My Tools\Flashpla.exe --> ok
C:\My Tools\ListFonts.exe --> ok
C:\My Tools\mplayerc.exe,Media Player Classic --> not created.


skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #28 on: December 22, 2006, 04:54 AM »
 :tellme: Forgot one vital information: A \ must be added to the end of a lone destination folder! See the description above!

Skrommel

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #29 on: December 25, 2006, 08:43 PM »
almost there but there are still some rough edges..

• the .exe appears again on the newly-created shortcuts.. (see above).
• besides this syntax, <path to source file>,<target folder>\<name of shortcut>.lnk, i also want to be able use this format: <path to source file>,<name of shortcut>.lnk, the target folder being the current folder of the text file.

thanks again, skrommel. :)

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #30 on: December 26, 2006, 01:27 PM »
 :) Try it once more!

And delete the TS.ini-file before running.

Skrommel

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #31 on: December 27, 2006, 09:14 PM »
yes, now it's a tip-top functional script.. good job, Skrommel & thanks. :Thmbsup:
p.s. some credit's on the way.. :-*