Advertisement
Titokhan

Toggle Real Time Protection

Nov 9th, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.56 KB | None | 0 0
  1. #NoTrayIcon
  2. #include <MsgBoxConstants.au3>
  3. #include <TrayConstants.au3> ; Required for the $TRAY_CHECKED and $TRAY_ICONSTATE_SHOW constants.
  4.  
  5. Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.
  6.  
  7. Example()
  8.  
  9. Func Example()
  10.  
  11.     $RegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Antimalware\Real-Time Protection"
  12.  
  13.     Local $idEnable = TrayCreateItem("Enable Real Time Protection")
  14.     Local $idDisable = TrayCreateItem("Disable Real Time Protection")
  15.     TrayCreateItem("") ; Create a separator line.
  16.  
  17.     Local $idAbout = TrayCreateItem("About")
  18.     TrayCreateItem("") ; Create a separator line.
  19.  
  20.     Local $idExit = TrayCreateItem("Exit")
  21.  
  22.     TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.
  23.  
  24.     While 1
  25.         Switch TrayGetMsg()
  26.             Case $idEnable
  27.                 RegWrite($RegKey, "DisableRealtimeMonitoring", "REG_DWORD", 0)
  28.  
  29.             Case $idDisable
  30.                 RegWrite($RegKey, "DisableRealtimeMonitoring", "REG_DWORD", 1)
  31.  
  32.             Case $idAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
  33.                 MsgBox($MB_SYSTEMMODAL, "", "MAMRTPS" & @CRLF & @CRLF & _
  34.                         "Version: 1.0" & @CRLF & _
  35.                         "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.
  36.  
  37.             Case $idExit ; Exit the loop.
  38.                 ExitLoop
  39.         EndSwitch
  40.     WEnd
  41. EndFunc   ;==>Example
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement