argumentum Posted December 31, 2024 Posted December 31, 2024 WinActiveBorder.zip ( Source and icon. You compile your own. ) Spoiler expandcollapse popup#include <GuiConstants.au3> #include <guiconstantsex.au3> #include <winapi.au3> #include <WindowsConstants.au3> If WinExists(StringTrimRight(@ScriptName, 3) & 'GUI') Then Exit _WinActiveBorder() Func _WinActiveBorder($iColor = 0x009999, $iWidth = 2) If FileExists(StringTrimRight(@ScriptFullPath, 4) & ".ico") Then TraySetIcon(StringTrimRight(@ScriptFullPath, 4) & ".ico") If Int($iWidth) < 1 Then $iWidth = 1 Local $aPos, $hWnd, $gX, $gY, $gW, $gH Local $hGUI = GUICreate(StringTrimRight(@ScriptName, 3) & 'GUI', 0, 0, 0, 0, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetBkColor($iColor) GUISetState() While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit If _WinAPI_GetIdleTime() > 10000 Then ContinueLoop $hWnd = WinGetHandle("[ACTIVE]") If @error Then ContinueLoop If $hWnd = $hGUI Then Send("!{TAB}") $hWnd = WinGetHandle("[ACTIVE]") EndIf $aPos = WinGetPos($hWnd) If @error Then ContinueLoop If __isTheSamePosAsBefore($aPos) Then ContinueLoop $gX = $aPos[0] + 7 ;X position ; left $gY = $aPos[1] ;Y position ; top $gW = $aPos[2] - 14 ;Width ; right $gH = $aPos[3] - 6 ;Height ; buttom __GUICreateInvRect($aPos, $hGUI, $iWidth, $iWidth, $gW - ($iWidth * 2), $gH - ($iWidth * 2)) WinMove($hGUI, "", $gX, $gY - $iWidth, $gW, $gH) WEnd EndFunc ;==>_WinActiveBorder Func __GUICreateInvRect($aPos, $hWnd, $iX, $iY, $iW, $iH) Local $iLeftRect = 0 Local $iTopRect = 0 Local $hMask_1 = _WinAPI_CreateRectRgn($iLeftRect, $iTopRect, $aPos[2], $iY) Local $hMask_2 = _WinAPI_CreateRectRgn($iLeftRect, $iTopRect, $iX, $aPos[3]) Local $hMask_3 = _WinAPI_CreateRectRgn($iX + $iW, $iTopRect, $aPos[2], $aPos[3]) Local $hMask_4 = _WinAPI_CreateRectRgn($iLeftRect, $iY + $iH, $aPos[2], $aPos[3]) _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_2, 2) _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_3, 2) _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_4, 2) _WinAPI_DeleteObject($hMask_2) _WinAPI_DeleteObject($hMask_3) _WinAPI_DeleteObject($hMask_4) _WinAPI_SetWindowRgn($hWnd, $hMask_1, 1) EndFunc ;==>_GUICreateInvRect Func __isTheSamePosAsBefore($aPos, $iMaxOfTheSame = 3) Local Static $aWas[4], $iCount = 0 $iCount += 1 For $n = 0 To 3 If $aWas[$n] <> $aPos[$n] Then $aWas = $aPos $iCount = 0 Return 0 EndIf Next If $iCount < $iMaxOfTheSame Then Return 0 $aWas = $aPos Return 1 EndFunc ;==>isTheSameAsBefore I draws a border on the active window. A rehash of @careca's code, so don't think too highly of me And is not perfect but, it tends to do what it claims. My happy new year code Gianni, CYCho, Danyfirex and 1 other 4 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Nine Posted December 31, 2024 Posted December 31, 2024 Instead of drawing the 4 sides individually, you could use this function : Func Rect($hWnd, $iX, $iY, $iWidth, $iHeight, $iSize = 4) Local $hMain = _WinAPI_CreateRectRgn($iX, $iY, $iX + $iWidth, $iY + $iHeight) Local $hMask = _WinAPI_CreateRectRgn($iX + $iSize, $iY + $iSize, $iX + $iWidth - $iSize, $iY + $iHeight - $iSize) _WinAPI_CombineRgn($hMain, $hMain, $hMask, $RGN_DIFF) _WinAPI_DeleteObject($hMask) _WinAPI_SetWindowRgn($hWnd, $hMain) EndFunc ;==>Rect argumentum 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
argumentum Posted December 31, 2024 Author Posted December 31, 2024 (edited) expandcollapse popup#include <GuiConstants.au3> #include <guiconstantsex.au3> #include <winapi.au3> #include <WindowsConstants.au3> If WinExists(StringTrimRight(@ScriptName, 3) & 'GUI') Then Exit ;~ #RequireAdmin ; for elevated windows HotKeySet("{ESC}", "Terminate") Func Terminate() GUIDelete() Exit EndFunc ;==>Terminate, like, emergency exit while testing =) _WinActiveBorder() Func _WinActiveBorder($iColor = 0xFF9999, $iWidth = 3) $iWidth += 5 If FileGetSize("WinActiveBorder.ico") Then TraySetIcon("WinActiveBorder.ico") If Int($iWidth) < 1 Then $iWidth = 1 Local $aPos, $hWnd, $gX, $gY, $gW, $gH Local $hGUI = GUICreate(StringTrimRight(@ScriptName, 3) & 'GUI', 0, 0, 0, 0, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TRANSPARENT)) GUISetBkColor($iColor) GUISetState() While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit If _WinAPI_GetIdleTime() > 10000 Then ContinueLoop $hWnd = WinGetHandle("[ACTIVE]") If @error Then ContinueLoop If $hWnd = $hGUI Then Send("!{TAB}") $hWnd = WinGetHandle("[ACTIVE]") EndIf $aPos = WinGetPos($hWnd) If @error Then ContinueLoop If __isTheSamePosAsBefore($aPos) Then ContinueLoop $gX = $aPos[0] + 5 ;X position ; left $gY = $aPos[1] ;Y position ; top $gW = $aPos[2] - 10 ;Width ; right $gH = $aPos[3] - 5 ;Height ; buttom __Rect($hGUI, 0, 0, $gW + ($iWidth * 2) - 10, $gH + ($iWidth * 2) - 10, $iWidth) _WinAPI_SetWindowPos($hGUI, $hWnd, $gX - $iWidth + 5, $gY - $iWidth + 5, $gW + ($iWidth * 2) - 10, $gH + ($iWidth * 2) - 10, $SWP_SHOWWINDOW) WEnd EndFunc ;==>_WinActiveBorder Func __Rect($hWnd, $iX, $iY, $iWidth, $iHeight, $iSize = 40) Local $hMain = _WinAPI_CreateRectRgn($iX, $iY, $iX + $iWidth, $iY + $iHeight) Local $hMask = _WinAPI_CreateRectRgn($iX + $iSize, $iY + $iSize, $iX + $iWidth - $iSize, $iY + $iHeight - $iSize) _WinAPI_CombineRgn($hMain, $hMain, $hMask, $RGN_DIFF) _WinAPI_DeleteObject($hMask) _WinAPI_SetWindowRgn($hWnd, $hMain) EndFunc ;==>__Rect Func __isTheSamePosAsBefore($aPos, $iMaxOfTheSame = 3) Local Static $aWas[4], $iCount = 0 $iCount += 1 For $n = 0 To 3 If $aWas[$n] <> $aPos[$n] Then $aWas = $aPos $iCount = 0 Return 0 EndIf Next If $iCount < $iMaxOfTheSame Then Return 0 $aWas = $aPos Return 1 EndFunc ;==>__isTheSamePosAsBefore .. thanks @Nine Back story: I have "Win 11 - GUI set border color" for Win11. This is for Win10 and me, with an all dark theme and the borders, without a visible shadow running on a remote desktop, put all this together as a test but thought that may come in handy for some of you too. Edited December 31, 2024 by argumentum back story Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Solution ioa747 Posted Wednesday at 05:55 PM Solution Posted Wednesday at 05:55 PM (edited) idea for dialog windows, like this in the scite with shift + f8 (parameters) or like ctrl + f (find) Spoiler expandcollapse popup#include <GuiConstants.au3> #include <guiconstantsex.au3> #include <winapi.au3> #include <WindowsConstants.au3> If WinExists(StringTrimRight(@ScriptName, 3) & 'GUI') Then Exit ;~ #RequireAdmin ; for elevated windows Opt("TrayAutoPause", 0) ; *** <-- HotKeySet("{ESC}", "Terminate") Func Terminate() GUIDelete() Exit EndFunc ;==>Terminate, like, emergency exit while testing =) _WinActiveBorder() Func _WinActiveBorder($iColor = 0xFF9999, $iWidth = 3) $iWidth += 5 If FileGetSize("WinActiveBorder.ico") Then TraySetIcon("WinActiveBorder.ico") If Int($iWidth) < 1 Then $iWidth = 1 Local $aPos, $hWnd, $gX, $gY, $gW, $gH Local $aClsz, $iFrameDiff, $iFrame = 7 ; *** <-- Local $hGUI = GUICreate(StringTrimRight(@ScriptName, 3) & 'GUI', 0, 0, 0, 0, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TRANSPARENT)) GUISetBkColor($iColor) GUISetState() While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit If _WinAPI_GetIdleTime() > 10000 Then ContinueLoop $hWnd = WinGetHandle("[ACTIVE]") If @error Then ContinueLoop If $hWnd = $hGUI Then Send("!{TAB}") $hWnd = WinGetHandle("[ACTIVE]") EndIf $aPos = WinGetPos($hWnd) If @error Then ContinueLoop $aClsz = WinGetClientSize($hWnd) ; *** <-- $iFrameDiff = ($aPos[2] - $aClsz[0]) / 2 $iFrame = ($iFrameDiff > 7 ? 7 : $iFrameDiff) If __isTheSamePosAsBefore($aPos) Then ContinueLoop $gX = $aPos[0] + $iFrame ;X position ; left $gY = $aPos[1] ;Y position ; top $gW = $aPos[2] - 2 * $iFrame ;Width ; right $gH = $aPos[3] - $iFrame ;Height ; buttom ; *** <-- __Rect($hGUI, 0, 0, $gW + ($iWidth * 2) - 10, $gH + ($iWidth * 2) - 10, $iWidth) _WinAPI_SetWindowPos($hGUI, $hWnd, $gX - $iWidth + 5, $gY - $iWidth + 5, $gW + ($iWidth * 2) - 10, $gH + ($iWidth * 2) - 10, $SWP_SHOWWINDOW) WEnd EndFunc ;==>_WinActiveBorder Func __Rect($hWnd, $iX, $iY, $iWidth, $iHeight, $iSize = 40) Local $hMain = _WinAPI_CreateRectRgn($iX, $iY, $iX + $iWidth, $iY + $iHeight) Local $hMask = _WinAPI_CreateRectRgn($iX + $iSize, $iY + $iSize, $iX + $iWidth - $iSize, $iY + $iHeight - $iSize) _WinAPI_CombineRgn($hMain, $hMain, $hMask, $RGN_DIFF) _WinAPI_DeleteObject($hMask) _WinAPI_SetWindowRgn($hWnd, $hMain) EndFunc ;==>__Rect Func __isTheSamePosAsBefore($aPos, $iMaxOfTheSame = 3) Local Static $aWas[4], $iCount = 0 $iCount += 1 For $n = 0 To 3 If $aWas[$n] <> $aPos[$n] Then $aWas = $aPos $iCount = 0 Return 0 EndIf Next If $iCount < $iMaxOfTheSame Then Return 0 $aWas = $aPos Return 1 EndFunc ;==>__isTheSamePosAsBefore ... and 🎇Happy New Year 🎇 Edited Wednesday at 05:58 PM by ioa747 argumentum 1 I know that I know nothing
DutchCoder Posted Thursday at 01:11 PM Posted Thursday at 01:11 PM Windows 11 also has a similar feature built-in (Settings -> Personalization -> Colors -> Show accent color on title bars and windows borders) argumentum 1
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