Jump to content

Is it possible to hide tray icons with AutoIt?


Recommended Posts

TraySetState(2)

That only affects the AutoIt script's tray icon, not another app's.

The desktop is just another window, and the system tray is just another control. Use AU3Info.exe to check them out. The controls there can be hidden/deleted/etc. just like any other.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

TraySetState(2)

As PsaltyDS said, this is only for AutoIt's icon.

The desktop is just another window, and the system tray is just another control. Use AU3Info.exe to check them out. The controls there can be hidden/deleted/etc. just like any other.

I actually checked it out before I posted. Under XP (not sure about other versions of windows), the entire tray/"Notification Area" is one ToolbarWindow32 control. I don't want to hide the entire tray area...

Perhaps it's a matter of a Windows API call? I don't know my WinAPI very well at all, but I'll look into it. In the meantime, any help would be appreciated!

Edited by phaze424
Link to comment
Share on other sites

That only affects the AutoIt script's tray icon, not another app's.

The desktop is just another window, and the system tray is just another control. Use AU3Info.exe to check them out. The controls there can be hidden/deleted/etc. just like any other.

:)

Does that actually work? Every time I've tried it just failed. I always use tuape's SYSTRAY UDF:

http://www.autoitscript.com/forum/index.ph...;hl=systray+udf

Works a dream :)

Link to comment
Share on other sites

As PsaltyDS said, this is only for AutoIt's icon.

I actually checked it out before I posted. Under XP (not sure about other versions of windows), the entire tray/"Notification Area" is one ToolbarWindow32 control. I don't want to hide the entire tray area...

Perhaps it's a matter of a Windows API call? I don't know my WinAPI very well at all, but I'll look into it. In the meantime, any help would be appreciated!

Look at the toolbar UDF commands. This demo hides/enables the Volume icon in my sytem tray:

#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

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Does that actually work? Every time I've tried it just failed. I always use tuape's SYSTRAY UDF:

http://www.autoitscript.com/forum/index.ph...;hl=systray+udf

Works a dream :)

Look at the toolbar UDF commands. This demo hides/enables the Volume icon in my sytem tray:

#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

:)

Thanks! I didn't even know about these UDFs. This should work well for my purposes.

Edited by phaze424
Link to comment
Share on other sites

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