Sign in to follow this  
Followers 0
SkinnyWhiteGuy

Interesting Revelation

3 posts in this topic

I was trying to get AutoIt to help me deselect some power configuration options for all the users in my school district (I work as a computer tech, so anything to make my job easier == GOLD). I was trying to disable Windows' "Prompt for password when computer resumes from standby" inside of the Power Options Properties page, and I discovered that it doesn't use Windows Standard CheckBoxes. I know this because ControlCommand("Power Options Properties,"",1307,"IsChecked","") always returns 0, no matter what.

I read deep in the forums about this same issue, and most of the time, it happened with other controls, and other programs. I think this is the first time I've seen it happen with an actual windows control panel page.

Here's the code, you can see for yourself how it does it (the include was in another part of my script, and I haven't had time to find the proper one to include to just get the needed functionality I wanted.)

#include <A3LTreeView.au3>
Run("rundll32.exe shell32.dll,Control_RunDLL powercfg.cpl,,3")
_Lib_WinWaitActive("Power Options Properties")
ControlCommand("Power Options Properties","",12320,"TabRight","")
$x = ControlCommand("Power Options Properties","Prompt for password when computer resumes from standby",1307,"IsChecked","")
MsgBox (4096,"Prompt for Pass",$x)
ControlClick("Power Options Properties", "", 1)
_Lib_WinWaitNotExists("Power Options Properties")

What's even more amazing, is that, while the Tabs accept the ControlCommand function just fine, the check box ignored, well, any command I sent it. I tried forcing it to check with it, then sending "!{P}" to uncheck it right back as a hack, it just ignored the ControlCommand. Tried "UnCheck","" and got nothing.

The story does have a happy ending, though. Using ControlSend and sending the control a {NUMPADSUB} did the trick (that took forever to trackdown in the forums). Just letting anyone else here know that, if your messing around with those options in the Power Config, use ControlSend with {NUMPADADD} and {NUMPADSUB}.

Share this post


Link to post
Share on other sites



$x = ControlCommand("Power Options Properties","",1307,"IsChecked","")

Try that


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

@Shevilie

Thanks for the reply. I could have sworn I tried that yesterday.

I just played with it a little bit, and found out the real interesting bit: my script was going to fast. When left as I had it, where the check for IsChecked happened right after the TabRight, it was still messing up on me. I put a Sleep in it, and it's working flawlessly now. Hmm, go figure.

At any rate, thanks for letting me know it works. It did seem very odd that it would refuse to work for a Control Panel screen, which is directly built into windows.

Edit: After a little more playing with it, even a Sleep(1) is just enough of a pause to make it work properly, just like this:

#include <A3LTreeView.au3>
Run("rundll32.exe shell32.dll,Control_RunDLL powercfg.cpl,,3")
_Lib_WinWaitActive("Power Options Properties")
ControlCommand("Power Options Properties","",12320,"TabRight","")
Sleep(1)
$x = ControlCommand("Power Options Properties","",1307,"IsChecked","")
MsgBox (4096,"Prompt for Pass",$x)
If $x = "1" Then
    ControlCommand("Power Options Properties","",1307,"UnCheck","")
EndIf
$x = ControlCommand("Power Options Properties","",1307,"IsChecked","")
MsgBox (4096,"Prompt for Pass",$x)
ControlClick("Power Options Properties", "", 1)
_Lib_WinWaitNotExists("Power Options Properties")

Not sure why it's needed, but it is, just comment out the sleep and see for yourself.

Edited by SkInNyWhItEGuY

Share this post


Link to post
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
Sign in to follow this  
Followers 0