#SingleInstance,Force
#NoEnv
ListLines,Off
#KeyHistory,0
AutoTrim,Off
CoordMode,Mouse,Screen
CoordMode,ToolTip
CoordMode,Pixel
CoordMode,Caret,Screen
DetectHiddenWindows,On
Menu,Tray,UseErrorLevel
process,priority,,realtime
SendMode,Input
SetBatchLines,-1
SetControlDelay,0
SetKeyDelay,0
SetTitleMatchMode,2
SetWinDelay,20
SetWorkingDir,%A_ScriptDir%
StringCaseSense,Off
OnExit,EXIT
ComObjError(false)
Gui,5:+hwndhDummy -Caption +Border +ToolWindow +E0x08000020
Settingspath=SOFTWARE\DF
SettingsDefault=
(
PopClasses=
popdistcoef=1.1
popFadeEffect=1
popmintrans=150
popshow=200
popWObutton=1
popHideSpeed=10
popShowSpeed=10
sleep=1
)
Gosub,LoadSettings
PopWin_IDa:=[]
PopClassesa:=[]
loop,parse,PopClasses,`,
{
if !a_loopfield
continue
PopClassesa.push(a_loopfield)
}
loop
{
DF_Time:=oldDF_Time!="" ? a_tickcount-oldDF_Time : 0
oldDF_Time:=a_tickcount
MouseGetPos,DF_X,DF_Y,DF_mwin,DF_mctrl
WinGetTitle,DF_Title,ahk_id %DF_mwin%
WinGetClass,DF_Class,ahk_id %DF_mwin%
WinGet,DF_ActiveWin,id,A
WinGetTitle,DF_ActiveTitle,ahk_id %DF_ActiveWin%
WinGetClass,DF_ActiveClass,ahk_id %DF_ActiveWin%
sleep,10
if (!popgetlist:=popgetlist>sleep+20 ? 0 : popgetlist="" ? 1 : popgetlist+DF_Time)
{
WinGet,poplist,list
loop,% poplist
{
popid:=poplist%a_index%
wingetclass,popclass,ahk_id %popid%
if ExistInArray(PopClassesa,popclass)
{
if !ExistInArray(PopWin_IDa,popid)
{
PopWin_IDa.Push(popid)
if popWObutton
SetStyleWin(popid,1)
WinGet,popExStyle,ExStyle,ahk_id %popid%
if (popExStyle & 0x8)
popontopsave%popid%:=1
else
popontopsave%popid%:=
}
}
}
}
if PopWin_IDa.MaxIndex() ; and (oldpopmx!=DF_X or oldpopmy!=DF_Y))
{
if (DF_ActiveWin!=oldDF_ActiveWin and !ExistInArray(PopWin_IDa,DF_ActiveWin) and !instr("Progman,Shell_TrayWnd",DF_ActiveClass))
lastwin:=DF_ActiveWin
oldDF_ActiveWin:=DF_ActiveWin
if !winexist("ahk_id " lastwin)
lastwin:=hDummy
WinGet,lastwinMinMax,MinMax,ahk_id %lastwin%
for i, e in PopWin_IDa
{
if !e
continue
ifwinexist,ahk_id %e%
{
WinGet,popMinMax%e%,MinMax,ahk_id %e%
WinGetPos,popwx,popwy,popww,popwh,ahk_id %e%
if (DF_mwin=e and pop%e%hiden)
{
if (!popupd%e%:=popupd%e%>100 ? 0 : popupd%e%="" ? 1 : popupd%e%+1)
WinSet,Transparent,255,Ahk_id %e%
}
if (popMinMax%e%=1 or popww>a_screenwidth or popwh>a_screenheight)
{
oldpopMinMax%e%:=popMinMax%e%
continue
}
else if (popMinMax%e%=-1 and oldpopMinMax%e%!=1)
{
WinRestore,ahk_id %e%
if (lastwinMinMax!=-1 and lastwinMinMax!="")
winactivate,ahk_id %lastwin%
else
winactivate,ahk_id %hDummy%
pop%e%OnTop=
pop%e%hiden:=pop_moveWin(e,0)
winset,AlwaysOnTop,on,ahk_id %e%
WinSet,Transparent,255,Ahk_id %e%
}
popxx:=a_screenwidth-popww
popyy:=a_screenheight-popwh
popdist:=(popxx>popyy ? popyy : popxx)//popdistcoef
popwindistx:=DF_X<popwx ? popwx-DF_X : DF_X>popwx+popww ? DF_X-(popwx+popww) : 0
popwindisty:=DF_Y<popwy ? popwy-DF_Y : DF_Y>popwy+popwh ? DF_Y-(popwy+popwh) : 0
popwindist:=popwindistx>popwindisty ? popwindistx : popwindisty
;tooltip,% "Transp = " popwindistRate "`nDist = " popwindist "`n" popdist "`n" popmintrans
if (DF_mwin=e and pop%e%hiden)
{
poptimer%e%+=DF_Time
if (poptimer%e%>popshow)
{
poptimer%e%=0
pop%e%hiden=
pop_moveWin(e,1,popShowSpeed)
WinSet,Transparent,255,Ahk_id %e%
winset,AlwaysOnTop,on,ahk_id %e%
}
}
else if (DF_mwin!=e and !pop%e%hiden)
{
poptimer%e%=0
if DF_Class not contains #32768,Popup,tooltip
{
if ((popwindist>popdist or !ExistInArray(PopWin_IDa,DF_ActiveWin)) and !(popwx>0 and popwy>0 and popwx+popww<a_screenwidth-5 and popwy+popwh<a_screenheight-5))
{
if (lastwinMinMax!=-1 and lastwinMinMax!="")
winactivate,ahk_id %lastwin%
else
winactivate,ahk_id %hDummy%
pop%e%OnTop=
pop%e%hiden:=pop_moveWin(e,0,popHideSpeed)
winset,AlwaysOnTop,on,ahk_id %e%
WinSet,Transparent,255,Ahk_id %e%
}
else if (popWObutton and !pop%e%OnTop and (popwx>0 and popwy>0 and popwx+popww<a_screenwidth-5 and popwy+popwh<a_screenheight-5))
{
pop%e%OnTop=1
winset,AlwaysOnTop,on,ahk_id %e%
}
if (oldpopmx%e%!=DF_X or oldpopmy%e%!=DF_Y)
{
popwindistRate:=round(((popwindist/(255/(255-popmintrans)))/popdist*255-255)*-1)
popwindistRate:=popwindistRate>255 ? 255 : popwindistRate<popmintrans ? popmintrans : popwindistRate
if popFadeEffect
WinSet,Transparent,%popwindistRate%,Ahk_id %e%
}
oldpopmx%e%:=DF_X
oldpopmy%e%:=DF_Y
}
}
else if (pop%e%hiden and DF_ActiveWin=e)
{
poptimer%e%=0
pop%e%hiden=
pop_moveWin(e,1,popShowSpeed)
WinSet,Transparent,255,Ahk_id %e%
winset,AlwaysOnTop,on,ahk_id %e%
}
else
poptimer%e%=0
if (pop%e%hiden)
{
if (!popupd%e%:=popupd%e%>100 ? 0 : popupd%e%="" ? 1 : popupd%e%+1)
DllCall("ShowWindow","ptr",e,"Int",8)
}
}
else
{
PopWin_IDa.RemoveAt(i)
pop%e%hiden=
pop%e%OnTop=
oldpopmx%e%=
oldpopmy%e%=
poptimer%e%=
popupd%e%=
}
}
}
}
f1::
mousegetpos,,,contextid
WinGetClass,contextclass,ahk_id %contextid%
PopWinadd:
PopClasses.=contextclass "`,"
PopClassesa.push(contextclass)
gosub,savesettings
return
f2::
mousegetpos,,,contextid
WinGetClass,contextclass,ahk_id %contextid%
PopWindel:
winset,AlwaysOnTop,% popontopsave%contextid%=1 ? "on" : "off",ahk_id %contextid%
if popWObutton
SetStyleWin(contextid,0)
for i, e in PopWin_IDa
if (e=contextid)
PopWin_IDa.RemoveAt(i), break
for i, e in PopClassesa
if (e=contextclass)
PopClassesa.RemoveAt(i), break
PopClasses:=RegExReplace(PopClasses, contextclass "`,", "")
gosub,savesettings
return
SetStyleWin(hwnd,add="")
{
WinHide,ahk_id %hwnd%
if add
WinSet,ExStyle,+0x80,ahk_id %hwnd%
else
WinSet,ExStyle,-0x80,ahk_id %hwnd%
WinShow,ahk_id %hwnd%
}
pop_moveWin(hwnd,Show,SmoothSpeed="")
{
WinGetPos,popwx,popwy,popww,popwh,ahk_id %hwnd%
if (popww>a_screenwidth or popwh>a_screenheight)
return ; -1
if show
{
if popwx<0
{
if SmoothSpeed
{
pos:=popwx, var:=popww/SmoothSpeed
loop,% SmoothSpeed
{
pos+=var
winmove,ahk_id %hwnd%,,% pos
if (pos>-var)
break
}
}
winmove,ahk_id %hwnd%,,0
return 1
}
else if (popwx+popww>a_screenwidth)
{
if SmoothSpeed
{
pos:=popwx, var:=popww/SmoothSpeed
loop,% SmoothSpeed
{
pos+=-var
winmove,ahk_id %hwnd%,,% pos
if (pos<a_screenwidth-popww+var)
break
}
}
winmove,ahk_id %hwnd%,,% a_screenwidth-popww
return 1
}
else if popwy<0
{
if SmoothSpeed
{
pos:=popwy, var:=popwh/SmoothSpeed
loop,% SmoothSpeed
{
pos+=var
winmove,ahk_id %hwnd%,,,% pos
if (pos>-var)
break
}
}
winmove,ahk_id %hwnd%,,,0
return 1
}
}
else
{
if (popwx<=0)
{
if SmoothSpeed
{
pos:=popwx, var:=popww/SmoothSpeed
loop,% SmoothSpeed
{
pos+=-var
winmove,ahk_id %hwnd%,,% pos
if (pos<-popww+var)
break
}
}
winmove,ahk_id %hwnd%,,% 5-popww
return 1
}
else if (popwx+popww>=a_screenwidth)
{
if SmoothSpeed
{
pos:=popwx, var:=popww/SmoothSpeed
loop,% SmoothSpeed
{
pos+=var
winmove,ahk_id %hwnd%,,% pos
if (pos>a_screenwidth-var)
break
}
}
winmove,ahk_id %hwnd%,,% a_screenwidth-5
return 1
}
else if (popwy<=0)
{
if SmoothSpeed
{
pos:=popwy, var:=popwh/SmoothSpeed
loop,% SmoothSpeed
{
pos+=-var
winmove,ahk_id %hwnd%,,,% pos
if (pos<-popwh+var)
break
}
}
winmove,ahk_id %hwnd%,,,% 5-popwh
return 1
}
}
}
SaveSettings:
if Settingspath=
Settingspath=SOFTWARE\Unknown_AHK_Script
loop,parse,SettingsDefault,`n
{
Loop,parse,a_loopfield,=
{
if a_index=1
{
Setting:=a_loopfield
Break
}
}
RegWrite,REG_SZ,HKCU,%Settingspath%,%Setting%,% %Setting%
}
LoadSettings:
if Settingspath=
Settingspath=SOFTWARE\Unknown_AHK_Script
loop,parse,SettingsDefault,`n
{
Loop,parse,a_loopfield,=
{
if a_index=1
Setting:=a_loopfield
else if a_index=2
Default:=a_loopfield
else
Default.="=" a_loopfield
}
RegRead,%Setting%,HKCU,%Settingspath%,%Setting%
if errorlevel
{
RegWrite,REG_SZ,HKCU,%Settingspath%,%Setting%,%Default%
RegRead,%Setting%,HKCU,%Settingspath%,%Setting%
}
}
popmintrans:= popmintrans<10 ? 10 : popmintrans>250 ? 250 : popmintrans
Return
Exit:
if !alreadyexit
{
gosub,SaveSettings
for i, e in PopWin_IDa
{
if !e
continue
winset,AlwaysOnTop,% popontopsave%e%=1 ? "on" : "off",ahk_id %e%
WinSet,Transparent,255,Ahk_id %e%
if popWObutton
SetStyleWin(e,0)
pop_moveWin(e,1)
}
alreadyexit=1
}
ExitApp
ExistInArray(array,Needle)
{
for i, e in array
if (e=Needle)
return 1
}
Наведи мышь на нужное окно и нажми F1 чтобы добавить класс окна в список, F2 - чтобы удалить из списка.
Баги: у некоторых окон могут совпадать классы и функция активируется для всех без исключения, подходящих под данный класс, иногда это не очень удобно. Пока не нашел метода фильтровать конкретные окна, т.к. заголовки окон могут меняться, к ним привязываться нельзя.
Предполагалось, что ты просто установишь это приложение...