VBA - 화면 밝기 자체 증가/감소

VBA - 화면 밝기 자체 증가/감소

문제:

내 노트북의 화면 밝기가 무작위로 감소했다가 다시 천천히 증가합니다. 내 사용자 양식을 안팎으로 페이드하는 매크로를 사용한 이후 이런 일이 발생했습니다.

나는 그 매크로를 사용한 것조차 후회했고 그 이후로 몇 주 전에 그 매크로를 삭제했습니다.

그런데 그 때부터 노트북 화면 밝기가 켜졌다 꺼졌다가 갑자기 줄어들었다가 제가 촉발하지 않아도 갑자기 갑자기 밝아지더군요.

나는 이미 그것을 삭제했습니다페이딩매크로!

이제 제 질문은 노트북 화면의 밝기를 어떻게 영구적으로 최대화할 수 있느냐는 것입니다. 노트북 화면의 밝기는 밝기의 영향을 받았다고 90% 확신합니다.페이딩제가 몇 주 전에 사용했던 매크로입니다.

밝기를 영구적으로 높이려면 또 다른 VBA를 작성해야 합니까?

이 문제를 어떻게 해결할 수 있나요?

아래는 제가 사용하고 이미 삭제한 매크로 코드입니다. 사용한 것을 후회합니다. 아래 링크와 코드:

https://wellsr.com/vba/2018/excel/vba-fade-userform-in-and-out/

'PLACE IN YOUR USERFORM CODE
Option Explicit
#If VBA7 Then
Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
Private Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As LongPtr, ByVal nIndex As Long) As Long
Private Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal hwnd As LongPtr) As Long
Private Declare PtrSafe Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As LongPtr, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long 
#Else
Private Declare Function FindWindow Lib "user32" _
    Alias "FindWindowA" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long

Private Declare Function GetWindowLong Lib "user32" _
    Alias "GetWindowLongA" ( _
    ByVal hwnd As Long, _
    ByVal nIndex As Long) As Long

Private Declare Function SetWindowLong Lib "user32" _
    Alias "SetWindowLongA" ( _
    ByVal hwnd As Long, _
    ByVal nIndex As Long, _
    ByVal dwNewLong As Long) As Long

Private Declare Function DrawMenuBar Lib "user32" ( _
    ByVal hwnd As Long) As Long

Private Declare Function SetLayeredWindowAttributes Lib "user32" ( _
                ByVal hwnd As Long, _
                ByVal crKey As Long, _
                ByVal bAlpha As Byte, _
                ByVal dwFlags As Long) As Long

#End If
'Constants for title bar
Private Const GWL_STYLE As Long = (-16)           'The offset of a window's style
Private Const GWL_EXSTYLE As Long = (-20)         'The offset of a window's extended style
Private Const WS_CAPTION As Long = &HC00000

'Style to add a titlebar
Private Const WS_EX_DLGMODALFRAME As Long = &H1   'Controls if the window has an icon

'Constants for transparency
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_COLORKEY = &H1                  'Chroma key for fading a certain color on your Form
Private Const LWA_ALPHA = &H2                     'Only needed if you want to fade the entire userform

'sleep
#If VBA7 Then
    Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr) 'For 64-Bit versions of Excel
    Dim formhandle As LongPtr
#Else
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 'For 32-Bit versions of Excel
    Dim formhandle As Long
#End If

Private Sub UserForm_Initialize()
'force the form to fully transparent before it even loads
formhandle = FindWindow(vbNullString, Me.Caption)
SetWindowLong formhandle, GWL_EXSTYLE, GetWindowLong(formhandle, GWL_EXSTYLE) Or WS_EX_LAYERED
SetOpacity (0)
End Sub

Private Sub UserForm_Activate()
'HideTitleBarAndBorder Me 'hide the titlebar and border
FadeUserform Me, True 'Fade your userform in
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
FadeUserform Me, False 'Fade your userform in
End Sub

Sub FadeUserform(frm As Object, Optional FadeIn As Boolean = True)
'Defaults to fade your userform in.
'Set the 2nd argument to False to Fade Out.
Dim iOpacity As Integer

formhandle = FindWindow(vbNullString, Me.Caption)

SetWindowLong formhandle, GWL_EXSTYLE, GetWindowLong(formhandle, GWL_EXSTYLE) Or WS_EX_LAYERED
'The following line sets the userform opacity equal to whatever value you have in iOpacity (0 to 255).
If FadeIn = True Then 'fade in
    For iOpacity = 0 To 255 Step 15
        Call SetOpacity(iOpacity)
    Next
Else 'fade out
    For iOpacity = 255 To 0 Step -15
        Call SetOpacity(iOpacity)
    Next
    Unload Me 'unload form once faded out
End If
End Sub

Sub SetOpacity(Opacity As Integer)
        SetLayeredWindowAttributes formhandle, Me.BackColor, Opacity, LWA_ALPHA
        Me.Repaint
Sleep 50
End Sub

Sub HideTitleBarAndBorder(frm As Object)
'Hide title bar and border around userform
'Source: https://wellsr.com/vba/2017/excel/remove-window-border-title-bar-around-userform-vba/
#If VBA7 Then
    Dim lngWindow As LongPtr
    Dim lFrmHdl As LongPtr
#Else
    Dim lngWindow As Long
    Dim lFrmHdl As Long
#End If
    lFrmHdl = FindWindow(vbNullString, frm.Caption)
'Build window and set window until you remove the caption, title bar and frame around the window
    lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE)
    lngWindow = lngWindow And (Not WS_CAPTION)
    SetWindowLong lFrmHdl, GWL_STYLE, lngWindow
    lngWindow = GetWindowLong(lFrmHdl, GWL_EXSTYLE)
    lngWindow = lngWindow And Not WS_EX_DLGMODALFRAME
    SetWindowLong lFrmHdl, GWL_EXSTYLE, lngWindow
    DrawMenuBar lFrmHdl
 End Sub

(아래 AppleOddity와 HarryMC의 도움으로 해결되었습니다... 정말 감사합니다!!). 첨부된 스크린샷의 솔루션은 다음 세 가지 사항을 확인하는 것입니다.

  • 디스플레이 밝기를 활성화했습니다. 비활성화해야 합니다("끄기").

  • 디스플레이 밝기가 어두워짐, 100%로 설정해야 함

  • 디스플레이 밝기, 100%로 설정해야 함

당신들은 멋진데!! 저는 이 웹사이트 StackExchange를 좋아합니다!!

여기에 이미지 설명을 입력하세요

관련 정보