Search code examples
pythonwindowsinterfacetaskbar

How can I run python script on Windows 7, with ability to enable/disable apperance of window and on taskbar?


I found only How to start a python script in the background once it's run? and how to run a python script in the background? - but it is permanent and is not allowing switching to a normal mode.

I want to periodically check for some situation (change of website) and notify me once it happens - without appearing as window and taking space in taskbar all the time.


Solution

  • You need to build a Windows SysTray App/Service using the Python for Windows Extensions

    Please see similar question: How to build a SystemTray app for Windows?

    This is by no means trivial, so please feel free to post follow-up questions of a more specific nature!

    Update:

    You may also find this 3rd-party module quite useful that seems to implement the hardest part of this for you as a reuseable library:

    https://github.com/Infinidat/infi.systray

    Example using infi.systray:

    from infi.systray import SysTrayIcon
    def say_hello(systray):
        print "Hello, World!"
    menu_options = (("Say Hello", None, say_hello),)
    systray = SysTrayIcon("icon.ico", "Example tray icon", menu_options)
    systray.start()
    

    Looking at the source code for infi.systray the nice thing about it is that it doesn't depend on pywin32. It uses ctypes which is available as part of the standard Python library.