Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6627501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:01:19+00:00 2026-05-25T22:01:19+00:00

Is there a way to use Python to get a list of all the

  • 0

Is there a way to use Python to get a list of all the icons in the system tray (lower right hand corner) and their associated processes and executables?

Here is a thread on how to do this using AHK:

http://www.autohotkey.com/forum/topic17314.html

but it relies heavily on AHK.

Note that I’m interested this for in Windows XP/7

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:01:20+00:00Added an answer on May 25, 2026 at 10:01 pm

    This is thick, thick win32 stuff. I started writing this using pywin32 but switched over to ctypes to better deal with the structures. Note, I wrote this in 32 win XP. You’ll have the change the TBBUTTON def for 64 bit. I am not sure what UAC will do to this (can you allocate memory in another process?).

    import commctrl, win32con
    from ctypes import *
    
    # represent the TBBUTTON structure
    # note this is 32 bit, 64 bit padds 4 more reserved bytes
    class TBBUTTON(Structure):
        _pack_ = 1
        _fields_ = [
            ('iBitmap', c_int),
            ('idCommand', c_int),
            ('fsState', c_ubyte),
            ('fsStyle', c_ubyte),
            ('bReserved', c_ubyte * 2),
            ('dwData', c_ulong),
            ('iString', c_int),
        ]
    
    # get the handle to the sytem tray
    hWnd = windll.user32.FindWindowA("Shell_TrayWnd", None)
    hWnd = windll.user32.FindWindowExA(hWnd, None, "TrayNotifyWnd", None)
    hWnd = windll.user32.FindWindowExA(hWnd, None, "SysPager", None)
    hWnd = windll.user32.FindWindowExA(hWnd, None, "ToolbarWindow32", None)
    
    # get the count of icons in the tray
    numIcons = windll.user32.SendMessageA(hWnd, commctrl.TB_BUTTONCOUNT, 0, 0)
    
    # allocate memory within the system tray
    pid = c_ulong();
    windll.user32.GetWindowThreadProcessId(hWnd, byref(pid))
    hProcess = windll.kernel32.OpenProcess(win32con.PROCESS_ALL_ACCESS, 0, pid)
    lpPointer = windll.kernel32.VirtualAllocEx(hProcess, 0, sizeof(TBBUTTON), win32con.MEM_COMMIT, win32con.PAGE_READWRITE)
    
    # init our tool bar button and a handle to it
    tbButton = TBBUTTON()
    butHandle = c_int()
    
    for i in range(numIcons):
        # query the button into the memory we allocated
        windll.user32.SendMessageA(hWnd, commctrl.TB_GETBUTTON, i, lpPointer)
        # read the memory into our button struct
        windll.kernel32.ReadProcessMemory(hProcess, lpPointer, addressof(tbButton), 20, None)
        # read the 1st 4 bytes from the dwData into the butHandle var
        # these first 4 bytes contain the handle to the button
        windll.kernel32.ReadProcessMemory(hProcess, tbButton.dwData, addressof(butHandle), 4, None)
    
        # get the pid that created the button
        butPid = c_ulong()
        windll.user32.GetWindowThreadProcessId(butHandle, byref(butPid))
    
        # i leave it to you to get the process from the pid
        # that should be trivial...
        print butPid
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way in Python to list all the currently in-use drive letters
Is there a better way to use glob.glob in python to get a list
Is there any way to get Python to use my ActiveTcl installation instead of
Is there a way to use a Cocoa IBOutlet in Python? Or do I
In python, is there a way I can use instance variables as optional arguments
How would I use python to check a list and delete all duplicates? I
Is there any way to use inheritance in database (Specifically in SQL Server 2005)?
Is there a way to use JQuery to cloak or encrypt email addresses on
Is there any way to use a constant as a hash key? For example:
Is there a way to use constants in JavaScript ? If not, what's the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.