Jump to content

Checking the Power Option


yash
 Share

Recommended Posts

Mains_Check.au3

Hi,

Please anyone can help me in how to check that the Laptop is in Battery or in AC power? i had written one script that check it but it does not go in loop i.e. after clicking on OK button it is not checking again that the Laptop is in Mains or AC power.

Here is my script......

#include <Process.au3>

run("control.exe","C:\WINDOWS\system32",@SW_HIDE)

sleep(1000)

$a = Call("Power")

Func Power()

sleep(500)

Send("{ASC 080}")

Send("{ASC 080}")

Send("{ENTER}")

sleep(1000)

send("^{TAB}")

send("^{TAB}")

$text = WinGetText("Power Options Properties")

$var = StringInStr ( $text, "AC power")

sleep(1000)

WinKill ( "Power Options Properties")

sleep(500)

WinClose ( "Control Panel")

sleep(500)

if $var = 0 THEN

MsgBox(0, "", "Please connect your Laptop to Mains")

$b=MsgBox(4, "", "Have you connected your Laptop to Mains")

if $b=7 then

exit

return 0

Endif

Else

MsgBox(0, "", "Laptop connected to Mains")

return 1

EndIf

EndFunc

I had tried so many options but unable to do it?

Please help me what to do?SHould anyone suggest any other way to do this?

Thanks

Yash

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...