spudw2k Posted March 2, 2020 Share Posted March 2, 2020 (edited) Had a customer who's Outlook somehow got Always on Top (AOT) enabled and we couldn't figure out how that happened or how to undo it. I put together a quick hack to turn it off, but then got inspired to make a (very simple) tool to allow toggling AOT on-demand via a hotkey. It runs in the notification area. Ctrl + Alt + T to toggle AOT for the active window. expandcollapse popup#NoTrayIcon #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <TrayConstants.au3> #include <AutoItConstants.au3> #include <WinAPI.au3> Opt("TrayMenuMode", 3) Opt("TrayOnEventMode",1) HotKeySet("^!t","_ToggleActiveWindow") _UI() Func _UI() TrayCreateItem("&About") TrayItemSetOnEvent(-1, "__About") TrayCreateItem("") ; Create a separator line. TrayCreateItem("E&xit") TrayItemSetOnEvent(-1, "__Exit") TraySetState($TRAY_ICONSTATE_SHOW) TraySetToolTip("Always on Top Tool") While 1 sleep(10) WEnd EndFunc Func _ToggleActiveWindow() Local $hWnd = WinGetHandle("[ACTIVE]") Local $sTitle = WinGetTitle("[ACTIVE]") If $sTitle == "" Then Return -1 $iExStyle = __GetWindowState($hWnd, $GWL_EXSTYLE) If BitAND($iExStyle, $WS_EX_TOPMOST) Then $iExStyle = BitXOR($iExStyle,$WS_EX_TOPMOST) $hAfter = $HWND_NOTOPMOST $sMsg = "off" Else $iExStyle = BitOR($iExStyle,$WS_EX_TOPMOST) $hAfter = $HWND_TOPMOST $sMsg = "on" EndIf $aWinPos = WinGetPos($hWnd) _WinAPI_SetWindowLong($hWnd,$GWL_EXSTYLE,$iExStyle) _WinAPI_SetWindowPos($hWnd, $hAfter, $aWinPos[0], $aWinPos[1], $aWinPos[2], $aWinPos[3], $SWP_FRAMECHANGED) __ToolTip("AOT turned " & $sMsg, $aWinPos[0] + ($aWinPos[2]/2), $aWinPos[1] + ($aWinPos[3]/2), $sTitle, 0, $TIP_CENTER + $TIP_BALLOON) EndFunc Func __About() MsgBox($MB_SYSTEMMODAL, "", "Always on Top Tool" & @CRLF & @CRLF & "Press Ctrl + Alt + T to toggle" & @CRLF & "Always on Top for the active window.", 5) EndFunc Func __Exit() HotKeySet("^!t") Exit EndFunc Func __GetWindowState($hWnd, $iIndex) Return _WinAPI_GetWindowLong($hWnd, $iIndex) EndFunc Func __ToolTip($sMsg, $iX, $iY, $sTitle, $iICon, $iOptions) AdlibRegister("__ToolTipOff","1500") ToolTip($sMsg, $iX, $iY, $sTitle, $iICon, $iOptions) EndFunc Func __ToolTipOff() ToolTip("") AdlibUnRegister() EndFunc Edited March 2, 2020 by spudw2k SouzaRM 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now