/*
by QQ 50786729
注意点:
为防止和系统自带功能冲突, (鼠标拖到屏幕上方时, 窗口自动最大化. 有冲突)
拖动鼠标时, 只要窗口顶端接触到屏幕上方, 就放开, 鼠标留点余地. 鼠标不要接触屏幕顶端.
这样可以和系统功能共存, 互不冲突.
*/
#SingleInstance ignore
CoordMode,Mouse,Screen
hiddenWH:=3 ;~ hiddenWH为高宽补偿值, 作用: 显示边缘条.
HiddenWinID:={}
SetTimer, CursorWinID, 300
OnExit("_ExitApp")
return
#IfWinActive ahk_class SciTEWindow
F4::
gosub UnAutohideAll
return
F5:: ;{ •••➤ 测试用
PostMessage 0x111, 106, 0,, ahk_class SciTEWindow ;~ 保存
Sleep 500
Reload
return ;}
#IfWinActive
~LButton:: ;{ •••➤
MouseGetPos,dx1 ,dy1 , LBID1 ;~ 取得鼠标按下时, 窗口ID1
WinGetPos,px1,py1,pW,pH,ahk_id %LBID1% ;~ 取得鼠标按下时, 窗口坐标x1,y1
Return ;}
~LButton Up:: ;{ •••➤
MouseGetPos,dx2 ,dy2 , LBID2 ;~ 取得鼠标弹起时, 窗口ID2
WinGetPos,px2,py2,,,ahk_id %LBID2% ;~ 取得鼠标弹起时, 窗口坐标x2,y2
;~ LButtonY2>0防止和系统最大化冲突. x移动或y移动=窗口有移动
if (LBID1=LBID2 && (px1!=px2 || py1!=py2) && (dx1!=dx2 || dy1!=dy2)){ ;~ 窗口已移动
;~ __________________鼠标移动模式
MoveMode=
if (py1>0 && py2<1 && dy2>0) ;~ Up 上拖到屏幕顶端 起始y 大于0, 结束y<0, 鼠标抬起y>0
MoveMode:="Up"
else if (py1<A_ScreenHeight && py2>A_ScreenHeight)
MoveMode:="Down"
else if (px1>0 && px2<1)
MoveMode:="Left"
else if (px1<A_ScreenWidth && px2>A_ScreenWidth)
MoveMode:="Right"
;~ Down, Left, Right
;~ __________________响应鼠标移动
;~ 格式: HiddenWinID[ID]:=[显x,显y,隐x,隐y,(已显/已隐)]
if (MoveMode="Up")
HiddenWinID[LBID1]:=[px1,py1,px2,-pH + hiddenWH,False]
else if (HiddenWinID[LBID1]){
HiddenWinID.Delete(LBID1)
WinSet, AlwaysOnTop, off, ahk_id %LBID1% ; 置顶
;~ WinSet, Style, +0xC00000, ahk_id %LBID1% ; 标题栏
WinSet, ExStyle, -0x80, ahk_id %LBID1% ; 移除任务栏图标
}
}
Return ;}
CursorWinID: ;{ •••➤ 鼠标检测
MouseGetPos, , , curWinId
if (preWinId!=curWinId){
if (HiddenWinID[preWinId]){
HiddenWinID[preWinId][5]:=True
WinMove, ahk_id %preWinId%, , HiddenWinID[preWinId][3], HiddenWinID[preWinId][4]
WinSet, AlwaysOnTop, on, ahk_id %preWinId%
;~ WinSet, Style, -0xC00000, ahk_id %preWinId%
WinSet, ExStyle, +0x80,ahk_id %preWinId%
}
preWinId:=curWinId
}
if (HiddenWinID[curWinId][5]) {
WinMove, ahk_id %curWinId%, , HiddenWinID[curWinId][3], -8
HiddenWinID[curWinId][5]:=false
}
return ;}
UnAutohideAll: ;{ •••➤ 恢复所有窗口
for Winid ,var in HiddenWinID
{
WinSet, AlwaysOnTop, off, ahk_id %Winid%
;~ WinSet, Style, +0xC00000, ahk_id %winId%
WinSet, ExStyle, -0x80, ahk_id %Winid%
WinMove, ahk_id %Winid%, , var[1],var[2]
;~ HiddenWinID.Delete(Winid)
}
HiddenWinID:={}
return ;}
_ExitApp(){
Gosub, UnAutohideAll ;~ 关闭程序时, 恢复所有隐藏窗口
ExitApp
}
补充图片更好些,代码最好放代码框中
不错的想法,可以把动图也放到帖子里。方便展示
赚几个钱进修.
都没钱看文章.
mark
不错
学习学习