Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   AutoIt (http://forum.oszone.net/forumdisplay.php?f=103)
-   -   [решено] Как убрать иконки из трея в данной ситуации? (http://forum.oszone.net/showthread.php?t=155211)

evg64 31-10-2009 16:48 1257552

Как убрать иконки из трея в данной ситуации?
 
Добрый день! В менеджере горячих клавиш я сделал хотки для маленького скрипта:

Код:

while ProcessExists ( "Autoit3.exe")
ProcessClose ( "Autoit3.exe")
wend

Скрипт закрывает процесс, но не убирает иконки из трея. Что дописать, чтобы он убирал и иконки?

beve 31-10-2009 17:27 1257578

Цитата:

Цитата evg64
Что дописать, чтобы он убирал и иконки? »

В данном случае не поможет ничего, кроме такого "алгоритма":
Код:

#include <WinAPI.au3>

$hTaskBar =
_WinAPI_FindWindow("Shell_TrayWnd", "")
$hParent =
ControlGetHandle($hTaskBar, "", "TrayNotifyWnd1")
$hWnd =
ControlGetHandle($hParent, "", "ToolbarWindow321")

$WinRect =
_WinAPI_GetWindowRect($hWnd)

$aMousePos = MouseGetPos()

$Left =
DllStructGetData($WinRect, "Left")
$Right =
DllStructGetData($WinRect, "Right")
$Top =
DllStructGetData($WinRect, "Top")

For $i = $Left To $Right
MouseMove($i, $Top, 0)
Next

MouseMove($aMousePos[0], $aMousePos[1], 0)


Creat0R 31-10-2009 18:46 1257662

Цитата:

данном случае не поможет ничего, кроме такого "алгоритма":
Вообще то есть метод “поэлегантнее” убрать иконки из трея ;) - Правда функция получается большеватая :)

Код:

_RefreshTrayIcons()

Func _RefreshTrayIcons()
        #Region - OS check
        ;64 bit OS currently untested ;StringCompare(@OSArch, "X86", 0) <> 0
        If @OSArch <> "X86" Then Return SetError(1, 0, -1)

        Select
                Case @OSVersion = "WIN_2000" ; StringCompare(@OSVersion, "WIN_2000", 0) = 0
                Case @OSVersion = "WIN_XP" ; StringCompare(@OSVersion, "WIN_XP", 0) = 0
                Case @OSVersion = "WIN_VISTA" ; StringCompare(@OSVersion, "WIN_VISTA", 0) = 0
                        ;Case @OSVersion = "WIN_2003"        ; StringCompare(@OSVersion, "WIN_2003", 0) = 0
                        ;Case @OSVersion = "WIN_2008"        ; StringCompare(@OSVersion, "WIN_2008", 0) = 0
                Case Else
                        Return SetError(1, 1, -1)
        EndSelect
        #EndRegion - OS check

        #Region - Declare constants
        ;#cs
        ;use include global constants or local constant magic numbers if includes not available
        If Not IsDeclared("TB_GETBUTTON") Then Assign("TB_GETBUTTON", 0x417, 1)
        If Not IsDeclared("TB_BUTTONCOUNT") Then Assign("TB_BUTTONCOUNT", 0x418, 1)
        If Not IsDeclared("PROCESS_VM_OPERATION") Then Assign("PROCESS_VM_OPERATION", 0x00000008, 1)
        If Not IsDeclared("PROCESS_VM_READ") Then Assign("PROCESS_VM_READ", 0x00000010, 1)
        If Not IsDeclared("MEM_COMMIT") Then Assign("MEM_COMMIT", 0x00001000, 1)
        If Not IsDeclared("MEM_RELEASE") Then Assign("MEM_RELEASE", 0x00008000, 1)
        If Not IsDeclared("PAGE_READWRITE") Then Assign("PAGE_READWRITE", 0x00000004, 1)
        If Not IsDeclared("ERROR_ALREADY_EXISTS") Then Assign("ERROR_ALREADY_EXISTS", 183, 1);winerror.h
        If Not IsDeclared("NIM_DELETE") Then Assign("NIM_DELETE", 0x2, 1) ;shellapi.h

        ;we are told 'Eval() is Evil', so is Execute() NOT Cute?
        Local Const $RefreshTray_TB_GETBUTTON = Execute("$TB_GETBUTTON")
        If @error Or IsInt($RefreshTray_TB_GETBUTTON) = 0 Or _
                        StringLen($RefreshTray_TB_GETBUTTON) = 0 Then Return SetError(2, 1, -1)
        Local Const $RefreshTray_TB_BUTTONCOUNT = Execute("$TB_BUTTONCOUNT")
        If @error Or IsInt($RefreshTray_TB_BUTTONCOUNT) = 0 Or _
                        StringLen($RefreshTray_TB_BUTTONCOUNT) = 0 Then Return SetError(2, 2, -1)
       
        Local $iTemp1 = Execute("$PROCESS_VM_OPERATION")
        If @error Or IsInt($iTemp1) = 0 Or StringLen($iTemp1) = 0 Then Return SetError(2, 3, -1)
        Local $iTemp2 = Execute("$PROCESS_VM_READ")
        If @error Or IsInt($iTemp2) = 0 Or StringLen($iTemp2) = 0 Then Return SetError(2, 4, -1)
        Local Const $RefreshTray_PROCESS_ACCESS = BitOR($iTemp1, $iTemp2)
        If @error Or StringLen($RefreshTray_PROCESS_ACCESS) = 0 Then Return SetError(2, 5, -1)
       
        Local Const $RefreshTray_MEM_COMMIT = Execute("$MEM_COMMIT")
        If @error Or IsInt($RefreshTray_MEM_COMMIT) = 0 Or _
                        StringLen($RefreshTray_MEM_COMMIT) = 0 Then Return SetError(2, 6, -1)
        Local Const $RefreshTray_MEM_RELEASE = Execute("$MEM_RELEASE")
        If @error Or IsInt($RefreshTray_MEM_RELEASE) = 0 Or _
                        StringLen($RefreshTray_MEM_RELEASE) = 0 Then Return SetError(2, 7, -1)
        Local Const $RefreshTray_PAGE_READWRITE = Execute("$PAGE_READWRITE")
        If @error Or IsInt($RefreshTray_PAGE_READWRITE) = 0 Or _
                        StringLen($RefreshTray_PAGE_READWRITE) = 0 Then Return SetError(2, 8, -1)
       
        ;not declared in AutoIt includes as of v3.3.0.0
        Local Const $RefreshTray_ERROR_ALREADY_EXISTS = Execute("$ERROR_ALREADY_EXISTS")
        If @error Or IsInt($RefreshTray_ERROR_ALREADY_EXISTS) = 0 Or _
                        StringLen($RefreshTray_ERROR_ALREADY_EXISTS) = 0 Then Return SetError(2, 9, -1)
        Local Const $RefreshTray_NIM_DELETE = Execute("$NIM_DELETE")
        If @error Or IsInt($RefreshTray_NIM_DELETE) = 0 Or _
                        StringLen($RefreshTray_NIM_DELETE) = 0 Then Return SetError(2, 10, -1)
        ;#ce
        #EndRegion - Declare constants

        #Region - Declare variables
        Local $hOwnerWin, $i_uID, $aRet, $iRet, $iButtonCount = 0, $hTrayWnd, $hTrayNotifyWnd, _
                        $hSysPager, $hToolbar, $iCount, $sRes, $iDLLUser32, $iDLLKrnl32, $iDLLShll32, _
                        $tTBBUTTON, $pTBBUTTON, $iTBBUTTON, $tTRAYDATA, $pTRAYDATA, $iTRAYDATA, _
                        $iProcessID, $hProcess, $pAddress, $iReturnError = 0, $iExtended = 0, $iLastError, $hMutex
        #EndRegion - Declare variables

        #Region - Get tray window handles - Shell_TrayWnd/TrayNotifyWnd/SysPager/ToolbarWindow32
        ;get Shell_TrayWnd handle
        $hTrayWnd = WinGetHandle("[CLASS:Shell_TrayWnd]") ; FindWindow
        If @error Or IsHWnd($hTrayWnd) = 0 Then Return SetError(3, 1, -1)
       
        ;get TrayNotifyWnd handle
        $hTrayNotifyWnd = ControlGetHandle($hTrayWnd, "", "[CLASS:TrayNotifyWnd]") ;FindWindowEx
        If @error Or IsHWnd($hTrayNotifyWnd) = 0 Then Return SetError(3, 2, -1)

        ;get SysPager handle
        If @OSVersion == "WIN_2000" Then
                $hSysPager = $hTrayNotifyWnd
        Else
                $hSysPager = ControlGetHandle($hTrayNotifyWnd, "", "[CLASS:SysPager]");FindWindowEx
                If @error Or IsHWnd($hSysPager) = 0 Then Return SetError(3, 3, -1)
        EndIf
       
        ;get tray notification area toolbar handle
        ;tray buttons split into two toolbars in Vista :
        ;Notification Area (ToolbarWindow321) and System Control Area (ToolbarWindow322)
        $hToolbar = ControlGetHandle($hSysPager, "", "[CLASS:ToolbarWindow32; INSTANCE:1]");FindWindowEx
        If @error Or IsHWnd($hToolbar) = 0 Then Return SetError(3, 4, -1)
        #EndRegion - Get tray window handles - Shell_TrayWnd/TrayNotifyWnd/SysPager/ToolbarWindow32

        #Region - Create Notification Area toolbar button structs TBBUTTON, TRAYDATA and NOTIFYICONDATA
        $sRes = "byte bReserved[2]"
        ;64 bit OS support (unfinished, unresearched and untested)
        If Number(StringRight(@OSArch, 2)) = 64 Then $sRes = "byte bReserved[6]"
        ;TBBUTTON struct
        Local Const $tag_TBBUTTON = "int iBitmap;int idCommand;byte fsState;byte fsStyle;" & _
                        $sRes & ";ulong_ptr dwData;int_ptr iString"
        $tTBBUTTON = DllStructCreate($tag_TBBUTTON)
        If @error Or IsDllStruct($tTBBUTTON) = 0 Then Return SetError(4, 1, -1)
        $pTBBUTTON = DllStructGetPtr($tTBBUTTON)
        If @error Or IsPtr($pTBBUTTON) = 0 Then Return SetError(4, 2, -1)
        $iTBBUTTON = DllStructGetSize($tTBBUTTON)
        If @error Or $iTBBUTTON = 0 Then Return SetError(4, 3, -1)

        ;TRAYDATA struct (undocumented)
        Local Const $tag_TRAYDATA = "hwnd hwnd;uint uID;uint uCallbackMessage;dword Reserved[2];ptr hIcon"
        $tTRAYDATA = DllStructCreate($tag_TRAYDATA)
        If @error Or IsDllStruct($tTRAYDATA) = 0 Then Return SetError(4, 4, -1)
        $pTRAYDATA = DllStructGetPtr($tTRAYDATA)
        If @error Or IsPtr($pTRAYDATA) = 0 Then Return SetError(4, 5, -1)
        $iTRAYDATA = DllStructGetSize($tTRAYDATA)
        If @error Or $iTRAYDATA = 0 Then Return SetError(4, 6, -1)
       
        ;NOTIFYICONDATA struct
        Local $tagNOTIFYICONDATA = "dword cbSize;hwnd hWnd;uint uID;uint uFlags;" & _
                        "uint uCallbackMessage;ptr hIcon;wchar szTip[128];dword dwState;dword dwStateMask;" & _
                        "wchar szInfo[256];uint uTimeout;wchar szInfoTitle[64];dword dwInfoFlags"
        Switch @OSVersion
                Case "WIN_XP" ;GUID
                        $tagNOTIFYICONDATA &= ";int Data1;short Data2;short Data3;byte Data4[8]"
                Case "WIN_VISTA" ;GUID and balloon tip icon
                        $tagNOTIFYICONDATA &= ";int Data1;short Data2;short Data3;byte Data4[8];ptr hBalloonIcon"
        EndSwitch

        Local $tNOTIFYICONDATA = DllStructCreate($tagNOTIFYICONDATA)
        If @error Or IsDllStruct($tNOTIFYICONDATA) = 0 Then Return SetError(4, 7, -1)
        Local $pNOTIFYICONDATA = DllStructGetPtr($tNOTIFYICONDATA)
        If @error Or IsPtr($pNOTIFYICONDATA) = 0 Then Return SetError(4, 8, -1)
        Local $iNOTIFYICONDATA = DllStructGetSize($tNOTIFYICONDATA)
        If @error Or $iNOTIFYICONDATA = 0 Then Return SetError(4, 9, -1)
        $iRet = DllStructSetData($tNOTIFYICONDATA, "cbSize", $iNOTIFYICONDATA)
        If @error Or $iRet <> $iNOTIFYICONDATA Then Return SetError(4, 10, -1)
       
        #EndRegion - Create Notification Area toolbar button structs TBBUTTON, TRAYDATA and NOTIFYICONDATA

        #Region - Open handles to user32.dll and kernel32.dll
        $iDLLUser32 = DllOpen("user32.dll")
        If @error Or $iDLLUser32 = -1 Then Return SetError(5, 1, -1)
        $iDLLKrnl32 = DllOpen("kernel32.dll")
        If @error Or $iDLLKrnl32 = -1 Then Return SetError(5, 2, -1)
        #EndRegion - Open handles to user32.dll and kernel32.dll

        #Region - Single instance check - (_Singleton)
        ;this function could be called from a script, and we need to close the mutex handle on return
        ;so by placing instance check here, fewer close mutex handle calls are needed on return from error
        $aRet = DllCall($iDLLKrnl32, "ptr", "CreateMutexW", "int", 0, "long", 1, "wstr", "RefreshTrayIcons2357")
        If @error Or UBound($aRet) <> 4 Or $aRet[0] = 0 Then
                DllClose($iDLLUser32)
                DllClose($iDLLKrnl32)
                Return SetError(6, 1, -1)
        EndIf
        $hMutex = $aRet[0]
       
        $aRet = DllCall($iDLLKrnl32, "int", "GetLastError")
        If @error Or UBound($aRet) <> 1 Then
                DllCall($iDLLKrnl32, "int", "CloseHandle", "ptr", $hMutex)
                DllClose($iDLLUser32)
                DllClose($iDLLKrnl32)
                Return SetError(6, 2, -1)
        EndIf
        $iLastError = $aRet[0]
       
        ;instance of program already running
        If $iLastError = $RefreshTray_ERROR_ALREADY_EXISTS Then
                ConsoleWrite("! CreateMutex - GetLastError: " & $iLastError & @CRLF)
                DllCall($iDLLKrnl32, "int", "CloseHandle", "ptr", $hMutex)
                DllClose($iDLLUser32)
                DllClose($iDLLKrnl32)
                Return SetError($iLastError, $iLastError, -1)
        EndIf

        #EndRegion - Single instance check - (_Singleton)

        #Region - Get explorer.exe process ID/handle, allocate memory, get toolbar button count
        ;get explorer.exe process ID
        $aRet = DllCall($iDLLUser32, "int", "GetWindowThreadProcessId", "hwnd", $hToolbar, "int*", -1)
        If @error Or UBound($aRet) <> 3 Or $aRet[2] <= 0 Then
                DllCall($iDLLKrnl32, "int", "CloseHandle", "ptr", $hMutex)
                DllClose($iDLLUser32)
                DllClose($iDLLKrnl32)
                Return SetError(6, 3, -1)
        EndIf
        $iProcessID = $aRet[2]

        ;get handle to explorer process
        $aRet = DllCall($iDLLKrnl32, "ptr", "OpenProcess", "dword", _
                        $RefreshTray_PROCESS_ACCESS, "int", 0, "int", $iProcessID)
        If @error Or UBound($aRet) <> 4 Or $aRet[0] = 0 Then
                DllCall($iDLLKrnl32, "int", "CloseHandle", "ptr", $hMutex)
                DllClose($iDLLUser32)
                DllClose($iDLLKrnl32)
                Return SetError(6, 4, -1)
        EndIf
        $hProcess = $aRet[0]
       
        ;get tray toolbar button count (visible and hidden inactive)
        $aRet = DllCall($iDLLUser32, "lparam", "SendMessage", "hwnd", _
                        $hToolbar, "int", $RefreshTray_TB_BUTTONCOUNT, "wparam", 0, "lparam", 0)
        If @error Or UBound($aRet) <> 5 Or $aRet[0] < 1 Then
                DllCall($iDLLKrnl32, "int", "CloseHandle", "ptr", $hProcess)
                DllCall($iDLLKrnl32, "int", "CloseHandle", "ptr", $hMutex)
                DllClose($iDLLUser32)
                DllClose($iDLLKrnl32)
                Return SetError(6, 5, -1)
        EndIf
        $iCount = $aRet[0] - 1
       
        ;allocate memory in explorer memspace
        $aRet = DllCall($iDLLKrnl32, "ptr", "VirtualAllocEx", "ptr", $hProcess, "ptr", 0, "int", _
                        $iTBBUTTON, "dword", $RefreshTray_MEM_COMMIT, "dword", $RefreshTray_PAGE_READWRITE)
        If @error Or UBound($aRet) <> 6 Or $aRet[0] = 0 Then
                DllCall($iDLLKrnl32, "int", "CloseHandle", "ptr", $hProcess)
                DllCall($iDLLKrnl32, "int", "CloseHandle", "ptr", $hMutex)
                DllClose($iDLLUser32)
                DllClose($iDLLKrnl32)
                Return SetError(6, 6, -1)
        EndIf
        $pAddress = $aRet[0]
       
        ;open shell32 dll handle for Shell_NotifyIconW API in loop
        $iDLLShll32 = DllOpen("shell32.dll")
        If @error Or $iDLLShll32 = -1 Then Return SetError(5, 3, -1)
       
        #EndRegion - Get explorer.exe process ID/handle, allocate memory, get toolbar button count

        #Region - Loop through toolbar buttons and check if owner window/process exists
        For $iID = $iCount To 0 Step -1
               
                ;check if toolbar exists (explorer crash)
                If IsHWnd($hToolbar) = 0 Then
                        $iReturnError = -1
                        ExitLoop
                EndIf

                ;fill explorer process allocated memory with TBBUTTON struct data
                ;for zero-based toolbar button index
                $aRet = DllCall($iDLLUser32, "lparam", "SendMessage", "hwnd", $hToolbar, _
                                "int", $RefreshTray_TB_GETBUTTON, "wparam", $iID, "lparam", $pAddress)
                If @error Or UBound($aRet) <> 5 Or $aRet[0] <> 1 Then
                        $iReturnError = BitOR($iReturnError, 2)
                        ContinueLoop
                EndIf

                ;read TBBUTTON struct data from explorer process memory into TBBUTTON struct
                $aRet = DllCall($iDLLKrnl32, "int", "ReadProcessMemory", "ptr", $hProcess, _
                                "ptr", $pAddress, "ptr", $pTBBUTTON, "int", $iTBBUTTON, "int*", -1)
                If @error Or UBound($aRet) <> 6 Or $aRet[5] <> $iTBBUTTON Then
                        $iReturnError = BitOR($iReturnError, 4)
                        ContinueLoop
                EndIf
               
                ;use extra data pointer to read TRAYDATA struct in explorer process memory
                ;into TRAYDATA struct
                $aRet = DllCall($iDLLKrnl32, "int", "ReadProcessMemory", "ptr", $hProcess, _
                                "ulong_ptr", DllStructGetData($tTBBUTTON, "dwData"), _
                                "ptr", $pTRAYDATA, "int", $iTRAYDATA, "int*", -1)
                If @error Or UBound($aRet) <> 6 Or $aRet[5] <> $iTRAYDATA Then
                        $iReturnError = BitOR($iReturnError, 8)
                        ContinueLoop
                EndIf

                ;get button/icon owner window handle from TRAYDATA struct
                $hOwnerWin = DllStructGetData($tTRAYDATA, 1)
                If @error Or $hOwnerWin = 0 Then
                        $iReturnError = BitOR($iReturnError, 16)
                        ContinueLoop
                EndIf
               
                ;get button/icon owner window application defined identifier from TRAYDATA struct
                $i_uID = DllStructGetData($tTRAYDATA, 2)
                If @error Or $i_uID < 0 Then
                        $iReturnError = BitOR($iReturnError, 32)
                        ContinueLoop
                EndIf

                ;ConsoleWrite('+$i_uID = ' & $i_uID & @crlf) ;debug only, Consolewrites() slow loops
               
                ;get owner process PID for associated tray button/icon handle, continue loop if process exists
                $aRet = DllCall($iDLLUser32, "int", "GetWindowThreadProcessId", "hwnd", $hOwnerWin, "int*", -1)
                If @error Or UBound($aRet) <> 3 Or $aRet[2] = -1 Then
                        ;second check: continue loop if data is not pointer or is pointer and a valid window handle
                        If IsPtr($hOwnerWin) = 0 Or IsHWnd($hOwnerWin) = 1 Then ContinueLoop
                Else
                        ContinueLoop
                EndIf
               
                ;set NOTIFYICONDATA struct hWnd element to button/icon owner window
                $iRet = DllStructSetData($tNOTIFYICONDATA, "hWnd", $hOwnerWin)
                If @error Or IsPtr($iRet) = 0 Then
                        $iReturnError = BitOR($iReturnError, 64)
                        ContinueLoop
                EndIf
               
                ;set NOTIFYICONDATA struct uID element to button/icon application identifier
                $iRet = DllStructSetData($tNOTIFYICONDATA, "uID", $i_uID)
                If @error Or $iRet <> $i_uID Then
                        $iReturnError = BitOR($iReturnError, 128)
                        ContinueLoop
                EndIf

                ;remove orphaned button/icon from toolbar
                ;requires matching handle and application defined identifier set to delete button
                ;Note: some icons have a uID value of 0 or 1.
                ;The value set depends on app developer, view $i_uID with ConsoleWrite()
                ;e.g. 4 hidden explorer icons in XP have uID range 4294967292-4294967295
                $aRet = DllCall($iDLLShll32, "int", "Shell_NotifyIconW", "dword", _
                                $RefreshTray_NIM_DELETE, "ptr", $pNOTIFYICONDATA)
                If @error Or UBound($aRet) <> 3 Or $aRet[0] <> 1 Then
                        $iReturnError = BitOR($iReturnError, 256)
                Else
                        $iButtonCount += $aRet[0]
                EndIf
               
        Next
        #EndRegion - Loop through toolbar buttons and check if owner window/process exists

        #Region - Cleanup: check button count, free memory, close process/mutex/DLL handles
        ;set @extended to button count verify error
        ;get tray toolbar button count (visible and hidden inactive)
        ;can only report number of buttons deleted, not if orphaned buttons missed in loop due to errors
        If $iReturnError <> -1 Then ; bypass button count if explorer tray toolbar handle invalid
                $aRet = DllCall($iDLLUser32, "lparam", "SendMessage", "hwnd", _
                                $hToolbar, "int", $RefreshTray_TB_BUTTONCOUNT, "wparam", 0, "lparam", 0)
                If @error = 0 And UBound($aRet) = 5 And $aRet[0] >= 1 Then
                        If ($iCount + 1) = ($aRet[0] + $iButtonCount) Then
                                ;current button count + deleted count equal to previous button count
                                $iExtended = 0
                        Else
                                ;current button count and deleted count not equal to previous button count
                                ;either returned deleted button count incorrect due to loop error or
                                ;buttons added or deleted by other processes before function returned
                                $iExtended = -1
                        EndIf
                Else
                        ;cannot verify deleted button count
                        $iExtended = -2
                EndIf
        Else
                $iExtended = -1
        EndIf

        ;deallocate the memory and close process/mutex handles
        $aRet = DllCall($iDLLKrnl32, "int", "VirtualFreeEx", "ptr", $hProcess, "ptr", _
                        $pAddress, "int", 0, "dword", $RefreshTray_MEM_RELEASE)
        If @error Or UBound($aRet) <> 5 Or $aRet[0] = 0 Then $iReturnError = BitOR($iReturnError, 512)

        $aRet = DllCall($iDLLKrnl32, "int", "CloseHandle", "ptr", $hProcess)
        If @error Or UBound($aRet) <> 2 Or $aRet[0] = 0 Then $iReturnError = BitOR($iReturnError, 1024)

        $aRet = DllCall($iDLLKrnl32, "int", "CloseHandle", "ptr", $hMutex)
        If @error Or UBound($aRet) <> 2 Or $aRet[0] <> 1 Then $iReturnError = BitOR($iReturnError, 2048)
       
        ;close open DLL handles
        DllClose($iDLLShll32)
        DllClose($iDLLUser32)
        DllClose($iDLLKrnl32)
        #EndRegion - Cleanup: check button count, free memory, close process/mutex/DLL handles

        Return SetError($iReturnError, $iExtended, $iButtonCount)
EndFunc

Источник

Iska 31-10-2009 19:05 1257686

Я бы предпочёл так:
Код:

AutoItSetOption("MustDeclareVars", 1)

; Получаем список окон скриптов AutoIt
Local $arrWinList = WinList("[CLASS:AutoIt v3;TITLE:AutoIt v3]")
Local $i, $strHwnd

; Перебираем их все
For $i = 1 to $arrWinList[0][0]
        ; Строим хэндл очередного окна
        $strHwnd = "[HANDLE:" & Hex($arrWinList[$i][1]) & "]"
       
        ; Если это окно не текущего процесса…
        If WinGetProcess($strHwnd) <> @AutoItPID Then
                ; Пробуем закрыть его
                WinClose($strHwnd)
        EndIf
Next


evg64 01-11-2009 12:22 1258155

Цитата:

Цитата Creat0R
Вообще то есть метод “поэлегантнее” »

Ого-го какие на офф форуме штуки выкладывают! :)
Размер функции - не проблема. Главное, что не тормозит даже несмотря на величину кода.

HukpoFuJl 26-04-2012 17:26 1906301

Очень древнюю тему поднимаю, но раз она выпадает первой в гугле по запросу "autoit скрыть иконку", то выложу и свой вариант решения, который компактнее представленных сдесь :)

PHP код:

#NoTrayIcon
#include <SysTray_UDF.au3>
Local $a1$a2

While 1
    $a1 
_SysTrayIconPids()
    
$a2 _SysTrayIconProcesses()
    For 
$i 0 To UBound($a1)-1
        
If $a1[$i] = -And $a2[$i] = "" Then
            _SysTrayIconRemove
($i)
            
Opt('TrayIconHide'0)
            
Opt('TrayIconHide'1)
        EndIf
    
Next
    Sleep
(3000)
WEnd 

SysTray_UDF.au3
Источник: autoit-script.ru



PS: Ответ на вопрос, который я гуглил тоже тут
PHP код:

Opt('TrayIconHide'0и Opt('TrayIconHide'1

PPS: Тег PHP забавно разукрашивает AutoIT код :)

SharkyEXE 27-03-2021 11:58 2954058

Всем здравствуйте

В трее есть значок программы AnyDesk

Если на него навести мышкой - ничего не показывается, мол, названия нету сверху этого значка

В сети нашел скрипт
https://www.autoitscript.com/forum/t...comment=493850
Скрытый текст
Код:

#Include <GuiToolBar.au3>

HotKeySet("{ESC}", "_Quit")

Opt("WinTitleMatchMode", 4)
Global $hTray = WinGetHandle("[CLASS:Shell_TrayWnd]")
Global $hToolbar = ControlGetHandle($hTray, "", "[CLASSNN:ToolbarWindow321]")
Global $iCnt = _GUICtrlToolbar_ButtonCount($hToolbar)
ConsoleWrite("Debug: $iCnt = " & $iCnt & @LF)
Global $iCmdVolume = -1
Global $sMsg, $sText, $iCmd
For $n = 0 To $iCnt - 1
    $sMsg = "Index: " & $n
    $iCmd = _GUICtrlToolbar_IndexToCommand($hToolbar, $n)
    $sMsg &= "  CommandID: " & $iCmd
    $sText = _GUICtrlToolbar_GetButtonText($hToolbar, $iCmd)
    If StringInStr($sText, "Volume") Then $iCmdVolume = $iCmd
    $sMsg &= "  Text: " & $sText
    ConsoleWrite("Debug: " & $sMsg & @LF)
Next
ConsoleWrite("Debug: $iCmdVolume = " & $iCmdVolume & @LF)

Global $bolVisible = True
While 1
    $bolVisible = Not $bolVisible
    If $bolVisible Then
        _GUICtrlToolbar_SetButtonState($hToolbar, $iCmdVolume, $TBSTATE_ENABLED)
    Else
        _GUICtrlToolbar_SetButtonState($hToolbar, $iCmdVolume, $TBSTATE_HIDDEN)
    EndIf
    Sleep(1000)
WEnd

Func _Quit()
    _GUICtrlToolbar_SetButtonState($hToolbar, $iCmdVolume, $TBSTATE_ENABLED)
    Exit
EndFunc

Этот скрипт отдает вот что
Цитата:

Debug: $iCnt = 3
Debug: Index: 0 CommandID: 2 Text:
Debug: Index: 1 CommandID: 1 Text: KeePass
Debug: Index: 2 CommandID: 0 Text: Динамики: 10%
Debug: $iCmdVolume = 1
Я Вас очень прошу, помогите скрыть в трее значок программы AnyDesk

Картинка

Спасибо.

Iska 27-03-2021 12:38 2954064

Цитата:

Цитата SharkyEXE
Если на него навести мышкой - ничего не показывается, мол, названия нету сверху этого значка »

У меня — показывается:


SharkyEXE 27-03-2021 13:04 2954068

Iska

Здравствуйте

Да я как бы могу ошибаться, у меня самая простая версия, тут как бы убрать, скрыть значок в трее :-)

При этом, есть такие как я, где на старой простой версии нету сверху значка никаких надписей, и хочется как бы убрать, скрыть значок в трее

Iska 27-03-2021 14:35 2954072

SharkyEXE, он убирается стандартным способом. У Вас же не Windows 2000?

Это я перфекционист, потому всегда отображаю все значки.

SharkyEXE 27-03-2021 14:49 2954074

Iska

Я имею ввиду, чтобы в трее вообще не показывался значок, не было значка в трее, а не просто скрыть его

Пока ковыряю это

Код:

# https://www.autoitscript.com/forum/topic/133523-solved-enough-hide-tray-icon-with-empty-title-of-program-i-shellexecute/?do=findComment&comment=930677

#Include <GuiToolBar.au3>
Global $params[100]
Global $paramcount=0
Global $p
Func FindBlankTrayIcons($musthide=False)
Local $hSysTray = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
;Msgbox (0,"toolbar",$hToolbar )
For $n = 0 To _GUICtrlToolbar_ButtonCount($hSysTray) - 1
  Local $iCmd = _GUICtrlToolbar_IndexToCommand($hSysTray, $n)
  Local $sText = _GUICtrlToolbar_GetButtonText($hSysTray, $iCmd)
  Local $visible= _GUICtrlToolbar_GetButtonState($hSysTray, $iCmd)==$TBSTATE_ENABLED
  If ($sText=='') Then
  _GUICtrlToolbar_SetButtonState($hSysTray, $iCmd, $TBSTATE_HIDDEN)
  EndIf
Next
EndFunc

Но работает нестабильно, хочется наверняка

Iska 27-03-2021 14:54 2954076

Цитата:

Цитата SharkyEXE
Я имею ввиду, чтобы в трее вообще не показывался значок, не было значка в трее, а не просто скрыть его »

А… Ясно.

yurfed 27-03-2021 15:29 2954078

Цитата:

Цитата SharkyEXE
Но работает нестабильно, хочется наверняка »

Я не совсем вьехал,
Цитата:

Цитата SharkyEXE
чтобы в трее вообще не показывался значок, не было значка в трее, а не просто скрыть его »

Уже средств самой Винды не хватает?
Панель управления\Все элементы панели управления\Значки области уведомлений.

Там и выберай что хочешь и не хочешь видеть.

Iska 27-03-2021 15:54 2954081

yurfed, не хватает. Ибо коллега SharkyEXE хочет вообще удалить оттуда значок, а не просто скрыть его.

yurfed 27-03-2021 16:31 2954086

Цитата:

Цитата SharkyEXE
При этом, есть такие как я, где на старой простой версии нету сверху значка никаких надписей, и хочется как бы убрать, скрыть значок в трее »

Извините, но вы такм что, колбасите по всем значкам и читаете надписи?
Очень глупая хотелка.

SharkyEXE 29-03-2021 10:43 2954234

yurfed

Здравствуйте

Просьба отнестись с пониманием, мне очень хочется, чтобы после запуска скрипта значок в трее - справа от языка клавиатуры или в скрытом меню-выпадающем списке (две стрелочки вверх) - пропал

Есть желание, найти возможность - помогите, нет и нет - я не хочу и нет желания заставить

Спасибо.

kokos76 04-05-2021 18:23 2957037

SharkyEXE, в этом коде https://autoit-script.ru/threads/kak...26/#post-89268 подправил одну цифру по этому примеру https://autoit-script.ru/threads/okn...9/#post-155314 (там же читать и предыдущий пост с вопросом) и он заработал на 10-ке
Код:


#include <GuiToolBar.au3>

$hWnd = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:3]')

For $i = 1 To _GUICtrlToolbar_ButtonCount($hWnd)
        $iCommandID = _GUICtrlToolbar_IndexToCommand($hWnd, $i)
        If StringInStr(_GUICtrlToolbar_GetButtonText($hWnd, $iCommandID), 'DeskPins') Then ; по подстроке в тексте иконки               
                _GUICtrlToolbar_DeleteButton($hWnd, $iCommandID)
                Opt('TrayIconHide', 1)
                Opt('TrayIconHide', 0)
                ExitLoop
        EndIf
Next

P.S. Работает только на видимой иконке. Буду копать дальше. Как временное решение, можно в Винде настроить подлежащую скрытию иконку, чтоб была всегда видима. Тогда она скроется этим кодом.

SharkyEXE 03-07-2021 09:18 2961337

Всем здравствуйте

Прошу прощения, возвращаясь к моему пожеланию http://forum.oszone.net/post-2954058-7.html

Неужели вокзал, неужели это невыполнимая задача - скрыть/удалить значок?

Спасибо.

alexei.bat 02-10-2022 20:42 2993486

Код описанный выше от kokos76 срабатывает не всегда у меня с прогой Google Chrome, при этом другие проги значки удаляет. Поэтому вот решение https://autoit-script.ru/threads/skr...22/post-157817


Время: 19:25.

Время: 19:25.
© OSzone.net 2001-