AlexKirst Posted June 19, 2014 Share Posted June 19, 2014 Hi everyone, I was wondering if there was any way to make a script that would go to the Notification Area Icons tab in control panel and turn off all icons EXCEPT power, volume, and network? The script I have been testing can open the panel and select the the right option, but the order that the icons appear in the list changes. Here is what I have so far: Run("RUNDLL32.EXE shell32.dll,Options_RunDLL 5") //run the control panel WinWaitActive("Notification Area Icons") WinActivate("Notification Area Icons") ControlClick("Notification Area Icons", "", "[CLASS:ComboBox; INSTANCE:1]") //click the first box ControlSend("Notification Area Icons", "", "[CLASS:ComboBox; INSTANCE:1]", "Show Icon and Notifications") //click Show Icon and Notifications. ControlClick("Notification Area Icons", "", "[CLASS:ComboBox; INSTANCE:2]") ControlSend("Notification Area Icons", "", "[CLASS:ComboBox; INSTANCE:2]", "Show Icon and Notifications") This works, but the problem I'm having is that the first and second "instance" is always different. Is there a way to specify which options are where? The main goal is to hide EVERYTHING other than the battery, network, and volume icons. Link to comment Share on other sites More sharing options...
Wombat Posted June 19, 2014 Share Posted June 19, 2014 You're going to want to get this tool: Once you begin to understand how to use it, this code should get you started: #include <Misc.au3> Do ;runs the following code until the condition in the UNTIL section is met If _IsPressed(10) Then ;_IsPressed(10) 10 is the SHIFT key ControlClick("[CLASS:Shell_TrayWnd]", "", 1502, "left") ;Sends a left click to the arrow in the toolbar Sleep(500) ;pauses to wait for the window to pop up ControlClick("[CLASS:NotifyIconOverflowWindow]", "", "[CLASS:SysLink]", "left") ;sends a left click to the "customize" link in the window EndIf Sleep(10) Until _IsPressed("1B") ;Waits for you to press the ESCAPE button before it exits the script Exit ;Exits the script I didn't know how much you knew so I commented on some things to help you out. From here using the tool I linked, the example script and the help file you should be able to accomplish your goal. Just look at us.Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner The internet is our one and only hope at a truly free world, do not let them take it from us... Link to comment Share on other sites More sharing options...
AlexKirst Posted June 19, 2014 Author Share Posted June 19, 2014 Thanks for your response. I got past that point with my original code, but my problem lies after that. The window tool does not identify which item the "control id" relates to, other than the "instance" number of the drop down list. Since the order of the list changes, how would I be able to set all of them to "hide" except for the ones I specified? Link to comment Share on other sites More sharing options...
Wombat Posted June 19, 2014 Share Posted June 19, 2014 I got past that point with my original code Which is why it is always a good idea to post the current code you have so those who attempt to help you don't waste their time. Not that I considered it a waste of my time but someone else might. Ok, every time I open that window the system icons are in the same order: Action Center Power Network Volume etc So all you need to do it appears is adapt this script: expandcollapse popup#include <Misc.au3> #include <Array.au3> #include <Constants.au3> #include <WinAPI.au3> Global $avChildren Opt("GUIOnEventMode", 1) Do ;runs the following code until the condition in the UNTIL section is met If _IsPressed(10) Then ;_IsPressed(10) 10 is the SHIFT key ControlClick("[CLASS:Shell_TrayWnd]", "", 1502, "left") ;Sends a left click to the arrow in the toolbar Sleep(500) ;pauses to wait for the window to pop up ControlClick("[CLASS:NotifyIconOverflowWindow]", "", "[CLASS:SysLink]", "left") ;sends a left click to the "customize" link in the window Sleep(500) $hWnd = WinGetHandle("[CLASS:CabinetWClass]") WinListChildren($hWnd, $avChildren) Sleep(1000) _ArrayDisplay($avChildren) EndIf Sleep(10) Until _IsPressed("1B") ;Waits for you to press the ESCAPE button before it exits the script Func WinListChildren($hWnd, ByRef $avArr) If UBound($avArr, 0) <> 2 Then Local $avTmp[10][2] = [[0]] $avArr = $avTmp EndIf Local $hChild = _WinAPI_GetWindow($hWnd, $GW_CHILD) While $hChild If $avArr[0][0]+1 > UBound($avArr, 1)-1 Then ReDim $avArr[$avArr[0][0]+10][2] $avArr[$avArr[0][0]+1][0] = $hChild $avArr[$avArr[0][0]+1][1] = _WinAPI_GetWindowText($hChild) $avArr[0][0] += 1 WinListChildren($hChild, $avArr) $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT) WEnd ReDim $avArr[$avArr[0][0]+1][2] Sleep(100) EndFunc Exit ;Exits the script So that it retrieves the instance as well, then have it change each instance of combobox to "Hide icon and notifications" except for instances 2, 3, and 4 Just look at us.Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner The internet is our one and only hope at a truly free world, do not let them take it from us... Link to comment Share on other sites More sharing options...
Malkey Posted June 19, 2014 Share Posted June 19, 2014 (edited) You might like to try this method.#include <GuiComboBox.au3> #include <GuiComboBoxEx.au3> Local $sText Run("RUNDLL32.EXE shell32.dll,Options_RunDLL 5") ;run the control panel WinActivate("Notification Area Icons") WinWaitActive("Notification Area Icons") Local $hCtrl = ControlGetHandle("Notification Area Icons", "", "ComboBox1") Local $a = _GUICtrlComboBoxEx_GetCurSel($hCtrl) _GUICtrlComboBoxEx_GetItemText($hCtrl, $a, $sText) ConsoleWrite($sText & @LF) If $sText <> "Hide icon and notifications" Then _GUICtrlComboBox_SelectString($hCtrl, "Hide icon and notifications") If MsgBox(1, "", 'Originally ComboBox displayed: "' & $sText & '"' & @CRLF & "Press OK to to revert back to the original display") = 1 Then _ _GUICtrlComboBox_SelectString($hCtrl, $sText) EndIf ; _GUICtrlComboBox_SelectString(ControlGetHandle ("Notification Area Icons","","ComboBox1"), "Show Icon and Notifications") ;click Show Icon and Notifications. Edited June 20, 2014 by Malkey Link to comment Share on other sites More sharing options...
Wombat Posted June 20, 2014 Share Posted June 20, 2014 You might like to try this method. #include <GuiComboBox.au3> #include <GuiComboBoxEx.au3> Local $sText Run("RUNDLL32.EXE shell32.dll,Options_RunDLL 5") ;run the control panel WinActivate("Notification Area Icons") WinWaitActive("Notification Area Icons") Local $hCtrl = ControlGetHandle("Notification Area Icons", "", "ComboBox1") Local $a = _GUICtrlComboBoxEx_GetCurSel($hCtrl) _GUICtrlComboBoxEx_GetItemText($hCtrl, $a, $sText) ConsoleWrite($sText & @LF) If $sText <> "Hide icon and notifications" Then _GUICtrlComboBox_SelectString($hCtrl, "Hide icon and notifications") If MsgBox(1, "", 'Originally ComboBox displayed: "' & $sText & '"' & @CRLF & "Press OK to to revert back to the original display") = 1 Then _ _GUICtrlComboBox_SelectString($hCtrl, $sText) EndIf ; _GUICtrlComboBox_SelectString(ControlGetHandle ("Notification Area Icons","","ComboBox1"), "Show Icon and Notifications") ;click Show Icon and Notifications. that's a better approach, but it doesn't solve the issue of allowing AlexKirst to disable all but a few based on the controls instance. A combination of what you posted and an altered version of what I posted would get AlexKirst closer to his/her goal. Just look at us.Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner The internet is our one and only hope at a truly free world, do not let them take it from us... Link to comment Share on other sites More sharing options...
AlexKirst Posted June 20, 2014 Author Share Posted June 20, 2014 Which is why it is always a good idea to post the current code you have so those who attempt to help you don't waste their time. Not that I considered it a waste of my time but someone else might. I did post my code in my original post. Its right in the middle. However, you said the instances are always the same. This is not true, as when you change the box to "hide icon and notifications" in any application, it changes the location of that application in the list. Since we will be working with hundreds of computers, I need to find a way which will read what order each is in, and then change the right ones to "show". EX. if the user turns "power" to "hide icon and notifications" it will not be in the same location as it would be if it was "show icon and notifications". This is my problem. If the list was static the code would be easy, but it changes depending on the users settings. Thanks for the help everyone. Link to comment Share on other sites More sharing options...
orbs Posted June 20, 2014 Share Posted June 20, 2014 if i may, a completely different approach to this problem is due. here are the facts (or well-established assumptions): 1) the settings the OP is interested in are user-specific. 2) the default settings are that system icons appear, and other icons appear for 30 seconds once started, then disappear. 3) unfortunately, there is no (formal) method to customize these settings programmatically. 4) scripting this involves the very much non-robust method of GUI management. one would deduce: (1) + (2) => why would you want to bother going thru it anyway? are you planning on doing it on the correct user profile? are you aware users are fully capable of undoing your work? (3) + (4) => using GUI management to script a large number of targets is prone to issues, and never is a good idea. you'd end-up with more trouble then it's worth. so, question asked: what is your goal in doing this? is it possible there is a better way to accomplish that goal? (one comes to mind: have it already preconfigured on an image base. other methods probably out there). now, this is my years of being strict rules-following sysadmin speaking. but if you really need it done, please share your reasons, and we'll probably manage to work something out. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
AlexKirst Posted June 20, 2014 Author Share Posted June 20, 2014 Here is our plan: We run an IT repair business that is currently in the process of becoming an MSP provider. We need to deploy this script to our monitored computers. We have our ways of deployment, and we have many other scripts that accomplish what we need. Overall, this script is here so that each computer we deploy the script to will be uniform and have a clean notification bar. We know that the user can change these settings, thats why if we continue to deploy the script on a schedule it will keep all of our monitored computers the same. We do not plan on installing an image on each computer, just running different scripts and functions through a deployment program so that each computer can be exactly as we set it. If there is anyway to do this, EX. registry edit. autoit, batch, java, vbs, exe, etc. it does not matter how it is done. As long as we can have these set how we would like, our goal is accomplished. Link to comment Share on other sites More sharing options...
orbs Posted June 20, 2014 Share Posted June 20, 2014 i'm all for uniformity, but THIS specific aspect i believe you should avoid. anyway, how about if you do not configure each and every icon separately, but instead you order "restore default icon behaviors" and then "Turn system icons on or off". Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now