[办公]分享一个我自用的快捷启动菜单

[办公]分享一个我自用的快捷启动菜单 [办公]分享一个我自用的快捷启动菜单

其实就是写了几个小函数

  • AddTcDirMenu(IniFile)

读取tc配置文件,把tc常用文件夹添加到菜单,必须填写tc配置文件路径

  • AddItem(argMenu, argPath, argName := “”, argIco := “”, argForRun := “”, argWorkDir := “”, argMinMax := “”)

添加文件到菜单,可执行文件和文本文件都可以,能自动寻找图标添加。两个必填参数

  • AddItemFromeDir(argMenuName, argDir, argItemName := “”, argIco := “”,onlyApp := 1)

从文件夹中批量添加文件到菜单,自动添加图标,可以选择是否只添加可执行文件。两个必填参数

 

试例代码:

  1. #singleinstance, force
  2. #NoEnv
  3. settitlematchmode, 2
  4. detecthiddenwindows, on
  5.  
  6. ; 全局变量 ;{{{
  7. global TCEXE := A_ScriptDir . "\..\totalcmd\totalcmd.exe"
  8. global INIFILE := A_ScriptDir . "\..\totalcmd\wincmd.ini"
  9. global TcN
  10. global ItemPath := {}
  11. global run_arg := {}
  12. global run_wkdir := {}
  13. global run_minmax := {}
  14. ;}}}
  15.  
  16. ; 初始化菜单 ;{{{
  17. menu tray, icon, Ico\lightning.ico
  18. menu tray, click, 2
  19. ; menu tray, nostandard
  20. gosub lm_reflash
  21. return ;}}}
  22.  
  23. lm_reflash: ;{{{ ; 菜单内容配置
  24. AddTcDirMenu(A_ScriptDir . "\..\totalcmd\wincmd.ini")
  25. AddItem("lm_net", "d:\Software\AutoHotkey\Scripts\!移动云办公.ahk")
  26.  
  27. menu LightM, add, LightM, Reload
  28. menu LightM, disable, LightM
  29. menu LightM, Default, LightM
  30. menu LightM, add
  31. AddItemFromeDir("LightM", "Tools", "快捷应用(&r)", "Ico\exe.ico")
  32. menu LightM, add, Tc收藏夹(&t), :TcDir
  33. menu LightM, add, 常用网站(&g), :lm_net
  34. menu LightM, add
  35. AddItem("LightM","C:\Program Files\Everything\Everything.exe","&Everything")
  36. AddItem("lightM", "powershell.exe","Power&Shell",,,"C:\Users\" . A_UserName)
  37. AddItem("lightM", "D:\MyProject\jupyter\Scripts\activate.bat","Jupyter","Ico\jupyter.ico",,"D:\MyProject\jupyter\UserDoc","Min")
  38. AddItem("lightM", "d:\Software\AutoHotkey\AutoHotkey.chm", "&Help", "Ico\help1.ico")
  39. menu LightM, add, RELOAD, reload
  40.  
  41. menu LightM, icon, LightM, Ico\lightning.ico
  42. menu LightM, icon, Tc收藏夹(&t), Ico\Explorer.ico
  43. menu LightM, icon, 常用网站(&g), Ico\Internet.ico
  44. menu LightM, icon, RELOAD, Ico\reload.ico
  45. return ;}}}
  46.  
  47.  
  48.  
  49. ;  以下是函数
  50.  
  51. AddTcDirMenu(IniFile){ ;{{{ 添加TC常用文件夹
  52. if(FileExist(INIFILE)){
  53. loop{
  54. IniRead OutputVar, %INIFILE%, DirMenu, Menu%A_Index%
  55. if(OutputVar = "Error")
  56. {
  57. TcN := A_Index
  58. menu TcDir, add, TC打开当前文件夹(&t), TcDirG
  59. menu TcDir, icon, TC打开当前文件夹(&t), Ico\Explorer.ico
  60. return
  61. }
  62. if(RegExMatch(OutputVar,"^-")){
  63. menu TcDir, add
  64. continue
  65. }
  66. menu TcDir, add, %OutputVar%, TcDirG
  67. menu TcDir, icon, %OutputVar%, Ico\Explorer.ico
  68. }
  69. }
  70. } ;}}}
  71.  
  72. TcDirG(ItemName, ItemPos, MenuName){ ;{{{ 用tc打开菜单下的文件夹
  73. global ActivePath
  74. if(ItemPos=TcN)
  75. {
  76. if(ActivePath = "Error")
  77. path := ""
  78. else
  79. path := ActivePath
  80. }
  81. else
  82. {
  83. IniRead OutputVar, %INIFILE%, DirMenu, cmd%ItemPos%
  84. path := StrReplace(OutputVar, "cd ")
  85. }
  86. run %TCEXE% %path%
  87. } ;}}}
  88.  
  89. AddItemFromeDir(argMenuName, argDir, argItemName := "", argIco := "",onlyApp := 1){ ;{{{ 从文件夹批量添加快捷方式
  90. if(!argItemName){
  91. argDir := RegExReplace(argDir, "\\$", "\")
  92. SplitPath, argDir, argItemName
  93. }
  94. loop, files, %argDir%\*.*
  95. {
  96. SplitPath, A_LoopFileFullPath,,, OutExtension
  97. if(onlyApp and OutExtension != "exe" and OutExtension != "Lnk")
  98. continue
  99. AddItem(argItemName, A_LoopFileFullPath)
  100. }
  101. menu, %argMenuName%, add, %argItemName%, :%argItemName%
  102. if(argIco)
  103. menu, %argMenuName%, icon, %argItemName%, %argIco%
  104. else
  105. menu, %argMenuName%, icon, %argItemName%, shell32.dll, 4
  106. } ;}}}
  107.  
  108. AddItem(argMenu, argPath, argName := "", argIco := "", argForRun := "", argWorkDir := "", argMinMax := ""){ ;{{{ 添加快捷方式到菜单
  109. SplitPath, argPath,,, OutExtension, OutNameNoExt
  110. if(argName)
  111. OutNameNoExt := argName
  112. ItemPath[OutNameNoExt] := argPath
  113. menu, %argMenu%, add, %OutNameNoExt%, ItemRun
  114. if(argForRun)
  115. run_arg[OutNameNoExt] := argForRun
  116. if(argWorkDir)
  117. run_wkdir[OutNameNoExt] := argWorkDir
  118. if(argMinMax)
  119. run_minmax[OutNameNoExt] := argMinMax
  120. if(argIco = ""){
  121. if(OutExtension="exe")
  122. menu, %argMenu%, icon, %OutNameNoExt%, %argPath%, 1
  123. else if(OutExtension="Lnk"){
  124. FileGetShortcut, %argPath%, argPath
  125. menu, %argMenu%, icon, %OutNameNoExt%, %argPath%, 1
  126. }
  127. else{
  128. RegRead, OutputVar, HKEY_CLASSES_ROOT, .%OutExtension%
  129. RegRead, OutputVar, HKEY_CLASSES_ROOT\%OutputVar%\DefaultIcon
  130. StringSplit, Icon, OutputVar, `,
  131. menu, %argMenu%, icon, %OutNameNoExt%, %Icon1%, %Icon2%
  132. }
  133. }
  134. else
  135. menu, %argMenu%, icon, %OutNameNoExt%, %argIco%
  136. } ;}}}
  137.  
  138. ItemRun(ItemName, ItemPos, MenuName){ ; 运行程序 ;{{{
  139. Target := ItemPath[ItemName]
  140. Target2 := run_arg[ItemName]
  141. run, %Target% %Target2%, % run_wkdir[ItemName], % run_minmax[ItemName]
  142. } ;}}}
  143.  
  144. reload(){ ; 重启脚本 ;{{{
  145. reload
  146. } ;}}}
  147.  
  148. !s:: ; 注册热键 ;{{{
  149. ActivePath := Explorer_getpath()
  150. menu LightM, show
  151. return ;}}}
  152.  
  153. #include Scripts\Lib\Explorer.ahk

 

 

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
其他应用

[游戏][LOL]卡牌切牌

2017-8-27 21:08:58

其他

[编程][网页]网页加载完毕的判断

2017-10-27 9:46:04

4 条回复 A文章作者 M管理员
欢迎您,新朋友,感谢参与互动!
  1. oeasy

    你为啥不早点发出来?

    • chn.fwt

      脚本错了一点,已经修改了。

  2. 送上性支座

    为什么不早点发出来

  3. Million

    新手入门 抱着学习的目的拜读一下 非常感谢

个人中心
购物车
优惠劵
私信列表
搜索