Python - win32con.FLASHW_* 标志

1 投票
2 回答
2738 浏览
提问于 2025-04-17 07:12

大家好,
在这个链接 http://docs.activestate.com/activepython/2.7/pywin32/win32gui__FlashWindowEx_meth.html 上,有关于win32gui.FlashWindowEx()的说明,我已经成功让它工作了。

import win32gui as w
a = w.GetForegroundWindow() #just get the handler/ID for the current window
w.FlashWindowEx(a,0,5,1000) #many variations of the 5,1000 have been tried

但是在Windows 7的任务栏中,图标只是变成了金色背景,并没有闪烁。所以我想问一下,有没有人了解文档中提到的win32con.FLASHW_*标志,或者能不能给我一个关于它们的更多信息的链接?
谢谢!

2 个回答

0

参考链接:http://guangboo.org/2013/05/14/wxpython-flashwindow-using-win32api

from ctypes import *
import win32con 
import win32gui as w
cur_window = w.GetForegroundWindow() #just get the handler/ID for the current window

class FLASHWINFO(Structure):
        _fields_ = [('cbSize', c_uint),
                ('hwnd', c_uint),
                ('dwFlags', c_uint),
                ('uCount', c_uint),
                ('dwTimeout', c_uint)]

def flash(hwnd):
        '''Flash a window with caption and tray.'''
        info = FLASHWINFO(0, hwnd, win32con.FLASHW_ALL | win32con.FLASHW_TIMERNOFG, 0, 0)
        info.cbSize = sizeof(info)
        FlashWindowEx(byref(info))

flash(cur_window)
1

关于 FlashWindowEx 函数的 Visual Basic 版本,微软的支持网站上有更多信息,您可以在这里找到:“如何使用 FlashWindowEx 来通知用户(来自 Visual Basic)”

那一页上还列出了 FLASHW_* 的各种标志。

撰写回答