Board logo

标题: [原创] ahk 配合 vbs 实现快捷键更改显示、排序方式 [打印本页]

作者: CrLf    时间: 2014-11-7 23:19     标题: ahk 配合 vbs 实现快捷键更改显示、排序方式

选自自用脚本,因 ahk 里的函数有时会卡其他线程,所以部分功能用 vbs 来配合实现:

vbs 部分:
  1. On Error Resume Next
  2. Dim Shell,SortKey
  3. Set Shell = WScript.CreateObject("Shell.Application")
  4. hwnd = WScript.Arguments(0)
  5. If WScript.Arguments.Count>1 Then
  6. SortKey = WScript.Arguments(1)
  7. Else
  8. SortKey = "System.ItemNameDisplay;"
  9. End If
  10. Set windows = Shell.Windows()
  11. For Each win In Shell.Windows()
  12. If CStr(win.hwnd) = hwnd Then
  13. If win.Document.SortColumns = "prop:"&SortKey Then SortKey="-"&SortKey
  14. win.Document.SortColumns = "prop:"&SortKey
  15. End If
  16. Next
复制代码
ahk 部分:
  1. #IfWinActive ahk_group WinGroup
  2. ;Alt+12345 对应 5 种显示方式
  3. !1::send !vx
  4. !2::send !vs
  5. !3::send !vn
  6. !4::send !vl
  7. !5::send !vd
  8. ;Ctrl+1234 对应 4 种排序方式
  9. ^1::
  10. hwnd := getActiveWindowHWND()
  11. traytip,, %hwnd%`,System.ItemNameDisplay;
  12. run, "D:\Include\文件夹排序.vbs" %hwnd% System.ItemNameDisplay;
  13. return
  14. ^2::
  15. hwnd := getActiveWindowHWND()
  16. traytip,, %hwnd%`,System.DateModified;
  17. run, "D:\Include\文件夹排序.vbs" %hwnd% System.DateModified;
  18. return
  19. ^3::
  20. hwnd := getActiveWindowHWND()
  21. traytip,, %hwnd%`,System.ItemTypeText;System.ItemNameDisplay;
  22. run, "D:\Include\文件夹排序.vbs" %hwnd% System.ItemTypeText;System.ItemNameDisplay;
  23. return
  24. ^4::
  25. hwnd := getActiveWindowHWND()
  26. traytip,, %hwnd%`,System.Size;
  27. run, "D:\Include\文件夹排序.vbs" %hwnd% System.Size;
  28. return
复制代码





欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2