本文整理汇总了Python中winUser.getWindowThreadProcessID函数的典型用法代码示例。如果您正苦于以下问题:Python getWindowThreadProcessID函数的具体用法?Python getWindowThreadProcessID怎么用?Python getWindowThreadProcessID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getWindowThreadProcessID函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: processGenericWinEvent
def processGenericWinEvent(eventID,window,objectID,childID):
"""Converts the win event to an NVDA event,
Checks to see if this NVDAObject equals the current focus.
If all goes well, then the event is queued and we return True
@param eventID: a win event ID (type)
@type eventID: integer
@param window: a win event's window handle
@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
@returns: True if the event was processed, False otherwise.
@rtype: boolean
"""
#Notify appModuleHandler of this new window
appModuleHandler.update(winUser.getWindowThreadProcessID(window)[0])
#Handle particular events for the special MSAA caret object just as if they were for the focus object
focus=eventHandler.lastQueuedFocusObject
if focus and objectID==winUser.OBJID_CARET and eventID in (winUser.EVENT_OBJECT_LOCATIONCHANGE,winUser.EVENT_OBJECT_SHOW):
NVDAEvent=("caret",focus)
else:
NVDAEvent=winEventToNVDAEvent(eventID,window,objectID,childID)
if not NVDAEvent:
return False
if NVDAEvent[0]=="nameChange" and objectID==winUser.OBJID_CURSOR:
mouseHandler.updateMouseShape(NVDAEvent[1].name)
return
if NVDAEvent[1]==focus:
NVDAEvent=(NVDAEvent[0],focus)
eventHandler.queueEvent(*NVDAEvent)
return True
开发者ID:BabbageCom,项目名称:nvda,代码行数:32,代码来源:IAccessibleHandler.py
示例2: _isUIAWindowHelper
def _isUIAWindowHelper(self,hwnd):
# UIA in NVDA's process freezes in Windows 7 and below
processID=winUser.getWindowThreadProcessID(hwnd)[0]
if windll.kernel32.GetCurrentProcessId()==processID:
return False
import NVDAObjects.window
windowClass=NVDAObjects.window.Window.normalizeWindowClassName(winUser.getClassName(hwnd))
# For certain window classes, we always want to use UIA.
if windowClass in goodUIAWindowClassNames:
return True
# allow the appModule for the window to also choose if this window is good
# An appModule should be able to override bad UIA class names as prescribed by core
appModule=appModuleHandler.getAppModuleFromProcessID(processID)
if appModule and appModule.isGoodUIAWindow(hwnd):
return True
# There are certain window classes that just had bad UIA implementations
if windowClass in badUIAWindowClassNames:
return False
if windowClass=="NetUIHWND":
parentHwnd=winUser.getAncestor(hwnd,winUser.GA_ROOT)
# #2816: Outlook 2010 auto complete does not fire enough UIA events, IAccessible is better.
# #4056: Combo boxes in Office 2010 Options dialogs don't expose a name via UIA, but do via MSAA.
if winUser.getClassName(parentHwnd) in {"Net UI Tool Window","NUIDialog"}:
return False
# allow the appModule for the window to also choose if this window is bad
if appModule and appModule.isBadUIAWindow(hwnd):
return False
# Ask the window if it supports UIA natively
res=windll.UIAutomationCore.UiaHasServerSideProvider(hwnd)
if res:
# the window does support UIA natively, but
# Microsoft Word should not use UIA unless we can't inject or the user explicitly chose to use UIA with Microsoft word
if windowClass=="_WwG" and not (config.conf['UIA']['useInMSWordWhenAvailable'] or not appModule.helperLocalBindingHandle):
return False
return bool(res)
开发者ID:MarcoZehe,项目名称:nvda,代码行数:35,代码来源:_UIAHandler.py
示例3: prePopup
def prePopup(self):
"""Prepare for a popup.
This should be called before any dialog or menu which should pop up for the user.
L{postPopup} should be called after the dialog or menu has been shown.
@postcondition: A dialog or menu may be shown.
"""
if winUser.getWindowThreadProcessID(winUser.getForegroundWindow())[0] != os.getpid():
# This process is not the foreground process, so bring it to the foreground.
self.Raise()
开发者ID:atsuoishimoto,项目名称:tweetitloud,代码行数:9,代码来源:__init__.py
示例4: 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
开发者ID:francipvb,项目名称:nvda,代码行数:53,代码来源:eventHandler.py
示例5: isUIAWindow
def isUIAWindow(self,hwnd):
now=time.time()
v=self.UIAWindowHandleCache.get(hwnd,None)
if not v or (now-v[1])>0.5:
if windll.kernel32.GetCurrentProcessId()==winUser.getWindowThreadProcessID(hwnd)[0]:
isUIA=False
elif winUser.getClassName(hwnd) in badUIAWindowClassNames:
isUIA=False
else:
isUIA=windll.UIAutomationCore.UiaHasServerSideProvider(hwnd)
self.UIAWindowHandleCache[hwnd]=(isUIA,now)
return isUIA
return v[0]
开发者ID:atsuoishimoto,项目名称:tweetitloud,代码行数:13,代码来源:UIAHandler.py
示例6: prePopup
def prePopup(self):
"""Prepare for a popup.
This should be called before any dialog or menu which should pop up for the user.
L{postPopup} should be called after the dialog or menu has been shown.
@postcondition: A dialog or menu may be shown.
"""
nvdaPid = os.getpid()
focus = api.getFocusObject()
if focus.processID != nvdaPid:
self.prevFocus = focus
self.prevFocusAncestors = api.getFocusAncestors()
if winUser.getWindowThreadProcessID(winUser.getForegroundWindow())[0] != nvdaPid:
# This process is not the foreground process, so bring it to the foreground.
self.Raise()
开发者ID:timothytylee,项目名称:nvda,代码行数:14,代码来源:__init__.py
示例7: kwargsFromSuper
def kwargsFromSuper(cls,kwargs,relation=None):
windowHandle=None
if relation in ('focus','foreground'):
windowHandle=winUser.getForegroundWindow()
if not windowHandle: windowHandle=winUser.getDesktopWindow()
if windowHandle and relation=="focus":
threadID=winUser.getWindowThreadProcessID(windowHandle)[1]
threadInfo=winUser.getGUIThreadInfo(threadID)
if threadInfo.hwndFocus: windowHandle=threadInfo.hwndFocus
elif isinstance(relation,tuple):
windowHandle=_windowFromPoint(ctypes.wintypes.POINT(relation[0],relation[1]))
if not windowHandle:
return False
kwargs['windowHandle']=windowHandle
return True
开发者ID:josephsl,项目名称:nvda4nvda,代码行数:15,代码来源:__init__.py
示例8: 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)
开发者ID:atsuoishimoto,项目名称:tweetitloud,代码行数:46,代码来源:IAccessibleHandler.py
示例9: _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
开发者ID:atsuoishimoto,项目名称:tweetitloud,代码行数:17,代码来源:watchdog.py
示例10: _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
开发者ID:lpintes,项目名称:NVDA,代码行数:18,代码来源:watchdog.py
示例11: requestWSRShowHideEvents
def requestWSRShowHideEvents(fn=None):
global requestedWSRShowHideEvents, hookId, eventCallback, wsrPanelHiddenFunction
if fn is None:
fn = wsrPanelHiddenFunction
else:
wsrPanelHiddenFunction = fn
if requestedWSRShowHideEvents:
return
try:
hwnd = winUser.FindWindow(u"MS:SpeechTopLevel", None)
except:
hwnd = None
if hwnd:
pid, tid = winUser.getWindowThreadProcessID(hwnd)
eventHandler.requestEvents(eventName='show', processId=pid, windowClassName='#32770')
eventCallback = make_callback(fn)
hookId = winUser.setWinEventHook(winUser.EVENT_OBJECT_HIDE, winUser.EVENT_OBJECT_HIDE, 0, eventCallback, pid, 0, 0)
requestedWSRShowHideEvents = True
开发者ID:dictationbridge,项目名称:dictationbridge-nvda,代码行数:18,代码来源:__init__.py
示例12: _get_lvAppImageID
def _get_lvAppImageID(self):
item=LVItemStruct(iItem=self.IAccessibleChildID-1,mask=LVIF_IMAGE)
(processID,threadID)=winUser.getWindowThreadProcessID(self.windowHandle)
processHandle=self.processHandle
internalItem=winKernel.virtualAllocEx(processHandle,None,sizeof(LVItemStruct),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
winKernel.writeProcessMemory(processHandle,internalItem,byref(item),sizeof(LVItemStruct),None)
winUser.sendMessage(self.windowHandle,LVM_GETITEM,0,internalItem)
dispInfo=NMLVDispInfoStruct()
dispInfo.item=internalItem
dispInfo.hdr.hwndFrom=self.windowHandle
dispInfo.hdr.idFrom=self.windowControlID
dispInfo.hdr.code=LVN_GETDISPINFO
internalDispInfo=winKernel.virtualAllocEx(processHandle,None,sizeof(NMLVDispInfoStruct),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
winKernel.writeProcessMemory(processHandle,internalDispInfo,byref(dispInfo),sizeof(NMLVDispInfoStruct),None)
winUser.sendMessage(self.parent.parent.windowHandle,winUser.WM_NOTIFY,LVN_GETDISPINFO,internalDispInfo)
winKernel.virtualFreeEx(processHandle,internalDispInfo,0,winKernel.MEM_RELEASE)
winKernel.readProcessMemory(processHandle,internalItem,byref(item),sizeof(LVItemStruct),None)
winKernel.virtualFreeEx(processHandle,internalItem,0,winKernel.MEM_RELEASE)
return item.iImage
开发者ID:atsuoishimoto,项目名称:tweetitloud,代码行数:19,代码来源:sysListView32.py
示例13: getListGroupInfo
def getListGroupInfo(windowHandle,groupIndex):
(processID,threadID)=winUser.getWindowThreadProcessID(windowHandle)
processHandle=oleacc.GetProcessHandleFromHwnd(windowHandle)
localInfo=LVGROUP()
localInfo.cbSize=sizeof(LVGROUP)
localInfo.mask=LVGF_HEADER|LVGF_FOOTER|LVGF_STATE|LVGF_ALIGN|LVGF_GROUPID
localInfo.stateMask=0xffffffff
remoteInfo=winKernel.virtualAllocEx(processHandle,None,sizeof(LVGROUP),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
winKernel.writeProcessMemory(processHandle,remoteInfo,byref(localInfo),sizeof(LVGROUP),None)
messageRes=winUser.sendMessage(windowHandle,LVM_GETGROUPINFOBYINDEX,groupIndex,remoteInfo)
winKernel.readProcessMemory(processHandle,remoteInfo,byref(localInfo),sizeof(LVGROUP),None)
winKernel.virtualFreeEx(processHandle,remoteInfo,0,winKernel.MEM_RELEASE)
localHeader=create_unicode_buffer(localInfo.cchHeader)
winKernel.readProcessMemory(processHandle,localInfo.pszHeader,localHeader,localInfo.cchHeader*2,None)
localFooter=create_unicode_buffer(localInfo.cchFooter)
winKernel.readProcessMemory(processHandle,localInfo.pszFooter,localFooter,localInfo.cchFooter*2,None)
winKernel.closeHandle(processHandle)
if messageRes==1:
return dict(header=localHeader.value,footer=localFooter.value,groupID=localInfo.iGroupId,state=localInfo.state,uAlign=localInfo.uAlign,groupIndex=groupIndex)
else:
return None
开发者ID:atsuoishimoto,项目名称:tweetitloud,代码行数:21,代码来源:sysListView32.py
示例14: _isUIAWindowHelper
def _isUIAWindowHelper(self,hwnd):
# UIA in NVDA's process freezes in Windows 7 and below
processID=winUser.getWindowThreadProcessID(hwnd)[0]
if windll.kernel32.GetCurrentProcessId()==processID:
return False
import NVDAObjects.window
windowClass=NVDAObjects.window.Window.normalizeWindowClassName(winUser.getClassName(hwnd))
# There are certain window classes that just had bad UIA implementations
if windowClass in badUIAWindowClassNames:
return False
if windowClass=="NetUIHWND":
parentHwnd=winUser.getAncestor(hwnd,winUser.GA_ROOT)
# #2816: Outlook 2010 auto complete does not fire enough UIA events, IAccessible is better.
if winUser.getClassName(parentHwnd)=="Net UI Tool Window":
return False
# allow the appModule for the window to also choose if this window is bad
appModule=appModuleHandler.getAppModuleFromProcessID(processID)
if appModule and appModule.isBadUIAWindow(hwnd):
return False
# Ask the window if it supports UIA natively
return windll.UIAutomationCore.UiaHasServerSideProvider(hwnd)
开发者ID:sonar-gnu-linux,项目名称:nvda,代码行数:21,代码来源:_UIAHandler.py
示例15: connectConsole
def connectConsole(obj):
global consoleObject, consoleOutputHandle, checkDeadTimer
#Get the process ID of the console this NVDAObject is fore
processID,threadID=winUser.getWindowThreadProcessID(obj.windowHandle)
#Attach NVDA to this console so we can access its text etc
try:
wincon.AttachConsole(processID)
except WindowsError as e:
log.debugWarning("Could not attach console: %r"%e)
return False
wincon.SetConsoleCtrlHandler(_consoleCtrlHandler,True)
consoleOutputHandle=winKernel.CreateFile(u"CONOUT$",winKernel.GENERIC_READ|winKernel.GENERIC_WRITE,winKernel.FILE_SHARE_READ|winKernel.FILE_SHARE_WRITE,None,winKernel.OPEN_EXISTING,0,None)
#Register this callback with all the win events we need, storing the given handles for removal later
for eventID in (winUser.EVENT_CONSOLE_CARET,winUser.EVENT_CONSOLE_UPDATE_REGION,winUser.EVENT_CONSOLE_UPDATE_SIMPLE,winUser.EVENT_CONSOLE_UPDATE_SCROLL,winUser.EVENT_CONSOLE_LAYOUT):
handle=winUser.setWinEventHook(eventID,eventID,0,consoleWinEventHook,0,0,0)
if not handle:
raise OSError("could not register eventID %s"%eventID)
consoleWinEventHookHandles.append(handle)
consoleObject=obj
checkDeadTimer=gui.NonReEntrantTimer(_checkDead)
checkDeadTimer.Start(CHECK_DEAD_INTERVAL)
return True
开发者ID:MarcoZehe,项目名称:nvda,代码行数:22,代码来源:winConsoleHandler.py
示例16: _isUIAWindowHelper
def _isUIAWindowHelper(self,hwnd):
# UIA in NVDA's process freezes in Windows 7 and below
processID=winUser.getWindowThreadProcessID(hwnd)[0]
if windll.kernel32.GetCurrentProcessId()==processID:
return False
import NVDAObjects.window
windowClass=NVDAObjects.window.Window.normalizeWindowClassName(winUser.getClassName(hwnd))
# For certain window classes, we always want to use UIA.
if windowClass in goodUIAWindowClassNames:
return True
# allow the appModule for the window to also choose if this window is good
# An appModule should be able to override bad UIA class names as prescribed by core
appModule=appModuleHandler.getAppModuleFromProcessID(processID)
if appModule and appModule.isGoodUIAWindow(hwnd):
return True
# There are certain window classes that just had bad UIA implementations
if windowClass in badUIAWindowClassNames:
return False
# allow the appModule for the window to also choose if this window is bad
if appModule and appModule.isBadUIAWindow(hwnd):
return False
# Ask the window if it supports UIA natively
res=windll.UIAutomationCore.UiaHasServerSideProvider(hwnd)
if res:
# the window does support UIA natively, but
# MS Word documents now have a fairly usable UI Automation implementation. However,
# Builds of MS Office 2016 before build 9000 or so had bugs which we cannot work around.
# And even current builds of Office 2016 are still missing enough info from UIA that it is still impossible to switch to UIA completely.
# Therefore, if we can inject in-process, refuse to use UIA and instead fall back to the MS Word object model.
if (
# An MS Word document window
windowClass=="_WwG"
# Disabling is only useful if we can inject in-process (and use our older code)
and appModule.helperLocalBindingHandle
# Allow the user to explisitly force UIA support for MS Word documents no matter the Office version
and not config.conf['UIA']['useInMSWordWhenAvailable']
):
return False
return bool(res)
开发者ID:BabbageCom,项目名称:nvda,代码行数:39,代码来源:_UIAHandler.py
示例17: processForegroundWinEvent
def processForegroundWinEvent(window,objectID,childID):
"""checks to see if the foreground win event is not the same as the existing focus or any of its parents,
then converts the win event to an NVDA event (instanciating an NVDA Object) and then checks the NVDAObject against the existing focus object.
If all is ok it queues the foreground event to NVDA and returns True.
@param window: a win event's window handle
@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
@returns: True if the foreground was processed, False otherwise.
@rtype: boolean
"""
#Ignore foreground events on windows that aren't the current foreground window
if window!=winUser.getForegroundWindow():
return False
# If there is a pending gainFocus, it will handle the foreground object.
oldFocus=eventHandler.lastQueuedFocusObject
#If this foreground win event's window is an ancestor of the existing focus's window, then ignore it
if isinstance(oldFocus,NVDAObjects.window.Window) and winUser.isDescendantWindow(window,oldFocus.windowHandle):
return False
#If the existing focus has the same win event params as these, then ignore this event
if isinstance(oldFocus,NVDAObjects.IAccessible.IAccessible) and window==oldFocus.event_windowHandle and objectID==oldFocus.event_objectID and childID==oldFocus.event_childID:
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_SYSTEM_FOREGROUND,window,objectID,childID,useCache=False)
if not NVDAEvent:
return False
eventHandler.queueEvent(*NVDAEvent)
return True
开发者ID:BabbageCom,项目名称:nvda,代码行数:36,代码来源:IAccessibleHandler.py
示例18: _get_windowThreadID
def _get_windowThreadID(self):
if hasattr(self,"_processIDThreadID"):
return self._processIDThreadID[1]
self._processIDThreadID=winUser.getWindowThreadProcessID(self.windowHandle)
return self._processIDThreadID[1]
开发者ID:josephsl,项目名称:nvda4nvda,代码行数:5,代码来源:__init__.py
示例19: 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
wClass = winUser.getClassName(windowHandle)
key = (eventName,
winUser.getWindowThreadProcessID(windowHandle)[0],
wClass)
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 wClass 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 wClass == "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
# #6713: Edge (and soon all UWP apps) will no longer have windows as descendants of the foreground window.
# However, it does look like they are always equal to or descendants of the "active" window of the input thread.
if wClass.startswith('Windows.UI.Core'):
gi=winUser.getGUIThreadInfo(0)
if winUser.isDescendantWindow(gi.hwndActive,windowHandle):
return True
fg = winUser.getForegroundWindow()
if wClass == "NetUIHWND" and winUser.getClassName(fg) == "Net UI Tool Window Layered":
# #5504: In Office >= 2013 with the ribbon showing only tabs,
# when a tab is expanded, the window we get from the focus object is incorrect.
# This window isn't beneath the foreground window,
# so our foreground application checks fail.
# Just compare the root owners.
if winUser.getAncestor(windowHandle, winUser.GA_ROOTOWNER) == winUser.getAncestor(fg, winUser.GA_ROOTOWNER):
return True
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
开发者ID:JRMeyer,项目名称:nvda,代码行数:69,代码来源:eventHandler.py
示例20: GetProcessHandleFromHwnd
def GetProcessHandleFromHwnd(windowHandle):
"""Retreaves a process handle of the process who owns the window.
If Windows Vista, uses GetProcessHandleFromHwnd found in oleacc.dll which allows a client with UIAccess to open a process who is elevated.
if older than Windows Vista, just uses OpenProcess from user32.dll instead.
@param windowHandle: a window of a process you wish to retreave a process handle for
@type windowHandle: integer
@returns: a process handle with read, write and operation access
@rtype: integer
"""
try:
return oledll.oleacc.GetProcessHandleFromHwnd(windowHandle)
except:
import winKernel
return winKernel.openProcess(winKernel.PROCESS_VM_READ|winKernel.PROCESS_VM_WRITE|winKernel.PROCESS_VM_OPERATION,False,winUser.getWindowThreadProcessID(windowHandle)[0])
开发者ID:MarcoZehe,项目名称:nvda,代码行数:14,代码来源:oleacc.py
注:本文中的winUser.getWindowThreadProcessID函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论