Sign in to follow this  
Followers 0
Ascend4nt

Windows Desktop Dimmer / Shade

49 posts in this topic

#1 ·  Posted (edited)

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
1 person likes this

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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: 04/09/2015

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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: 04/09/2015

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
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..

Share this post


Link to post
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"...

Share this post


Link to post
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.

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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: 04/09/2015

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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. :)

Share this post


Link to post
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.

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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: 04/09/2015

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

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

Share this post


Link to post
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:

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
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:) ...

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • elsemieni
      By elsemieni
      Hey hello.
      I came here with maybe too specific questions about uncommon things, but as people says, I don't lose anything trying to asking here 
      There's long time that I have a little "experimental" idea: Use windows desktop and it icon system like old videogame consoles (where "sprites" are used to draw things on screen, can be manipulated/animated to make interesting things happen). Some of that inspiration came from another experiments from demoscene.
      Researching the possibilities of doing something like that (maybe not so intense) I found that the Windows Desktop uses a GuiListView to show and arrange icons (and of course, AutoIt provides UDF's for that  ). So, I'm used that UDF to create dummy icons (not putting files on Desktop, just modifiying the "GUI layer" of desktop for put non-working icons), setting custom values like coordinates, name and Icon (from a list of loaded icons in the GuiListView).  As you can see in next image works well in Windows XP... even in Windows 95 (that's not the case from Windows Vista to 10, but I already posted another question here about that... anyways, for now I'm working that with a isolated XP machine... sigh).

      Another video doing an animation with that:
      How I make that custom icons? Here:
      $hWnd = ControlGetHandle("Program Manager", "", "[CLASS:SysListView32; INSTANCE:1]") $newItem = _GUICtrlListView_AddItem ( $hWnd, "TEST", 32 ) ; with an icon of index 32 _GUICtrlListView_SetItemPosition ( $hWnd, $newItem, 300, 300 ) ; set some example property. Put in X=300 Y=300 Okay, so the next phase was changing the icons with custom ones. And here starts the issues. As AutoIT help says, icons from GuiListView came from a loaded GUIImageList, which, seeing past images I conclude that it's already preloaded with some sort of most used icons (something like an icon cache?). But If I modify it (or create another GUIImageList and then put into the GuiListView) the icons became corrupted and replaced with blank ones. (can be reverted deleting IconCache.db, just like when windows shows wrong icons in desktop).
      How I change icons? Here
      $hImage = _GUIImageList_Create(48, 48, 5) ; create an image list for 48x48 icons $newIcon = _GUIImageList_AddIcon($imageList, @SystemDir & "\shell32.dll", 110) ; just adding a new icon in the image list _GUICtrlListView_SetImageList($hWnd, $hImage, 0) ; $hwnd is the desktop hwnd Another option as workaround for setting icons was getting the desktop GUIImageList, and modifiyng it directly. I otbtain a GUIImageList handle, but ... without any images inside! (That's strange beacuse, when I set desktop item icons without altering the GUIImageList, it applies correctly). And finally if I try to add new ones, it returns -1 with @error setted.
      How I'm trying to get  desktop GUIImageList? Here.
      $imageList = _GUICtrlListView_GetImageList ( $hWnd, 0 ) MsgBox(0,_GUIImageList_GetImageCount ( $imageList ), $imageList) ; getting image count and GUIImageList handle $newIcon = _GUIImageList_AddIcon($imageList, @SystemDir & "\shell32.dll", 110) ; adding icons without success So, what is the question? There's something wrong I'm doing while trying to set the new icon set on desktop? Or desktop icons work in different way than the rest of the GuiListView's? Or there's something really stupid that I can't saw before that corrupts the icons? 
      Also... if there's not known solution for that, do you have some idea for doing a workaround for that? Or another crazy idea? (Maybe putting real files instead dummy icons could be a solution ... a very slow one). Or even maybe (maybe not, I sure about that xD) do you want to help with this "experiment".
      Thanks in advance, have a good day  
    • k4rl3on
      By k4rl3on
      Hi,
      How can i make function _ExplorerGetSelectedItems get selecteds items on the Desktop?
      Func _ExplorerGetSelectedItems($sCabinetWClass="[CLASS:CabinetWClass]") Local $Ret = "" Local $aIndexes, $sSelected, $sSelected_Path Local $hSearch, $sCurrentFile $sSelected_Path = ControlGetText($sCabinetWClass, "", "Edit1") ConsoleWrite($sSelected_Path&@CRLF) $aIndexes = StringSplit(ControlListView($sCabinetWClass, "", "SysListView321", "GetSelected", 1), "|") If $aIndexes[0] = 1 And ($aIndexes[1] == "" Or $aIndexes[1] = 0) Then Return SetError(1, 0, 0) For $i = 1 To $aIndexes[0] $sSelected = ControlListView($sCabinetWClass, "", "SysListView321", "GetText", $aIndexes[$i]) $sCurrentFile = StringRegExpReplace($sSelected_Path, "\\+$", "") & "\" & $sSelected If Not FileExists($sCurrentFile) Then ;Search the extension for file... $hSearch = FileFindFirstFile($sCurrentFile & ".*") If $hSearch <> -1 Then $sSelected = FileFindNextFile($hSearch) FileClose($hSearch) EndIf EndIf ;Check if item is a directory If StringInStr(FileGetAttrib($sCurrentFile), "D") > 0 Then $sSelected = "*"&$sSelected $Ret = $Ret&$sSelected&Chr(10) Sleep(1) Next Return $Ret EndFunc  
    • ozmike
      By ozmike
      Hey could be interesting to the AutoIt devs out there 
      Will win32  apps (autoit apps)  work in the new windows 10 store? 
      Early days yet won't be in the initial win 10 release...
       
      Note  win32 apps are now called many things
      - desktop apps
      - CWA ( Classic Windows Apps - not country womens ..assoc. ) 
      - Project C(entenial) apps 
      These apps will not be sandboxed but NOT be allowed to run as admin , all files will be sandboxed installation handled through the store..
       
      blog link
      How does this affect autoit - ?
      FYI
       following as not supported in Project C apps:
      “Windows NT Services”, “Things running in the kernel” (device drivers) “System Level Software” (anything not running in the user context) “Elevation”, meaning anything that causes a standard user to get a UAC prompt “will be blocked”. Using parts of other apps in your app, at least in version 1. John indicated that they would like to support extensibility and plug-ins, just probably not initially. The implication was that this might be a direct UWA thing and not specific to Project C, but we can’t be sure.
       following as supported in Project C apps:
      “COM” “WMI” “Networking” “Anything else a standard app does that isn’t in the system space”. I am guessing that there are a lot of other things that might end up in the ‘not supported’ list that you might have thought falls under the last item in the supported list but turns out is not supported, but we just don’t know yet:
      WMI Providers Windows Timed and Triggered Events (but they can write new UWA background triggers) Custom ETW Providers COM localsystem (out of process) running as the system to avoid UAC prompts Maybe DCOM Software Clients, Application Capabilities Shell Extensions, Browser Helper Objects, and the like  
      FYI
    • RTFC
      By RTFC
      Two tiny, simple scripts (secondDesktop & desktopSwitch) that elaborate (slightly) on _WinAPI_CreateDesktop() to create a second workspace with some interesting features:
      Startup: define any number of programmes to be auto-started on the second desktop, hard-coded (by you, in desktopSwitch.au3) or parsed as parameters (from secondDesktop.au3); Full desktop mode: provides acccess to all your desktop shortcuts, start menu (Win7), taskbar, plus a one-button switch in both desktops; Kiosk mode: provides an empty workspace where only your designated startup entries will run; Switch button/GUI is absent; an unadvertised hotkey provides switching to the original desktop (Ctrl-Alt-Del still works, but a task manager started on the second desktop will appear on the original desktop). To enable kiosk mode, set flag $kioskmode=True in secondDesktop.au3; Security: software keyloggers running in your regular environment cannot capture keystrokes on the second desktop, and windows messages cannot be sent between desktops, so your apps won't be hijacked easily through remote control. (NB not extensively tested; use at your own risk!) In full desktop mode, the (red or green) background colour of the Switch GUI shows you whether you are on the exposed or secure desktop. I SecondDesktop.v0.8.7z (first beta release)
      Important: you'll need to compile desktopSwitch before running secondDesktop. You can test your edited version of desktopSwitch.au3 "dry," as a script on your regular desktop first, by setting its internal flag $testing=True; but don't forget to reset that flag again before compiling.
    • aNewLyfe
      By aNewLyfe
      I'm trying to make a desktop wallpaper application with video support.
      But stuck at z-order.
      Any suggestions? How to put autoit window before desktop listview?
      I'm currently attaching window to the WorkerW. also tried the $HWND_BOTTOM const of _WinAPI_SetWindowPos but when i apply this, win goes invisible.
      no luck yet any help will be appreciated