本文整理汇总了Python中winUser.isDescendantWindow函数的典型用法代码示例。如果您正苦于以下问题:Python isDescendantWindow函数的具体用法?Python isDescendantWindow怎么用?Python isDescendantWindow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isDescendantWindow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: shouldAcceptEvent
def shouldAcceptEvent(eventName, windowHandle=None):
"""Check whether an event should be accepted from a platform API.
Creating NVDAObjects and executing events can be expensive
and might block the main thread noticeably if the object is slow to respond.
Therefore, this should be used before NVDAObject creation to filter out any unnecessary events.
A platform API handler may do its own filtering before this.
"""
if not windowHandle:
# We can't filter without a window handle.
return True
key = (eventName,
winUser.getWindowThreadProcessID(windowHandle)[0],
winUser.getClassName(windowHandle))
if key in _acceptEvents:
return True
if eventName == "valueChange" and config.conf["presentation"]["progressBarUpdates"]["reportBackgroundProgressBars"]:
return True
if eventName == "show":
# Only accept 'show' events for specific cases, as otherwise we get flooded.
return winUser.getClassName(windowHandle) in (
"Frame Notification Bar", # notification bars
"tooltips_class32", # tooltips
"mscandui21.candidate", "mscandui40.candidate", "MSCandUIWindow_Candidate", # IMM candidates
"TTrayAlert", # 5405: Skype
)
if eventName == "reorder":
# Prevent another flood risk.
return winUser.getClassName(windowHandle) == "TTrayAlert" # #4841: Skype
if eventName == "alert" and winUser.getClassName(winUser.getAncestor(windowHandle, winUser.GA_PARENT)) == "ToastChildWindowClass":
# Toast notifications.
return True
if eventName in ("menuEnd", "switchEnd", "desktopSwitch"):
# #5302, #5462: These events can be fired on the desktop window
# or windows that would otherwise be blocked.
# Platform API handlers will translate these events to focus events anyway,
# so we must allow them here.
return True
if windowHandle == winUser.getDesktopWindow():
# #5595: Events for the cursor get mapped to the desktop window.
return True
fg = winUser.getForegroundWindow()
if (winUser.isDescendantWindow(fg, windowHandle)
# #3899, #3905: Covers cases such as the Firefox Page Bookmarked window and OpenOffice/LibreOffice context menus.
or winUser.isDescendantWindow(fg, winUser.getAncestor(windowHandle, winUser.GA_ROOTOWNER))):
# This is for the foreground application.
return True
if (winUser.user32.GetWindowLongW(windowHandle, winUser.GWL_EXSTYLE) & winUser.WS_EX_TOPMOST
or winUser.user32.GetWindowLongW(winUser.getAncestor(windowHandle, winUser.GA_ROOT), winUser.GWL_EXSTYLE) & winUser.WS_EX_TOPMOST):
# This window or its root is a topmost window.
# This includes menus, combo box pop-ups and the task switching list.
return True
return False
示例2: __contains__
def __contains__(self,obj):
if not obj.windowClassName.startswith("Internet Explorer_"):
return False
#'select' tag lists have MSAA list items which do not relate to real HTML nodes.
#Go up one parent for these and use it instead
if isinstance(obj,NVDAObjects.IAccessible.IAccessible) and not isinstance(obj,NVDAObjects.IAccessible.MSHTML.MSHTML) and obj.role==controlTypes.ROLE_LISTITEM:
parent=obj.parent
if parent and isinstance(parent,NVDAObjects.IAccessible.MSHTML.MSHTML):
obj=parent
#Combo box lists etc are popup windows, so rely on accessibility hierarchi instead of window hierarchi for those.
#However only helps in IE8.
if obj.windowStyle&winUser.WS_POPUP:
parent=obj.parent
obj.parent=parent
while parent and parent.windowHandle==obj.windowHandle:
newParent=parent.parent
parent.parent=newParent
parent=newParent
if parent and parent.windowClassName.startswith('Internet Explorer_'):
obj=parent
if not winUser.isDescendantWindow(self.rootDocHandle,obj.windowHandle) and obj.windowHandle!=self.rootDocHandle:
return False
newObj=obj
while isinstance(newObj,NVDAObjects.IAccessible.MSHTML.MSHTML):
if newObj==self.rootNVDAObject:
return True
if newObj.role in (controlTypes.ROLE_APPLICATION,controlTypes.ROLE_DIALOG):
break
newObj=newObj.parent
return False
示例3: event_gainFocus
def event_gainFocus(vmID,accContext):
tempContext=accContext
while tempContext:
try:
tempContext=bridgeDll.getActiveDescendent(vmID,tempContext)
except:
tempContext=None
try:
depth=bridgeDll.getObjectDepth(vmID,tempContext)
except:
depth=-1
if tempContext and (depth<=0 or bridgeDll.isSameObject(vmID,accContext,tempContext)):
tempContext=None
if tempContext:
bridgeDll.releaseJavaObject(vmID,accContext)
accContext=tempContext
jabContext=JABContext(vmID=vmID,accContext=accContext)
if not winUser.isDescendantWindow(winUser.getForegroundWindow(),jabContext.hwnd):
return
focus=eventHandler.lastQueuedFocusObject
if (isinstance(focus,NVDAObjects.JAB.JAB) and focus.jabContext==jabContext):
return
obj=NVDAObjects.JAB.JAB(jabContext=jabContext)
if obj.role==controlTypes.ROLE_UNKNOWN:
return
eventHandler.queueEvent("gainFocus",obj)
示例4: event_gainFocus
def event_gainFocus(self, obj, nextHandler):
if self.chatWindow and not winUser.isDescendantWindow(self.chatWindow, obj.windowHandle):
self.conversationLostFocus()
# A conversation might have its own top level window,
# but foreground changes often trigger gainFocus instead of focusEntered.
self.conversationMaybeFocused(obj)
nextHandler()
示例5: event_valueChange
def event_valueChange(self):
global lastMSNHistoryValue
if winUser.isDescendantWindow(winUser.getForegroundWindow(),self.windowHandle):
value=self.value
if value!=lastMSNHistoryValue and config.conf["presentation"]["reportDynamicContentChanges"]:
speech.speakText(value)
lastMSNHistoryValue=value
示例6: event_valueChange
def event_valueChange(self):
if self.event_childID==0 and self.event_objectID == winUser.OBJID_CLIENT and winUser.isDescendantWindow(winUser.getForegroundWindow(),self.windowHandle):
# Acrobat has indicated that a page has died and been replaced by a new one.
# The new page has the same event params, so we must bypass NVDA's IAccessible caching.
obj = getNVDAObjectFromEvent(self.windowHandle, -4, 0)
if not obj:
return
eventHandler.queueEvent("gainFocus",obj)
示例7: _getNVDAObjectFromOffset
def _getNVDAObjectFromOffset(self,offset):
try:
p=self._getPointFromOffset(offset)
except (NotImplementedError,LookupError):
return self.obj
obj=api.getDesktopObject().objectFromPoint(p.x,p.y)
from NVDAObjects.window import Window
if not obj or not isinstance(obj,Window) or not winUser.isDescendantWindow(self.obj.windowHandle,obj.windowHandle):
return self.obj
return obj
示例8: event_gainFocus
def event_gainFocus(vmID,accContext,hwnd):
jabContext=JABContext(hwnd=hwnd,vmID=vmID,accContext=accContext)
if not winUser.isDescendantWindow(winUser.getForegroundWindow(),jabContext.hwnd):
return
focus=eventHandler.lastQueuedFocusObject
if (isinstance(focus,NVDAObjects.JAB.JAB) and focus.jabContext==jabContext):
return
obj=NVDAObjects.JAB.JAB(jabContext=jabContext)
if obj.role==controlTypes.ROLE_UNKNOWN:
return
eventHandler.queueEvent("gainFocus",obj)
示例9: _get_SDMChild
def _get_SDMChild(self):
if controlTypes.STATE_FOCUSED in self.states:
hwndFocus=winUser.getGUIThreadInfo(0).hwndFocus
if hwndFocus and hwndFocus!=self.windowHandle and winUser.isDescendantWindow(self.windowHandle,hwndFocus) and not winUser.getClassName(hwndFocus).startswith('bosa_sdm'):
obj=getNVDAObjectFromEvent(hwndFocus,winUser.OBJID_CLIENT,0)
if not obj: return None
if getattr(obj,'parentSDMCanOverrideName',True):
obj.name=self.name
obj.keyboardShortcut=self.keyboardShortcut
obj.parent=self
return obj
return None
示例10: event_stateChange
def event_stateChange(self):
# iTunes has indicated that a page has died and been replaced by a new one.
focus = api.getFocusObject()
if not winUser.isDescendantWindow(self.windowHandle, focus.windowHandle):
return
if focus.role:
# The old document is still alive.
return
# The new page has the same event params, so we must bypass NVDA's IAccessible caching.
obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(focus.windowHandle, winUser.OBJID_CLIENT, 0)
if not obj:
return
eventHandler.queueEvent("gainFocus",obj)
示例11: event_stateChange
def event_stateChange(self):
# iTunes has indicated that a page has died and been replaced by a new one.
focus = api.getFocusObject()
if not winUser.isDescendantWindow(self.windowHandle, focus.windowHandle):
return
# The new page has the same event params, so we must bypass NVDA's IAccessible caching.
obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(focus.windowHandle, winUser.OBJID_CLIENT, 0)
if not obj:
return
if focus.treeInterceptor:
speech.cancelSpeech()
treeInterceptorHandler.killTreeInterceptor(focus.treeInterceptor)
eventHandler.queueEvent("gainFocus",obj)
示例12: __contains__
def __contains__(self,obj):
if self.isWindowless:
if not isinstance(obj, NVDAObjects.IAccessible.IAccessible):
return False
if obj.windowHandle != self.rootDocHandle:
return False
info = obj.IAccessibleIdentity
if not info:
return False
ID=info['objectID']
try:
self.rootNVDAObject.IAccessibleObject.accChild(ID)
return True
except COMError:
return False
return winUser.isDescendantWindow(self.rootDocHandle, obj.windowHandle)
示例13: processFocusWinEvent
def processFocusWinEvent(window,objectID,childID,force=False):
"""checks to see if the focus win event is not the same as the existing focus,
then converts the win event to an NVDA event (instanciating an NVDA Object) then calls processFocusNVDAEvent. If all is ok it returns True.
@type window: integer
@param objectID: a win event's object ID
@type objectID: integer
@param childID: a win event's child ID
@type childID: integer
@param force: If True, the shouldAllowIAccessibleFocusEvent property of the object is ignored.
@type force: boolean
@returns: True if the focus is valid and was handled, False otherwise.
@rtype: boolean
"""
windowClassName=winUser.getClassName(window)
# Generally, we must ignore focus on child windows of SDM windows as we only want the SDM MSAA events.
# However, we don't want to ignore focus if the child ID isn't 0,
# as this is a child control and the SDM MSAA events don't handle child controls.
if childID==0 and not windowClassName.startswith('bosa_sdm') and winUser.getClassName(winUser.getAncestor(window,winUser.GA_PARENT)).startswith('bosa_sdm'):
return False
rootWindow=winUser.getAncestor(window,winUser.GA_ROOT)
# If this window is not within the foreground window and this window or its root window is not a popup window, and this window's root window is not the highest in the z-order
if not winUser.isDescendantWindow(winUser.getForegroundWindow(),window) and not (winUser.getWindowStyle(window) & winUser.WS_POPUP or winUser.getWindowStyle(rootWindow)&winUser.WS_POPUP) and winUser.getPreviousWindow(rootWindow)!=0:
# This is a focus event from a background window, so ignore it.
return False
#Notify appModuleHandler of this new foreground window
appModuleHandler.update(winUser.getWindowThreadProcessID(window)[0])
#If Java access bridge is running, and this is a java window, then pass it to java and forget about it
if JABHandler.isRunning and JABHandler.isJavaWindow(window):
JABHandler.event_enterJavaWindow(window)
return True
#Convert the win event to an NVDA event
NVDAEvent=winEventToNVDAEvent(winUser.EVENT_OBJECT_FOCUS,window,objectID,childID,useCache=False)
if not NVDAEvent:
return False
eventName,obj=NVDAEvent
if (childID==0 and obj.IAccessibleRole==oleacc.ROLE_SYSTEM_LIST) or (objectID==winUser.OBJID_CLIENT and "SysListView32" in obj.windowClassName):
# Some controls incorrectly fire focus on child ID 0, even when there is a child with focus.
try:
realChildID=obj.IAccessibleObject.accFocus
except:
realChildID=None
if isinstance(realChildID,int) and realChildID>0 and realChildID!=childID:
realObj=NVDAObjects.IAccessible.IAccessible(IAccessibleObject=obj.IAccessibleObject,IAccessibleChildID=realChildID,event_windowHandle=window,event_objectID=objectID,event_childID=realChildID)
if realObj:
obj=realObj
return processFocusNVDAEvent(obj,force=force)
示例14: _shouldRecoverAfterMinTimeout
def _shouldRecoverAfterMinTimeout():
info=winUser.getGUIThreadInfo(0)
#If hwndFocus is 0, then the OS is clearly busy and we don't want to timeout prematurely.
if not info.hwndFocus: return False
# Import late to avoid circular import.
import api
#If a system menu has been activated but NVDA's focus is not yet in the menu then use min timeout
if info.flags&winUser.GUI_SYSTEMMENUMODE and info.hwndMenuOwner and api.getFocusObject().windowClassName!='#32768':
return True
if winUser.getClassName(info.hwndFocus) in safeWindowClassSet:
return False
if not winUser.isDescendantWindow(info.hwndActive, api.getFocusObject().windowHandle):
# The foreground window has changed.
return True
newHwnd=info.hwndFocus
newThreadID=winUser.getWindowThreadProcessID(newHwnd)[1]
return newThreadID!=api.getFocusObject().windowThreadID
示例15: _shouldRecoverAfterMinTimeout
def _shouldRecoverAfterMinTimeout():
info=winUser.getGUIThreadInfo(0)
if not info.hwndFocus:
# The foreground thread is frozen or there is no foreground thread (probably due to a freeze elsewhere).
return True
# Import late to avoid circular import.
import api
#If a system menu has been activated but NVDA's focus is not yet in the menu then use min timeout
if info.flags&winUser.GUI_SYSTEMMENUMODE and info.hwndMenuOwner and api.getFocusObject().windowClassName!='#32768':
return True
if winUser.getClassName(info.hwndFocus) in safeWindowClassSet:
return False
if not winUser.isDescendantWindow(info.hwndActive, api.getFocusObject().windowHandle):
# The foreground window has changed.
return True
newHwnd=info.hwndFocus
newThreadID=winUser.getWindowThreadProcessID(newHwnd)[1]
return newThreadID!=api.getFocusObject().windowThreadID