Jump to content

Winxp remove a program's taskbar tray icon


jack71
 Share

Go to solution Solved by jack71,

Recommended Posts

So I'm writing a script that makes a notepad window ontop, however it can still be minimized via clicking on the notepad taskbar tray icon, which I don't want the user to be able to.

I've found that this works great for Vista/7/8.1:

Local Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}"
Local Const $sIID_ITaskbarList = "{56FDF342-FD6D-11D0-958A-006097C9A090}"
Local Const $sTagITaskbarList = "HrInit hresult(); AddTab hresult(hwnd); DeleteTab hresult(hwnd); ActivateTab hresult(hwnd); SetActiveAlt hresult(hwnd);"
Local $oTaskbarList = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList, $sTagITaskbarList)
$oTaskbarList.DeleteTab($windowhandle)
 
However on winxp sp3, this doesn't work to remove the taskbar tray icon.  Are the first two constants not correct for winxp machines?
 
Thanks.
Edited by jack71
Link to comment
Share on other sites

  • Moderators

So taskbar tab windows.  Tray is completely different.

Try using ... was going to write code, but remembered someone did something before that I know should work on XP too.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

So taskbar tab windows.  Tray is completely different.

Try using ... was going to write code, but remembered someone did something before that I know should work on XP too.

 

Hmm... that's not working on win 8.1.  

Also just to clarify even further:

TaskBow5.jpg?e65bc4

I am talking about the "Untitled - Notepad" on the taskbar, next to the pinned chrome and IE icons.

Link to comment
Share on other sites

  • Moderators

Yes, those are taskbar tabs.

You said you needed an XP solution, not a windows 8 solution.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Yes, those are taskbar tabs.

You said you needed an XP solution, not a windows 8 solution.

 

I need cross platform :).  I have several machines that have WinXP sp3, Win7 and Win8.1.  I guess I can do an OS check and proceed from there.  Was hoping there was one solution for all 3 :).

Link to comment
Share on other sites

  • Moderators

Yes, I figured as much... Yes, check the OS with a switch or if/then statement.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Both of this example work on XP and 7

Without ObjCreateInterface

; Johnmcloud - 2015
Run(@WindowsDir & "\notepad.exe", "", @SW_HIDE)
$hNotepad = WinWait("[CLASS:Notepad]")

_TaskbarTab($hNotepad, 0)
MsgBox(4096, "", "Look in the Taskbar.  There should no longer be a Notepad entry but Notepad is still running." & @CRLF & @CRLF & "Press OK to continue.")
Sleep(1000)
_TaskbarTab($hNotepad, 1)
MsgBox(4096, "", "Look in the Taskbar and you should see an entry for Notepad." & @CRLF & @CRLF & "Press OK to continue.")
WinClose($hNotepad)

Func _TaskbarTab($hWnd, $iVisible)
    Local $hParent = WinGetHandle("[CLASS:Progman]")
    If $iVisible = 0 Then
        DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $hParent)
        WinActivate($hWnd, "")
        WinSetState($hWnd, "", @SW_SHOW)
    ElseIf $iVisible = 1 Then
        DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", "")
    EndIf
EndFunc   ;==>_TaskbarTab

With ObjCreateInterface

; Declare the CLSID, IID and interface description for ITaskbarList.
; It is not necessary to describe the members of IUnknown.
Local Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}"
Local Const $sIID_ITaskbarList = "{56FDF342-FD6D-11D0-958A-006097C9A090}"
Local Const $sTagITaskbarList = "HrInit hresult(); AddTab hresult(hwnd); DeleteTab hresult(hwnd); ActivateTab hresult(hwnd); SetActiveAlt hresult(hwnd);"
; Create the object.
Local $oTaskbarList = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList, $sTagITaskbarList)
; Initialize the iTaskbarList object.
$oTaskbarList.HrInit()
; Run Notepad.
Run("notepad.exe")
; Wait for the Notepad window to appear and get a handle to it.
Local $hNotepad = WinWait("[CLASS:Notepad]")
; Tell the user what to look for.
MsgBox(4096, "", "Look in the Taskbar and you should see an entry for Notepad." & @CRLF & @CRLF & "Press OK to continue.")
; Delete the Notepad entry from the Taskbar.
$oTaskbarList.DeleteTab($hNotepad)
; Tell the user to look again.
MsgBox(4096, "", "Look in the Taskbar.  There should no longer be a Notepad entry but Notepad is still running." & @CRLF & @CRLF & "Press OK to continue.")
; Close Notepad.
WinClose($hNotepad)
Edited by johnmcloud
Link to comment
Share on other sites

 

Both of this example work on XP and 7

Without ObjCreateInterface

; Johnmcloud - 2015
Run(@WindowsDir & "\notepad.exe", "", @SW_HIDE)
$hNotepad = WinWait("[CLASS:Notepad]")

_TaskbarTab($hNotepad, 0)
MsgBox(4096, "", "Look in the Taskbar.  There should no longer be a Notepad entry but Notepad is still running." & @CRLF & @CRLF & "Press OK to continue.")
Sleep(1000)
_TaskbarTab($hNotepad, 1)
MsgBox(4096, "", "Look in the Taskbar and you should see an entry for Notepad." & @CRLF & @CRLF & "Press OK to continue.")
WinClose($hNotepad)

Func _TaskbarTab($hWnd, $iVisible)
    Local $hParent = WinGetHandle("[CLASS:Progman]")
    If $iVisible = 0 Then
        DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $hParent)
        WinActivate($hWnd, "")
        WinSetState($hWnd, "", @SW_SHOW)
    ElseIf $iVisible = 1 Then
        DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", "")
    EndIf
EndFunc   ;==>_TaskbarTab

With ObjCreateInterface

; Declare the CLSID, IID and interface description for ITaskbarList.
; It is not necessary to describe the members of IUnknown.
Local Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}"
Local Const $sIID_ITaskbarList = "{56FDF342-FD6D-11D0-958A-006097C9A090}"
Local Const $sTagITaskbarList = "HrInit hresult(); AddTab hresult(hwnd); DeleteTab hresult(hwnd); ActivateTab hresult(hwnd); SetActiveAlt hresult(hwnd);"
; Create the object.
Local $oTaskbarList = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList, $sTagITaskbarList)
; Initialize the iTaskbarList object.
$oTaskbarList.HrInit()
; Run Notepad.
Run("notepad.exe")
; Wait for the Notepad window to appear and get a handle to it.
Local $hNotepad = WinWait("[CLASS:Notepad]")
; Tell the user what to look for.
MsgBox(4096, "", "Look in the Taskbar and you should see an entry for Notepad." & @CRLF & @CRLF & "Press OK to continue.")
; Delete the Notepad entry from the Taskbar.
$oTaskbarList.DeleteTab($hNotepad)
; Tell the user to look again.
MsgBox(4096, "", "Look in the Taskbar.  There should no longer be a Notepad entry but Notepad is still running." & @CRLF & @CRLF & "Press OK to continue.")
; Close Notepad.
WinClose($hNotepad)

 

Thanks Johnmcloud!  The 2nd one with objcreate works on win8.1.  Going to try that on the winxp machines later!  Thanks!

Link to comment
Share on other sites

On my XP Pro SP3 the second one work fine. Don't quote, is unecessary.

::shrug:: I don't know why it doesn't work on my end, running SP3 as well.

I've ran into one problem with the second script you posted.  It does work to remove the taskbar tab, but WinSetOnTop no longer works, whether are put it before your script or after it will not SetOnTop.

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