Windows 8 Action Center

Started by MK, January 14, 2016, 03:27:41 PM

Previous topic - Next topic

MK

Hello Everyone,

I need a little guidance on enable/disabling check boxes on a Windows Form (Windows 8.1 Action Center)

What I am trying to do is to uncheck selected options in action center; but before the script executes - I may not know what status the check boxes are.

At the social.technet.microsoft site, someone wrote a script that is exactly what I need, unfortunately it was not written for WinBatch but rather autoit.  I can convert most of the commands, but I don't know what the WinBatch equivalency for the lines that begin with ControlCommand would be.   Can anyone help me find the WinBatch equivalent command(s). 

Thank you,

The autoit script is:

+-----------------------------------------------------------------------------------+
I based mine off of yours, but in autoit. You can select the ones you want checked or unchecked.

; Open Action Center
;http://msdn.microsoft.com/en-us/library/windows/desktop/cc144191(v=vs.85).aspx
Run( "Control.exe -name ""Microsoft.ActionCenter""" )
; Wait for the control panel to open
WinWait(  "Action Center","" )
; Select "Change Action Center Settings"
;WinActivate( "Action Center","")
;Send( "+{TAB 8}{ENTER}" )
ControlSend( "Action Center", "", "DirectUIHWND3","+{TAB 8}{ENTER}" )
; Wait for the control panel to open
WinWait( "Change Action Center settings","" )
ControlCommand( "Change Action Center settings","","Button1","Check","") ; Windows Update
ControlCommand( "Change Action Center settings","","Button2","Check","") ; Spyware
ControlCommand( "Change Action Center settings","","Button3","Check","") ; Internet Security
ControlCommand( "Change Action Center settings","","Button4","Check","") ; UAC
ControlCommand( "Change Action Center settings","","Button5","UnCheck","") ; Network Firewall
ControlCommand( "Change Action Center settings","","Button6","Check","") ; Virus Protection
ControlCommand( "Change Action Center settings","","Button7","UnCheck","") ; Windows Backup
ControlCommand( "Change Action Center settings","","Button8","Check","") ; Check for Updates
ControlCommand( "Change Action Center settings","","Button9","Check","") ; Windows Troubleshooting
ControlClick( "Change Action Center settings","","Button10","Left") ; Click Ok
; Wait for the control panel to open
WinWait(  "Action Center","" )
; Close the control panel
WinClose( "Action Center","" )

td

Please check out the cCheckBox function documentation in the Consolidated WIL Help file.  You may also need the CWndbyname function to obtain the handle to each checkbox control as is done in the example in the cCheckBox funcion's help file topic.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

This gets pretty ugly.  It might be better to poke around in the registry and set what you want that way.

Code (winbatch) Select
AddExtender("wwctl44i.dll")         ; Installs a WIL extender dll.

Run( "Control.exe", "-name Microsoft.ActionCenter" )
; Wait for the control panel to open
WinWaitExist("Action Center", -1 )
; Select "Change Action Center Settings"
WinActivate( "Action Center")
SendKey( "{TAB 11}{ENTER}" )

; Wait for the control panel to open
WinWaitExist( "Change Action Center settings", 2)
hWnd = DllHWND("Change Action Center settings")
hChild = cWndbyClass(hWnd,"ShellTabWindowClass")
hChild = cWndByClass(hChild, "DUIViewWndClassName")
hChild = cWndByClass(hChild, "DirectUIHWND")
hChild = cWndByClass(hChild, "CtrlNotifySink")

hChild = cWndByClass(hChild, "XBabyHost")
hChild = cWndByClass(hChild, "DirectUIHWND")
hChild = cWndInfo( hChild, 8)
for x = 1 to 3
   hChild = cWndInfo( hChild, 6)
next
hBtn = cWndbyname(hChild,"Windows Update")
cCheckBox(hBtn, 1)
hChild = cWndInfo( hChild, 6)
hBtn = cWndbyname(hChild,"Spyware and unwanted software protection")
cCheckBox(hBtn, 1)


This looks interesting:

https://social.technet.microsoft.com/Forums/windows/en-US/2baeb384-02e9-473b-aedd-4e2a8fcc9b90/disabling-a-specific-action-center-message-via-script-or-registry-key?forum=w7itproinstall

But admittedly, it would be a bit of work sorting out which key goes with which setting.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Another option, if you have the latest version of Winbatch, would be to use WinMacro to record a SendKey and MousePlay script to automate your task.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

MK

Thanks TD.

Your help is greatly appreciated.
I definitely have to read up on the cw... commands.  They definitely seem powerful (but a little complex).

As I was working with the script you provided (again .... thank you for that), It dawned on me that since I already have to 'sendkey' to the window(s) to open action center, I can use    SendKeysTo("Action Center","{-}") to deselect a check box.  I don't have to worry about what value it was set to previously.


td

You don't need to know if the check box is checked or not use cCheckBox but you can use cCheckBox to determine if a box is checked.  Look the function up in the Consolidated WIL Help file for details. 

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade