Putting focus on tray icons in Windows XP using Python

I am a supporter of the Windows-XP keyboard, and I want to bind Start - T to place the keyboard focus on the tray icon. (Because it will be much better than Start - B , and then many Shift - Tab s.)

So, I would like to make a Python program that puts the keyboard in focus on the tray icons. How can I do this with Python? I know very little about Windows behavior management.

If there is any ready-made program that will do this, I will also be happy to find out about it.

+6
source share
1 answer

I am 99% sure that there is no affordable way to access the notification area in the tray. The actual focus element is the overflow button, not the tray icon itself, and the Windows Shell team does not want to guarantee that this button will always be focused or even this button will exist in future versions of Windows. Therefore, the API does not have access to it. This is an extremely hacky way to do this, it may stop working at any time - only for personal use (tested on Windows 7):

import win32gui import win32con taskbar = win32gui.FindWindow("Shell_TrayWnd", None) trayArea = win32gui.FindWindowEx(taskbar, None, "TrayNotifyWnd", None) win32gui.SetForegroundWindow(taskbar) win32gui.SendMessage(trayArea, win32con.WM_SETFOCUS, 0, 0) 

Once again, do not use it in an application that other people will use . win32gui is part of Win32 Extensions .

You can use RegisterHotKey for a hotkey, but it should be easier for Explorer to handle this - add a link to your Start script and select a hotkey for it.

+1
source

Source: https://habr.com/ru/post/891049/


All Articles