本脚本代码在宿主对象不激活时只是等待,不会不停的监控肃窗口。

[AHK]吸附窗口_ci

#Persistent
#SingleInstance,FORCE
宿主:="ahk_class SciTEWindow"
跟屁虫:="ahk_class Notepad"

Loop
{
	WinGetClass,_ActiveTitle,A
	If instr(宿主,_ActiveTitle) 
	{
		WinGetPos , X, Y, Width, Height,%宿主%
		X1:= x+Width
		Y1:=y+Height
		WinMove,%跟屁虫%,,%X1%,%Y%,200,400
		WinSet, Topmost,on, %跟屁虫%
		WinRestore,%跟屁虫%
		Sleep,600
	}
	else
	{
		WinSet, AlwaysOnTop,off, %跟屁虫%
		if not instr(跟屁虫,_ActiveTitle)
		{
			WinSet, Bottom,, %跟屁虫%
		}
		WinWaitNotActive,%宿主%	
   }
}
return