#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=wuau.ico #AutoIt3Wrapper_Res_Comment=Windows Update Hider, disables Restart dialog after Update Installation. #AutoIt3Wrapper_Res_Description=Windows Update Hider, disables Restart dialog after Update Installation. #AutoIt3Wrapper_Res_Fileversion=1.0.0.0 #AutoIt3Wrapper_Res_LegalCopyright=by Jan Reiss - Mascott.de 2009 #AutoIt3Wrapper_Res_Language=1031 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Opt("WinTitleMatchMode", 4) Global $tray_win[3],$i_oldPID = 999999 Global $g_eventerror = 0 ; to be checked to know if com error occurs. Must be reset after handling. $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Install a custom error handler, no MSGBox/ErrorBox Func MyErrFunc() $g_eventerror = hex($oMyError.number,8) Endfunc _Singleton(@UserName) ; nur einmal starten lassen pro angemeldeter User. ; involved DLLs/Modules #cs C:\WINDOWS\system32\ADVAPI32.dll 0x77da0000 680 kB Erweitertes Windows 32 Base-API C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\COMCTL32.dll 0x773a0000 1,01 MB User Experience Controls Library C:\WINDOWS\system32\COMDLG32.dll 0x76350000 296 kB DLL für gemeinsame Dialoge C:\WINDOWS\system32\ctype.nls 0x160000 12 kB C:\WINDOWS\system32\GDI32.dll 0x77ef0000 292 kB GDI Client DLL C:\WINDOWS\system32\iertutil.dll 0x40f50000 1,91 MB Run time utility for Internet Explorer C:\WINDOWS\system32\IMM32.DLL 0x76330000 116 kB Windows XP IMM32 API Client DLL C:\WINDOWS\system32\kernel32.dll 0x7c800000 1,03 MB Client-DLL für Windows NT-Basis-API C:\WINDOWS\system32\locale.nls 0x90000 260 kB C:\WINDOWS\system32\MPR.dll 0x71a80000 72 kB Router-DLL für Mehrfachanbieter C:\WINDOWS\system32\msctfime.ime 0x75250000 184 kB Microsoft Text Frame Work Service IME C:\WINDOWS\system32\msvcrt.dll 0x77be0000 352 kB Windows NT CRT DLL C:\WINDOWS\system32\Normaliz.dll 0x140000 36 kB Unicode Normalization DLL C:\WINDOWS\system32\ntdll.dll 0x7c910000 740 kB DLL für NT-Layer C:\WINDOWS\system32\ole32.dll 0x774b0000 1,24 MB Microsoft OLE für Windows C:\WINDOWS\system32\OLEAUT32.dll 0x770f0000 556 kB C:\WINDOWS\system32\PSAPI.DLL 0x76bb0000 44 kB Process Status Helper C:\WINDOWS\system32\RPCRT4.dll 0x77e50000 584 kB Remote Procedure Call Runtime C:\WINDOWS\system32\Secur32.dll 0x77fc0000 68 kB Security Support Provider Interface C:\WINDOWS\system32\SETUPAPI.dll 0x778f0000 976 kB Windows Setup-API C:\WINDOWS\system32\SHELL32.dll 0x7e670000 8,13 MB Allgemeine Windows-Shell-DLL C:\WINDOWS\system32\SHLWAPI.dll 0x77f40000 472 kB Shell Light-weight Utility Library C:\WINDOWS\system32\sortkey.nls 0xe0000 260 kB C:\WINDOWS\system32\sorttbls.nls 0x130000 24 kB C:\WINDOWS\system32\unicode.nls 0x70000 88 kB C:\WINDOWS\system32\urlmon.dll 0x452e0000 1,2 MB OLE32 Extensions for Win32 C:\WINDOWS\system32\USER32.dll 0x7e360000 580 kB Client-DLL für Windows XP USER-API C:\WINDOWS\system32\USERENV.dll 0x76620000 728 kB Userenv C:\WINDOWS\system32\uxtheme.dll 0x5b0f0000 224 kB Microsoft UxTheme-Bibliothek C:\WINDOWS\system32\VERSION.dll 0x77bd0000 32 kB Version Checking and File Installation Libraries C:\WINDOWS\system32\WININET.dll 0x408b0000 920 kB Internet Extensions for Win32 C:\WINDOWS\system32\WINMM.dll 0x76af0000 184 kB MCI API-DLL C:\WINDOWS\system32\WS2_32.dll 0x71a10000 92 kB Windows Socket 2.0 32-Bit DLL C:\WINDOWS\system32\WS2HELP.dll 0x71a00000 32 kB Windows Socket 2.0 Helper für Windows NT C:\WINDOWS\system32\WSOCK32.dll 0x71a30000 40 kB Windows Socket-32-Bit-DLL #ce AdlibEnable("disable_button", 1000) ; jede sekunde schauen ob der Update Dialog da ist. While True ; alle 5 Sekunden im systray nach wuauclt*.exe schauen und das Icon löschen. $tray_win[1] = _FindTrayToolbarWindow(1) ; performance fix, lokalisiert systray nur noch einmal jeden durchlauf. $tray_win[2] = _FindTrayToolbarWindow(2) ; performance fix, lokalisiert win7 notify area nur noch einmal jeden durchlauf. $count = _SysTrayIconCount() For $i = $count - 1 To 0 Step -1 $handle = _SysTrayGetButtonInfo($i) $pid = WinGetProcess($handle) if $PID = $i_oldPID Then $name = "wuauclt.exe" ; fix für performance steigerung, 50% cpu usage reduction Else $name = _ProcessGetName($pid) EndIf If $pid = -1 Or $name = "wuauclt.exe" Or $name = "wuauclt1.exe" Then _SysTrayIconRemove($i) $i_oldPID = $pid EndIf Next If @OSVersion = "WIN_7" Then $countwin7 = _SysTrayIconCount(2) For $i = $countwin7 - 1 To 0 Step -1 $handle = _SysTrayGetButtonInfo($i, 2) $pid = WinGetProcess($handle) if $PID = $i_oldPID Then $name = "wuauclt.exe" ; fix für performance steigerung, 50% cpu usage reduction Else $name = _ProcessGetName($pid) EndIf If $pid = -1 Or $name = "wuauclt.exe" Or $name = "wuauclt1.exe" Then _SysTrayIconRemove($i, 2) $i_oldPID = $pid EndIf Next EndIf _ReduceMemory() Sleep(1000 * 5) WEnd Func _Singleton($sOccurenceName, $iFlag = 0) Local Const $ERROR_ALREADY_EXISTS = 183 Local Const $SECURITY_DESCRIPTOR_REVISION = 1 Local $handle, $lastError, $pSecurityAttributes = 0 If BitAND($iFlag, 2) Then ; The size of SECURITY_DESCRIPTOR is 20 bytes. We just ; need a block of memory the right size, we aren't going to ; access any members directly so it's not important what ; the members are, just that the total size is correct. Local $structSecurityDescriptor = DllStructCreate("dword[5]") Local $pSecurityDescriptor = DllStructGetPtr($structSecurityDescriptor) ; Initialize the security descriptor. Local $aRet = DllCall("advapi32.dll", "int", "InitializeSecurityDescriptor", _ "ptr", $pSecurityDescriptor, "dword", $SECURITY_DESCRIPTOR_REVISION) If Not @error And $aRet[0] Then ; Add the NULL DACL specifying access to everybody. $aRet = DllCall("advapi32.dll", "int", "SetSecurityDescriptorDacl", _ "ptr", $pSecurityDescriptor, "int", 1, "ptr", 0, "int", 0) If Not @error And $aRet[0] Then ; Create a SECURITY_ATTRIBUTES structure. Local $structSecurityAttributes = DllStructCreate("dword;ptr;int") ; Assign the members. DllStructSetData($structSecurityAttributes, 1, DllStructGetSize($structSecurityAttributes)) DllStructSetData($structSecurityAttributes, 2, $pSecurityDescriptor) DllStructSetData($structSecurityAttributes, 3, 0) ; Everything went okay so update our pointer to point to our structure. $pSecurityAttributes = DllStructGetPtr($structSecurityAttributes) EndIf EndIf EndIf $handle = DllCall("kernel32.dll", "int", "CreateMutex", "ptr", $pSecurityAttributes, "long", 1, "str", $sOccurenceName) $lastError = DllCall("kernel32.dll", "int", "GetLastError") If $lastError[0] = $ERROR_ALREADY_EXISTS Then If BitAND($iFlag, 1) Then Return SetError($lastError[0], $lastError[0], 0) Else Exit -1 EndIf EndIf Return $handle[0] EndFunc ;==>_Singleton Func disable_button() ; wenn der Update Dialog da ist graue den "Jetzt Neustarten" Button aus. ControlDisable("Automatische Updates", "Soll der Computer jetzt neu ge", "Button1") EndFunc Func _ReduceMemory() ; macht das WorkingSet leer, produziert zwar ne Mänge PageFaults aber hält den RAM frei.(alter autoit memory leak fix.) Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) Return $ai_Return[0] EndFunc;==> _ReduceMemory() Func _ProcessGetName($i_PID) If Not ProcessExists($i_PID) Then SetError(1) Return '' EndIf Local $a_Processes = ProcessList() If Not @error Then For $i = 1 To $a_Processes[0][0] If $a_Processes[$i][1] = $i_PID Then Return $a_Processes[$i][0] EndIf Next EndIf SetError(1) Return '' EndFunc ;==>_ProcessGetName Func _SysTrayIconRemove($index, $iWin = 1) Local Const $TB_DELETEBUTTON = 1046 If $index < 0 Or $index > _SysTrayIconCount($iWin) - 1 Then Return -1 Local $hWnd = $tray_win[$iWin] ; performance fix, lokalisiert systray nur noch einmal jeden durchlauf. If $hwnd = -1 Then Return -1 Local $ret = DllCall("user32.dll", "int", "SendMessageW", "hwnd", $hWnd, "uint", $TB_DELETEBUTTON, "wparam", $index, "lparam", 0) If @error Or Not $ret[0] Then Return -1 Return $ret[0] EndFunc ;==>_SysTrayIconRemove Func _SysTrayGetButtonInfo($iIndex, $iWin = 1) ; removed additional cases to save space Local Const $TB_GETBUTTON = 1047 Local Const $TB_GETBUTTONTEXT = 1099 Local Const $TB_GETBUTTONINFO = 1089 Local Const $TB_HIDEBUTTON = 1028 ; WM_USER +4 Local Const $TB_GETITEMRECT = 1053 Local $taglocalTBBUTTON If @OSArch = "X86" Then $taglocalTBBUTTON = "int iBitmap;int idCommand;byte fsState;byte fsStyle;byte bReserved[2];uint_ptr dwData;int_ptr iString" Else ; X64 $taglocalTBBUTTON = "int iBitmap;int idCommand;byte fsState;byte fsStyle;byte bReserved[6];uint_ptr dwData;int_ptr iString" EndIf Local Const $ACCESS = BitOR(0x0008, 0x0010, 0x0400) ; VM_OPERATION, VM_READ, QUERY_INFORMATION Local $TBBUTTON = DllStructCreate($taglocalTBBUTTON) Local $ExtraData = DllStructCreate("hwnd[2]") Local $trayHwnd = $tray_win[$iWin] ; performance fix, lokalisiert systray nur noch einmal jeden durchlauf. Local $return = -1 If $trayHwnd = -1 Then Return -1 Local $ret = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $trayHwnd, "dword*", 0) If @error Or Not $ret[2] Then Return -1 Local $pId = $ret[2] Local $procHandle = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", $ACCESS, "int", False, "dword", $pId) If @error Or Not $procHandle[0] Then Return -2 Local $lpData = DllCall("kernel32.dll", "ptr", "VirtualAllocEx", "ptr", $procHandle[0], "ptr", 0, "ulong", DllStructGetSize($TBBUTTON), "dword", 0x1000, "dword", 0x04) If Not @error And $lpData[0] Then DllCall("user32.dll", "int", "SendMessageW", "hwnd", $trayHwnd, "uint", $TB_GETBUTTON, "wparam", $iIndex, "lparam", $lpData[0]) DllCall("kernel32.dll", "int", "ReadProcessMemory", "ptr", $procHandle[0], "ptr", $lpData[0], "ptr", DllStructGetPtr($TBBUTTON), "ulong", DllStructGetSize($TBBUTTON), "ulong*", 0) DllCall("kernel32.dll", "int", "ReadProcessMemory", "ptr", $procHandle[0], "ptr", DllStructGetData($TBBUTTON, 6), "ptr", DllStructGetPtr($ExtraData), "ulong", DllStructGetSize($ExtraData), "ulong*", 0) $return = DllStructGetData($ExtraData, 1, 1) DllCall("kernel32.dll", "int", "VirtualFreeEx", "ptr", $procHandle[0], "ptr", $lpData[0], "ulong", 0, "dword", 0x8000) Else $return = -3 EndIf DllCall("kernel32.dll", "int", "CloseHandle", "ptr", $procHandle[0]) Return $return EndFunc ;==>_SysTrayGetButtonInfo Func _SysTrayIconCount($iWin = 1) Local Const $TB_BUTTONCOUNT = 1048 Local $hWnd = $tray_win[$iWin] ; performance fix, lokalisiert systray nur noch einmal jeden durchlauf. If $hWnd = -1 Then Return -1 Local $count = DllCall("user32.dll", "int", "SendMessageW", "hwnd", $hWnd, "uint", $TB_BUTTONCOUNT, "wparam", 0, "lparam", 0) If @error Then Return -1 Return $count[0] EndFunc ;==>_SysTrayIconCount Func _FindTrayToolbarWindow($iWin = 1) Local $hwnd, $ret = -1 If $iWin = 1 Then $hWnd = DllCall("user32.dll", "hwnd", "FindWindow", "str", "Shell_TrayWnd", "ptr", 0) If @error Then Return -1 $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "TrayNotifyWnd", "ptr", 0) If @error Then Return -1 If @OSVersion <> "WIN_2000" Then $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "SysPager", "ptr", 0) If @error Then Return -1 EndIf $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "ToolbarWindow32", "ptr", 0) If @error Then Return -1 $ret = $hwnd[0] ElseIf $iWin = 2 Then ; NotifyIconOverflowWindow for Windows 7 $hWnd = DllCall("user32.dll", "hwnd", "FindWindow", "str", "NotifyIconOverflowWindow", "ptr", 0) If @error Then Return -1 $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "ToolbarWindow32", "ptr", 0) If @error Then Return -1 $ret = $hwnd[0] EndIf Return $ret EndFunc ;==>_FindTrayToolbarWindow