I'm using winreg
to block the pesky taskbar window preview when hovering over taskbar thumbnails. I'm changing the registry successfully, and if I manually restart explorer.exe
either using the CMD or the Task Manager, the changes are successful.
我当前的问题是,我希望能够在没有手动交互的情况下做到这一点,并使其尽可能无缝。
Upon extensive research, I learned that whenever we do such changes using the Windows GUI, there is a message broadcasted via SendMessage(), using the HWND_BROADCAST
message as hWnd
and WM_SETTINGCHANGE
as Msg
. Using win32gui
make such call but the changes still aren't reflected. Reproducible code below:
import winreg
import win32gui
import win32con
aReg = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
access_key = winreg.OpenKey(aReg, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", 0, winreg.KEY_SET_VALUE)
# Change values:
winreg.SetValueEx(access_key, aeropeak_name, 1, winreg.REG_DWORD, 1)
winreg.SetValueEx(access_key, "ExtendedUIHoverTime", 1, winreg.REG_DWORD, 100000)
# Close connections:
winreg.CloseKey(access_key)
aReg.Close()
# Neither of these work:
# Trial 1
win32gui.SendMessageTimeout(win32con.HWND_BROADCAST, win32con.WM_SETTINGCHANGE, 0, "Environment", win32con.SMTO_ABORTIFHUNG, 5000)
# Trial 2
win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SETTINGCHANGE, 1, 'Environment')
您能帮我找出如何使这些更改立即显示在资源管理器中吗?