本文整理汇总了Python中winUser.getWindowThreadProcessID函数的典型用法代码示例。如果您正苦于以下问题:Python getWindowThreadProcessID函数的具体用法?Python getWindowThreadProcessID怎么用?Python getWindowThreadProcessID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getWindowThreadProcessID函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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)
示例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()
示例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
示例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]
示例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()
示例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
示例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)
示例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
示例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
示例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
示例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
示例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
示例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)
示例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