fix: preserve legacy cleanup document and tip transitions
This commit is contained in:
1 parent
7eafae417d
commit
701e5cd3b4
2 files changed
+66
-5
No files matched your search
@@ -252,7 +252,7 @@ def _post_window_message(window, hwnd, pid, message):
|
||||
win32gui.PostMessage(hwnd, message, 0, 0)
|
||||
|
||||
|
||||
def _process_windows(pids):
|
||||
def _process_windows(pids, *, include_hidden_documents=False):
|
||||
result = _WindowSnapshot(pids)
|
||||
if not pids: return result
|
||||
import win32api, win32con, win32gui, win32process
|
||||
@@ -271,10 +271,13 @@ def _process_windows(pids):
|
||||
kind = win32gui.GetClassName(handle)
|
||||
if kind == 'MDIClient' and win32gui.GetWindow(handle, win32con.GW_CHILD):
|
||||
documents.append(handle)
|
||||
if win32gui.IsWindowVisible(handle):
|
||||
visible = bool(win32gui.IsWindowVisible(handle))
|
||||
if visible or (include_hidden_documents and kind.casefold().startswith('afx:')
|
||||
and win32gui.GetClassName(win32gui.GetParent(handle)) == 'MDIClient'):
|
||||
children.append({'hwnd': int(handle), 'class': kind,
|
||||
'id': win32gui.GetDlgCtrlID(handle) & 0xffff,
|
||||
'text': win32gui.GetWindowText(handle), 'enabled': bool(win32gui.IsWindowEnabled(handle))})
|
||||
'text': win32gui.GetWindowText(handle), 'enabled': bool(win32gui.IsWindowEnabled(handle)),
|
||||
'visible': visible})
|
||||
win32api.SetLastError(0)
|
||||
win32gui.EnumChildWindows(hwnd, child, None)
|
||||
window = {'hwnd': int(hwnd), 'title': win32gui.GetWindowText(hwnd),
|
||||
@@ -651,7 +654,7 @@ def _cancelled_diagnostic_record(row):
|
||||
def _legacy_diagnostic_windows(row):
|
||||
"""Adapt the existing complete private-desktop snapshot for diagnostic policy."""
|
||||
import win32con, win32gui
|
||||
snapshot = _process_windows({row['pid']})
|
||||
snapshot = _process_windows({row['pid']}, include_hidden_documents=True)
|
||||
if _window_error(snapshot, row['pid']):
|
||||
raise ValueError('STARTUP_WINDOW_UNCONFIRMED')
|
||||
result = []
|
||||
@@ -664,7 +667,7 @@ def _legacy_diagnostic_windows(row):
|
||||
if benign:
|
||||
continue
|
||||
with _window_desktop(window['desktop']):
|
||||
children = [dict(c, parent=win32gui.GetParent(c['hwnd']), visible=True) for c in window['children']]
|
||||
children = [dict(c, parent=win32gui.GetParent(c['hwnd'])) for c in window['children']]
|
||||
result.append(dict(hwnd=window['hwnd'], pid=row['pid'], **{'class':window['class']},
|
||||
text=window['title'], enabled=window['enabled'], children=children,
|
||||
owner=int(win32gui.GetWindow(window['hwnd'], win32con.GW_OWNER) or 0)))
|
||||
@@ -711,6 +714,8 @@ def _close_registered_startup(row, handle, proof, *, stop=None):
|
||||
has_tip = any(w['title'] == 'Tip of the Day' for w in snapshot.get(row['pid'],[]))
|
||||
if has_tip and confirmed() and _dismiss_startup_tip(tip_row,handle,snapshot.get(row['pid'],[]),
|
||||
incomplete=_window_error(snapshot,row['pid']),deadline=deadline,stop=stop) is not None:
|
||||
if closed is None:
|
||||
continue # Tip may precede loading; the same intent still owns its one Close.
|
||||
while time.monotonic() < deadline:
|
||||
if win32event.WaitForSingleObject(handle,100) == win32con.WAIT_OBJECT_0:
|
||||
return {'release_status':'RELEASED','detail':'已关闭启动提示并正常退出'}
|
||||
|
||||
Reference in new issue
Block a user