Jump to content

Windows Desktop Dimmer / Shade


Ascend4nt
 Share

Recommended Posts

Windows Desktop Dimmer / Shade


Are your eyes being blinded by the bright white light leaping from your screen and burning your retinas out? Yeah, so were mine. So I looked for ways to adjust this, but each thing had its limitations.

- LCD brightness adjustments: Yes, this is the obvious choice. But there's two problems:

  • The monitor emits a high pitched noise (common with LCD dimming)
  • In different scenarios, brighter is better (games, movies). And what a pain to constantly adjust!

- Graphics Card software adjustments: Pain in the ass, often inconsistent, and might ruin contrast, wash out colors, or otherwise not give the results you want. Its even more of a pain when dealing with more than one monitor. And again - see #2 above.

So what other option is there? Well, there's this novel idea of using a desktop dimmer 'window' - basically a click-through full-screen GUI that is fully transparent - thus altering the screen colors. I got this idea from this Android app called 'Screen Filter'. I had explored the idea with this very basic test code:

 

; Styles: Basic: WS_POPUP (0x80000000), Extended: WS_EX_NOACTIVATE 0x08000000,
; $WS_EX_TOOLWINDOW (0x80) + $WS_EX_TOPMOST (0x8)? + $WS_EX_TRANSPARENT (click-through)
$hGUI=GUICreate("",@DesktopWidth,@DesktopHeight,0,0,0x80000000,0x08000080 + 0x20)
WinSetTrans($hGUI, "", 110)
WinSetOnTop($hGUI, "", 1)
GUISetBkColor(0x141414)
WinSetState($hGUI, "", @SW_SHOWNOACTIVATE)
Sleep(5000)

This worked well when put inside a 'real' AutoIt script. However, there was a constant issue revolving around windows stealing the top-most attribute, thus causing them to hover 'above' the desktop shade. So (as you'll see from the posts below), we created workarounds by resetting the top-most flag. But that made things a bit, well, ugly. A number of people tried to come up with methods that tried to solve this problem - and really, its an interesting read, so check out the posts that follow. The thing is, everybody ran into the same losing-topmost status problem.. UNTIL, that is, lorenkinzel came in and> posted a script that surprised us all :)

 

24vn1bp.jpg 2gwc4ya.jpg

Dimmer Control / Tray Menu

Turns out one easy API call was all it took to adjust the screen brightness. No fancy Desktop Shade GUI's were needed. So, KaFu took it one step further by developing a simple GUI, and I made some adjustments (see above pics), implemented some fixes, and the rest is history. We now have a nice 'Windows Desktop Dimmer' program that I find to be a must-have addition to my Windows toolbox.

Ah, and I should mention the neat '>Windows Focus' GUI that was developed by KaFu in response to my '>Active Window Dimmer' script. Mine simply dimmed the active window, while KaFu's dimmed everything BUT the active window. This creates a cool movie-theater or focus-writer effect that I find actually compliments the Windows Dimmer.  *UPDATE: See '>Spotlight + Focus GUI' script for some new eyestrain-relieving experiments! And check out RedShiftGUI for even better ideas for eyestrain relief!

So, with all that said, I might as well post the whole package of scripts together as one ZIP. Use just the Windows Dimmer, or mix together different scripts for some funky effects! (see the attachment below)

Oh, one more thing, just to clear up the context of post #2: it had to do with a question I had regarding any theories or common practices used to adjust brightness without losing contrast or details.

WindowsDimmerShadeAndFocus.zip [previous downloads: 137]

Changelog:

2013-05-14

+ Added _GraphicsIsGammaRampSupported() function which checks if the graphics device supports Gamma Ramps (used by WindowsDimmer.au3).

+ Small speedup of DLLCalls

Edited by Ascend4nt
Link to comment
Share on other sites

Hi m8,

long time not seen :). Well, definitely an interesting idea. I did some manual testing back and forth, and the best results in dimming I've got using a grey color and changing the transparency level. Also Google brought up this article:

http://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color

The formulas mentioned there should all be somewhere in the source of

The main challenge I see is the selection of the color to use, best results would of course be a by-pixel evaluation, but I think this is performance wise out of question.

Maybe of some use, I didn't test it

Func _CalcContrastColor($crBg)
    ; http://www.codeproject.com/KB/tips/JbColorContrast.aspx
    Local Const $TOLERANCE = 30
    If (Abs(BitAND($crBg, 0xFF) - 0x80) <= $TOLERANCE And Abs(BitAND(BitShift($crBg, 8), 0xFF) - 0x80) <= $TOLERANCE And Abs(BitAND(BitShift($crBg, 16), 0xFF) - 0x80) <= $TOLERANCE) Then Return BitAND((0x7F7F7F + $crBg), 0xFFFFFF);
    Return BitXOR($crBg, 0xFFFFFF);
EndFunc   ;==>_CalcContrastColor
Link to comment
Share on other sites

With KaFu's function and your code Ascend4nt, I would say that's a good combination.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Hey, good to see ya Kafu. Hmm.. I'm gonna have to look into those links. I don't know if a contrast color would be what I'm looking for? Seems that everything likes to burn my retinas out with pure blinding white colors, argh!

You know what's funny - clicking 'login' on the forum did exactly what I was looking for, to the browser window. It just dimmed everything quite nicely while focusing on the login box. I recall you doing a function like that in one of your projects KaFu? Something with an about box?

Oh, and I figured I'd update the above post with something that's less 'white' looking, and closer to what I find suits my needs.. I'd be curious what settings you all find is best for you? (by mucking around with BkColor() and transparency) Hopefully that question doesn't result in spam hehe.

Just an FYI - using Windows Aero flip, opening menus, and anything that changes topmost window will bypass the 'filter'. You could of course make the program reset its topmost flag every so often, though it still won't affect certain features. Those things don't really bother me though - just sitting and using a browser or IDE or text editor is what kills me.

oh an hey guinness, looks like i'm bumpin into you all over :)

Link to comment
Share on other sites

oh an hey guinness, looks like i'm bumpin into you all over :)

I'm not complaining. 0_-

Also is _GUIDisable (in my signature) what you were kind of referring to?

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Yeah, I've used something similar for the SMF install screen with v1.8 or something, except that I made it layered and not transparent (if I recall right)... and after some complaints that the rest of the the desktop is not accessible anymore I've removed it again :lol:...

How about this?

$hGUI=GUICreate("",@DesktopWidth,@DesktopHeight,0,0,0x80000000,0x08000080 + 0x20)
WinSetTrans($hGUI, "", 50)
WinSetOnTop($hGUI, "", 1)
GUISetBkColor(0x000000)
WinSetState($hGUI, "", @SW_SHOWNOACTIVATE)
Sleep(5000)

Edit: I just realize the little annoyance of other windows stealing the topmost position (e.g. click on the taskbar, menu drop-downs)...

Edited by KaFu
Link to comment
Share on other sites

Also is _GUIDisable (in my signature) what you were kind of referring to?

That's actually pretty cool, and would be useful to do individual-window dimming. However I keep getting a 'subscript used with non-Array variable' with your code (line 79).

How about this?

F' me, that's nearly perfect! Wow, I can't believe using a black background color didn't occur to me.

Oh, and that method you used, KaFu.. I swore it was in an 'about' box and that it simply 'dimmed' the rest of windows. Maybe I'm not recalling correctly..

Link to comment
Share on other sites

Yeah, used the same function there too :), for install and about, you recall it better than me :lol:... btw, I just realize the little annoyance of other windows stealing the topmost position (e.g. click on the taskbar, menu drop-downs)... looping and resetting the topmost flag is a workaround, but the other windows sadly still "flash"...

Link to comment
Share on other sites

That's actually pretty cool, and would be useful to do individual-window dimming. However I keep getting a 'subscript used with non-Array variable' with your code (line 79).

With the examples I don't get that, but I can see where some error checking could be used. Thanks.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Okay, I've just thrown something together that makes this a workable UDF, I'll update the first post.

guinness, sorry I should have been more clear - I wrote a simple test to use _GUIDisable() on another window (firefox, notepad, etc).. that's where the crash occurred.

Link to comment
Share on other sites

looping and resetting the topmost flag is a workaround, but the other windows sadly still "flash"...

Wow, I've just noticed that the topmost-rest is pretty obvious, and kind of annoying. Hmm.. I'm not sure there's a clear solution to this problem though? I can't recall if there's a way to determine if the active window is topmost.. hmm

Link to comment
Share on other sites

I think WinList() returns the windows in z-order.

HotKeySet("{ESC}", "_Exit")

Global $hWnd_Topmost
$hGUI = GUICreate("Topmost Test", @DesktopWidth, @DesktopHeight, 0, 0, 0x80000000, 0x08000080 + 0x20)
WinSetTrans($hGUI, "", 50)
WinSetOnTop($hGUI, "", 1)
GUISetBkColor(0x000000)
WinSetState($hGUI, "", @SW_SHOWNOACTIVATE)

While Sleep(10)
    $aWinlist = WinList()
    ;_ArrayDisplay($aWinlist)
    If $hWnd_Topmost <> $aWinlist[1][1] Then
        $hWnd_Topmost = $aWinlist[1][1]
        ConsoleWrite(TimerInit() & @TAB & $hWnd_Topmost & @TAB & WinGetTitle($hWnd_Topmost, "") & @CRLF)
        If $hWnd_Topmost <> $hGUI Then
            WinSetOnTop($hGUI, "", 1)
        EndIf
    EndIf
WEnd

Func _Exit()
    Exit
EndFunc   ;==>_Exit
Link to comment
Share on other sites

I think WinList() returns the windows in z-order.

Dang, you posted that as I posted an updated version, haha. The new version just tests to see if there's changes in the currently 'active' window. It appears to be less annoying... but it doesn't recognize windows that reset their always-on-top bit, like for example Task Manager. I'm not sure that's too big of a deal though?

Your version is nice, and its quite funny to see the competition between the running code and the Windows interface. Even changing menus causes it to invoke.

I'll leave it up to people to decide which they like better though. :)

Link to comment
Share on other sites

Okay, I've just thrown something together that makes this a workable UDF, I'll update the first post.

guinness, sorry I should have been more clear - I wrote a simple test to use _GUIDisable() on another window (firefox, notepad, etc).. that's where the crash occurred.

Yeh it only works on AutoIt native GUIs.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

So I wasn't completely satisfied with leaving well enough alone.. Now there's a Active-Window chaser version. It only dims the active window! This *can* be combined with the other dimmer function if you're a nut :)

Update in first post.

Link to comment
Share on other sites

Very nice Ascend4nt.

This is actually on my autoit todo list.

I'm currently using a piece of software called F.lux so my screen brightness changes according to time of day. But this particular piece of software has some problems. For example, with my graphics card, the mouse cursor gets too bright.

Your script will come in really handy. ;) Although i just found it has simillar problems :P

Thank you for this.

Edited by telmob
Link to comment
Share on other sites

This is also a next effect :)...

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $bHKPressed = False

$hGUI = GUICreate("Test", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TRANSPARENT))
WinSetTrans($hGUI, "", 150)
WinSetOnTop($hGUI, "", 1)
GUISetBkColor(0)
WinSetState($hGUI, "", @SW_SHOWNOACTIVATE)

HotKeySet("!q", "_HotKeyPressed")

Local $msg, $hWin, $hLastActiveWin, $aPos, $aLastPos

While 1
    $msg = GUIGetMsg()
    If ($msg = -3 Or $bHKPressed) Then
        ExitLoop
    EndIf
    $hWin = WinGetHandle("[ACTIVE]")
    $aPos = WinGetPos($hWin)
    ; Workaround for certain scenarios where position isn't able to be retrieved
    If (@error) Then
        $aPos = $aLastPos
        $hWin = $hLastActiveWin
        ; Different active window, or different size/position?
    ElseIf ($hWin <> $hLastActiveWin Or _
            $aPos[0] <> $aLastPos[0] Or $aPos[1] <> $aLastPos[1] Or _
            $aPos[2] <> $aLastPos[2] Or $aPos[3] <> $aLastPos[3]) Then

        ;ConsoleWrite("New active window or position: Win:"&WinGetTitle($hWin)&@CRLF)
        _GuiHole($hGUI, $aPos[0], $aPos[1], $aPos[2], $aPos[3])
        WinSetOnTop($hGUI, "", 1)
        $hLastActiveWin = $hWin
        $aLastPos = $aPos
    EndIf

    Sleep(10)
WEnd

Func _GuiHole($h_win, $i_x, $i_y, $i_sizew, $i_sizeh)
    Dim $pos, $outer_rgn, $inner_rgn, $wh, $combined_rgn
    $pos = WinGetPos($h_win)
    $outer_rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", $pos[2], "long", $pos[3])
    $inner_rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $i_x, "long", $i_y, "long", $i_x + $i_sizew, "long", $i_y + $i_sizeh)
    $combined_rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $combined_rgn[0], "long", $outer_rgn[0], "long", $inner_rgn[0], "int", $RGN_DIFF)
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $combined_rgn[0], "int", 1)
EndFunc   ;==>_GuiHole

Func _HotKeyPressed()
    $bHKPressed = True
EndFunc   ;==>_HotKeyPressed
Edited by KaFu
Link to comment
Share on other sites

Very nice Ascend4nt.

...

Your script will come in really handy. ;) Although i just found it has simillar problems :P

Thank you for this.

No prob, mate. Yah, I know the problems with certain Windows elements fighting for the 'top' of the stack is annoying, but I find its not as 'painful' to my eyes if only a few elements sneak on top now and then. For me it was mainly about being able to read, write and edit stuff without going blind. :geek:

Oh and btw, there's a way to override the system cursors - check out my Crosshairs GUI (link in signature).

This is also a next effect :)...

Hahah, very cool!! This is like a movie-theater, or 'focus writer' effect, where outside distractions are kept to a minimum. I can see this being useful too!

Gosh, we should start a 'Stupid GUI tricks' thread for all the neat things we've come up with. Shaped GUI's, cross-hairs, rubber-band boxes, windows dimmer/focus GUI's, etc. I actually have a few 'just for fun' scripts I've had laying around, one that creates a bunch of standard shaped GUI's (stars, boxes, triangles, circles) and just throws them around the screen haha..

Anyway, cool effect, man. :sorcerer:

Link to comment
Share on other sites

Here another way! Guess which variant?

;coded by UEZ 2013
#include <Constants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>


Global $fOpaqueLevel = 20.0 ; 20%
Global $iDimmer = 0x000000 ;black in RGB
Global Const $hFullScreen = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]")
Global Const $aFullScreen = WinGetPos($hFullScreen) ;for multi monitor support

_GDIPlus_Startup()
Global $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int",  $aFullScreen[2], "int",  $aFullScreen[3], "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
$hBitmap = $hBitmap[6]
Global Const $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsClear($hGraphic, 0xFF000000 + $iDimmer)
Global Const $hGUI = GUICreate("", $aFullScreen[2], $aFullScreen[3], $aFullScreen[0], $aFullScreen[1], $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST + $WS_EX_TRANSPARENT + $WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOWNOACTIVATE, $hGUI)
SetTransparentBitmap($hGUI, $hBitmap, Int(0xFF * $fOpaqueLevel / 100))

HotKeySet("^q","_Exit") ;CTRL+Q
Global Const $hDLL = DllOpen('user32.dll')
While Sleep(10)
    $aRet = DllCall($hDLL, 'hwnd', 'GetTopWindow', 'hwnd', 0)
    If $aRet[0] <> $hGUI Then
        WinSetOnTop($hGUI, "", True)
    EndIf
WEnd

Func _Exit()
    DllClose($hDLL)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_BitmapDispose($hBitmap)
    GUIDelete()
    Exit
EndFunc

Func SetTransparentBitmap($hGUI, $hImage, $iOpacity = 0xFF)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", 1)
    _WinAPI_UpdateLayeredWindow($hGUI,  $hMemDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>SetTransparentBitmap

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I'll call it Gangnam... ehhh, GDIman Style :lol:... nevertheless, same problem as with the others ones, does not really stick to the top (click taskbar), a WinSetOnTop should be added to the loop, also the exit hotkey is not "shift ESC" o:) ...

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...