Jump to content

Windows Desktop Dimmer / Shade


Ascend4nt
 Share

Recommended Posts

Thanks KaFu, modified GDIpnam style code :cheer: <- this is GDIpnam style dance :D

Br,

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 tried to be clever registering the WM_ACTIVATE message and setting the parent of the GUI to the desktop handle, but seems your versions are better.

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

What about this >>

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

_Singleton('TransBackground')

Global Enum $__hGUI, $__iGUIMax
Global $__vGUIAPI[$__iGUIMax]

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

Example()

Func Example()
    Local Const $nShadeColor = 0, $nTransparency = 100
    _SetGUI(GUICreate('', @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TRANSPARENT)))
    GUISetBkColor($nShadeColor)

    _SetWindowNonMinimizable(_GetGUI())

    WinSetOnTop(_GetGUI(), '', 1)
    WinSetTrans(_GetGUI(), '', $nTransparency)
    GUISetState(@SW_SHOWNOACTIVATE, _GetGUI())

    GUIRegisterMsg($WM_WINDOWPOSCHANGED, 'WM_WINDOWPOSCHANGED')

    While 1
        Sleep(1000)
    WEnd
EndFunc   ;==>Example

Func _Exit()
    GUIDelete(_GetGUI())
    Exit
EndFunc   ;==>_Exit

Func _GetGUI()
    Return $__vGUIAPI[$__hGUI]
EndFunc   ;==>_GetGUI

Func _SetGUI($hGUI)
    $__vGUIAPI[$__hGUI] = $hGUI
    Return $__vGUIAPI[$__hGUI]
EndFunc   ;==>_SetGUI

Func _SetWindowNonMinimizable($hWnd)
    Return _WinAPI_SetWindowLong($hWnd, $GWL_HWNDPARENT, ControlGetHandle('[CLASS:Progman]', '', 'SysListView321'))
EndFunc   ;==>_SetWindowNonMinimizable

Func WM_WINDOWPOSCHANGED($hWnd, $iMsg, $wParam, $lParam)
    Local $tWINDOWPOS = DllStructCreate($tagWINDOWPOS, $lParam)
    If DllStructGetData($tWINDOWPOS, 'hWnd') == _GetGUI() Then
        WinSetOnTop(_GetGUI(), '', 1)
        ConsoleWrite('Re-Activated: ' & _GetGUI() & @CRLF)
    EndIf
    Return _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>WM_WINDOWPOSCHANGED

Please feel free to scrutinise me.

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

Isn't that an issue with all the examples that have been posted here though?

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

When I click the taskbar, the "Re-Activated:" is not fired, the taskbar stays on top. With the examples using a loop there's a flash only (taskbar taking top for some ms), this has not (can not?) be solved.

Link to comment
Share on other sites

Does ShellProc help?

I did think about this, but then voted against it. But now looking at the MSDN article perhaps I shouldn't have been so quick to do so.

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

I've already tried that using this example and monitoring the $EVENT_SYSTEM_FOREGROUND, but the result is the same, the notification comes after the fact and the window set on top (e.g. taskbar) still flashes.

Link to comment
Share on other sites

I've already tried that using this example and monitoring the $EVENT_SYSTEM_FOREGROUND, but the result is the same, the notification comes after the fact and the window set on top (e.g. taskbar) still flashes.

I was about to commit to finding out, but if you've done it already seems pointless to do so.

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

This may not be the method of choice, but it does make an effective screen dimmer without flashing in the taskbar.

I got the dimmer functions from Autoit.de.

#include <GUIConstantSex.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
Opt("GUIOnEventMode", 1)
$rgb = 128
$dimBoGUI = GUICreate("DesktopDimmer", 162, 260, 1, @DesktopHeight * .3, $WS_POPUP, $WS_EX_TOOLWINDOW)
GUISetStyle($WS_POPUP, $WS_EX_COMPOSITED + $WS_EX_LAYERED, $dimBoGUI)
_WinAPI_SetLayeredWindowAttributes($dimBoGUI, 0xABCDEF, 255)
GUISetBkColor(0xABCDEF);(0xffffff)while messing with gui. Else, (0xABCDEF)
$dimButton = GUICtrlCreateButton("dimmer", 0, 10, 15, 15)
GUICtrlSetBkColor($dimButton, 0x7f001f)
GUICtrlSetColor($dimButton, 0x7f001f)
GUICtrlSetOnEvent($dimButton, "dimmer")
$normButton = GUICtrlCreateButton("return to normal", 0, 30, 15, 15)
GUICtrlSetBkColor($normButton, 0x7f703f)
GUICtrlSetColor($normButton, 0x7f703f)
GUICtrlSetOnEvent($normButton, "normal")
$brightButton = GUICtrlCreateButton("brighter", 0, 50, 15, 15)
GUICtrlSetBkColor($brightButton, 0x42177f)
GUICtrlSetColor($brightButton, 0x42177f)
GUICtrlSetOnEvent($brightButton, "brighter")
$closeButton = GUICtrlCreateButton("X", 0, 80, 17, 25)
GUICtrlSetBkColor($closeButton, 0xff0000)
GUICtrlSetTip($closeButton, "shut this silly thing down")
GUICtrlSetOnEvent($closeButton, "xIt")
$sourceButton = GUICtrlCreateButton("spit-out a source file", 0, 0, 8, 8)
GUICtrlSetBkColor($sourceButton, 0xcc0088)
GUICtrlSetColor($sourceButton, 0xcc0088)
GUICtrlSetOnEvent($sourceButton, "install")
GUISetState(@SW_SHOW)
AdlibRegister("getThePos1", 500)
_ReduceMemory()
While 1
Sleep(10)
WEnd
Func xIt()
normal();return brightness to normal
Exit
EndFunc ;==>xIt
Func getThePos1()
$CI = GUIGetCursorInfo($dimBoGUI)
If $CI[4] = $dimButton Then
dimGetBig()
Else
dimShrink()
EndIf
getThePos2()
EndFunc ;==>getThePos1
Func getThePos2()
$CI = GUIGetCursorInfo($dimBoGUI)
If $CI[4] = $normButton Then
normGetBig()
Else
normShrink()
EndIf
getThePos3()
EndFunc ;==>getThePos2
Func getThePos3()
$CI = GUIGetCursorInfo($dimBoGUI)
If $CI[4] = $brightButton Then
brightGetBig()
Else
brightShrink()
EndIf
getThePos4()
EndFunc ;==>getThePos3
Func getThePos4()
$CI = GUIGetCursorInfo($dimBoGUI)
If $CI[4] = $sourceButton Then
sourceGetBig()
Else
sourceShrink()
EndIf
EndFunc ;==>getThePos4
Func dimGetBig()
ControlMove("", "dimmer", $dimButton, Default, Default, 160, 200)
GUICtrlSetColor($dimButton, 0x000000)
EndFunc ;==>dimGetBig
Func dimShrink()
ControlMove("", "dimmer", $dimButton, Default, Default, 15, 15)
GUICtrlSetColor($dimButton, 0x7f001f)
EndFunc ;==>dimShrink
;>>>>>>>>>>>>>>
Func normGetBig()
ControlMove("", "return to normal", $normButton, Default, Default, 160, 200)
GUICtrlSetColor($normButton, 0x000000)
EndFunc ;==>normGetBig
Func normShrink()
ControlMove("", "return to normal", $normButton, Default, Default, 15, 15)
GUICtrlSetColor($normButton, 0x7f703f)
EndFunc ;==>normShrink
;>>>>>>>>>>>>>>
Func brightGetBig()
ControlMove("", "brighter", $brightButton, Default, Default, 160, 200)
GUICtrlSetColor($brightButton, 0x000000)
EndFunc ;==>brightGetBig
Func brightShrink()
ControlMove("", "brighter", $brightButton, Default, Default, 15, 15)
GUICtrlSetColor($brightButton, 0x42177f)
EndFunc ;==>brightShrink
;>>>>>>>>>>>>>>
Func sourceGetBig()
ControlMove("", "spit-out a source file", $sourceButton, Default, Default, 160, 45);200
GUICtrlSetColor($sourceButton, 0x000000)
EndFunc ;==>sourceGetBig
Func sourceShrink()
ControlMove("", "spit-out a source file", $sourceButton, Default, Default, 8, 8)
GUICtrlSetColor($sourceButton, 0xcc0088)
EndFunc ;==>sourceShrink
;>>>>>>>>>>>>>>
;got the below from autoit.de. I modified only the func names.
Func dimmer()
If $rgb > 0 Then
$rgb = $rgb - 10
_SetGamma($rgb, $rgb, $rgb)
EndIf
EndFunc ;==>dimmer
Func normal()
$rgb = 128
_SetGamma($rgb, $rgb, $rgb)
EndFunc ;==>normal
Func brighter()
If $rgb < 286 Then
$rgb = $rgb + 10
_SetGamma($rgb, $rgb, $rgb)
EndIf
EndFunc ;==>brighter
Func _SetGamma($vRed = 128, $vGreen = 128, $vBlue = 128)
Local $n_ramp, $rVar, $gVar, $bVar, $Ret, $i, $dc
If $vRed < 0 Or $vRed > 386 Then
SetError(1)
Return -1 ;Invalid Red value
EndIf
If $vGreen < 0 Or $vGreen > 386 Then
SetError(2)
Return -1 ;Invalid Green value
EndIf
If $vBlue < 0 Or $vBlue > 386 Then
SetError(3)
Return -1 ;Invalid Blue value
EndIf
$dc = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
$n_ramp = DllStructCreate("short[" & (256 * 3) & "]")
For $i = 0 To 256
$rVar = $i * ($vRed + 128)
If $rVar > 65535 Then $rVar = 65535
$gVar = $i * ($vGreen + 128)
If $gVar > 65535 Then $gVar = 65535
$bVar = $i * ($vBlue + 128)
If $bVar > 65535 Then $bVar = 65535
DllStructSetData($n_ramp, 1, Int($rVar), $i) ;red
DllStructSetData($n_ramp, 1, Int($gVar), $i + 256) ;green
DllStructSetData($n_ramp, 1, Int($bVar), $i + 512) ;blue
Next
$Ret = DllCall("gdi32.dll", "int", "SetDeviceGammaRamp", _
"int", $dc[0], "ptr", DllStructGetPtr($n_ramp))
$dc = 0
$n_ramp = 0
EndFunc ;==>_SetGamma
;>>>>>>>>>>>>>>
Func _ReduceMemory($i_PID = -1)
If $i_PID <> -1 Then
Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
$ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
Else
$ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
EndIf
Return $ai_Return[0]
EndFunc ;==>_ReduceMemory
Func install()
; this is a literal filepath & must be changed to where your script is located
FileInstall("Q:\au3 projects\desktop dimmer\desktop dimmer.au3", @ScriptDir & "\desktop dimmer.au3");check path>>fix
EndFunc ;==>install
Link to comment
Share on other sites

This may not be the method of choice, but it does make an effective screen dimmer without flashing in the taskbar.

I got the dimmer functions from Autoit.de.

Folks I think we have a winner! haha.. wow, that came completely out of left field! Aside from the horrid GUI (sorry haha), that code works great, and its all due to manipulating 'SetDeviceGammaRamp', an API call I didn't even know of. Thanks for that!

Also I have to acknowledge all the other contributions to the thread - KaFu of course, UEZ for your GDIpnam style version (haha), guinness.. its cool to see a community working together on solving interesting problems.

I think the 'focus' and 'follow-window' shade GUI's still have their place, but I'm not sure there's a need for a full-screen desktop shader anymore :)

I'll update the first post later with links to these other posts and solutions. However.. maybe we should tackle the issue of creating a nice GUI, maybe with a slider control? Or possibly we could just hotkey it out to some Ctrl-Alt-+, Ctrl-Alt-- keys..

Link to comment
Share on other sites

This may not be the method of choice, but it does make an effective screen dimmer without flashing in the taskbar. I got the dimmer functions from Autoit.de.

A really nice find :thumbsup:! Thanks for pointing out this Api.

A drawback might be the remark on MSDN for SetDeviceGammaRamp:

"The SetDeviceGammaRamp function sets the gamma ramp on direct color display boards having drivers that support downloadable gamma ramps in hardware."

Sounds to me like there are drivers that do not support this... well, can't have everything :).

However.. maybe we should tackle the issue of creating a nice GUI, maybe with a slider control?

Something like this :whistle:?

#NoTrayIcon
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)
Opt("GUIOnEventMode", 1)
$hGUI_Tray = GUICreate(" DGC", 64, 200, 1, 1, Default, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetOnEvent($GUI_EVENT_CLOSE, "_Tray_GUI_Hide")
$c_Button_Reset = GUICtrlCreateButton("Reset", 5, 7, 54, 20)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetOnEvent(-1, "_Gamma_Reset")
$c_Slider_Average = GUICtrlCreateSlider(12, 28, 44, 175, BitOR($TBS_BOTH, $TBS_AUTOTICKS, $TBS_VERT))
$h_Slider_Average = GUICtrlGetHandle($c_Slider_Average)
GUICtrlSetLimit(-1, 256, 0)
GUICtrlSetData(-1, 128)
GUIRegisterMsg($WM_ACTIVATE, "WM_ACTIVATE")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
TraySetClick(8)
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "_Exit")
TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, "_Tray_GUI_Show")
TraySetState()
TraySetToolTip("DGC - Desktop Gamma Changer (left click to change / right click to exit)")
OnAutoItExitRegister("_Gamma_Reset")
While 1
Sleep(10)
WEnd
Func _Exit()
Exit
EndFunc ;==>_Exit
Func _Tray_GUI_Show()
Local $aMousePos = MouseGetPos()
WinMove($hGUI_Tray, "", $aMousePos[0] - 70, $aMousePos[0] - 345)
GUISetState(@SW_SHOW, $hGUI_Tray)
EndFunc ;==>_Tray_GUI_Show
Func _Tray_GUI_Hide()
GUISetState(@SW_HIDE, $hGUI_Tray)
EndFunc ;==>_Tray_GUI_Hide
Func _Gamma_Reset()
_SetDeviceGammaRamp(128, 128, 128)
GUICtrlSetData($c_Slider_Average, 128)
EndFunc ;==>_Gamma_Reset
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
Local $iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $h_Slider_Average
Switch $iCode
    Case -16
     Local $iAv = GUICtrlRead($c_Slider_Average)
     _SetDeviceGammaRamp($iAv, $iAv, $iAv)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func WM_ACTIVATE($hWnd, $Msg, $wParam, $lParam)
Switch $hWnd
Case $hGUI_Tray
If Not $wParam Then ; Window de-activated
    _Tray_GUI_Hide()
EndIf
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_ACTIVATE
Func _SetDeviceGammaRamp($vRed = 128, $vGreen = 128, $vBlue = 128)
Local $n_ramp, $rVar, $gVar, $bVar, $Ret, $i, $hDC
If $vRed < 0 Or $vRed > 386 Then
SetError(1)
Return -1 ;Invalid Red value
EndIf
If $vGreen < 0 Or $vGreen > 386 Then
SetError(2)
Return -1 ;Invalid Green value
EndIf
If $vBlue < 0 Or $vBlue > 386 Then
SetError(3)
Return -1 ;Invalid Blue value
EndIf
$hDC = _WinAPI_GetDC(0)
$n_ramp = DllStructCreate("short[" & (256 * 3) & "]")
For $i = 0 To 256
$rVar = $i * ($vRed + 128)
If $rVar > 65535 Then $rVar = 65535
$gVar = $i * ($vGreen + 128)
If $gVar > 65535 Then $gVar = 65535
$bVar = $i * ($vBlue + 128)
If $bVar > 65535 Then $bVar = 65535
DllStructSetData($n_ramp, 1, Int($rVar), $i) ;red
DllStructSetData($n_ramp, 1, Int($gVar), $i + 256) ;green
DllStructSetData($n_ramp, 1, Int($bVar), $i + 512) ;blue
Next
$Ret = DllCall("gdi32.dll", "int", "SetDeviceGammaRamp", "int", $hDC, "ptr", DllStructGetPtr($n_ramp))
_WinAPI_ReleaseDC(0, $hDC)
EndFunc ;==>_SetDeviceGammaRamp
Link to comment
Share on other sites

Something like this :whistle:?

Nice! Although there was a typo in this one line:

WinMove($hGUI_Tray, "", $aMousePos[0] - 70, $aMousePos[0] - 345)

shoulda been:

WinMove($hGUI_Tray, "", $aMousePos[0] - 70, $aMousePos[1] - 345)

And since we are improving on things... ;) I like interactive adjustments, plus the ability to use my mouse scroll wheel, so here's another version with WM_VSCROLL messages captured (and auto-slider-focus):

Edit: code snipped, there's

Edited by Ascend4nt
Link to comment
Share on other sites

Post #3000 :ILA2:

Nice! Although there was a typo in this one line:

Darn, if you don't follow up instantly... I knew there was something wrong with the positioning, sometimes it's too easy :lol:...

Now, really looks good already, I'll search my lib for a proper icon in the evening.

Link to comment
Share on other sites

Well, I'm glad that I posted it here instead of the "GUI design concepts" thread.

As I pointed out, I didn't write this one.

My only real contribution to this script was......the GUI. :thumbsup:

The following versions posted ARE substantial cosmetic improvements & slightly easier to use.

Link to comment
Share on other sites

KaFu,

Maybe it's just me but I tested your code and you're missing GUISetState() as the GUI didn't display.

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

My bad, I didn't read the code thoroughly. Sorry.

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

Post #3000

Congrats mate! haha. There should be cake..

My only real contribution to this script was......the GUI. :thumbsup:

haha, don't feel bad man, it was a neat little GUI attempt.

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...