本文整理汇总了Python中Quartz.kCGNullWindowID方法的典型用法代码示例。如果您正苦于以下问题:Python Quartz.kCGNullWindowID方法的具体用法?Python Quartz.kCGNullWindowID怎么用?Python Quartz.kCGNullWindowID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quartz
的用法示例。
在下文中一共展示了Quartz.kCGNullWindowID方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_window_list
# 需要导入模块: import Quartz [as 别名]
# 或者: from Quartz import kCGNullWindowID [as 别名]
def _get_window_list(self):
""" Returns a dictionary of details about open windows """
window_list = Quartz.CGWindowListCopyWindowInfo(Quartz.kCGWindowListExcludeDesktopElements, Quartz.kCGNullWindowID)
return window_list
## Highlighting functions
示例2: getAllTitles
# 需要导入模块: import Quartz [as 别名]
# 或者: from Quartz import kCGNullWindowID [as 别名]
def getAllTitles():
"""Returns a list of strings of window titles for all visible windows.
"""
# Source: https://stackoverflow.com/questions/53237278/obtain-list-of-all-window-titles-on-macos-from-a-python-script/53985082#53985082
windows = Quartz.CGWindowListCopyWindowInfo(Quartz.kCGWindowListExcludeDesktopElements | Quartz.kCGWindowListOptionOnScreenOnly, Quartz.kCGNullWindowID)
return ['%s %s' % (win[Quartz.kCGWindowOwnerName], win.get(Quartz.kCGWindowName, '')) for win in windows]
示例3: getActiveWindow
# 需要导入模块: import Quartz [as 别名]
# 或者: from Quartz import kCGNullWindowID [as 别名]
def getActiveWindow():
"""Returns a Window object of the currently active Window."""
# Source: https://stackoverflow.com/questions/5286274/front-most-window-using-cgwindowlistcopywindowinfo
windows = Quartz.CGWindowListCopyWindowInfo(Quartz.kCGWindowListExcludeDesktopElements | Quartz.kCGWindowListOptionOnScreenOnly, Quartz.kCGNullWindowID)
for win in windows:
if win['kCGWindowLayer'] == 0:
return '%s %s' % (win[Quartz.kCGWindowOwnerName], win.get(Quartz.kCGWindowName, '')) # Temporary. For now, we'll just return the title of the active window.
raise Exception('Could not find an active window.') # Temporary hack.
示例4: getWindowsAt
# 需要导入模块: import Quartz [as 别名]
# 或者: from Quartz import kCGNullWindowID [as 别名]
def getWindowsAt(x, y):
windows = Quartz.CGWindowListCopyWindowInfo(Quartz.kCGWindowListExcludeDesktopElements | Quartz.kCGWindowListOptionOnScreenOnly, Quartz.kCGNullWindowID)
matches = []
for win in windows:
w = win['kCGWindowBounds']
if pygetwindow.pointInRect(x, y, w['X'], w['Y'], w['Width'], w['Height']):
matches.append('%s %s' % (win[Quartz.kCGWindowOwnerName], win.get(Quartz.kCGWindowName, '')))
return matches
示例5: getWindowGeometry
# 需要导入模块: import Quartz [as 别名]
# 或者: from Quartz import kCGNullWindowID [as 别名]
def getWindowGeometry(title):
# TEMP - this is not a real api, I'm just using this name to stoe these notes for now.
windows = Quartz.CGWindowListCopyWindowInfo(Quartz.kCGWindowListExcludeDesktopElements | Quartz.kCGWindowListOptionOnScreenOnly, Quartz.kCGNullWindowID)
for win in windows:
if title in '%s %s' % (win[Quartz.kCGWindowOwnerName], win.get(Quartz.kCGWindowName, '')):
w = win['kCGWindowBounds']
return (w['X'], w['Y'], w['Width'], w['Height'])
示例6: isVisible
# 需要导入模块: import Quartz [as 别名]
# 或者: from Quartz import kCGNullWindowID [as 别名]
def isVisible(title):
# TEMP - this is not a real api, I'm just using this name to stoe these notes for now.
windows = Quartz.CGWindowListCopyWindowInfo(Quartz.kCGWindowListExcludeDesktopElements | Quartz.kCGWindowListOptionOnScreenOnly, Quartz.kCGNullWindowID)
for win in windows:
if title in '%s %s' % (win[Quartz.kCGWindowOwnerName], win.get(Quartz.kCGWindowName, '')):
return win['kCGWindowAlpha'] != 0.0
示例7: _is_main_window_open
# 需要导入模块: import Quartz [as 别名]
# 或者: from Quartz import kCGNullWindowID [as 别名]
def _is_main_window_open(self):
"""Main window, not login one"""
windows = CGWindowListCopyWindowInfo(kCGWindowListExcludeDesktopElements, kCGNullWindowID)
for window in windows:
try:
if 'Blizzard Battle.net' == window['kCGWindowName']:
log.debug('Main Battle.net window was found')
return True
except KeyError:
continue
return False
示例8: get_screen_pixel
# 需要导入模块: import Quartz [as 别名]
# 或者: from Quartz import kCGNullWindowID [as 别名]
def get_screen_pixel(x, y):
image = CG.CGWindowListCreateImage(
CoreGraphics.CGRectMake(x, y, 2, 2),
CG.kCGWindowListOptionOnScreenOnly,
CG.kCGNullWindowID,
CG.kCGWindowImageDefault)
bytes = CG.CGDataProviderCopyData(CG.CGImageGetDataProvider(image))
b, g, r, a = struct.unpack_from("BBBB", bytes, offset=0)
return (r, g, b, a)
示例9: get_all_windows
# 需要导入模块: import Quartz [as 别名]
# 或者: from Quartz import kCGNullWindowID [as 别名]
def get_all_windows():
global all_windows
if not all_windows:
all_windows = Quartz.CGWindowListCopyWindowInfo(Quartz.kCGWindowListExcludeDesktopElements, Quartz.kCGNullWindowID)
for window in all_windows:
if False and window.valueForKey_('kCGWindowIsOnscreen') :
print(window)
return all_windows
示例10: get_pixels
# 需要导入模块: import Quartz [as 别名]
# 或者: from Quartz import kCGNullWindowID [as 别名]
def get_pixels(self, monitor):
width, height = monitor[b'width'], monitor[b'height']
left, top = monitor[b'left'], monitor[b'top']
rect = Quartz.CGRect((left, top), (width, height))
options = Quartz.kCGWindowListOptionOnScreenOnly
winid = Quartz.kCGNullWindowID
default = Quartz.kCGWindowImageDefault
self.image = Quartz.CGWindowListCreateImage(rect, options, winid, default)
if not self.image:
raise ScreenshotError('MSS: CGWindowListCreateImage() failed.')
return self.image