コード例 #1
0
ファイル: registry.py プロジェクト: thnguyn2/ECE_527_MP
 def stop(self, *args):
         """
         Quits the main loop.
         """
         if not self.has_implementations:
                 self._set_default_registry ()
         Atspi.event_quit()
コード例 #2
0
ファイル: registry.py プロジェクト: Alberto-Beralix/Beralix
        def deregisterKeystrokeListener(self,
                                        client,
                                        key_set=[],
                                        mask=0,
                                        kind=(_KEY_PRESSED_EVENT, _KEY_RELEASED_EVENT)):
                """
                Deregisters a listener for key stroke events.

                @@param client: Callable to be invoked when the event occurs
                @@type client: callable
                @@param key_set: Set of hardware key codes to stop monitoring. Leave empty
                        to indicate all keys.
                @@type key_set: list of integer
                @@param mask: When the mask is None, the codes in the key_set will be 
                        monitored only when no modifier is held. When the mask is an 
                        integer, keys in the key_set will be monitored only when the modifiers in
                        the mask are held. When the mask is an iterable over more than one 
                        integer, keys in the key_set will be monitored when any of the modifier
                        combinations in the set are held.
                @@type mask: integer, iterable, None
                @@param kind: Kind of events to stop watching, KEY_PRESSED_EVENT or 
                        KEY_RELEASED_EVENT.
                @@type kind: list
                @@raise KeyError: When the client isn't already registered for events
                """
                if not self.has_implementations:
                        self._set_default_registry ()
                try:
                        listener = self.event_listeners[client]
                except:
                        return
                Atspi.deregister_keystroke_listener (listener, key_set, mask, kind)
コード例 #3
0
ファイル: registry.py プロジェクト: GNOME/pyatspi2
 def stop(self, *args):
     """
             Quits the main loop.
             """
     if not self.has_implementations:
         self._set_default_registry()
     Atspi.event_quit()
コード例 #4
0
    def _register_atspi_keystroke_listeners(self, register):
        if self._keystroke_listeners_registered != register:
            modifier_masks = range(16)

            if register:
                if not self._keystroke_listener:
                    self._keystroke_listener = \
                       Atspi.DeviceListener.new(self._on_atspi_keystroke, None)

                for modifier_mask in modifier_masks:
                    Atspi.register_keystroke_listener( \
                                        self._keystroke_listener,
                                        None,        # key set, None=all
                                        modifier_mask,
                                        Atspi.KeyEventType.PRESSED,
                                        Atspi.KeyListenerSyncType.SYNCHRONOUS)
            else:
                # Apparently any single deregister call will turn off
                # all the other registered modifier_masks too. Since
                # deregistering takes extremely long (~2.5s for 16 calls)
                # seize the opportunity and just pick a single arbitrary
                # mask (Quantal).
                modifier_masks = [2]

                for modifier_mask in modifier_masks:
                    Atspi.deregister_keystroke_listener(
                                        self._keystroke_listener,
                                        None, # key set, None=all
                                        modifier_mask,
                                        Atspi.KeyEventType.PRESSED)

        self._keystroke_listeners_registered = register
コード例 #5
0
    def _register_atspi_keystroke_listeners(self, register):
        if not "Atspi" in globals():
            return

        if self._keystroke_listeners_registered != register:
            modifier_masks = range(16)

            if register:
                if not self._keystroke_listener:
                    self._keystroke_listener = \
                       Atspi.DeviceListener.new(self._on_atspi_keystroke, None)

                for modifier_mask in modifier_masks:
                    Atspi.register_keystroke_listener( \
                                        self._keystroke_listener,
                                        None,        # key set, None=all
                                        modifier_mask,
                                        Atspi.KeyEventType.PRESSED,
                                        Atspi.KeyListenerSyncType.SYNCHRONOUS)
            else:
                # Apparently any single deregister call will turn off
                # all the other registered modifier_masks too. Since
                # deregistering takes extremely long (~2.5s for 16 calls)
                # seize the opportunity and just pick a single arbitrary
                # mask (Quantal).
                modifier_masks = [2]

                for modifier_mask in modifier_masks:
                    Atspi.deregister_keystroke_listener(
                        self._keystroke_listener,
                        None,  # key set, None=all
                        modifier_mask,
                        Atspi.KeyEventType.PRESSED)

        self._keystroke_listeners_registered = register
コード例 #6
0
ファイル: registry.py プロジェクト: Alberto-Beralix/Beralix
        def registerKeystrokeListener(self,
                                      client,
                                      key_set=[],
                                      mask=0,
                                      kind=(_KEY_PRESSED_EVENT, _KEY_RELEASED_EVENT),
                                      synchronous=True,
                                      preemptive=True,
                                      global_=False):
                """
                Registers a listener for key stroke events.

                @@param client: Callable to be invoked when the event occurs
                @@type client: callable
                @@param key_set: Set of hardware key codes to stop monitoring. Leave empty
                        to indicate all keys.
                @@type key_set: list of integer
                @@param mask: When the mask is None, the codes in the key_set will be 
                        monitored only when no modifier is held. When the mask is an 
                        integer, keys in the key_set will be monitored only when the modifiers in
                        the mask are held. When the mask is an iterable over more than one 
                        integer, keys in the key_set will be monitored when any of the modifier
                        combinations in the set are held.
                @@type mask: integer, iterable, None
                @@param kind: Kind of events to watch, KEY_PRESSED_EVENT or 
                        KEY_RELEASED_EVENT.
                @@type kind: list
                @@param synchronous: Should the callback notification be synchronous, giving
                        the client the chance to consume the event?
                @@type synchronous: boolean
                @@param preemptive: Should the callback be allowed to preempt / consume the
                        event?
                @@type preemptive: boolean
                @@param global_: Should callback occur even if an application not supporting
                        AT-SPI is in the foreground? (requires xevie)
                @@type global_: boolean
                """
                if not self.has_implementations:
                        self._set_default_registry ()
                try:
                        listener = self.event_listeners[client]
                except:
                        listener = self.event_listeners[client] = Atspi.DeviceListener.new(self.eventWrapper, client)
                syncFlag = self.makeSyncType(synchronous, preemptive, global_)
                try:
                        iter(mask)
                        masks = mask
                except:
                        masks = [mask]
                for m in masks:
                        Atspi.register_keystroke_listener(listener,
                                                          key_set,
                                                          m,
                                                          self.makeKind (kind),
                                                          syncFlag)
コード例 #7
0
ファイル: registry.py プロジェクト: jaduwvad/makolli_blackbox
        def registerKeystrokeListener(self,
                                      client,
                                      key_set=[],
                                      mask=0,
                                      kind=(_KEY_PRESSED_EVENT, _KEY_RELEASED_EVENT),
                                      synchronous=True,
                                      preemptive=True,
                                      global_=False):
                """
                Registers a listener for key stroke events.

                @@param client: Callable to be invoked when the event occurs
                @@type client: callable
                @@param key_set: Set of hardware key codes to stop monitoring. Leave empty
                        to indicate all keys.
                @@type key_set: list of integer
                @@param mask: When the mask is None, the codes in the key_set will be 
                        monitored only when no modifier is held. When the mask is an 
                        integer, keys in the key_set will be monitored only when the modifiers in
                        the mask are held. When the mask is an iterable over more than one 
                        integer, keys in the key_set will be monitored when any of the modifier
                        combinations in the set are held.
                @@type mask: integer, iterable, None
                @@param kind: Kind of events to watch, KEY_PRESSED_EVENT or 
                        KEY_RELEASED_EVENT.
                @@type kind: list
                @@param synchronous: Should the callback notification be synchronous, giving
                        the client the chance to consume the event?
                @@type synchronous: boolean
                @@param preemptive: Should the callback be allowed to preempt / consume the
                        event?
                @@type preemptive: boolean
                @@param global_: Should callback occur even if an application not supporting
                        AT-SPI is in the foreground? (requires xevie)
                @@type global_: boolean
                """
                if not self.has_implementations:
                        self._set_default_registry ()
                try:
                        listener = self.event_listeners[client]
                except:
                        listener = self.event_listeners[client] = Atspi.DeviceListener.new(self.eventWrapper, client)
                syncFlag = self.makeSyncType(synchronous, preemptive, global_)
                if hasattr(mask, '__iter__'):
                        masks = mask
                else:
                        masks = [mask]
                for m in masks:
                        Atspi.register_keystroke_listener(listener,
                                                          key_set,
                                                          m,
                                                          self.makeKind (kind),
                                                          syncFlag)
コード例 #8
0
ファイル: model.py プロジェクト: J-Arun-Mani/Scream
    def __init__(self):

        self.display = GdkX11.X11Display.get_default()
        self.screen = Wnck.Screen.get_default()
        self.props = {
            "window": None,
            "fmt": "jpg",
            "x1": None,
            "y1": None,
            "x2": None,
            "y2": None,
        }
        Atspi.init()
コード例 #9
0
ファイル: model.py プロジェクト: J-Arun-Mani/Scream
    def execute(self, filename: str, keyval: int):

        if keyval:
            Atspi.generate_keyboard_event(keyval, None,
                                          Atspi.KeySynthType.PRESSRELEASE)
        self.capture(
            filename=filename,
            window=self.props["window"],
            type=self.props["type"],
            x1=self.props["x1"],
            y1=self.props["y1"],
            x2=self.props["x2"],
            y2=self.props["y2"],
        )
コード例 #10
0
    def getLocalizedRoleName(self, obj, role=None):
        """Returns the localized name of the given Accessible object; the name
        is suitable to be brailled.

        Arguments:
        - obj: an Accessible object
        - role: an optional pyatspi role to use instead
        """

        if _settingsManager.getSetting('brailleRolenameStyle') \
                == settings.BRAILLE_ROLENAME_STYLE_SHORT:
            objRole = role or obj.getRole()
            rv = shortRoleNames.get(objRole)
            if rv:
                return rv

        if not isinstance(role, pyatspi.Role):
            try:
                return obj.getLocalizedRoleName()
            except:
                return ''

        if not role:
            return ''

        nonlocalized = Atspi.role_get_name(role)
        atkRole = Atk.role_for_name(nonlocalized)

        return Atk.role_get_localized_name(atkRole)
コード例 #11
0
    def getLocalizedRoleName(self, obj, role=None):
        """Returns the localized name of the given Accessible object; the name
        is suitable to be brailled.

        Arguments:
        - obj: an Accessible object
        - role: an optional pyatspi role to use instead
        """

        if _settingsManager.getSetting('brailleRolenameStyle') \
                == settings.BRAILLE_ROLENAME_STYLE_SHORT:
            objRole = role or obj.getRole()
            rv = shortRoleNames.get(objRole)
            if rv:
                return rv

        if not isinstance(role, pyatspi.Role):
            try:
                return obj.getLocalizedRoleName()
            except:
                return ''

        if not role:
            return ''

        nonlocalized = Atspi.role_get_name(role)
        atkRole = Atk.role_for_name(nonlocalized)

        return Atk.role_get_localized_name(atkRole)
コード例 #12
0
ファイル: registry.py プロジェクト: GNOME/pyatspi2
    def generateMouseEvent(self, x, y, name):
        """
                Generates a mouse event at the given absolute x and y coordinate. The kind
                of event generated is specified by the name. For example, MOUSE_B1P 
                (button 1 press), MOUSE_REL (relative motion), MOUSE_B3D (butten 3 
                double-click).

                @@param x: Horizontal coordinate, usually left-hand oriented
                @@type x: integer
                @@param y: Vertical coordinate, usually left-hand oriented
                @@type y: integer
                @@param name: Name of the event to generate
                @@type name: string
                """
        if not self.has_implementations:
            self._set_default_registry()
        Atspi.generate_mouse_event(x, y, name)
コード例 #13
0
ファイル: registry.py プロジェクト: GNOME/pyatspi2
    def setReferenceWIndow(accessible):
        """
                Sets the reference window that will be used when
                generateMouseEvent is called. Coordinates will be assumed to
                be relative to this window. This * is needed because, due to
                Wayland's security model, it is not currently possible to
                possible to retrieve global coordinates.
                If NULL is passed, then AT-SPI will use the window that has
                focus at the time that atspi_generate_mouse_event is called.

                @@param accessible: the accessible corresponding to the window
                to select. should be a top-level window with a role of
                pyatspi.ROLE_APPLICATION.
                """
        if not self.has_implementations:
            self._set_default_registry()
        Atspi.setReferenceWindow(accessible)
コード例 #14
0
ファイル: registry.py プロジェクト: thnguyn2/ECE_527_MP
        def generateMouseEvent(self, x, y, name):
                """
                Generates a mouse event at the given absolute x and y coordinate. The kind
                of event generated is specified by the name. For example, MOUSE_B1P 
                (button 1 press), MOUSE_REL (relative motion), MOUSE_B3D (butten 3 
                double-click).

                @@param x: Horizontal coordinate, usually left-hand oriented
                @@type x: integer
                @@param y: Vertical coordinate, usually left-hand oriented
                @@type y: integer
                @@param name: Name of the event to generate
                @@type name: string
                """
                if not self.has_implementations:
                        self._set_default_registry ()
                Atspi.generate_mouse_event (x, y, name)
コード例 #15
0
ファイル: atspi.py プロジェクト: pid0/flashvnc
def find_program(pid):
    desktop = Atspi.get_desktop(0)

    child_count = desktop.get_child_count()
    for i in range(child_count):
        child = desktop.get_child_at_index(i)
        if child.get_process_id() == pid:
            return child
コード例 #16
0
ファイル: registry.py プロジェクト: thnguyn2/ECE_527_MP
        def generateKeyboardEvent(self, keycode, keysym, kind):
                """
                Generates a keyboard event. One of the keycode or the keysym parameters
                should be specified and the other should be None. The kind parameter is 
                required and should be one of the KEY_PRESS, KEY_RELEASE, KEY_PRESSRELEASE,
                KEY_SYM, or KEY_STRING.

                @@param keycode: Hardware keycode or None
                @@type keycode: integer
                @@param keysym: Symbolic key string or None
                @@type keysym: string
                @@param kind: Kind of event to synthesize
                @@type kind: integer
                """
                if not self.has_implementations:
                        self._set_default_registry ()
                if keysym is None:
                        keysym = ""
                Atspi.generate_keyboard_event (keycode, keysym, kind)
コード例 #17
0
ファイル: registry.py プロジェクト: GNOME/pyatspi2
    def generateKeyboardEvent(self, keycode, keysym, kind):
        """
                Generates a keyboard event. One of the keycode or the keysym parameters
                should be specified and the other should be None. The kind parameter is 
                required and should be one of the KEY_PRESS, KEY_RELEASE, KEY_PRESSRELEASE,
                KEY_SYM, KEY_STRING, KEY_LOCKMODIFIERS, or KEY_UNLOCKMODIFIERS.

                @@param keycode: Hardware keycode or None
                @@type keycode: integer
                @@param keysym: Symbolic key string or None
                @@type keysym: string
                @@param kind: Kind of event to synthesize
                @@type kind: integer
                """
        if not self.has_implementations:
            self._set_default_registry()
        if keysym is None:
            keysym = ""
        Atspi.generate_keyboard_event(keycode, keysym, kind)
コード例 #18
0
ファイル: registry.py プロジェクト: GNOME/pyatspi2
    def start(self, asynchronous=False, gil=True, **kwargs):
        """
                Enter the main loop to start receiving and dispatching events.

                @@param asynchronous: Should event dispatch be asynchronous
                        (decoupled) from event receiving from the AT-SPI registry?
                @@type asynchronous: boolean
                @@param gil: Add an idle callback which releases the Python GIL for a few
                        milliseconds to allow other threads to run? Necessary if other threads
                        will be used in this process.
                @@type gil: boolean
                """
        if 'async' in kwargs:
            # support previous API
            asynchronous = kwargs['async']
        if not self.has_implementations:
            self._set_default_registry()
        self.started = True

        if gil:

            def releaseGIL():
                try:
                    time.sleep(1e-2)
                except KeyboardInterrupt as e:
                    # store the exception for later
                    releaseGIL.keyboard_exception = e
                    self.stop()
                return True

            # make room for an exception if one occurs during the
            releaseGIL.keyboard_exception = None
            i = GLib.idle_add(releaseGIL)
            Atspi.event_main()
            GLib.source_remove(i)
            if releaseGIL.keyboard_exception is not None:
                # raise an keyboard exception we may have gotten earlier
                raise releaseGIL.keyboard_exception
        else:
            Atspi.event_main()

        self.started = False
コード例 #19
0
ファイル: registry.py プロジェクト: thnguyn2/ECE_527_MP
        def getDesktop(self, i):
                """
                Gets a reference to the i-th desktop.

                @@param i: Which desktop to get
                @@type i: integer
                @@return: Desktop reference
                @@rtype: Accessibility.Desktop
                """
                if not self.has_implementations:
                        self._set_default_registry ()
                return Atspi.get_desktop(i)
コード例 #20
0
def get_app(name):
    desktop = Atspi.get_desktop(0)
    start = time.time()
    timeout = 5
    app = None
    while app is None and (time.time() - start) < timeout:
        gen = (child for _i, child in children(desktop)
               if child and child.get_name() == name)
        app = next(gen, None)
        if app is None:
            time.sleep(0.6)
    return app
コード例 #21
0
ファイル: registry.py プロジェクト: GNOME/pyatspi2
    def getDesktop(self, i):
        """
                Gets a reference to the i-th desktop.

                @@param i: Which desktop to get
                @@type i: integer
                @@return: Desktop reference
                @@rtype: Accessibility.Desktop
                """
        if not self.has_implementations:
            self._set_default_registry()
        return Atspi.get_desktop(i)
コード例 #22
0
ファイル: registry.py プロジェクト: GNOME/pyatspi2
    def deregisterKeystrokeListener(self,
                                    client,
                                    key_set=[],
                                    mask=0,
                                    kind=(_KEY_PRESSED_EVENT,
                                          _KEY_RELEASED_EVENT)):
        """
                Deregisters a listener for key stroke events.

                @@param client: Callable to be invoked when the event occurs
                @@type client: callable
                @@param key_set: Set of hardware key codes to stop monitoring. Leave empty
                        to indicate all keys.
                @@type key_set: list of integer
                @@param mask: When the mask is None, the codes in the key_set will be 
                        monitored only when no modifier is held. When the mask is an 
                        integer, keys in the key_set will be monitored only when the modifiers in
                        the mask are held. When the mask is an iterable over more than one 
                        integer, keys in the key_set will be monitored when any of the modifier
                        combinations in the set are held.
                @@type mask: integer, iterable, None
                @@param kind: Kind of events to stop watching, KEY_PRESSED_EVENT or 
                        KEY_RELEASED_EVENT.
                @@type kind: list
                @@raise KeyError: When the client isn't already registered for events
                """
        if not self.has_implementations:
            self._set_default_registry()
        try:
            listener = self.event_listeners[client]
        except:
            return

        if hasattr(mask, '__iter__'):
            masks = mask
        else:
            masks = [mask]
        for m in masks:
            Atspi.deregister_keystroke_listener(listener, key_set, m,
                                                self.makeKind(kind))
コード例 #23
0
ファイル: registry.py プロジェクト: GNOME/pyatspi2
        def start(self, asynchronous=False, gil=True, **kwargs):
                """
                Enter the main loop to start receiving and dispatching events.

                @@param asynchronous: Should event dispatch be asynchronous
                        (decoupled) from event receiving from the AT-SPI registry?
                @@type asynchronous: boolean
                @@param gil: Add an idle callback which releases the Python GIL for a few
                        milliseconds to allow other threads to run? Necessary if other threads
                        will be used in this process.
                @@type gil: boolean
                """
                if 'async' in kwargs:
                    # support previous API
                    asynchronous = kwargs['async']
                if not self.has_implementations:
                        self._set_default_registry ()
                self.started = True

                if gil:
                        def releaseGIL():
                                try:
                                        time.sleep(1e-2)
                                except KeyboardInterrupt as e:
                                        # store the exception for later
                                        releaseGIL.keyboard_exception = e
                                        self.stop()
                                return True
                        # make room for an exception if one occurs during the 
                        releaseGIL.keyboard_exception = None
                        i = GLib.idle_add(releaseGIL)
                        Atspi.event_main()
                        GLib.source_remove(i)
                        if releaseGIL.keyboard_exception is not None:
                                # raise an keyboard exception we may have gotten earlier
                                raise releaseGIL.keyboard_exception
                else:
                        Atspi.event_main()

                self.started = False
コード例 #24
0
ファイル: e2e.py プロジェクト: MrBrenlla/IPM_1
def run(path, name= None):
    name = name or f"{path}-test-{str(random.randint(0, 100000000))}"
    process = subprocess.Popen([path, '--name', name])
    desktop = Atspi.get_desktop(0)
    start = time.time()
    timeout = 5
    app = None
    while app is None and (time.time() - start) < timeout:
        gen = (child for _i, child in children(desktop) if child and child.get_name() == name)
        app = next(gen, None)
        if app is None:
            time.sleep(0.6)
    return (process, app)
コード例 #25
0
ファイル: sound_generator.py プロジェクト: GNOME/orca
    def _generateRoleName(self, obj, **args):
        """Returns an array of sounds indicating the role of obj."""

        if not _settingsManager.getSetting('playSoundForRole'):
            return []

        role = args.get('role', obj.getRole())
        filename = Atspi.role_get_name(role).replace(' ', '_')
        result = self._convertFilenameToIcon(filename)
        if result:
            return [result]

        return []
コード例 #26
0
    def _generateRoleName(self, obj, **args):
        """Returns an array of sounds indicating the role of obj."""

        if not _settingsManager.getSetting('playSoundForRole'):
            return []

        role = args.get('role', obj.getRole())
        filename = Atspi.role_get_name(role).replace(' ', '_')
        result = self._convertFilenameToIcon(filename)
        if result:
            return [result]

        return []
コード例 #27
0
ファイル: registry.py プロジェクト: jaduwvad/makolli_blackbox
                        self._set_default_registry ()
                self.started = True

                if gil:
                        def releaseGIL():
                                try:
                                        time.sleep(1e-2)
                                except KeyboardInterrupt as e:
                                        # store the exception for later
                                        releaseGIL.keyboard_exception = e
                                        self.stop()
                                return True
                        # make room for an exception if one occurs during the 
                        releaseGIL.keyboard_exception = None
                        i = GLib.idle_add(releaseGIL)
                        Atspi.event_main()
                        GLib.source_remove(i)
                        if releaseGIL.keyboard_exception is not None:
                                # raise an keyboard exception we may have gotten earlier
                                raise releaseGIL.keyboard_exception
                else:
                        Atspi.event_main()

                self.started = False

        def stop(self, *args):
                """
                Quits the main loop.
                """
                if not self.has_implementations:
                        self._set_default_registry ()
コード例 #28
0
ファイル: registry.py プロジェクト: thnguyn2/ECE_527_MP
                        self._set_default_registry ()
                self.started = True

                if gil:
                        def releaseGIL():
                                try:
                                        time.sleep(1e-2)
                                except KeyboardInterrupt, e:
                                        # store the exception for later
                                        releaseGIL.keyboard_exception = e
                                        self.stop()
                                return True
                        # make room for an exception if one occurs during the 
                        releaseGIL.keyboard_exception = None
                        i = GObject.idle_add(releaseGIL)
                        Atspi.event_main()
                        GObject.source_remove(i)
                        if releaseGIL.keyboard_exception is not None:
                                # raise an keyboard exception we may have gotten earlier
                                raise releaseGIL.keyboard_exception
                else:
                        Atspi.event_main()

                self.started = False

        def stop(self, *args):
                """
                Quits the main loop.
                """
                if not self.has_implementations:
                        self._set_default_registry ()
コード例 #29
0
def release(button=1, x_offset=0, y_offset=0):
    Atspi.generate_mouse_event(x_offset, y_offset, "b%sr" % button)
    return True
コード例 #30
0
 def click(self, button=1, x_offset=0, y_offset=0):
     point = self._accessible.get_position(Atspi.CoordType.SCREEN)
     Atspi.generate_mouse_event(point.x+x_offset,
                                point.y+y_offset,
                                "b%sc" % button)
コード例 #31
0
ファイル: KeySynth.py プロジェクト: bfredl/chordkey
 def press_key_string(self, string):
     #print("press_key_string")
     Atspi.generate_keyboard_event(0, string, Atspi.KeySynthType.STRING)
コード例 #32
0
ファイル: KeySynth.py プロジェクト: bfredl/chordkey
 def release_keycode(self, keycode):
     #print("release_keycode")
     Atspi.generate_keyboard_event(keycode, "", Atspi.KeySynthType.RELEASE)
コード例 #33
0
ファイル: atspi.py プロジェクト: pid0/flashvnc
def main(argv):
    if Atspi.init() != 0:
        eprint("could not init")
        return 1

    pid = int(argv[1])
    command = argv[2]
    command_args = argv[3:]

    start_time = time.perf_counter()
    (client, drawing_area) = find(pid)
    while (client is None or drawing_area is None) and command == "wait":
        time.sleep(0.1)
        if time.perf_counter() - start_time > TIMEOUT_IN_S:
            return 1
        (client, drawing_area) = find(pid)

    if client is None:
        eprint("no such pid")
        return 1
    if drawing_area is None:
        eprint("client has no drawing area")
        return 1

    if command == "wait":
        return 0


#    extents = obj.get_extents(Atspi.CoordType.SCREEN)
#    print(extents.x, extents.y, extents.width, extents.height)
#    testPy.grab_focus()
#    print(Atspi.generate_mouse_event(extents.x, extents.y, "b1c")) #button 1 click

    screen_extents = drawing_area.get_extents(Atspi.CoordType.SCREEN)
    window_extents = drawing_area.get_extents(Atspi.CoordType.WINDOW)

    #needs can_focus on target widget
    drawing_area.grab_focus()

    if command == "mouse":
        if command_args[0] == "m":
            relative = command_args[1] == "rel"
            x = int(command_args[2])
            y = int(command_args[3])
            if not relative:
                x += screen_extents.x
                y += screen_extents.y
            return move_mouse(relative, x, y)
        else:
            return generate_mouse_event(command_args[0])
    elif command == "query-screen-size":
        eprint(window_extents.width, window_extents.height)
        return query_return_code(
            window_extents.width == int(command_args[0])
            and window_extents.height == int(command_args[1]))
    elif command == "take-screenshot":
        dest = command_args[0]
        screen = Gdk.get_default_root_window()
        pixbuf = Gdk.pixbuf_get_from_window(screen, screen_extents.x,
                                            screen_extents.y,
                                            screen_extents.width,
                                            screen_extents.height)
        pixbuf.savev(dest, "png", [], [])
    elif command == "focus":
        time.sleep(0.5)
        drawing_area.grab_focus()
        time.sleep(0.5)
    elif command.startswith("key"):
        return generate_keyboard_event(command, int(command_args[0]))
    elif command == "resize":
        width, height = (s for s in command_args[:2])
        if subprocess.run([
                "xdotool", "getactivewindow", "windowsize", "--sync", width,
                height
        ]).returncode != 0:
            return False
    else:
        eprint("no such command")
        return 2

    return 0
コード例 #34
0
ファイル: tree.py プロジェクト: erik/sugar-build
import logging
import time

from gi.repository import Atspi
from gi.repository import GLib

Atspi.set_timeout(-1, -1)


def get_root():
    return Node(Atspi.get_desktop(0))


def _retry_find(func):
    def wrapped(*args, **kwargs):
        result = None
        n_retries = 1

        while n_retries <= 50:
            logging.info("Try %d, name=%s role_name=%s" %
                         (n_retries, kwargs.get(
                             "name", None), kwargs.get("role_name", None)))

            try:
                result = func(*args, **kwargs)
            except GLib.GError, e:
                # The application is not responding, try again
                if e.code == Atspi.Error.IPC:
                    continue

                logging.error("GError code %d", e.code)
コード例 #35
0
def press(button=1, x_offset=0, y_offset=0):
    Atspi.generate_mouse_event(x_offset, y_offset, "b%sp" % button)
    return True
コード例 #36
0
def release(button=1, x_offset=0, y_offset=0):
    Atspi.generate_mouse_event(x_offset, y_offset, "b%sr" % button)
    return True
コード例 #37
0
def absMotion(x_offset=0, y_offset=0):
    Atspi.generate_mouse_event(x_offset, y_offset, "abs")
    return True
コード例 #38
0
 def click(self, button=1, x_offset=0, y_offset=0):
     point = self._accessible.get_position(Atspi.CoordType.SCREEN)
     Atspi.generate_mouse_event(point.x + x_offset, point.y + y_offset,
                                "b%sc" % button)
コード例 #39
0
def get_root():
    return Node(Atspi.get_desktop(0))
コード例 #40
0
 def click(self, button=1):
     point = self._accessible.get_position(Atspi.CoordType.SCREEN)
     Atspi.generate_mouse_event(point.x, point.y, "b%sc" % button)
コード例 #41
0
ファイル: tree.py プロジェクト: AlanJAS/sugar-build
import logging
import time

from gi.repository import Atspi
from gi.repository import GLib

Atspi.set_timeout(-1, -1)


def get_root():
    return Node(Atspi.get_desktop(0))


def _retry_find(func):
    def wrapped(*args, **kwargs):
        result = None
        n_retries = 1

        while n_retries <= 50:
            logging.info("Try %d, name=%s role_name=%s" %
                         (n_retries,
                          kwargs.get("name", None),
                          kwargs.get("role_name", None)))

            try:
                result = func(*args, **kwargs)
            except GLib.GError, e:
                # The application is not responding, try again
                if e.code == Atspi.Error.IPC:
                    continue
コード例 #42
0
ファイル: KeySynth.py プロジェクト: bfredl/chordkey
 def press_keycode(self, keycode):
     #print("press_keycode")
     Atspi.generate_keyboard_event(keycode, "", Atspi.KeySynthType.PRESS)
コード例 #43
0
def get_root():
    return Node(Atspi.get_desktop(0))
コード例 #44
0
def key_press(key_name):
    key_sym = name_to_sym(key_name)
    Atspi.generate_keyboard_event(key_sym,
                                  None,
                                  Atspi.KeySynthType.SYM)
コード例 #45
0
 def click(self, button=1):
     point = self._accessible.get_position(Atspi.CoordType.SCREEN)
     Atspi.generate_mouse_event(point.x, point.y, "b%sc" % button)
コード例 #46
0
def absMotion(x_offset=0, y_offset=0):
    Atspi.generate_mouse_event(x_offset, y_offset, "abs")
    return True
コード例 #47
0
ファイル: state.py プロジェクト: ch1huizong/scode
def StateSet_getStates(self):
    ret = []
    for i in range(0, 64):
        if (self.states & (1 << i)):
            ret.append(Atspi.StateType(i))
    return ret
コード例 #48
0
def key_press(key_name):
    key_sym = name_to_sym(key_name)
    Atspi.generate_keyboard_event(key_sym, None, Atspi.KeySynthType.SYM)
コード例 #49
0
def press(button=1, x_offset=0, y_offset=0):
    Atspi.generate_mouse_event(x_offset, y_offset, "b%sp" % button)
    return True