Jump to content

Disabling System Tray Icons


Mat
 Share

Recommended Posts

Hey everyone, here is my first full script!!

It is a very simple script that tells you whether your system tray icons are enabled/disabled - and then gives you the option to change it and restart your computer. this could actually be useful if you decide to clean up your desktop and make it free of clutter! Next I'm going to write similar scripts for the clock/desktop items etc, and but it into a single GUI.

;---------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------| M@'s Tray Item tool |-----------------------------------------------------------
;---------------------------------------------------| Func_Tray |----------------------------------------------------------------

#include <GUIConstantsEx.au3>
#NoTrayIcon

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
    Local $YesID, $NoID, $ExitID, $msg, $MsgBox2, $MsgBox1, $var, $errorbox

$var = RegRead("HKey_current_user\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\", "NoTrayItemsDisplay")
if @error <> 0 Then 
$errorbox = msgbox(52, "error", "Error finding registry key - the system cannot find the file specified. Do you want to continue anyway?") 
endif
if $errorbox = 7 then exit
select
case $var = 1 
   msgbox(64, "%REGVALUE% = 1", "The tray icons are currently disabled")
case $var = 0 
   msgbox(64, "%REGVALUE% = 0", "The tray icons are currently enabled")
endselect
    GUICreate("Regedit", 210, 80)
    GUICtrlCreateLabel("Do You Want to Display Tray Items?", -1, 0)
    $YesID = GUICtrlCreateButton("Yes", 10, 50, 50, 20)
    $NoID = GUICtrlCreateButton("No", 80, 50, 50, 20)
    $ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20)

    GUISetState()

    Do
        $msg = GUIGetMsg()

        Select
            Case $msg = $YesID
            RegDelete ( "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoTrayItemsDisplay")
            RegWrite ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\", "NoTrayItemsDisplay", "REG_DWORD", "0")
            $msgbox1 = MsgBox(36,"Notification","Operation complete - Tray icons will be shown on next boot." & @CRLF & "" & @CRLF & "Would you like to restart your computer now?")
            Case $msg = $NoID
            RegDelete ( "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoTrayItemsDisplay")
            RegWrite ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\", "NoTrayItemsDisplay", "REG_DWORD", "1")
            $msgbox2 = MsgBox(36,"Notification","Operation complete - Tray icons will not be shown on next boot." & @CRLF & "" & @CRLF & "Would you like to restart your computer now?")
            Case $msg = $ExitID
            Case $msg = $GUI_EVENT_CLOSE
            Select
    Case $MsgBox1 = 6
Shutdown(6)
    Case $MsgBox1 = 7
Exit
EndSelect
        EndSelect
                    Select
    Case $MsgBox2 = 6
Shutdown(6)
    Case $MsgBox2 = 7
Exit
EndSelect
    Until $msg = $ExitID or $msg = $GUI_Event_Close
EndFunc

;---------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------| Script End |--------------------------------------------------------------------
;---------------------------------------------------------------------------------------------------------------------------------

All feedback is welcome!!

mdiesel

Now includes disabling the clock - even though you can do this easily anyway

;---------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------| M@'s Tray Item tool |-----------------------------------------------------------
;---------------------------------------------------------------------------------------------------------------------------------

#include <GUIConstantsEx.au3>
#NoTrayIcon

Opt('MustDeclareVars', 1)

_Main()
_Clock()
_Tray()

Func _Main()
   Local $TrayID, $ClockID, $ExitID, $msg

    GUICreate("Regedit, Main", 240, 80)
    GUICtrlCreateLabel("Do You Want to Edit the clock or System Tray?", -1, 0)
    $TrayID = GUICtrlCreateButton("Tray", 10, 50, 50, 20)
    $ClockID = GUICtrlCreateButton("Clock", 80, 50, 50, 20)
    $ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20)

    GUISetState()
    
    Do
        $msg = GUIGetMsg()
        Select
            Case $msg = $TrayID
            _Tray()
            winclose("Regedit, main")
            Case $msg = $ClockID
           _Clock()
            winclose("Regedit, main")          
            Case $msg = $ExitID
            Exit
            Case $msg = $GUI_EVENT_CLOSE
            Exit
        EndSelect
    Until  $msg = $ExitID or $msg = $GUI_Event_Close
endfunc

;---------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------| M@'s Tray Item tool |-----------------------------------------------------------
;---------------------------------------------------| Func_Clock |----------------------------------------------------------------

Func _clock()
    Local $YesID, $NoID, $ExitID, $msg, $MsgBox2, $MsgBox1, $var, $errorbox

$var = RegRead("HKey_current_user\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\", "HideClock")
if @error <> 0 Then 
$errorbox = msgbox(52, "error", "Error finding registry key - the system cannot find the file specified. Do you want to continue anyway?") 
endif
if $errorbox = 7 then exit
select
case $var = 1 
   msgbox(64, "%REGVALUE% = 1", "The clock is currently disabled")
case $var = 0 
   msgbox(64, "%REGVALUE% = 0", "The clock is currently enabled")
case @error <> 0
   msgbox(64, "%REGVALUE% = 0", "The clock is currently enabled")
endselect
    GUICreate("Regedit", 210, 80)
    GUICtrlCreateLabel("Do You Want to Display The clock?", -1, 0)
    $YesID = GUICtrlCreateButton("Yes", 10, 50, 50, 20)
    $NoID = GUICtrlCreateButton("No", 80, 50, 50, 20)
    $ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20)

    GUISetState()

    Do
        $msg = GUIGetMsg()

        Select
            Case $msg = $YesID
            RegDelete ( "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\HideClock")
            RegWrite ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\", "HideClock", "REG_DWORD", "0")
            $msgbox1 = MsgBox(36,"Notification","Operation complete - The clock will be shown on next boot." & @CRLF & "" & @CRLF & "Would you like to restart your computer now?")
            Case $msg = $NoID
            RegDelete ( "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\HideClock")
            RegWrite ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\", "HideClock", "REG_DWORD", "1")
            $msgbox2 = MsgBox(36,"Notification","Operation complete - The clock will not be shown on next boot." & @CRLF & "" & @CRLF & "Would you like to restart your computer now?")
            Case $msg = $ExitID
            exit
            Case $msg = $GUI_EVENT_CLOSE
            exit
        EndSelect
            
Select
    Case $MsgBox1 = 6
Shutdown(6)
    Case $MsgBox1 = 7
Exit
EndSelect

Select
    Case $MsgBox2 = 6
Shutdown(6)
    Case $MsgBox2 = 7
Exit
EndSelect

    Until $msg = $ExitID or $msg = $GUI_Event_Close
    
EndFunc

;---------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------| M@'s Tray Item tool |-----------------------------------------------------------
;---------------------------------------------------| Func_Tray |----------------------------------------------------------------

Func _Tray()
    Local $YesID, $NoID, $ExitID, $msg, $MsgBox2, $MsgBox1, $var, $errorbox

$var = RegRead("HKey_current_user\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\", "NoTrayItemsDisplay")
if @error <> 0 Then 
$errorbox = msgbox(52, "error", "Error finding registry key - the system cannot find the file specified. Do you want to continue anyway?") 
endif
if $errorbox = 7 then exit
select
case $var = 1 
   msgbox(64, "%REGVALUE% = 1", "The tray icons are currently disabled")
case $var = 0 
   msgbox(64, "%REGVALUE% = 0", "The tray icons are currently enabled")
case @error <> 0
   msgbox(64, "%REGVALUE% = 0", "The clock is currently enabled")
endselect
    GUICreate("Regedit", 210, 80)
    GUICtrlCreateLabel("Do You Want to Display Tray Items?", -1, 0)
    $YesID = GUICtrlCreateButton("Yes", 10, 50, 50, 20)
    $NoID = GUICtrlCreateButton("No", 80, 50, 50, 20)
    $ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20)

    GUISetState()

    Do
        $msg = GUIGetMsg()

        Select
            Case $msg = $YesID
            RegDelete ( "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoTrayItemsDisplay")
            RegWrite ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\", "NoTrayItemsDisplay", "REG_DWORD", "0")
            $msgbox1 = MsgBox(36,"Notification","Operation complete - Tray icons will be shown on next boot." & @CRLF & "" & @CRLF & "Would you like to restart your computer now?")
            Case $msg = $NoID
            RegDelete ( "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoTrayItemsDisplay")
            RegWrite ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\", "NoTrayItemsDisplay", "REG_DWORD", "1")
            $msgbox2 = MsgBox(36,"Notification","Operation complete - Tray icons will not be shown on next boot." & @CRLF & "" & @CRLF & "Would you like to restart your computer now?")
            Case $msg = $ExitID
            exit
            Case $msg = $GUI_EVENT_CLOSE
            exit
        EndSelect
            
Select
    Case $MsgBox1 = 6
Shutdown(6)
    Case $MsgBox1 = 7
Exit
EndSelect

Select
    Case $MsgBox2 = 6
Shutdown(6)
    Case $MsgBox2 = 7
Exit
EndSelect

    Until $msg = $ExitID or $msg = $GUI_Event_Close
    
EndFunc

;---------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------| Script End |--------------------------------------------------------------------
;---------------------------------------------------------------------------------------------------------------------------------
Edited by Mat
Link to comment
Share on other sites

  • 1 month later...

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...