Mat Posted February 28, 2009 Posted February 28, 2009 (edited) 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. expandcollapse popup;--------------------------------------------------------------------------------------------------------------------------------- ;-----------------------------------------------| 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 expandcollapse popup;--------------------------------------------------------------------------------------------------------------------------------- ;-----------------------------------------------| 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 June 18, 2010 by Mat AutoIt Project Listing
rajeshontheweb Posted April 5, 2009 Posted April 5, 2009 i get: Error finding registry key - the system cannot find the file specified. Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet
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