ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

批量复制、安装和设置电脑软件的批处理脚本程序源代码-2022年1月6日

2022-01-06 15:04:33  阅读:271  来源: 互联网

标签:exe AutoHotkey AHK Gui 2022 ahk Path 源代码 电脑软件


批量复制、安装和设置电脑软件的批处理脚本程序源代码-2022年1月6日

https://www.autoahk.com/archives/39241

 

我能力有限,无法使用路径中带有空格符的 %~dp0

如果有那位网友有完美的带空格路径解决方案请在本文最下面的评论区回复一下,谢谢。

 

D:\ProgramSetup\Setup.bat

  1. rem 批量复制、安装和设置电脑软件的批处理脚本程序源代码-2022年1月6日
  2. rem D:\ProgramSetup\Setup.bat
  3. rem 可以在局域网共享文件夹、RaiDrive连接群晖WebDAV后映射的虚拟磁盘或者银灿IS903量产U盘USB-CD-ROM中运行此批处理脚本
  4. rem 路径中不可以有空格
  5. rem 1、复制批处理脚本所在文件夹中的文件到D:\Program
  6. Start /Wait Robocopy.exe %~dp0 D:\Program\ /e /mt /r:3 /w:3 *.*
  7. rem 2、全自动静默安装AutoHotkey自动化热键脚本编程环境
  8. Start /Wait D:/Program/AutoHotkey/AutoHotkey_1.1.33.10_setup.exe /S /A32 /U32 /U64 /D=D:/Program/AutoHotkey/
  9. rem 3、等待3秒钟
  10. ping -n 3 127.0.0.1>nul 2>nul
  11. rem 4、设置AHK类型的自动化热键脚本文件的右键菜单关联(新建、运行、编译、编辑)
  12. Start D:/Program/AutoHotkey/RightMenuSetup.ahk
  13. rem 作者: 甲壳虫<jdchenjian@gmail.com>
  14. rem 修改作者: 兔子
  15. rem 5、运行、显示、最大化并激活 Total Commander 10.00 程序窗口
  16. Start D:\Program\TotalCMD\Run.ahk
  17. rem 6、运行并最小化 Everything 程序窗口
  18. Start /Min D:\Program\Everything\Everything.exe
  19. rem 7、运行Maye(快速启动工具,用于管理和使用快捷方式、
  20. rem 设置快捷键(TotalCMD设置为F8,Everything设置为F11))
  21. Start D:\Program\Maye\Maye.exe
  22. rem https://blog.arae.cc/post/25830.html
  23. rem https://github.com/25H/Maya/releases/latest
  24. rem https://www.lanzoux.com/b0bqwqjvg
  25. exit

 

D:/Program/AutoHotkey/RightMenuSetup.ahk

  1. /*
  2. D:/Program/AutoHotkey/RightMenuSetup.ahk
  3. AutoHotkey 版本: 1.x
  4. 操作系统: WinXP
  5. 作者: 甲壳虫<jdchenjian@gmail.com>
  6. 博客: http://hi.baidu.com/jdchenjian
  7. 脚本说明: 此工具用来修改 AutoHotkey 脚本的右键菜单关联,适用于 AutoHotkey 安装版、绿色版。
  8. 脚本版本: 2009-01-21
  9. 修改作者: 兔子
  10. 更新说明:
  11. 2010.01.09 之前某个时间,修改AHK路径、编辑器路径、编译器路径,默认全部在当前目录下寻找
  12. 2010.01.09 去掉默认在新建菜单的勾
  13. 2010.06.21 如果SCITE为默认编辑器,则复制个人配置文件“SciTEUser.properties”到%USERPROFILE%
  14. 2010.06.25 修正因#NoEnv使%USERPROFILE%变量直接引用无效
  15. 2016.04.18 删除“2010.06.21”的改动
  16. */
  17. ; --- 20190207 晓亮修改 ---
  18. #NoEnv
  19. SetWorkingDir, %A_ScriptDir%
  20. ; 管理员权限运行
  21. RunWith("admin")
  22. #NoEnv
  23. #SingleInstance, force
  24. SendMode Input
  25. SetWorkingDir %A_ScriptDir%
  26. ; 版本(仅用于显示)
  27. Script_Version=v1.0.3.2
  28. ; AutoHotkey 原版的相关信息写在注册表HKCR主键中,
  29. ; 尝试是当前用户否有权操作该键,如果无权操作HKCR键(受限用户),
  30. ; 可通过操作注册表HKCU键来实现仅当前用户关联AHK脚本。
  31. IsLimitedUser:=0
  32. RegWrite, REG_SZ, HKCR, .test
  33. if ErrorLevel
  34. IsLimitedUser:=1
  35. RegDelete, HKCR, .test
  36. if ErrorLevel
  37. IsLimitedUser:=1
  38. if IsLimitedUser=0 ; 非受限用户操作HKCR键
  39. {
  40. RootKey=HKCR
  41. Subkey=
  42. }
  43. else ; 受限用户操作HKCU键
  44. {
  45. RootKey=HKCU
  46. Subkey=Software\Classes\ ; <-- 为简化后面的脚本,此子键须以“\”结尾
  47. }
  48. ; 检查是否存在AHK注册表项
  49. RegRead, FileType, %RootKey%, %Subkey%.ahk
  50. if FileType<>
  51. {
  52. RegRead, value, %RootKey%, %Subkey%%FileType%\Shell\Open\Command ;AHK路径
  53. AHK_Path:=PathGetPath(value)
  54. RegRead, value, %RootKey%, %Subkey%%FileType%\Shell\Edit\Command ;编辑器路径
  55. Editor_Path:=PathGetPath(value)
  56. RegRead, value, %RootKey%, %Subkey%%FileType%\Shell\Compile\Command ;编译器路径
  57. Compiler_Path:=PathGetPath(value)
  58. RegRead, Template_Name, %RootKey%, %Subkey%.ahk\ShellNew, FileName ;模板文件名
  59. }
  60. else
  61. FileType=AutoHotkeyScript
  62. if AHK_Path=
  63. {
  64. IfExist, %A_ScriptDir%\AutoHotkey.exe
  65. AHK_path=%A_ScriptDir%\AutoHotkey.exe
  66. }
  67. if Editor_Path=
  68. {
  69. IfExist, %A_ScriptDir%\SciTE\SciTE.exe
  70. Editor_Path=%A_ScriptDir%\SciTE\SciTE.exe
  71. }
  72. if Compiler_Path=
  73. {
  74. IfExist, %A_ScriptDir%\Compiler\Ahk2Exe.exe
  75. Compiler_Path=%A_ScriptDir%\Compiler\Ahk2Exe.exe
  76. }
  77. if Template_Name=
  78. Template_Name=Template.ahk
  79. ; --- 20190207 晓亮修改 ---
  80. ;设置AHK默认文件夹为 D:\Program\AutoHotkey
  81. AHK_path=D:\Program\AutoHotkey\AutoHotkeyU32.exe
  82. Editor_Path=D:\Program\AutoHotkey\SciTE\SciTE.exe
  83. Compiler_Path=D:\Program\AutoHotkey\Compiler\Ahk2Exe.exe
  84. Gui, Add, Tab, x10 y10 w480 h250 Choose1, 设置|说明
  85. Gui, Tab, 1
  86. Gui, Add, GroupBox, x20 y40 w460 h50 , “运行脚本”关联的 AutoHotkey
  87. Gui, Add, Edit, x35 y60 w340 h20 vAHK_Path, %AHK_path%
  88. Gui, Add, Button, x385 y60 w40 h20 gFind_AHK, 浏览
  89. Gui, Add, GroupBox, x20 y100 w460 h50 , “编辑脚本”关联的编辑器
  90. Gui, Add, Edit, x35 y120 w340 h20 vEditor_Path, %Editor_Path%
  91. Gui, Add, Button, x385 y120 w40 h20 gChoose_Editor, 浏览
  92. Gui, Add, Button, x430 y120 w40 h20 gDefault_Editor, 默认
  93. Gui, Add, GroupBox, x20 y160 w460 h50 , “编译脚本”关联的编译器
  94. Gui, Add, Edit, x35 y180 w340 h20 vCompiler_Path, %Compiler_Path%
  95. Gui, Add, Button, x385 y180 w40 h20 gChoose_Compiler, 浏览
  96. Gui, Add, Button, x430 y180 w40 h20 gDefault_Compiler, 默认
  97. Gui, Add, Checkbox, x35 y230 w270 h20 gNew_Script vNew_Script, 右键“新建”菜单中增加“AutoHotkey 脚本”
  98. Gui, Add, Button, x310 y230 w80 h20 vEdit_Template gEdit_Template, 编辑脚本模板
  99. Gui, Add, Button, x400 y230 w80 h20 vDelete_Template gDelete_Template, 删除脚本模板
  100. Gui, Tab, 2
  101. Gui, Font, bold
  102. Gui, Add, Text,, AutoHotkey 脚本关联工具 ScriptSetting %Script_Version%
  103. Gui, Font
  104. Gui, Font, CBlue underline
  105. Gui, Add, Text, gWebsite, 作者:甲壳虫 <jdchenjian@gmail.com>`n`n博客:http://hi.baidu.com/jdchenjian
  106. Gui, Font
  107. Gui, Add, Text, w450, 此工具用来修改 AutoHotkey 脚本的右键菜单关联,适用于 AutoHotkey 安装版、绿色版。
  108. Gui, Add, Text, w450, 您可以用它来修改默认脚本编辑器、编译器,修改默认的新建脚本模板。设置后,在右键菜单中添加“运行脚本”、“编辑脚本”、“编译脚本”和“新建 AutoHotkey 脚本”等选项。
  109. Gui, Add, Text, w450, 要取消脚本的系统关联,请按“卸载”。注意:卸载后您将无法通过双击来运行脚本,也不能通过右键菜单来启动脚本编辑器...
  110. Gui, Tab
  111. Gui, Add, Button, x100 y270 w60 h20 default gInstall, 设置
  112. Gui, Add, Button, x200 y270 w60 h20 gUninstall, 卸载
  113. Gui, Add, Button, x300 y270 w60 h20 gCancel, 取消
  114. Gui, Show, x250 y200 h300 w500 CEnter, ScriptSetting %Script_Version%
  115. GuiControl, Disable, Edit_Template ; 使“编辑脚本模板”按钮无效
  116. IfNotExist, %A_WinDir%\ShellNew\%Template_Name%
  117. GuiControl, Disable, Delete_Template ; 使“删除脚本模板”按钮无效
  118. ; 当鼠标指向链接时,指针变成手形
  119. hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
  120. OnMessage(0x200,"WM_MOUSEMOVE")
  121. ; --- 20190207 晓亮修改 ---
  122. goto,Install
  123. return
  124. ; 改变鼠标指针为手形
  125. WM_MOUSEMOVE(wParam,lParam)
  126. {
  127. global hCurs
  128. MouseGetPos,,,,ctrl
  129. if ctrl in static2
  130. DllCall("SetCursor","UInt",hCurs)
  131. return
  132. }
  133. return
  134. GuiClose:
  135. GuiEscape:
  136. Cancel:
  137. ExitApp
  138. ; 查找 AutoHotkey 主程序
  139. Find_AHK:
  140. Gui +OwnDialogs
  141. FileSelectFile, AHK_Path, 3, , 查找 AutoHotkey.exe, AutoHotkey.exe
  142. if AHK_Path<>
  143. GuiControl,,AHK_Path, %AHK_Path%
  144. gosub Default_Compiler
  145. return
  146. ; 选择脚本编辑器
  147. Choose_Editor:
  148. Gui +OwnDialogs
  149. FileSelectFile, Editor_Path, 3, , 选择脚本编辑器, 程序(*.exe)
  150. if Editor_Path<>
  151. GuiControl,,Editor_Path, %Editor_Path%
  152. return
  153. ; 默认脚本编辑器
  154. Default_Editor:
  155. IfExist, %A_ScriptDir%\SciTE\SciTE.exe
  156. Editor_Path=%A_ScriptDir%\SciTE\SciTE.exe
  157. else ifExist, %A_WinDir%\system32\notepad.exe
  158. Editor_Path=%A_WinDir%\system32\notepad.exe
  159. GuiControl,, Editor_Path, %Editor_Path%
  160. return
  161. ; 选择脚本编译器
  162. Choose_Compiler:
  163. Gui +OwnDialogs
  164. FileSelectFile, Compiler_Path, 3, , 选择脚本编译器, 程序(*.exe)
  165. if Compiler_Path<>
  166. GuiControl,,Compiler_Path, %Compiler_Path%
  167. return
  168. ; 默认脚本编译器
  169. Default_Compiler:
  170. GuiControlGet, AHK_Path
  171. SplitPath, AHK_Path, ,AHK_Dir
  172. IfExist, %AHK_Dir%\Compiler\Ahk2Exe.exe
  173. {
  174. Compiler_Path=%AHK_Dir%\Compiler\Ahk2Exe.exe
  175. GuiControl,, Compiler_Path, %Compiler_Path%
  176. }
  177. return
  178. ; 设置
  179. Install:
  180. Gui, Submit
  181. IfNotExist, %AHK_Path%
  182. {
  183. MsgBox, 16, ScriptSetting %Script_Version%, AutoHotkey 路径错误 !
  184. return
  185. }
  186. IfNotExist, %Editor_Path%
  187. {
  188. MsgBox, 16, ScriptSetting %Script_Version%, 编辑器路径错误 !
  189. return
  190. }
  191. IfNotExist, %Compiler_Path%
  192. {
  193. MsgBox, 16, ScriptSetting %Script_Version%, 编译器路径错误 !
  194. return
  195. }
  196. ; 写入注册表
  197. RegWrite, REG_SZ, %RootKey%, %Subkey%.ahk,, %FileType%
  198. if New_Script=1
  199. {
  200. RegWrite, REG_SZ, %RootKey%, %Subkey%.ahk\ShellNew, FileName, %Template_Name%
  201. IfNotExist, %A_WinDir%\ShellNew\%Template_Name%
  202. gosub Create_Template
  203. }
  204. else
  205. {
  206. ; --- 20190207 晓亮修改 ---
  207. ; --- 此处不要删除右键新建ahk文件的菜单所以注释掉此代码
  208. ;RegDelete, %RootKey%, %Subkey%.ahk\ShellNew
  209. IfExist, %A_WinDir%\ShellNew\%Template_Name%
  210. gosub Delete_Template
  211. }
  212. RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%,, AutoHotkey 脚本
  213. RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%\DefaultIcon,, %AHK_Path%`,1
  214. RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%\Shell,, Open
  215. RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%\Shell\Open,, 运行脚本
  216. RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%\Shell\Open\Command,, "%AHK_Path%" "`%1" `%*
  217. RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%\Shell\Edit,, 编辑脚本
  218. RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%\Shell\Edit\Command,, "%Editor_Path%" "`%1"
  219. RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%\Shell\Compile,, 编译脚本
  220. IfInString, Compiler_Path, Ahk2Exe.exe
  221. RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%\Shell\Compile\Command,, "%Compiler_Path%" /in "`%1"
  222. else
  223. RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%\Shell\Compile\Command,, "%Compiler_Path%" "`%1"
  224. /* 新版的scite不需要将“SciTEUser.properties”放在“USERPROFILE”目录下了
  225. if Editor_Path=%A_ScriptDir%\SciTE\SciTE.exe
  226. {
  227. EnvGet,USERPROFILE,USERPROFILE
  228. FileCopy,%A_ScriptDir%\SciTE\SciTEUser.properties,%USERPROFILE%\SciTEUser.properties,1
  229. }
  230. */
  231. ;MsgBox, 64, ScriptSetting %Script_Version%, 设置完毕 !
  232. ExitApp
  233. ; 卸载
  234. Uninstall:
  235. ; --- 20190207 晓亮修改 ---
  236. ;MsgBox, 36, ScriptSetting %Script_Version%
  237. ;, 注意:卸载后您将无法通过双击来运行脚本,也不能通过右键菜单来启动脚本编辑器...`n`n确定要取消 AHK 脚本的系统关联吗 ?
  238. ;IfMsgBox, Yes
  239. ;{
  240. ;RegDelete, %RootKey%, %Subkey%.ahk
  241. ;RegDelete, %RootKey%, %Subkey%%FileType%
  242. ;gosub Delete_Template
  243. ;ExitApp
  244. ;}
  245. return
  246. ; 编辑脚本模板
  247. Edit_Template:
  248. GuiControlGet, Editor_Path
  249. IfNotExist, %Editor_Path%
  250. {
  251. MsgBox, 64, ScriptSetting %Script_Version%, 脚本编辑器路径错误 !
  252. return
  253. }
  254. IfNotExist, %A_WinDir%\ShellNew\%Template_Name%
  255. gosub Create_Template
  256. Run, %Editor_Path% %A_WinDir%\ShellNew\%Template_Name%
  257. return
  258. ; 使编辑脚本模板按钮有效/无效
  259. New_Script:
  260. GuiControlGet, New_Script
  261. if New_Script=0
  262. GuiControl, Disable, Edit_Template
  263. else
  264. GuiControl, Enable, Edit_Template
  265. return
  266. ; 新建脚本模板
  267. Create_Template:
  268. GuiControlGet, AHK_Path
  269. FileGetVersion, AHK_Ver, %AHK_Path%
  270. FileAppend,
  271. (
  272. /*
  273. AutoHotkey 版本: %AHK_Ver%
  274. 操作系统: %A_OSVersion%
  275. 作者: %A_UserName%
  276. 网站: http://www.AutoHotkey.com
  277. 脚本说明:
  278. 脚本版本: v1.0
  279. */
  280. #NoEnv
  281. SendMode Input
  282. SetWorkingDir `%A_ScriptDir`%
  283. ), %A_WinDir%\ShellNew\%Template_Name%
  284. GuiControl, Enable, Delete_Template ; 使“删除脚本模板”按钮有效
  285. return
  286. ; 删除脚本模板
  287. Delete_Template:
  288. ; --- 20190207 晓亮修改 ---
  289. ;MsgBox, 36, ScriptSetting %Script_Version%
  290. ; , 要删除当前的 AHK 脚本模板吗 ?`n`n脚本模板被删除后,仍可通过本工具重建模板。
  291. ;IfMsgBox, Yes
  292. ;FileDelete, %A_WinDir%\ShellNew\%Template_Name%
  293. ;GuiControl, Disable, Delete_Template ; 使“删除脚本模板”按钮无效
  294. return
  295. ; 打开网站
  296. Website:
  297. Run, http://hi.baidu.com/jdchenjian
  298. return
  299. ; 从注册表值字符串中提取路径
  300. PathGetPath(pSourceCmd)
  301. {
  302. local Path, ArgsStartPos = 0
  303. if (SubStr(pSourceCmd, 1, 1) = """")
  304. Path := SubStr(pSourceCmd, 2, InStr(pSourceCmd, """", false, 2) - 2)
  305. else
  306. {
  307. ArgsStartPos := InStr(pSourceCmd, " ")
  308. if ArgsStartPos
  309. Path := SubStr(pSourceCmd, 1, ArgsStartPos - 1)
  310. else
  311. Path = %pSourceCmd%
  312. }
  313. return Path
  314. }
  315. ; 强制自身进程以 管理员权限 或 普通权限 或 ANSI 或 U32 或 U64 版本运行。
  316. ; 例1: runwith("admin","u32") 强制自身以 u32 + 管理员权限 运行。
  317. ; 例2: runwith("","ansi") 强制自身以 ansi 版本运行(权限不变)。
  318. ; 例3: runwith("normal") 强制自身以 普通权限 运行(版本不变)。
  319. RunWith(RunAsAdmin:="Default", ANSI_U32_U64:="Default")
  320. {
  321. ; 格式化预期的模式
  322. switch, RunAsAdmin
  323. {
  324. case "Normal","Standard","No","0": RunAsAdmin:=0
  325. case "Admin","Yes","1": RunAsAdmin:=1
  326. case "default": RunAsAdmin:=A_IsAdmin
  327. default: RunAsAdmin:=A_IsAdmin
  328. }
  329. switch, ANSI_U32_U64
  330. {
  331. case "A32","ANSI","A": ANSI_U32_U64:="AutoHotkeyA32.exe"
  332. case "U32","X32","32": ANSI_U32_U64:="AutoHotkeyU32.exe"
  333. case "U64","X64","64": ANSI_U32_U64:="AutoHotkeyU64.exe"
  334. case "default": ANSI_U32_U64:="AutoHotkey.exe"
  335. default: ANSI_U32_U64:="AutoHotkey.exe"
  336. }
  337. ; 获取传递给 “.ahk” 的用户参数(不是 /restart 之类传递给 “.exe” 的开关参数)
  338. for k, v in A_Args
  339. {
  340. if (RunAsAdmin=1)
  341. {
  342. ; 转义所有的引号与转义符号
  343. v:=StrReplace(v, "\", "\\")
  344. v:=StrReplace(v, """", "\""")
  345. ; 无论参数中是否有空格,都给参数两边加上引号
  346. ; Run 的内引号是 "
  347. ScriptParameters .= (ScriptParameters="") ? """" v """" : A_Space """" v """"
  348. }
  349. else
  350. {
  351. ; 转义所有的引号与转义符号
  352. ; 注意要转义两次 Run 和 RunAs.exe
  353. v:=StrReplace(v, "\", "\\")
  354. v:=StrReplace(v, """", "\""")
  355. v:=StrReplace(v, "\", "\\")
  356. v:=StrReplace(v, """", "\""")
  357. ; 无论参数中是否有空格,都给参数两边加上引号
  358. ; RunAs.exe 的内引号是 \"
  359. ScriptParameters .= (ScriptParameters="") ? "\""" v "\""" : A_Space "\""" v "\"""
  360. }
  361. }
  362. ; 判断当前 exe 是什么版本
  363. if (!A_IsUnicode)
  364. RunningEXE:="AutoHotkeyA32.exe"
  365. else if (A_PtrSize=4)
  366. RunningEXE:="AutoHotkeyU32.exe"
  367. else if (A_PtrSize=8)
  368. RunningEXE:="AutoHotkeyU64.exe"
  369. ; 运行模式与预期相同,则直接返回。 ANSI_U32_U64="AutoHotkey.exe" 代表不对 ahk 版本做要求。
  370. if (A_IsAdmin=RunAsAdmin and (ANSI_U32_U64="AutoHotkey.exe" or ANSI_U32_U64=RunningEXE))
  371. return
  372. ; 如果当前已经是使用 /restart 参数重启的进程,则报错避免反复重启导致死循环。
  373. else if (RegExMatch(DllCall("GetCommandLine", "str"), " /restart(?!\S)"))
  374. {
  375. 预期权限:=(RunAsAdmin=1) ? "管理员权限" : "普通权限"
  376. 当前权限:=(A_IsAdmin=1) ? "管理员权限" : "普通权限"
  377. ErrorMessage=
  378. (LTrim
  379. 预期使用: %ANSI_U32_U64%
  380. 当前使用: %RunningEXE%
  381. 预期权限: %预期权限%
  382. 当前权限: %当前权限%
  383. 程序即将退出。
  384. )
  385. MsgBox 0x40030, 运行状态与预期不一致, %ErrorMessage%
  386. ExitApp
  387. }
  388. else
  389. {
  390. ; 获取 AutoHotkey.exe 的路径
  391. SplitPath, A_AhkPath, , Dir
  392. if (RunAsAdmin=0)
  393. {
  394. ; 强制普通权限运行
  395. switch, A_IsCompiled
  396. {
  397. ; %A_ScriptFullPath% 必须加引号,否则含空格的路径会被截断。%ScriptParameters% 必须不加引号,因为构造时已经加了。
  398. ; 工作目录不用单独指定,默认使用 A_WorkingDir 。
  399. case, "1": Run, RunAs.exe /trustlevel:0x20000 "\"%A_ScriptFullPath%\" /restart %ScriptParameters%",, Hide
  400. default: Run, RunAs.exe /trustlevel:0x20000 "\"%Dir%\%ANSI_U32_U64%\" /restart \"%A_ScriptFullPath%\" %ScriptParameters%",, Hide
  401. }
  402. }
  403. else
  404. {
  405. ; 强制管理员权限运行
  406. switch, A_IsCompiled
  407. {
  408. ; %A_ScriptFullPath% 必须加引号,否则含空格的路径会被截断。%ScriptParameters% 必须不加引号,因为构造时已经加了。
  409. ; 工作目录不用单独指定,默认使用 A_WorkingDir 。
  410. case, "1": Run, *RunAs "%A_ScriptFullPath%" /restart %ScriptParameters%
  411. default: Run, *RunAs "%Dir%\%ANSI_U32_U64%" /restart "%A_ScriptFullPath%" %ScriptParameters%
  412. }
  413. }
  414. ExitApp
  415. }
  416. }

 

D:\Program\TotalCMD\Run.ahk

  1. ;
  2. ;/*
  3. ; D:\Program\TotalCMD\Run.ahk
  4. ;===========================================
  5. ; 设置激活或者隐藏 Total Commander 10.00 主窗口的快捷键为 F8
  6. ; https://www.autoahk.com/archives/37780
  7. ; https://www.cnblogs.com/delphixx/p/15718194.html
  8. ;
  9. ; 脚本作者 : ds920
  10. ; 最新版本 : 1.1
  11. ; 更新时间 : 2021年12月22日
  12. ;
  13. ; 用法: (需要最新版本 AHK v1.1.31+)
  14. ; 1. 到飞扬时空的新浪博客下载并安装TotalCommander中文增强版到文件夹D:/TotalCMD
  15. ; 2. 将本脚本保存为"RunTC.ahk"并复制到D:/TotalCMD文件夹中
  16. ; 3. 使用Maye来设置RunTC.ahk的热键为 F8
  17. ;
  18. ; 升级更新历史:
  19. ; 版本1.0 2021年12月22日 新建 创建此AutoHotkey脚本并测试通过F8热键功能
  20. ; 版本1.1 2021年12月22日 修改 调整删除 SetTimer 定时器时判断TC主窗口是否激活的顺序
  21. ; 把基于窗口类的激活判断语句"if(WinActive("ahk_class" TTOTAL_CMD))"放在最外层
  22. ; 防止有相同标题的窗口激活时(例如:相同标题的浏览器等等)窗口激活误判
  23. ;
  24. ; 由于AutoHotkey的Hotkey语句设置的热键必需在任务栏或者桌面进程激活时才有效,
  25. ; 所以请使用Maye来设置Total Commander的热键 F8
  26. ; https://blog.arae.cc/post/25830.html
  27. ; https://github.com/25H/Maya/releases/
  28. ;
  29. ; 可以用 Total Commander 访问用RaiDrive异地远程连接群晖WebDAV文件服务并映射成的本地虚拟磁盘盘符 Z: 分区
  30. ; 可以用 Total Commander 访问用NetDrive2异地远程连接群晖SFTP文件服务并映射成的本地虚拟磁盘盘符 Y: 分区
  31. ; 可以用支持 Total Commander的WebDAV文件服务访问插件异地远程连接群晖WebDAV文件服务中的网络共享文件夹
  32. ; 可以用KeePass或者KeePass2Android来连接坚果云或者
  33. ; 群晖NAS的WebDAV文件服务来管理网址、用户名、账号、密码、口令、暗号、纪念日等个人敏感隐私信息和数据
  34. ; 可以用FileZilla Pro 专业版软件异地远程连接群晖的WebDAV文件服务并
  35. ; 批量上传文件夹到群晖的 RAID 1 镜像存储池中的共享文件夹之中
  36. ; 可以用腾讯文档的电脑客户端来新建在线文档和在线表格来进行办公文档和办公表格的分享和协作
  37. ; 可以用Bulk Rename Utility 2.7.1.2来批量重命名或者编号群晖WebDAV文件服务中的共享文件夹中的大量文件
  38. ; 可以用Double Killer Pro V 2.1.0.104来批量删除群晖WebDAV文件服务中的共享文件夹中的重复文件
  39. ; 可以安装并升级更新"火绒安全软件"来防杀电脑病毒木马恶意软件并拦截垃圾广告弹出的骚扰窗口
  40. ; 可以用SGI备份还原映像总裁镜像总裁一键还原工具软件来备份保护Windows操作系统和
  41. ; 电脑中应用程序软件和设置到GHO系统镜像文件
  42. ; SGI备份还原映像总裁镜像总裁一键还原工具软件官方网址是 https://www.sysceo.com/Software-softwarei-id-253.html
  43. ; 以便今后用杏雨梨云启动维护系统可启动固态U盘来恢复电脑系统应用程序软件GHO系统镜像文件到电脑的系统分区C盘
  44. ; 可以用Shadow Defender 影子卫士来保护Windows操作系统和电脑中应用程序软件的设置,
  45. ; 防止电脑软件设置被未授权的用户和程序非法更改和破坏
  46. ; 如果无法安装 Shadow Defender 影子卫士时可以用"DeepFreeze冰点还原精灵"或者
  47. ; "PowerShadow影子系统"或者"Returnil Virtual System(RVS)"来代替影子卫士
  48. ;
  49. ;===========================================
  50. ;*/
  51. #SingleInstance,Ignore
  52. loop,5
  53. {
  54. DetectHiddenWindows,On
  55. Sleep,5
  56. IfWinExist,QQ595076941_AutoAHKRun
  57. ExitApp
  58. }
  59. Gui, Show, Hide,QQ595076941_AutoAHKRun
  60. #Persistent
  61. ; #NoTrayIcon
  62. DetectHiddenWindows,On
  63. SetTitleMatchMode,2
  64. ; 设置激活或者隐藏 Total Commander 10.00 主窗口的快捷键为 F8
  65. ; Hotkey,F8,ActivateOrHideWindowHotkey
  66. ActivateOrHideWindowHotkey()
  67. return
  68. ; ——————————————————–
  69. ActivateOrHideWindowHotkey()
  70. {
  71. ; MsgBox,PressedHotkey检测到已经按下快捷键
  72. Sleep,5
  73. IfWinActive,ahk_class TTOTAL_CMD
  74. {
  75. Sleep,5
  76. if(WinActive(ahk_class TTOTAL_CMD))
  77. {
  78. Sleep,5
  79. WinGetClass, MyClass, A
  80. IfInString,MyClass,TTOTAL_CMD
  81. {
  82. Sleep,5
  83. IfWinActive,Total Commander
  84. {
  85. TCTitle:="Total Commander"
  86. Sleep,5
  87. WinGetActiveTitle,Title
  88. IfInString,Title,%TCTitle%
  89. {
  90. ; MsgBox,MinimizeWindow最小化指定窗口
  91. WinMinimize,Total Commander ahk_class TTOTAL_CMD
  92. Sleep,5
  93. ExitApp
  94. }
  95. }
  96. }
  97. }
  98. }
  99. else
  100. {
  101. ; MsgBox,ActivateWindow显示并且最大化并且激活指定窗口
  102. SetTimer,ActivateWindowTimer,20
  103. }
  104. }
  105. ; ——————————————————–
  106. ;根据窗口类名显示并激活Total Commander窗口
  107. ActivateWindowTimer()
  108. {
  109. ; 1、如果程序没有运行则运行程序,这里我把可执行文件名改成了TotalCMD-v10.exe
  110. Process,Exist,TotalCMD-v10.exe
  111. if (%ErrorLevel%=0)
  112. {
  113. IfExist,D:/Program/TotalCMD/TotalCMD.exe
  114. {
  115. Run,D:/Program/TotalCMD/TotalCMD.exe
  116. }
  117. else
  118. {
  119. MsgBox,找不到文件 D:/Program/TotalCMD/TotalCMD.exe
  120. return
  121. }
  122. }
  123. ; 2、显示并激活(切换到)指定窗口
  124. WinShow,Total Commander ahk_class TTOTAL_CMD
  125. WinMove,Total Commander ahk_class TTOTAL_CMD,,0,0,A_ScreenWidth,A_ScreenHeight
  126. WinActivate,Total Commander ahk_class TTOTAL_CMD
  127. WinMaximize,Total Commander ahk_class TTOTAL_CMD
  128. Sleep,5
  129. DetectHiddenWindows,On
  130. SetTitleMatchMode,2
  131. WinGet, WinID, ID,Total Commander ahk_class TTOTAL_CMD
  132. DllCall("SwitchToThisWindow", "UInt", WinID, "UInt", 1)
  133. ; 3、检查指定窗口是否激活成功,
  134. ; 假如激活成功则退出Timer计时器循环执行,
  135. ; 如果激活失败则继续尝试激活指定窗口
  136. Sleep,5
  137. IfWinActive,ahk_class TTOTAL_CMD
  138. {
  139. Sleep,5
  140. if(WinActive(ahk_class TTOTAL_CMD))
  141. {
  142. Sleep,5
  143. WinGetClass, MyClass, A
  144. IfInString,MyClass,TTOTAL_CMD
  145. {
  146. Sleep,5
  147. IfWinActive,Total Commander
  148. {
  149. TCTitle:="Total Commander"
  150. Sleep,5
  151. WinGetActiveTitle,Title
  152. IfInString,Title,%TCTitle%
  153. {
  154. SetTimer,ActivateWindowTimer,Delete
  155. Sleep,5
  156. ExitApp
  157. }
  158. }
  159. }
  160. }
  161. }
  162. }
  163. ;================= The End =================
  164. ;
  165. /*
  166. ;================= 根据窗口类名激活或者隐藏窗口的AutoHotkey函数 =================
  167. ; 请使用 窗口信息工具 AHKInfo 1.3.5 获取窗口的类名
  168. ;根据窗口类名激活或者隐藏窗口
  169. ActivateOrHideWindow(VarExeFileName:="TotalCMD-v10″,VarWinClassName:="TTOTAL_CMD")
  170. {
  171. ; 1、如果程序没有运行则运行程序
  172. Process,Exist,%VarExeFileName%.exe
  173. if (%ErrorLevel%=0)
  174. {
  175. IfExist,%VarExeFileName%.exe
  176. {
  177. Run,%VarExeFileName%.exe
  178. return
  179. }
  180. else
  181. {
  182. MsgBox,找不到文件 %VarExeFileName%.exe
  183. return
  184. }
  185. }
  186. ; 2、如果窗口未置顶则显示并激活(切换到)指定窗口
  187. IfWinNotActive,ahk_class %VarWinClassName%
  188. {
  189. loop,2
  190. {
  191. Sleep,50
  192. WinShow,ahk_class %VarWinClassName%
  193. ;~ WinMaximize,ahk_class %VarWinClassName%
  194. Sleep,50
  195. WinGet, WinID, ID,ahk_class %VarWinClassName%
  196. Sleep,50
  197. DllCall("SwitchToThisWindow", "UInt", WinID, "UInt", 1)
  198. }
  199. return
  200. }
  201. ; 3、如果窗口已经显示并置顶则隐藏窗口
  202. ;~ WinMinimize,ahk_class %VarWinClassName%
  203. WinHide,ahk_class %VarWinClassName%
  204. }
  205. */
  206. ;

 

D:\ProgramSetup\Tree.txt

  1. 卷 软件 的文件夹 PATH 列表
  2. 卷序列号为 ILOV-EYOU
  3. D:.
  4. ├─AutoHotkey
  5. │ ├─AHK电子书
  6. │ ├─Compiler
  7. │ ├─Icon
  8. │ └─SciTE
  9. │ ├─extensions
  10. │ ├─locales
  11. │ ├─toolbar
  12. │ │ └─Lib
  13. │ ├─tools
  14. │ │ ├─AHK 正则终结者
  15. │ │ │ └─Lib
  16. │ │ ├─AHK 爬虫终结者
  17. │ │ │ ├─jsoneditor-5.15.0
  18. │ │ │ │ └─dist
  19. │ │ │ │ └─img
  20. │ │ │ └─Lib
  21. │ │ ├─AHK 脚本关联工具
  22. │ │ ├─AHK-Rare
  23. │ │ │ ├─assets
  24. │ │ │ ├─lib
  25. │ │ │ │ └─Highlighters
  26. │ │ │ └─tools
  27. │ │ ├─ahkinfo
  28. │ │ ├─AhkSpy
  29. │ │ ├─AHK_Window_Info
  30. │ │ ├─Au3Record
  31. │ │ ├─Auto-GUI
  32. │ │ │ ├─Constantine
  33. │ │ │ ├─Icons
  34. │ │ │ ├─Include
  35. │ │ │ ├─Lib
  36. │ │ │ └─Settings
  37. │ │ ├─Auto-Syntax-Tidy
  38. │ │ │ └─Syntax
  39. │ │ ├─AutoItMacroGenerator
  40. │ │ ├─AutoScriptWriter
  41. │ │ ├─CLISD
  42. │ │ ├─ColorFinder
  43. │ │ │ └─Lib
  44. │ │ ├─eXeScope
  45. │ │ ├─FindText
  46. │ │ ├─GenDocs
  47. │ │ │ ├─Demo
  48. │ │ │ └─Lib
  49. │ │ ├─iCodeRepository3
  50. │ │ │ ├─Clipboard_monitor
  51. │ │ │ ├─help
  52. │ │ │ │ └─pictures
  53. │ │ │ └─爱码源码仓库
  54. │ │ │ ├─AutoHotkey
  55. │ │ │ └─AutoHotkey2
  56. │ │ ├─Lib
  57. │ │ │ └─DebugVars
  58. │ │ ├─MacroCreator
  59. │ │ │ ├─Documentation
  60. │ │ │ │ ├─Lib
  61. │ │ │ │ └─MacroCreator_Help-doc
  62. │ │ │ │ ├─Examples
  63. │ │ │ │ └─Images
  64. │ │ │ ├─Lang
  65. │ │ │ ├─LIB
  66. │ │ │ └─Resources
  67. │ │ │ └─Icons
  68. │ │ ├─MagicBox
  69. │ │ │ ├─Examples
  70. │ │ │ ├─Functions
  71. │ │ │ ├─Icons
  72. │ │ │ ├─Lib
  73. │ │ │ └─Settings
  74. │ │ ├─SciTE交互示例
  75. │ │ ├─SmartGUI
  76. │ │ ├─Spy++
  77. │ │ ├─TestSuite
  78. │ │ ├─ViewWizard
  79. │ │ ├─WindowSpy
  80. │ │ ├─智能操作
  81. │ │ └─自动更新
  82. │ ├─user
  83. │ │ ├─Extensions
  84. │ │ ├─Macros
  85. │ │ ├─Scriptlets
  86. │ │ ├─Settings
  87. │ │ └─Styles
  88. │ ├─中文帮助
  89. │ └─技巧
  90. ├─Everything
  91. ├─FileZillaPro
  92. │ ├─Data
  93. │ ├─docs
  94. │ ├─filezillacfg
  95. │ ├─KeePass
  96. │ │ ├─Languages
  97. │ │ ├─Plugins
  98. │ │ └─XSL
  99. │ ├─locales
  100. │ │ ├─an
  101. │ │ ├─ar
  102. │ │ ├─az
  103. │ │ ├─bg_BG
  104. │ │ ├─ca
  105. │ │ ├─ca_ES@valencia
  106. │ │ ├─co
  107. │ │ ├─cs_CZ
  108. │ │ ├─cy
  109. │ │ ├─da
  110. │ │ ├─de
  111. │ │ ├─el
  112. │ │ ├─es
  113. │ │ ├─et
  114. │ │ ├─eu
  115. │ │ ├─fa_IR
  116. │ │ ├─fi_FI
  117. │ │ ├─fr
  118. │ │ ├─gl_ES
  119. │ │ ├─he_IL
  120. │ │ ├─hr
  121. │ │ ├─hu_HU
  122. │ │ ├─hy
  123. │ │ ├─id_ID
  124. │ │ ├─is
  125. │ │ ├─it
  126. │ │ ├─ja_JP
  127. │ │ ├─ka
  128. │ │ ├─kab
  129. │ │ ├─km_KH
  130. │ │ ├─ko_KR
  131. │ │ ├─ku
  132. │ │ ├─ky
  133. │ │ ├─lo_LA
  134. │ │ ├─lt_LT
  135. │ │ ├─lv_LV
  136. │ │ ├─mk_MK
  137. │ │ ├─nb_NO
  138. │ │ ├─ne
  139. │ │ ├─nl
  140. │ │ ├─nn_NO
  141. │ │ ├─oc
  142. │ │ ├─pl_PL
  143. │ │ ├─pt_BR
  144. │ │ ├─pt_PT
  145. │ │ ├─ro_RO
  146. │ │ ├─ru
  147. │ │ ├─sk_SK
  148. │ │ ├─sl_SI
  149. │ │ ├─sr
  150. │ │ ├─sv
  151. │ │ ├─ta
  152. │ │ ├─th_TH
  153. │ │ ├─tr
  154. │ │ ├─uk_UA
  155. │ │ ├─vi_VN
  156. │ │ ├─zh_CN
  157. │ │ └─zh_TW
  158. │ ├─resources
  159. │ │ ├─16x16
  160. │ │ ├─20x20
  161. │ │ ├─24x24
  162. │ │ ├─32x32
  163. │ │ ├─480x480
  164. │ │ ├─48x48
  165. │ │ ├─blukis
  166. │ │ │ ├─16x16
  167. │ │ │ ├─32x32
  168. │ │ │ └─48x48
  169. │ │ ├─classic
  170. │ │ │ └─16x16
  171. │ │ ├─cyril
  172. │ │ │ └─16x16
  173. │ │ ├─default
  174. │ │ │ └─480x480
  175. │ │ ├─flatzilla
  176. │ │ │ ├─16x16
  177. │ │ │ ├─24x24
  178. │ │ │ ├─32x32
  179. │ │ │ └─48x48
  180. │ │ ├─lone
  181. │ │ │ ├─16x16
  182. │ │ │ ├─32x32
  183. │ │ │ └─48x48
  184. │ │ ├─minimal
  185. │ │ │ ├─16x16
  186. │ │ │ └─32x32
  187. │ │ ├─opencrystal
  188. │ │ │ ├─16x16
  189. │ │ │ ├─20x20
  190. │ │ │ ├─24x24
  191. │ │ │ ├─32x32
  192. │ │ │ └─48x48
  193. │ │ ├─sun
  194. │ │ │ └─48x48
  195. │ │ ├─tango
  196. │ │ │ ├─16x16
  197. │ │ │ ├─32x32
  198. │ │ │ └─48x48
  199. │ │ └─xrc
  200. │ └─手动复制备份的配置和数据文件
  201. │ ├─7z1900
  202. │ ├─7zSfxTool
  203. │ │ ├─Plugin
  204. │ │ └─SFX 模块
  205. │ └─TrafficMonitor显示电脑网速监控悬浮窗
  206. │ ├─Logo
  207. │ └─skins
  208. │ ├─0默认皮肤
  209. │ ├─皮肤01
  210. │ ├─皮肤02
  211. │ ├─皮肤03
  212. │ ├─皮肤04
  213. │ ├─皮肤05
  214. │ ├─皮肤06
  215. │ ├─皮肤07
  216. │ ├─皮肤08
  217. │ ├─皮肤09
  218. │ ├─皮肤10
  219. │ ├─皮肤11
  220. │ └─皮肤12
  221. ├─FolderSizes
  222. ├─FSCapture
  223. │ └─Languages
  224. ├─Hash
  225. ├─IObitUnlocker
  226. ├─JexChan
  227. ├─KeePass
  228. │ ├─Languages
  229. │ ├─Plugins
  230. │ └─XSL
  231. ├─Maye
  232. │ ├─bak
  233. │ ├─cache
  234. │ │ ├─icon
  235. │ │ └─search
  236. │ └─skin
  237. ├─PowerOff
  238. ├─Robocopy
  239. ├─SGI
  240. ├─TotalCMD
  241. │ ├─Cache
  242. │ ├─Filter32
  243. │ ├─Language
  244. │ └─User
  245. ├─TrafficMonitor
  246. │ ├─Logo
  247. │ └─skins
  248. │ ├─0默认皮肤
  249. │ ├─皮肤01
  250. │ ├─皮肤02
  251. │ ├─皮肤03
  252. │ ├─皮肤04
  253. │ ├─皮肤05
  254. │ ├─皮肤06
  255. │ ├─皮肤07
  256. │ ├─皮肤08
  257. │ ├─皮肤09
  258. │ ├─皮肤10
  259. │ ├─皮肤11
  260. │ └─皮肤12
  261. ├─WizTree
  262. │ ├─locale
  263. │ │ ├─bg
  264. │ │ │ └─LC_MESSAGES
  265. │ │ ├─da
  266. │ │ │ └─LC_MESSAGES
  267. │ │ ├─de
  268. │ │ │ └─LC_MESSAGES
  269. │ │ ├─el
  270. │ │ │ └─LC_MESSAGES
  271. │ │ ├─en
  272. │ │ │ └─LC_MESSAGES
  273. │ │ ├─es
  274. │ │ │ └─LC_MESSAGES
  275. │ │ ├─fr
  276. │ │ │ └─LC_MESSAGES
  277. │ │ ├─hu
  278. │ │ │ └─LC_MESSAGES
  279. │ │ ├─it
  280. │ │ │ └─LC_MESSAGES
  281. │ │ ├─ja
  282. │ │ │ └─LC_MESSAGES
  283. │ │ ├─ko
  284. │ │ │ └─LC_MESSAGES
  285. │ │ ├─nl
  286. │ │ │ └─LC_MESSAGES
  287. │ │ ├─no
  288. │ │ │ └─LC_MESSAGES
  289. │ │ ├─pl
  290. │ │ │ └─LC_MESSAGES
  291. │ │ ├─pt_BR
  292. │ │ │ └─LC_MESSAGES
  293. │ │ ├─ru
  294. │ │ │ └─LC_MESSAGES
  295. │ │ ├─sk
  296. │ │ │ └─LC_MESSAGES
  297. │ │ ├─sr
  298. │ │ │ └─LC_MESSAGES
  299. │ │ ├─sv
  300. │ │ │ └─LC_MESSAGES
  301. │ │ ├─tr
  302. │ │ │ └─LC_MESSAGES
  303. │ │ ├─uk
  304. │ │ │ └─LC_MESSAGES
  305. │ │ ├─zh_CHS
  306. │ │ │ └─LC_MESSAGES
  307. │ │ └─zh_CHT
  308. │ │ └─LC_MESSAGES
  309. │ └─log
  310. ├─_Fix
  311. │ └─局域网共享
  312. │ └─备用版本-一键设置局域网共享
  313. ├─_Setup
  314. │ ├─DeepFreeze
  315. │ │ ├─360文件解锁
  316. │ │ │ ├─Config
  317. │ │ │ │ └─defaultskin
  318. │ │ │ ├─MINI
  319. │ │ │ └─Utils
  320. │ │ └─LockHunter32
  321. │ ├─FastCopy
  322. │ │ └─doc
  323. │ ├─NetDrive2
  324. │ ├─ShadowDefender
  325. │ └─WebDrive
  326. └─图压

 

标签:exe,AutoHotkey,AHK,Gui,2022,ahk,Path,源代码,电脑软件
来源: https://www.cnblogs.com/delphixx/p/15771095.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有