It is currently Mon Dec 09, 2019 11:28 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: does it exist an API for windows 10 to change the power plan
PostPosted: Fri Jun 14, 2019 6:53 am 
Offline
User
User

Joined: Mon Sep 06, 2010 3:05 pm
Posts: 72
Hello,

I want to implement a software which change Power Plan for windows 10 by programming time triggers.

Somebody knows an api to change the power plan ?

Sorry for my english... I am french !

Arnaud


Top
 Profile  
Reply with quote  
 Post subject: Re: does it exist an API for windows 10 to change the power
PostPosted: Fri Jun 14, 2019 7:31 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat May 05, 2007 5:31 pm
Posts: 630
Location: Linz, Austria
You could use RunProgram with:
Code:
powercfg -list (get power scheme GUID)
powercfg -setactive GUID


Top
 Profile  
Reply with quote  
 Post subject: Re: does it exist an API for windows 10 to change the power
PostPosted: Sun Jun 16, 2019 4:34 pm 
Offline
User
User

Joined: Mon Sep 06, 2010 3:05 pm
Posts: 72
Thanks a lot !


Top
 Profile  
Reply with quote  
 Post subject: Re: does it exist an API for windows 10 to change the power
PostPosted: Sun Jun 16, 2019 10:00 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4448
Location: Germany
You need a wrapper for powrprof.dll

Like done here:

https://github.com/Ravatsaas/PowerManagerAPI


Top
 Profile  
Reply with quote  
 Post subject: Re: does it exist an API for windows 10 to change the power
PostPosted: Sun Jun 16, 2019 10:19 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4448
Location: Germany
As a starting point:
Code:
Prototype.l Prototype_PowerGetActiveScheme(*UserPowerKey, *ActivePolicyGuid)

Global PowerGetActiveScheme.Prototype_PowerGetActiveScheme

powrprof = OpenLibrary(#PB_Any, "powrprof.dll")
If powrprof
   
  PowerGetActiveScheme = GetFunction(powrprof, "PowerGetActiveScheme")
 
  Define *test.GUID
 
  PowerGetActiveScheme(#Null, @*test)
 
  GUID$ = RSet(Hex(*test\Data1, #PB_Long), 8, "0") + "-"
  GUID$ + RSet(Hex(*test\Data2, #PB_Word), 4, "0") + "-"
  GUID$ + RSet(Hex(*test\Data3, #PB_Word), 4, "0") + "-"
  GUID$ + RSet(Hex(*test\Data4[0] << 8 | *test\Data4[1], #PB_Word), 4, "0") + "-"
  GUID$ + RSet(Hex(*test\Data4[2], #PB_Byte), 2, "0")
  GUID$ + RSet(Hex(*test\Data4[3], #PB_Byte), 2, "0")
  GUID$ + RSet(Hex(*test\Data4[4], #PB_Byte), 2, "0")
  GUID$ + RSet(Hex(*test\Data4[5], #PB_Byte), 2, "0")
  GUID$ + RSet(Hex(*test\Data4[6], #PB_Byte), 2, "0")
  GUID$ + RSet(Hex(*test\Data4[7], #PB_Byte), 2, "0")
  Debug GUID$
 
  LocalFree_(*test)
 
  CloseLibrary(powrprof)
EndIf


Top
 Profile  
Reply with quote  
 Post subject: Re: does it exist an API for windows 10 to change the power
PostPosted: Mon Jun 17, 2019 12:49 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4448
Location: Germany
I could not resist:

viewtopic.php?p=538242#p538242


Last edited by infratec on Wed Jun 19, 2019 9:02 pm, edited 4 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: does it exist an API for windows 10 to change the power
PostPosted: Mon Jun 17, 2019 5:14 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat May 05, 2007 5:31 pm
Posts: 630
Location: Linz, Austria
Nice one, thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: does it exist an API for windows 10 to change the power
PostPosted: Wed Jun 19, 2019 12:50 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4448
Location: Germany
I extended the version above.


Top
 Profile  
Reply with quote  
 Post subject: Re: does it exist an API for windows 10 to change the power
PostPosted: Wed Jun 19, 2019 8:58 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4448
Location: Germany
I converted the complete stuff (above)

viewtopic.php?p=538242#p538242

:mrgreen:


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye