[办公]资源管理器中文首字母快搜

[办公]资源管理器中文首字母快搜

;AHKVersion: Unicode 64bit v2.0 a077
;Author: fuwt
;date: 2017-01-25
;2017-02-20T19:47:18: 增加聚焦功能
SetWorkingDir, %A_ScriptDir%
global Items := []
global dic := {}
;注册热键
Hotkey, if, WinActive("ahk_class CabinetWClass") && A_CaretX = ""
loop(26){
	thisHotkey := Chr(A_Index + 96)
	ToolTip, % Hotkey
	Hotkey, %thisHotkey%, QuickSearch
}
Hotkey, %A_Space%, QuickSearch
;创建字典
LoopRead("dic"){
	line := StrSplit(A_LoopReadLine, A_Tab)
	key := line[1]
	value := line[2]
	dic[key] .= value
}
return

#If WinActive("ahk_class CabinetWClass") && A_CaretX = ""
~Enter::
esc::
	Hotkeys := ""
	ToolTip
return

Backspace::
	Hotkeys := SubStr(Hotkeys, 1, StrLen(Hotkeys) - 1)
	ToolTip, % Hotkeys
return

QuickSearch:
	Matched := ""
	Hotkeys := Hotkeys . A_ThisHotkey
	ToolTip, % Hotkeys
	ControlGetText, Path, ToolbarWindow323, A

	Path := getPath()
	folder := ComObjCreate("shell.Application").NameSpace(Path)
	items := folder.Items
	for item in items{
		if MatchStr(item.name, Hotkeys){
			Matched .= item.name . "`n"
			;ToolTip % hotkeys "`n" Matched
			SelectItem(item.name)
			break
		}
		}
return

MatchStr(str, chrs){
	ismatch := 1
	if InStr(chrs, A_Space){
		LoopParse(chrs,A_Space){
		ismatch *= RegExMatch(StrToChr(str), "i)" . A_LoopField)
	}
	return ismatch
}
else{
	return RegExMatch(StrToChr(str), "i)^" . chrs)
}
}
StrToChr(name){
	thisChr := ""
	LoopParse(name){
	if dic[A_LoopField]
		thisChr := thisChr . dic[A_LoopField]
	else
		thisChr := thisChr . A_LoopField
}
return thisChr
}
getPath(){
	thisHwnd := WinGetID("A")
	ProcessName := WinGetProcessName("A")
	class := WinGetClass("A")

		if ProcessName!="explorer.exe"
			return
	for window in ComObjCreate("Shell.Application").Windows {
		if window.name = "文件资源管理器" && window.hwnd == thisHwnd
			path := StrReplace(window.LocationURL, "file:///", "")
	path := StrReplace(path, "/", "\")

	path := StrReplace(path, "`%20"," ")
}
return path
}
SelectItem(argv){
	hwnd := WinActive("a")
	Windows := ComObjCreate("shell.Application").Windows
	for window in Windows{
		if window.hwnd == hwnd
			thisWindow := window
}
folder := thisWindow.document.folder

for item in folder.items
	if item.name == argv
		thisWindow.document.SelectItem(item, 13)
	}

 

[su_highlight]源码为ahk V2版本,已打包编译(含码表文件)[/su_highlight]

http://pan.baidu.com/s/1i452lyl

 

 

 


亲爱的朋友们,如果你认为本站不错请打赏,我们非常感谢你的支持!

[su_button url=”http://www.autoahk.com/buyamoney” style=”3d” color=”#ffe41c” size=”20″ radius=”round”]赏[/su_button]



给TA捐赠
共{{data.count}}人
人已捐赠
其他案例

[办公]input-ahk(Flapy-Autohotkey):用ahk写一个简单输入法

2017-2-20 17:08:58

其他

[GUI]TreeVIEW实例,动态显示控件内容

2017-2-21 12:38:33

7 条回复 A文章作者 M管理员
  1. AHK中文社区

    1.1版本会更好!

  2. AHK中文社区

    v2版本人用的少

    • chn.fwt

      我的自用脚本已经全转v2,感觉函数式的输入一些… 懒得写1.1的了。 都会编译后再上传

  3. YanYan

    The following variable name contains an illegal character:
    “”dic””

    为啥下载到百度盘的 也一样报错?

  4. YanYan

    字母敲击完了,屏上也出提示了,怎么定位到文件上呢?

  5. ahker

    好东西,我来仿制个V1的

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