[AHK]以编辑方式打开AutoHotkey脚本的方式

105 篇文章 5 订阅

正常.ahk文件回车即运行,想要编辑必须右键菜单,选择E,或者鼠标单击[编辑]。

更好的方式Shift+Enter作为热键来进行编辑代码。

 

#IfWinActive ahk_class TTOTAL_CMD
+Enter::
#IfWinActive ahk_class CabinetWClass
+Enter:: ;open file with Paint/Notepad (open folder in new window)
#IfWinActive ahk_class ExploreWClass
+Enter::
#IfWinActive ahk_class Progman
+Enter::
#IfWinActive ahk_class WorkerW
+Enter::
WinGet, hWnd, ID, A
WinGetClass, vWinClass, % "ahk_id " hWnd
vPath := "", vIsDir := 0

if (vWinClass = "TTOTAL_CMD") 
{
	MsgBox "Tc"
}
if (vWinClass = "CabinetWClass") || (vWinClass = "ExploreWClass")
{
	for oWin in ComObjCreate("Shell.Application").Windows
	{
		if (oWin.HWND = hWnd)
		{
			vIsDir := oWin.Document.FocusedItem.IsFolder
			vPath := oWin.Document.FocusedItem.Path
			break
		}
	}
	oWin := ""
}
else if (vWinClass = "Progman") || (vWinClass = "WorkerW")
{
	VarSetCapacity(hWnd, 4, 0)
	;SWC_DESKTOP := 0x8 ;VT_BYREF := 0x4000 ;VT_I4 := 0x3 ;SWFO_NEEDDISPATCH := 0x1
	oWin := ComObjCreate("Shell.Application").Windows.FindWindowSW(0, "", 8, ComObject(0x4003, &hWnd), 1)
	vIsDir := oWin.Document.FocusedItem.IsFolder
	vPath := oWin.Document.FocusedItem.Path
	oWin := ""
}

if (vPath = "")
{
	MsgBox, % "error: file not found"
	return
}
else if !FileExist(vPath)
{
	MsgBox, % "error: file not found:`r`n" vPath
	return
}
else if vIsDir
{
	Run, % Chr(34) vPath Chr(34)
	return
}
FileGetSize, vSizeMB, % vPath, M
if (vSizeMB > 6)
{
	MsgBox, % "error: file too big: " vSizeMB " MB"
	return
}

SplitPath, vPath, vName, vDir, vExt, vNameNoExt, vDrive
FileGetSize, vSizeMB, % vPath, M
if (vExt = "lnk")
	FileGetShortcut, % vPath, vPath

if vExt in ,bat,ahk,reg,vbs,txt,htm,html,mht,cpp,h,m3u,mpcpl,url,clp,ini,cfg,csv,srt,log
	Run, "notepad.exe" "%vPath%"             ;这里改成你常用的文本编辑器
else if vExt in bmp,gif,jpe,jpeg,jpg,png
	Run, "mspaint.exe" "%vPath%"

Return

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值