/ShellLinkA/examples/example1.ahk

http://github.com/maul-esel/COM-Classes · AutoHotKey · 37 lines · 16 code · 4 blank · 17 comment · 0 complexity · 1fc71c16f3e1fe650d3069d3f98b69e1 MD5 · raw file

  1. /*
  2. Example: Demonstrates the usage of *ShellLinkA.ahk*
  3. * Creating a new shell link (shortcut)
  4. * Setting its properties
  5. * Saving it to a file.
  6. Authors:
  7. - maul.esel (https://github.com/maul-esel)
  8. License:
  9. - *LGPL* (http://www.gnu.org/licenses/lgpl-2.1.txt)
  10. Requirements:
  11. AutoHotkey - AHK v2 alpha
  12. OS - Windows XP / Windows 2000 Server or higher
  13. Classes - _CCF_Error_Handler_, CCFramework, Unknown, ShellLinkA, Persist, PersistFile
  14. */
  15. #SingleInstance off
  16. #include ..\..\_CCF_Error_Handler_.ahk
  17. #include ..\..\CCFramework.ahk
  18. #include ..\..\Unknown\Unknown.ahk
  19. #include ..\ShellLinkA.ahk
  20. #include ..\..\Persist\Persist.ahk
  21. #include ..\..\PersistFile\PersistFile.ahk
  22. link := new ShellLinkA() ; create a shell link
  23. link.SetPath(A_Comspec) ; set the target + other properties of the link
  24. link.SetDescription("this is a test file by an AHK script")
  25. link.SetIconLocation(A_WinDir "\system32\imageres.dll", 23)
  26. link.SetWorkingDirectory(A_MyDocuments)
  27. link.SetArguments("/k `"echo Hi! This is a test.`"")
  28. file := new PersistFile(link.QueryInterface(PersistFile.IID)) ; get a PersistFile instance for the link
  29. file.Save(A_Desktop "\comspec.lnk.lnk", true) ; save the link to a file (somehow the '.lnk' is trucated...)
  30. MsgBox Saved the shell link to %A_Desktop%\comspec.lnk ; report to user