[框架]通过tooltip实现快捷键提示并点击

功能:通过tooltip实现对应程序的快捷键提示,并可以点击,例如打开scite或者文件资源管理器,按住ctrl并用鼠标左键点击。
;----------------说明区----------------------
;功能:通过tooltip实现对应程序的快捷键提示,并可以点击,例如打开scite或者文件资源管理器,按住ctrl并用鼠标左键点击。
;额外说明,适用于1080p分辨率,如果是其他分辨率,自己修改代码91行的数字。
;环境:win10
;作者:kazhafeizhale
;时间:2018年11月4日
;---------------自动执行段--------------------
#SingleInstance force
#InstallKeybdHook
#InstallMouseHook
SetBatchLines, -1
CoordMode, Mouse, Screen ;
SetTitleMatchMode, 2
SetWorkingDir %A_ScriptDir%

enum:=0
MenuTitle = -=-=-快捷键提示&点击-=-=-=-
UMDelay = 0
SetFormat, float, 0.0
MenuItems = f:搜索文件/a:全选/选择3/选择4/选择5
numItems:=5

MenuItems1 = f:搜索文件/a:全选/选择3/选择4/选择5
numItems:=5
return
;---------------热键区------------------------
~$Ctrl::
	MouseGetPos, , , preview_id, Control

	if(enum==1)
	{
		return
	}
enum:=1
HowLong = 0

;根据不同的软件执行不同的提示按键
MouseGetPos, , , soft_id, soft_Control
WinGetClass, soft_class, ahk_id %soft_id%
WinGetTitle, soft_title, ahk_id %soft_id%
if(soft_class=="SciTEWindow")
{
	gosub, scite
}
else if(soft_class=="CabinetWClass")
{
	gosub, filed
}
return

Ctrl Up::
{
	enum:=0
	ToolTip
}
return

;-------------标签区---------------------------
f:搜索文件:
	SendInput,^f
return

a:全选:
	SendInput,^a
return

选择3:
return

选择4:
return

选择5:
return

MenuClick:
	Hotkey, ~*LButton, Off
	MouseGetPos, mX,mY , id, Control
	WinGetClass, class, ahk_id %id%
	WinGetTitle, title, ahk_id %id%
	if(class!="ToolTips_class32")
	{
		;WinActivate, %MenuTitle%
		MouseGetPos, mX,mY , id, Control
		;MsgBox,% class " " mX " " mY
		ToolTip
		return
	}
ToolTip

mY :=mY- (y1+10+17*2)+17+8 ;Space after which first line starts
;MsgBox,% mY
mY /= 17 ;Space taken by each line
;IfLess, mY, 1, Return
;IfGreater, mY, %numItems%, Return
StringTrimLeft, TargetSection, MenuItem%mY%, 0
StringReplace, TargetSection, TargetSection, %a_Space%,, A
;MsgBox,% TargetSection
try
{
	gosub, %TargetSection%
}
return

MenuClick1:
	Hotkey, ~*LButton, Off
	MouseGetPos, mX,mY , id, Control
	WinGetClass, class, ahk_id %id%
	WinGetTitle, title, ahk_id %id%
	if(class!="ToolTips_class32")
	{
		MouseGetPos, mX,mY , id, Control
		ToolTip
		return
	}
ToolTip

mY :=mY- (y1+10+17*2)+17+8 ;Space after which first line starts
;MsgBox,% mY
mY /= 17 ;Space taken by each line
;IfLess, mY, 1, Return
;IfGreater, mY, %numItems%, Return
StringTrimLeft, TargetSection, MenuItem%mY%, 0
StringReplace, TargetSection, TargetSection, %a_Space%,, A
;MsgBox,% TargetSection
try
{
	gosub, %TargetSection%
}
return

scite:
	{
		;MsgBox,% "ok"
		DynMenu =
		loop
		{
			IfEqual, Dyn%a_index%,, break
			StringGetPos, ppos, dyn%a_index%, |
			StringLeft, item, dyn%a_index%, %ppos%
			ppos += 2
			StringMid, win, dyn%a_index%, %ppos%, 1000
			IfWinActive, %win%,
				DynMenu = %DynMenu%/%item%
		}
		;Joins sorted main menu and dynamic menu
		Sort, MenuItems, D/
		TempMenu = %MenuItems%%DynMenu%
		;clears earlier entries
		loop
		{
			IfEqual, MenuItem%a_index%,, break
			MenuItem%a_index% =
		}
		;creates new entries
		loop, Parse, TempMenu, /
		{
			MenuItem%a_index% = %a_loopfield%
		}
		;creates the menu
		Menu = %MenuTitle%
		loop
		{
			IfEqual, MenuItem%a_index%,, break
			;numItems ++
			StringTrimLeft, MenuText, MenuItem%a_index%, 0
			Menu = %Menu%`n%MenuText%
		}
		;MouseGetPos, mX, mY
		Hotkey, ~*LButton, MenuClick
		Hotkey, ~*LButton, On
		;ToolTip, %Menu%, %mX%, %mY%
		ToolTip, %Menu%,
		MouseGetPos, x1, y1 ,
		;WinActivate, %MenuTitle%
	}
return

filed:
	DynMenu =
	loop
	{
		IfEqual, Dyn%a_index%,, break

		StringGetPos, ppos, dyn%a_index%, |
		StringLeft, item, dyn%a_index%, %ppos%
		ppos += 2
		StringMid, win, dyn%a_index%, %ppos%, 1000

		IfWinActive, %win%,
			DynMenu = %DynMenu%/%item%
	}

	;Joins sorted main menu and dynamic menu
	Sort, MenuItems1, D/
	TempMenu = %MenuItems1%%DynMenu%

	;clears earlier entries
	loop
	{
		IfEqual, MenuItem%a_index%,, break
		MenuItem%a_index% =
	}

	;creates new entries
	loop, Parse, TempMenu, /
	{
		MenuItem%a_index% = %a_loopfield%
	}

	;creates the menu
	Menu = %MenuTitle1%
	loop
	{
		IfEqual, MenuItem%a_index%,, break
		;numItems ++
		StringTrimLeft, MenuText, MenuItem%a_index%, 0
		Menu = %Menu%`n%MenuText%
	}
	MouseGetPos, mX, mY
	Hotkey, ~*LButton, MenuClick1
	Hotkey, ~*LButton, On
	ToolTip, %Menu%,
	MouseGetPos, x1, y1 ,

	;------------函数类区-------------------------

 

最后修改: 2019-12-9 10:40

人已赞赏
AHKV1

[框架]通过menu来实现快捷操作

2018-11-4 16:17:50

AHKV1

选择性保存文本源码

2018-11-5 23:29:00

4 条回复 A文章作者 M管理员
  1. 作者我对你这个觉得很有用处啊,想改一个有可以智能提示的功能,能留下联系方式,或者直接加我qq 51758018吗,有偿的,价格可以商量

  2. 这个原创击中了ahk的痛点,非常不错的框架脚本!ahk是一个快捷键生成器,但是我们不擅长记忆很多快键键,如果这个能够拓展一下,应用也是无穷尽的!
    这个主意非常棒!
    鉴于连续两篇高质量文章的输出奖励1000A币,同时赠送一个月的VIP会员!

    • 大神们,我是你们的粉丝,给我也奖励下吧 ✗吐舌头✗

    • 高质量=奖励

个人中心
今日签到
有新私信 私信列表
搜索