;Ctrl+鼠标中键置顶/取消置顶当前窗口
Hotkey,$^MButton,SetWinTop,On
MsgBox,262180,操作提示,可以使用Ctrl+鼠标中键置顶/取消置顶当前窗口!
Return
;;置顶/取消置顶当前窗口
SetWinTop:
MouseGetPos, , , Mid
SetAlwaysOnTop(Mid)
Return
;;窗口置顶Toggle
SetAlwaysOnTop(HWND){
WinGetClass,WinClass,ahk_id %HWND%
;;去除系统等窗口元素
if (Not WinClass~="i)^(windows.ui.+|Shell_TrayWnd|workerW|NotifyIconOverflowWindow|Program Manager|Progman|ATL\:.+)$"&&WinExist("ahk_id " HWND)){
WinGet, ExStyle, ExStyle, ahk_id %HWND%
WinGet, ProcessPath, ProcessPath , ahk_id %HWND%
FileDescription:=FileGetInfo(ProcessPath, "FileDescription")
if (ExStyle & 0x8){
DetectHiddenWindows, On
WinGetTitle,WinTitle,ahk_id %HWND%
if (WinTitle&&InStr(WinTitle,"已置顶")){
WinTitle:=StrReplace(WinTitle,"【已置顶】")
WinSetTitle, ahk_id %HWND%, , %WinTitle%
}
DetectHiddenWindows, Off
WinSet, AlwaysOnTop, Off, ahk_id %HWND%
if FileDescription
TrayTip,%FileDescription%,已取消置顶当前窗口!,,1
}else{
DetectHiddenWindows, On
WinGetTitle,WinTitle,ahk_id %HWND%
if (WinTitle&&!InStr(WinTitle,"已置顶")){
WinTitle:=WinTitle . "【已置顶】"
WinSetTitle, ahk_id %HWND%, , %WinTitle%
}
DetectHiddenWindows, Off
WinSet, AlwaysOnTop, On, ahk_id %HWND%
if FileDescription
TrayTip,%FileDescription%,当前窗口已置顶!,,1
}
}
}
/*
FileDescription 文件描述说明
FileVersion 文件版本
InternalName 内部名称
LegalCopyright 法律版权所有
OriginalFilename 创建文件时所使用的名称
ProductName 产品名称
ProductVersion 产品版本
CompanyName 企业名称
PrivateBuild 私有版本的信息
SpecialBuild 特殊内部版本信息
LegalTrademarks 文件的商标和注册商标
*/
;;获取文件信息
FileGetInfo(FilePath:="", p*) { ; Written by SKAN, modified by HotKeyIt ; www.autohotkey.com/forum/viewtopic.php?p=233188#233188 CD:24-Nov-2008 / LM:27-Oct-2010
static DLL:="Version\GetFileVersion"
If ! FSz := DllCall( DLL "InfoSize" (A_IsUnicode ? "W" : "A"), "Str",FilePath, "UInt",0 )
Return DllCall( "SetLastError", UInt,1 ),""
VarSetCapacity( FVI, FSz, 0 ),DllCall( DLL "Info" ( A_IsUnicode ? "W" : "A"), "Str",FilePath, "UInt",0, "UInt",FSz, "PTR",&FVI )
If !DllCall( "Version\VerQueryValue" (A_IsUnicode ? "W" : "A"), "PTR",&FVI, "Str","\VarFileInfo\Translation", "PTR*",Transl, "PTR",0 )
Return DllCall( "SetLastError", UInt,2 ),""
If !Trans:=format("{1:.8X}",NumGet(Transl+0,"UInt"))
Return DllCall( "SetLastError", UInt,3),""
for k,v in p
{
subBlock := "\StringFileInfo\" SubStr(Trans,-3) SubStr(Trans,1,4) "\" v
If ! DllCall( "Version\VerQueryValue" ( A_IsUnicode ? "W" : "A"), "PTR",&FVI, "Str",SubBlock, "PTR*",InfoPtr, "UInt",0 )
continue
If Value := StrGet( InfoPtr )
Info .= p.MaxIndex()=1?Value:SubStr( v " ",1,24 ) . A_Tab . Value . "`n"
}
Info:=RTrim(Info,"`n")
Return Info
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。