누군가가 나를 안내 할 수 있습니까 밝기가 변경 될 때을 사용하면 Windows 시스템에서 vC++을 사용할 수 있습니까? 또는 변경할 때마다 밝기 슬라이더 값을 가져와야합니다. 도움이 될 것입니다.윈도우에서 시스템 밝기 이벤트 받기
미리 감사드립니다.
누군가가 나를 안내 할 수 있습니까 밝기가 변경 될 때을 사용하면 Windows 시스템에서 vC++을 사용할 수 있습니까? 또는 변경할 때마다 밝기 슬라이더 값을 가져와야합니다. 도움이 될 것입니다.윈도우에서 시스템 밝기 이벤트 받기
미리 감사드립니다.
늦게 대답하지만 같은 것을 찾고 있습니다. 밝기를 제어하는 것이 Windows 작업은 아니지만 때로는 드라이버 작업이고 ACPI 호출과 직접 관련 될 수도 있지만 Windows에서 WMI 이벤트를 구현하여 변경 사항에 대한 정보를 얻을 수 있습니다. 특히 Windows가 밝기 변경 이벤트를 수신 할 때마다 필요한 정보를 제공하는 WmiMonitorBrightnessEvent를 구현해야합니다. 아래 샘플 코드는 @RRUZ 응답 here에있는 C# 코드의 C++/CLI 로의 직접 변환입니다. 여기서 WmiMonitorBrightnessEvent를 사용했습니다.
EventWatcherAsync.h
#pragma once
using namespace System;
using namespace System::Management;
ref class EventWatcherAsync
{
public:
void WmiEventHandler(Object^ sender, EventArrivedEventArgs^ e);
EventWatcherAsync();
};
EventWatcherAsync.cpp
#include "stdafx.h"
#include "EventWatcherAsync.h"
void EventWatcherAsync::WmiEventHandler(Object^ sender, EventArrivedEventArgs^ e)
{
Console::WriteLine("Active : " + e->NewEvent->Properties["Active"]->Value->ToString());
Console::WriteLine("Brightness : " + e->NewEvent->Properties["Brightness"]->Value->ToString());
Console::WriteLine("InstanceName : " + e->NewEvent->Properties["InstanceName"]->Value->ToString());
}
EventWatcherAsync::EventWatcherAsync()
{
try
{
System::String^ ComputerName = "localhost";
System::String^ WmiQuery;
ManagementEventWatcher^ Watcher;
ManagementScope^ Scope;
if (ComputerName != "localhost")
{
ConnectionOptions^ Conn = gcnew ConnectionOptions();
Conn->Username = "";
Conn->Password = "";
Conn->Authority = "ntlmdomain:DOMAIN";
Scope = gcnew ManagementScope(String::Format("\\\\{0}\\root\\WMI", ComputerName), Conn);
}
else
Scope = gcnew ManagementScope(String::Format("\\\\{0}\\root\\WMI", ComputerName));
Scope->Connect();
WmiQuery = "Select * From WmiMonitorBrightnessEvent";
Watcher = gcnew ManagementEventWatcher(Scope, gcnew EventQuery(WmiQuery));
Watcher->EventArrived += gcnew EventArrivedEventHandler(this, &EventWatcherAsync::WmiEventHandler);
Watcher->Start();
Console::Read();
Watcher->Stop();
}
catch (Exception^ e)
{
Console::WriteLine("Exception {0} Trace {1}", e->Message, e->StackTrace);
}
}
당신이 밝기 장에 의해 무슨 뜻 이죠하여 Main.cpp
#include "stdafx.h"
#include "EventWatcherAsync.h"
using namespace System;
int main(array<System::String ^> ^args)
{
Console::WriteLine("Listening {0}", "WmiMonitorBrightnessEvent");
Console::WriteLine("Press Enter to exit");
EventWatcherAsync^ eventWatcher = gcnew EventWatcherAsync();
Console::Read();
return 0;
}
네? 어떤 밝기? – Spook
Windows OS를 사용하는 노트북이나 태블릿에 대해 말하면 시스템의 밝기를 변경할 수 있습니까? 따라서 밝기가 변할 때이 이벤트를해야합니다. @ Spook –
물론, AFAIK는 운영 체제와 관련된 값이 아닙니다 (적어도 Windows에서는). 각 노트북 또는 태블릿에는 밝기에 대한 하드웨어 정보를 전달하는 고유 드라이버가 있습니다. 나는이 정보에 접근하는 일반적인 방법이 있음을 거의 의심하지 않는다. – Spook