本地文件夹版超级命令发布

之前僵尸老哥想着做一个本地文件夹版本的超级命令,这个想法确实不错,主要由于xml格式都不太熟悉,自己修改起来有些麻烦

沿袭了一部分僵尸大佬的思路,我又另起炉灶做了一个版本的本地文件夹版超级命令,主要思路来自于zzz大佬的超级命令

这个现在算是乞丐版,主体功能都有了,一些自动建立索引的之后补上

工具的特定可以自己指定想要的文件夹和格式

就是只能搜索到指定文件夹和后缀的内容

并且支持拼音简拼,没有采用超级命令的py库方案,使用了tcmatch方案

并且支持空格分割的模糊搜索,虽然整体思路和超级命令不相同,但是实现的效果还是大部分实现了基础体验的

演示视频

提供源码和分享网盘

链接:https://pan.baidu.com/s/1Q2Hr_UdlXi62sPNnVfnfww?pwd=14tx
提取码:14tx
--来自百度网盘超级会员V4的分享

 

源码

;*************************************  admin    ***********************
loop, %0%
{
	param := %A_Index% ; Fetch the contents of the variable whose name is contained in A_Index.
	params .= A_Space . param
}
ShellExecute := A_IsUnicode ? "shell32\ShellExecute":"shell32\ShellExecuteA"
if not A_IsAdmin
{
	if A_IsCompiled
		DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_ScriptFullPath, str, params , str, A_WorkingDir, int, 1)
	else
		DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_AhkPath, str, """" . A_ScriptFullPath . """" . A_Space . params, str, A_WorkingDir, int, 1)
	ExitApp
}
#SingleInstance Force
#MaxMem 640
#KeyHistory 0
#Persistent
SetBatchLines -1
DetectHiddenWindows On
SetWinDelay -1
SetControlDelay -1
SetWorkingDir %A_ScriptDir%
CoordMode, ToolTip, Screen
CoordMode, Caret , Screen
ListLines Off
#Include <btt>
#Include <ini>
#Include <class_listbox>
; OnMessage(0x020A,"Mouse_MButton_W1")
; OnMessage(0x0201,"Mouse_LButton_D1")

index:
	global path:=ext:=ext_list:=""
	global Showarr := {}
	htime()
	if (!st:=ini("settings.ini")){
		MsgBox,缺失配置文件
		ExitApp
	}
	for k,v in st["设置项目"]
		%k%:=v
	for k,v in st["排除软件"]
		GroupAdd,排除, %v%
	for k,v in st["path"]
		(!path) ? path:=v : path.="|" v
	for k,v in st["ext"]{
		(!ext_list) ? ext_list:=v : ext_list.="|" v
		(!ext) ? ext:=v : ext.="|" v
	}
	path.="||" , ext_list.="||" , ext:="(" ext ")"

	;keyboard
	Hotkey,+enter, searchbar

	;*************************************  btt style     ***********************
	BttStyle := {Margin:10 ; If omitted, 5 will be used. Range 0-30.
		, TabStops:[50, 80, 100] ; If omitted, [50] will be used. This value must be an array.
		, TextColor:"0xff" . 预览字体颜色 ; ARGB
		, BackgroundColor:"0xff" . 预览背景颜色 ; ARGB
		, Font:预览字体名称 ; If omitted, ToolTip's Font will be used. Can specify the font file path.
		, FontSize:预览字体大小 ; If omitted, 12 will be used.
		, FontRender:5 ; If omitted, 5 will be used. Range 0-5.
	, FontStyle:"Regular"}
	Btt(启动词, 0, 0, ,"BttStyle")
	SetTimer, Gui_Destroy, -1000

	;get the files
	Dir_File_All := {}
	for k,v in st["path"]{
		loop Files, %v%\*.*, R
		{
			if (regexmatch(A_LoopFileExt,ext))
				Dir_File_All["" A_LoopFileName ""] := A_LoopFileFullPath
		}
	}
	MsgBox,% htime()
return

Refresh:
	Showstr :=cm_mode_sigh:= "" , Showarr := {}
	ControlGetText, Query, , ahk_id %SSK%
	For a,b in Dir_File_All{ ;b[1]
		if (InStr(Query," ")){
			Query_arr := StrSplit(Query, " ")
			for k,v in Query_arr{
				if (!TCMatch(a,v)){
					find_sign := false
					break
				}
				if (TCMatch(a,v))
					find_cm_sign := true
			}
			if (find_sign = true)
				Showarr.Push(a)
		}else{
			if (TCMatch(a,Query))
				Showarr.Push(a)
		}
	}
	gosub update_listbox

return

Preview:
	if (A_GuiEvent = "DoubleClick")
		switch_esec("edit")
	if (显示预览=1){
		Add_Script_Path :=Bttstr :=Script_Path_Long:=Script_Str := ""
		Gui, ss:Submit, NoHide
		arrKey:=RegExReplace(command,"^\d{1,10}\s+")
		Script_Path_Long :=Dir_File_All[arrKey]
		FileRead, Script_Str, % Script_Path_Long
		Bttstr := RegExReplace(Script_Str,"m`a).{100}", "$0`n")
		Bttstr :=Script_Path_Long "`n" Bttstr
		btt_which(预览位置)
	}
return
update_listbox:
	GuiControl, ss:, -Redraw, Command
	For k,v in Showarr
	{
		Showstr .= "|" k " " v
		n := A_Index
	}
	Showstr := (Query) ? Showstr : ""
	;************************************* 更新      ***********************
	GuiControl, ss:, Command, % (Showstr) ? Showstr : ""
	if (是否显示所有=0)
		ListN := ((n < 最大显示行) ? n : 最大显示行) * CListBox.GetItemHeight(LIST)
	else
		ListN := n * CListBox.GetItemHeight(LIST)
	ListN := !(Showstr) ? 0 : ListN
	GuiControl, ss:Move, Command, % "h" ListN
	ChooseRow := 1
	GuiControl, ss:Choose, command, % ChooseRow
	gosub Preview
	Gui, ss:show, AutoSize
	if !(Showstr) {
		Btt()
		GuiControl, ss:, Command, |
	}
	GuiControl, ss:, +Redraw, Command
return

btt_which(which){
	global
	if (which="右")
		btt_pos := Btt(Bttstr, xpos+列表宽度+5, ypos, ,"BttStyle")
	else if (预览位置="左")
		btt_pos := Btt(Bttstr, xpos-btt_pos.w, ypos, ,"BttStyle")
	Else
		btt_pos := Btt(Bttstr, xpos, ypos-250, ,"BttStyle"), btt_pos := Btt(Bttstr, xpos, ypos-btt_pos.h, ,"BttStyle")
return
}

searchbar:
	gosub Gui_Destroy
	Gui, ss:Margin, 0, 0
	Gui, ss:-Caption +Border
	Gui, ss:+AlwaysOnTop -DPIScale +ToolWindow +HwndMyGuiHwnd +E0x02000000 +E0x00080000
	Gui, ss:Font, s%字体大小%, %字体名称%
	Gui, ss:Add, Edit, gRefresh vsearchBar HwndSSK w%列表宽度% -E0x200
	SetEditCueBanner(SSK,搜索框提示)
	Gui, ss:Font, s%字体大小%, %字体名称%
	Gui, ss:Add, ListBox, hwndLIST h0 vCommand -HScroll -E0x200 w%列表宽度% gPreview
	Gui ss:+LastFound ; Make the Gui window the last found window for use by the line below.
	GuiControl, ss:Move, Command, h0
	ControlColor(SSK, MyGuiHwnd, "0x" 搜索框背景颜色, "0x" 字体颜色)
	ControlColor(LIST, MyGuiHwnd, "0x" 列表背景颜色, "0x" 字体颜色)
	MouseGetPos, xpos, ypos
	Gui, ss:show, AutoSize x%xpos% y%ypos%
return

updown(which){
	global
	if (which="up")
		ChooseRow := (ChooseRow > 1) ? ChooseRow - 1 : ChooseRow
	else
		ChooseRow := (ChooseRow < n) ? ChooseRow + 1 : ChooseRow
	GuiControl, ss:Choose, command, % ChooseRow
	Sleep 50
	gosub Preview
return
}

Gui_Destroy:
ssGuiEscape:
ssGuiClose:
	Btt()
	Gui, ss:Destroy
return

switch_esec(which){ ;执行哪个
	global
	gosub Gui_Destroy
	SplitPath,Script_Path_Long, , sPath
	switch which{
	case "send":
		Clipboard := "" , Clipboard := Script_Str
		ClipWait,1
		SendInput, ^v
	case "copy":
		Clipboard := "" , Clipboard := Script_Str
	case "run":
		Run,%Script_Path_Long%
	case "edit1":
		Run, %编辑器1% %Script_Path_Long%
	case "edit2":
		Run, %编辑器2% %Script_Path_Long%
	case "folder":
		Run,%文件管理器% %sPath%
	}
	return
}

#If (WinActive("ahk_id " MyGuiHwnd) && (Showstr))
	#If

#If (WinActive("ahk_id " MyGuiHwnd) && (Showstr))
	F1::chooseNumber(1)
F2::chooseNumber(2)
F3::chooseNumber(3)
F4::chooseNumber(4)
F5::chooseNumber(5)
F6::chooseNumber(6)
F7::chooseNumber(7)
F8::chooseNumber(8)
F9::chooseNumber(9)
up::updown("up")
Down::updown("down")
^d::switch_esec("send")
^c::switch_esec("copy")
^r::switch_esec("run")
enter::switch_esec("edit1")
^f::switch_esec("folder")
#If

chooseNumber(number){
	ChooseRow:=number
	GuiControl, ss:Choose, command, % ChooseRow
	gosub Preview
	return
}

ControlColor(Control, Window, bc := "", tc := "", Redraw := True) {
	local a := {}
	a["c"] := Control
	a["g"] := Window
	a["bc"] := (bc == "") ? "" : (((bc & 255) << 16) + (((bc >> 8) & 255) << 8) + (bc >> 16))
	a["tc"] := (tc == "") ? "" : (((tc & 255) << 16) + (((tc >> 8) & 255) << 8) + (tc >> 16))

	CC_WindowProc("Set", a, "", "")

	if (Redraw) {
		WinSet Redraw,, ahk_id %Control%
	}
}
CC_WindowProc(hWnd, uMsg, wParam, lParam) {
	local tc, bc, a
	static Win := {}
	; Critical

	if uMsg Between 0x132 And 0x138 ; WM_CTLCOLOR(MsgBox|Edit|LISTBOX|BTN|DLG|SCROLLBAR|static)
	if (Win[hWnd].HasKey(lParam)) {
		if (tc := Win[hWnd, lParam, "tc"]) {
			DllCall("gdi32.dll\SetTextColor", "Ptr", wParam, "UInt", tc)
		}

		if (bc := Win[hWnd, lParam, "bc"]) {
			DllCall("gdi32.dll\SetBkColor", "Ptr", wParam, "UInt", bc)
		}

	return Win[hWnd, lParam, "Brush"] ; return the HBRUSH to notify the OS that we altered the HDC.
}

if (hWnd == "Set") {
	a := uMsg
	Win[a.g, a.c] := a

	if ((Win[a.g, a.c, "tc"] == "") && (Win[a.g, a.c, "bc"] == "")) {
		Win[a.g].Remove(a.c, "")
	}

	if (!Win[a.g, "WindowProcOld"]) {
		Win[a.g,"WindowProcOld"] := DllCall("SetWindowLong" . (A_PtrSize == 8 ? "Ptr" : "")
		, "Ptr", a.g, "Int", -4, "Ptr", RegisterCallback("CC_WindowProc", "", 4), "UPtr")
	}

	if (Win[a.g, a.c, "bc"] != "") {
		Win[a.g, a.c, "Brush"] := DllCall("gdi32.dll\CreateSolidBrush", "UInt", a.bc, "UPtr")
	}

	return
}

return DllCall("CallWindowProc", "Ptr", Win[hWnd, "WindowProcOld"], "Ptr", hWnd, "UInt", uMsg, "Ptr", wParam, "Ptr", lParam, "Ptr")
}
SetEditCueBanner(HWND, Cue) { ; requires AHL_L
	Static EM_SETCUEBANNER := (0x1500 + 1)
	Return DllCall("User32.dll\SendMessageW", "Ptr", HWND, "Uint", EM_SETCUEBANNER, "Ptr", True, "WStr", Cue)
}

给TA捐赠
共{{data.count}}人
人已捐赠
AHKV1

ahk控制excel随笔之布尔值的差异

2022-9-22 21:33:54

AHKV1

AHK版本和调用dll的总结

2022-9-24 8:35:25

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
有新私信 私信列表
搜索