Turning of the monitors
-
Wow, I thought there would be something easy as just function.TurnOffMonitor(x) ... :sigh:
Yeah, right next to
DoesEverything.MakeMeCoffee()
. :rolleyes: If there was a method or something for every possible feature (which is impossible), what would be the point of having programmers?Microsoft MVP, Visual C# My Articles
-
Its funny how some think someone else should write their code. Is the monitor power button looking like a more feasible implementation for you? :-) This is easily a case where one can overuse technology. By the time it takes you to figure out how to use the objects in
Management
you could have just shut off your monitor.Ahrghhh.... I just wanted a little help for a something that mattered to me, but I guess I'll have to stick to what what my newbe skills could to come up with:
private void Form1_Load(object sender, System.EventArgs e) { this.Location = new Point(0,0); this.BackColor = Color.Black; this.Size = new Size(1280*2, 1024); }
all through it doesn't turn off the monitors (since my monitors are backlighted), but at least it dims the light. Thank you guys X| -
Yeah, right next to
DoesEverything.MakeMeCoffee()
. :rolleyes: If there was a method or something for every possible feature (which is impossible), what would be the point of having programmers?Microsoft MVP, Visual C# My Articles
Heath Stewart wrote: what would be the point of having programmers? Programmers are no longer needed in this world, at least not with the newly released API's containing things like this:
IDevelop id = DeveloperFactory.CreateDeveloper();
id.WriteCompleteApplicationWithNoErrors();- Nick Parker
My Blog | My Articles -
Ahrghhh.... I just wanted a little help for a something that mattered to me, but I guess I'll have to stick to what what my newbe skills could to come up with:
private void Form1_Load(object sender, System.EventArgs e) { this.Location = new Point(0,0); this.BackColor = Color.Black; this.Size = new Size(1280*2, 1024); }
all through it doesn't turn off the monitors (since my monitors are backlighted), but at least it dims the light. Thank you guys X|PrebKlok wrote: Thank you guys X| What's the bad mood for? Do you not want to learn anything at all? Do you want to be a newbie forever? I suppose, if that's the manner in which you want things handled you should be upset. - Nick Parker
My Blog | My Articles -
Heath Stewart wrote: what would be the point of having programmers? Programmers are no longer needed in this world, at least not with the newly released API's containing things like this:
IDevelop id = DeveloperFactory.CreateDeveloper();
id.WriteCompleteApplicationWithNoErrors();- Nick Parker
My Blog | My ArticlesBut the factory pattern used in the "new APIs" is from .NET 2.0 Beta. You don't want beta developers, do you? :-D I guess maybe I should just be a park ranger out in Washington now that Redmond has decided us programmers are absolete. :(( :-D
Microsoft MVP, Visual C# My Articles
-
But the factory pattern used in the "new APIs" is from .NET 2.0 Beta. You don't want beta developers, do you? :-D I guess maybe I should just be a park ranger out in Washington now that Redmond has decided us programmers are absolete. :(( :-D
Microsoft MVP, Visual C# My Articles
Heath Stewart wrote: I guess maybe I should just be a park ranger out in Washington now that Redmond has decided us programmers are absolete. Hey, if you did, who could blame you - this[^] view looks awesome. :) - Nick Parker
My Blog | My Articles -
Heath Stewart wrote: I guess maybe I should just be a park ranger out in Washington now that Redmond has decided us programmers are absolete. Hey, if you did, who could blame you - this[^] view looks awesome. :) - Nick Parker
My Blog | My ArticlesWell, when you an Megan come up to visit (BTW - have a thread about my new job in my blog) we can take you there! And since I'm absolete now with that pesky
DoesEverything
class, we'll probably just have a cabin (so it's close to work) there! :-DMicrosoft MVP, Visual C# My Articles
-
By reading about the System.Management[^] classes and their examples in the .NET Framework SDK. It's the only way to learn. You can also download the Management Extensions for Visual Studio .NET from the links below, which installs extensions into VS.NET's Server Explorer. You can find the class you want and drag and drop it to your project ot create a typed
ManagementObject
(supported properties and methods are reflected on the created type), but all this does is provide a wrapper for callingManagementObject.InvokeMethod
,ManagementObject.Get
, andManagementObject.Put
.- Management (WMI) Extensions for Visual Studio .NET 2002 Server Explorer (RTM)[^]
- Management (WMI) Extensions for Visual Studio .NET 2003 Server Explorer[^]
Microsoft MVP, Visual C# My Articles
Ok, would this be the way to go?
object [] arg = {6}; ManagementClass mc = new ManagementClass("Win32_DesktopMonitor"); mc.InvokeMethod("SetPowerState", arg);
problem is that I get the an exception: An unhandled exception of type 'System.Management.ManagementException' occurred in system.management.dll Additional information: This method is not implemented in any class -
Ok, would this be the way to go?
object [] arg = {6}; ManagementClass mc = new ManagementClass("Win32_DesktopMonitor"); mc.InvokeMethod("SetPowerState", arg);
problem is that I get the an exception: An unhandled exception of type 'System.Management.ManagementException' occurred in system.management.dll Additional information: This method is not implemented in any classIf you followed my directions (downloaded the WMI extensions for VS.NET) and generated a typed class for the
Win32_DesktopMonitor
CIMv2 class, you might see immediately what was wrong:SetPowerState
takes two parameters: aUInt16
and aDateTime
. Change the first line toobject[] arg = {6, DateTime.Now};
and it should work.Microsoft MVP, Visual C# My Articles
-
If you followed my directions (downloaded the WMI extensions for VS.NET) and generated a typed class for the
Win32_DesktopMonitor
CIMv2 class, you might see immediately what was wrong:SetPowerState
takes two parameters: aUInt16
and aDateTime
. Change the first line toobject[] arg = {6, DateTime.Now};
and it should work.Microsoft MVP, Visual C# My Articles
Hmm... changing the line now gives this execption: An unhandled exception of type 'System.Management.ManagementException' occurred in system.management.dll Additional information: Type mismatch I'm not sure if I understood your direction 100%. After having installed the WMI extensions, I opened the Server Explore and browsed to Servers|MyComputerName|Management Clas|Desktop Settings and then I right clicked and chose "Generate Managed Class"
-
Hmm... changing the line now gives this execption: An unhandled exception of type 'System.Management.ManagementException' occurred in system.management.dll Additional information: Type mismatch I'm not sure if I understood your direction 100%. After having installed the WMI extensions, I opened the Server Explore and browsed to Servers|MyComputerName|Management Clas|Desktop Settings and then I right clicked and chose "Generate Managed Class"
That's not the right class. You have to right-click on "Management Classes" and add a new class: root\CIMv2\Win32_DesktopMonitor. Generate a new class from that. Try
object[] arg = new object[] {(ushort)6, DateTime.Now};
. It really shouldn't matter since non-decimal numeric types are implicitly convertible, but it's worth a try. This could present a problem since the method is discovered by the types of parameters, and since just6
would actually be anint
(System.Int32
), that could be the source of the problem.Microsoft MVP, Visual C# My Articles
-
That's not the right class. You have to right-click on "Management Classes" and add a new class: root\CIMv2\Win32_DesktopMonitor. Generate a new class from that. Try
object[] arg = new object[] {(ushort)6, DateTime.Now};
. It really shouldn't matter since non-decimal numeric types are implicitly convertible, but it's worth a try. This could present a problem since the method is discovered by the types of parameters, and since just6
would actually be anint
(System.Int32
), that could be the source of the problem.Microsoft MVP, Visual C# My Articles
-
I can't find any Win32_xxxxx in root\CIMv2\ Here is a screenshot of what is see: www.klokmose.dk/images/screen1.jpg[^] Anyway the (ushort)6 didn't help anything
Since the dialog is showing the friendly names, the logical conclusion would be to find something that resembles "Win32_DesktopMonitor", like "Monitors". Add that and generate a class for your project.
Microsoft MVP, Visual C# My Articles