本文整理匯總了Python中pyatspi.Registry類的典型用法代碼示例。如果您正苦於以下問題:Python Registry類的具體用法?Python Registry怎麽用?Python Registry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Registry類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: reclaimScripts
def reclaimScripts(self):
"""Compares the list of known scripts to the list of known apps,
deleting any scripts as necessary.
"""
from pyatspi import Registry
try:
desktop = Registry.getDesktop(0)
except:
debug.printException(debug.LEVEL_FINEST)
return
appList = self.appScripts.keys()
appList = filter(lambda a: a!= None and a not in desktop, appList)
for app in appList:
appScript = self.appScripts.pop(app)
_eventManager.deregisterScriptListeners(appScript)
del appScript
try:
toolkitScripts = self.toolkitScripts.pop(app)
except KeyError:
pass
else:
for toolkitScript in toolkitScripts.values():
_eventManager.deregisterScriptListeners(toolkitScript)
del toolkitScript
del app
示例2: reclaimScripts
def reclaimScripts(self):
"""Compares the list of known scripts to the list of known apps,
deleting any scripts as necessary.
"""
from pyatspi import Registry
try:
desktop = Registry.getDesktop(0)
except:
debug.printException(debug.LEVEL_FINEST)
return
appList = list(self.appScripts.keys())
appList = [a for a in appList if a != None and a not in desktop]
for app in appList:
appScript = self.appScripts.pop(app)
del appScript
try:
toolkitScripts = self.toolkitScripts.pop(app)
except KeyError:
pass
else:
for toolkitScript in list(toolkitScripts.values()):
del toolkitScript
del app
示例3: absoluteMotionWithTrajectory
def absoluteMotionWithTrajectory(source_x, source_y, dest_x, dest_y, mouseDelay=None, check=True):
"""
Synthetize mouse absolute motion with trajectory. The 'trajectory' means that the whole motion
is divided into several atomic movements which are synthetized separately.
"""
if check:
checkCoordinates(source_x, source_y)
checkCoordinates(dest_x, dest_y)
logger.log("Mouse absolute motion with trajectory to (%s,%s)" % (dest_x, dest_y))
dx = float(dest_x - source_x)
dy = float(dest_y - source_y)
max_len = max(abs(dx), abs(dy))
if max_len == 0:
# actually, no motion requested
return
dx /= max_len
dy /= max_len
act_x = float(source_x)
act_y = float(source_y)
for _ in range(0, int(max_len)):
act_x += dx
act_y += dy
if mouseDelay:
doDelay(mouseDelay)
registry.generateMouseEvent(int(act_x), int(act_y), name='abs')
if mouseDelay:
doDelay(mouseDelay)
else:
doDelay()
示例4: relativeMotion
def relativeMotion(x, y, mouseDelay=None):
logger.log("Mouse relative motion of (%s,%s)" % (x, y))
registry.generateMouseEvent(x, y, 'rel')
if mouseDelay:
doDelay(mouseDelay)
else:
doDelay()
示例5: test_image_video_mix
def test_image_video_mix(self):
files = ["1sec_simpsons_trailer.mp4", "flat_colour2_640x480.png",
"flat_colour4_1600x1200.jpg", "flat_colour1_640x480.png",
"flat_colour3_320x180.png", "flat_colour5_1600x1200.jpg"]
samples = self.import_media_multiple(files)
seektime = self.search_by_text("0:00:00.000", self.pitivi, roleName="text")
timeline = self.get_timeline()
tpos = timeline.position
#One video, one image
for sample in samples[1:]:
self.insert_clip(sample)
self.insert_clip(samples[0])
end = self.search_clip_end(30, seektime, timeline)
cend = end / 11.139
dogtail.rawinput.absoluteMotion(tpos[0] + cend - 2, tpos[1] + 30)
registry.generateKeyboardEvent(dogtail.rawinput.keyNameToKeyCode("Shift_L"), None, KEY_PRESS)
dogtail.rawinput.press(tpos[0] + cend - 2, tpos[1] + 30)
sleep(0.5)
dogtail.rawinput.absoluteMotion(tpos[0] + cend - 40, tpos[1] + 30)
sleep(0.5)
dogtail.rawinput.release(tpos[0] + cend - 40, tpos[1] + 30)
registry.generateKeyboardEvent(dogtail.rawinput.keyNameToKeyCode("Shift_L"), None, KEY_RELEASE)
self.nextb.click()
self.assertNotEqual(seektime.text, "0:00:11.139")
示例6: mouse_event
def mouse_event(x, y, button, eventType):
"""
> Description
Generates a mouse press or release event on a specific pixel on the screen
> Parameters
x (int): the x coordinate where the event will be generated
y (int): the y coordinate where the event will be generated
button (str): A string indicating which mouse button to press/release. One of 'left', 'right' or 'middle'
eventType (str): A string indicating the event type. One of 'press' or 'release'
> Returns
None
> Example
# this example could demonstrate a drag and drop of a file
# press the left mouse button at 100, 100
Macro.mouse_event(100, 100, 'left', 'press')
# move the cursor to 400, 400
Macro.move_cursor_to(400, 400)
# then, release the mouse
Macro.mouse_event(400, 400, 'left', 'press')
"""
buttonToNo = {'left':1, 'right':2, 'middle':3 }
controller.generateMouseEvent(x, y, 'b' + str(buttonToNo[button]) + ('p' if eventType == 'press' else 'r'))
示例7: test_image_video_mix
def test_image_video_mix(self):
files = [
"tears of steel.webm",
"flat_colour2_640x480.png",
"flat_colour4_1600x1200.jpg",
"flat_colour1_640x480.png",
"flat_colour3_320x180.png",
"flat_colour5_1600x1200.jpg",
]
samples = self.import_media_multiple(files)
timecode_widget = self.viewer.child(name="timecode_entry").child(roleName="text")
tpos = self.timeline.position
# One video, one image
for sample in samples[1:]:
self.insert_clip(sample)
self.insert_clip(samples[0])
sleep(0.3)
end = self.search_clip_end(30, timecode_widget, self.timeline)
cend = end / 11.139
dogtail.rawinput.absoluteMotion(tpos[0] + cend - 2, tpos[1] + 30)
registry.generateKeyboardEvent(dogtail.rawinput.keyNameToKeyCode("Shift_L"), None, KEY_PRESS)
dogtail.rawinput.press(tpos[0] + cend - 2, tpos[1] + 30)
sleep(0.5)
dogtail.rawinput.absoluteMotion(tpos[0] + cend - 40, tpos[1] + 30)
sleep(0.5)
dogtail.rawinput.release(tpos[0] + cend - 40, tpos[1] + 30)
registry.generateKeyboardEvent(dogtail.rawinput.keyNameToKeyCode("Shift_L"), None, KEY_RELEASE)
self.goToEnd_button.click()
self.assertNotEqual(timecode_widget.text, "0:00:11.139")
示例8: import_media_multiple
def import_media_multiple(self, files):
dogtail.rawinput.pressKey("Esc") # Ensure the welcome dialog is closed
self.import_button.click()
import_dialog = self.pitivi.child(name="Select One or More Files",
roleName="file chooser", recursive=False)
path_toggle = import_dialog.child(
name="Type a file name", roleName="toggle button")
if not path_toggle.checked:
path_toggle.click()
dir_path = os.path.realpath(__file__).split(
"dogtail_scripts/")[0] + "samples/"
import_dialog.child(roleName='text').text = dir_path
time.sleep(0.2)
dogtail.rawinput.pressKey("Enter")
# We are now in the samples directory, select various items.
# We use Ctrl click to select multiple items. However, since the first
# row of the filechooser is always selected by default, we must not use
# ctrl when selecting the first item of our list, in order to deselect.
ctrl_code = dogtail.rawinput.keyNameToKeyCode("Control_L")
file_list = import_dialog.child(name="Files", roleName="table")
first = True
for f in files:
time.sleep(0.5)
file_list.child(name=f).click()
if first:
registry.generateKeyboardEvent(ctrl_code, None, KEY_PRESS)
first = False
registry.generateKeyboardEvent(ctrl_code, None, KEY_RELEASE)
import_dialog.button('Add').click()
current_search_text = self.medialibrary.child(
name="media_search_entry", roleName="text").text.lower()
if current_search_text != "":
# Failure to find some icons might be because of search filtering.
# The following avoids searching for files that can't be found.
for f in files:
if current_search_text not in f.lower():
files.remove(f)
# Check if non-filtered items are now visible in the media library.
samples = []
for i in range(5):
# The time it takes for icons to appear is unpredictable,
# therefore we try up to 5 times to look for them
icons = self.medialibrary.findChildren(
GenericPredicate(roleName="icon"))
for icon in icons:
for f in files:
if icon.text == f:
samples.append(icon)
files.remove(f)
if len(files) == 0:
break
time.sleep(0.5)
return samples
示例9: doubleClick
def doubleClick(x, y, button=1, check=True):
"""
Synthesize a mouse button double-click at (x,y)
"""
if check:
checkCoordinates(x, y)
logger.log("Mouse button %s doubleclick at (%s,%s)" % (button, x, y))
registry.generateMouseEvent(x, y, 'b%sd' % button)
doDelay()
示例10: press
def press(x, y, button=1, check=True):
"""
Synthesize a mouse button press at (x,y)
"""
if check:
checkCoordinates(x, y)
logger.log("Mouse button %s press at (%s,%s)" % (button, x, y))
registry.generateMouseEvent(x, y, name='b%sp' % button)
doDelay()
示例11: release
def release(x, y, button=1, check=True):
"""
Synthesize a mouse button release at (x,y)
"""
if check:
checkCoordinates(x, y)
logger.log("Mouse button %s release at (%s,%s)" % (button, x, y))
registry.generateMouseEvent(x, y, 'b%sr' % button)
doDelay()
示例12: click
def click(x, y, button=1, check=True):
"""
Synthesize a mouse button click at (x,y)
"""
if check:
checkCoordinates(x, y)
logger.log("Mouse button %s click at (%s,%s)" % (button, x, y))
registry.generateMouseEvent(x, y, 'b%sc' % button)
doDelay(config.actionDelay)
示例13: pressKey
def pressKey(keyName):
"""
Presses (and releases) the key specified by keyName.
keyName is the English name of the key as seen on the keyboard. Ex: 'enter'
Names are looked up in Gdk.KEY_ If they are not found there, they are
looked up by uniCharToKeySym().
"""
keySym = keyNameToKeySym(keyName)
registry.generateKeyboardEvent(keySym, None, KEY_SYM)
doTypingDelay()
示例14: relativeMotion
def relativeMotion(x, y, mouseDelay=None):
"""
Synthetize a relative motion from actual position.
Note: Does not check if the end coordinates are positive.
"""
logger.log("Mouse relative motion of (%s,%s)" % (x, y))
registry.generateMouseEvent(x, y, name='rel')
if mouseDelay:
doDelay(mouseDelay)
else:
doDelay()
示例15: absoluteMotion
def absoluteMotion(x, y, mouseDelay=None, check=True):
"""
Synthesize mouse absolute motion to (x,y)
"""
if check:
checkCoordinates(x, y)
logger.log("Mouse absolute motion to (%s,%s)" % (x, y))
registry.generateMouseEvent(x, y, 'abs')
if mouseDelay:
doDelay(mouseDelay)
else:
doDelay()