def run(self):
     """
     listener keycode _exit_check_key
     """
     try:
         while True:
             if keyboard_check.check_key_is_press(self._exit_check_key):
                 _thread.interrupt_main()
     except AutoControlException:
         _thread.interrupt_main()
         raise AutoControlException(je_auto_control_critical_exit_error)
def stop_record():
    if sys.platform == "darwin":
        raise AutoControlException(macos_record_error)
    action_queue = recorder.stop_record()
    if action_queue is None:
        raise AutoControlJsonActionException
    action_list = list(action_queue.queue)
    new_list = list()
    for action in action_list:
        if action[0] == "type_key":
            new_list.append([action[0], dict([["keycode", action[1]]])])
        else:
            new_list.append([action[0], dict(zip(["mouse_keycode", "x", "y"], [action[0], action[1], action[2]]))])
    return new_list
    def run(self, reply):
        """
        :param reply listener return data
        get data
        while data not null and still listener
            get event

        """
        try:
            data = reply.data
            while len(data) and self.still_listener:
                event, data = rq.EventField(None).parse_binary_value(
                    data, current_display.display, None, None)
                if event.detail != 0:
                    if event.type is X.ButtonRelease or event.type is X.KeyRelease:
                        self.event_keycode = event.detail
                        self.event_position = event.root_x, event.root_y
                        if self.record_flag is True:
                            temp = (event.type, event.detail, event.root_x,
                                    event.root_y)
                            self.record_queue.put(temp)
        except AutoControlException:
            raise AutoControlException(listener_error)
 def run(self):
     """
     while still listener
         get context
         set handler
         set test_record
         get event
     """
     if self.still_listener:
         try:
             # Monitor keypress and button press
             if self.context is None:
                 self.context = current_display.record_create_context(
                     0, [record.AllClients], [{
                         'core_requests': (0, 0),
                         'core_replies': (0, 0),
                         'ext_requests': (0, 0, 0, 0),
                         'ext_replies': (0, 0, 0, 0),
                         'delivered_events': (0, 0),
                         'device_events':
                         (X.KeyReleaseMask, X.ButtonReleaseMask),
                         'errors': (0, 0),
                         'client_started':
                         False,
                         'client_died':
                         False,
                     }])
                 current_display.record_enable_context(
                     self.context, self.handler.run)
                 current_display.record_free_context(self.context)
             # keep running this to get event
             next_event = self.root.display.next_event()
         except AutoControlException:
             raise AutoControlException(listener_error)
         finally:
             self.handler.still_listener = False
             self.still_listener = False
Example #5
0
import sys

from je_auto_control.utils.exception.exception_tag import windows_import_error
from je_auto_control.utils.exception.exceptions import AutoControlException

if sys.platform not in ["win32", "cygwin", "msys"]:
    raise AutoControlException(windows_import_error)
"""
windows mouse virtual keycode
"""

win32_MOVE = 0x0001
win32_LEFTDOWN = 0x0002
win32_LEFTUP = 0x0004
win32_RIGHTDOWN = 0x0008
win32_RIGHTUP = 0x0010
win32_MIDDLEDOWN = 0x0020
win32_MIDDLEUP = 0x0040
win32_DOWN = 0x0080
win32_XUP = 0x0100
win32_WHEEL = 0x0800
win32_HWHEEL = 0x1000
win32_ABSOLUTE = 0x8000
win32_XBUTTON1 = 0x0001
win32_XBUTTON2 = 0x0002

win32_VK_LBUTTON = 0x01
win32_VK_RBUTTON = 0x02
win32_VK_MBUTTON = 0x04
win32_VK_XBUTTON1 = 0x05
win32_VK_XBUTTON2 = 0x06
import sys

from je_auto_control.utils.exception.exceptions import AutoControlException
from je_auto_control.utils.exception.exception_tag import linux_import_error

if sys.platform not in ["linux", "linux2"]:
    raise AutoControlException(linux_import_error)

import Xlib
from Xlib import XK
from je_auto_control.linux_with_x11.core.utils.x11_linux_display import display

"""
x11 linux virtual keycode
"""
x11_linux_key_backspace = display.keysym_to_keycode(Xlib.XK.string_to_keysym("BackSpace"))
x11_linux_key_slash_b = display.keysym_to_keycode(Xlib.XK.string_to_keysym("BackSpace"))
x11_linux_key_tab = display.keysym_to_keycode(Xlib.XK.string_to_keysym("Tab"))
x11_linux_key_enter = display.keysym_to_keycode(Xlib.XK.string_to_keysym("Return"))
x11_linux_key_return = display.keysym_to_keycode(Xlib.XK.string_to_keysym("Return"))
x11_linux_key_shift = display.keysym_to_keycode(Xlib.XK.string_to_keysym("Shift_L"))
x11_linux_key_ctrl = display.keysym_to_keycode(Xlib.XK.string_to_keysym("Control_L"))
x11_linux_key_alt = display.keysym_to_keycode(Xlib.XK.string_to_keysym("Alt_L"))
x11_linux_key_pause = display.keysym_to_keycode(Xlib.XK.string_to_keysym("Pause"))
x11_linux_key_capslock = display.keysym_to_keycode(Xlib.XK.string_to_keysym("Caps_Lock"))
x11_linux_key_esc = display.keysym_to_keycode(Xlib.XK.string_to_keysym("Escape"))
x11_linux_key_escape = display.keysym_to_keycode(Xlib.XK.string_to_keysym("Escape"))
x11_linux_key_pgup = display.keysym_to_keycode(Xlib.XK.string_to_keysym("Page_Up"))
x11_linux_key_pgdn = display.keysym_to_keycode(Xlib.XK.string_to_keysym("Page_Down"))
x11_linux_key_pageup = display.keysym_to_keycode(Xlib.XK.string_to_keysym("Page_Up"))
x11_linux_key_pagedown = display.keysym_to_keycode(Xlib.XK.string_to_keysym("Page_Down"))
def record():
    if sys.platform == "darwin":
        raise AutoControlException(macos_record_error)
    return recorder.record()
Example #8
0
import sys

from je_auto_control.utils.exception.exception_tag import osx_import_error
from je_auto_control.utils.exception.exceptions import AutoControlException

if sys.platform not in ["darwin"]:
    raise AutoControlException(osx_import_error)

"""
osx keyboard virtual keycode
"""
osx_key_a = osx_key_A = 0x00
osx_key_s = osx_key_S = 0x01
osx_key_d = osx_key_D = 0x02
osx_key_f = osx_key_F = 0x03
osx_key_h = osx_key_H = 0x04
osx_key_g = osx_key_G = 0x05
osx_key_z = osx_key_Z = 0x06
osx_key_x = osx_key_X = 0x07
osx_key_c = osx_key_C = 0x08
osx_key_v = osx_key_V = 0x09
osx_key_b = osx_key_B = 0x0b
osx_key_q = osx_key_Q = 0x0c
osx_key_w = osx_key_W = 0x0d
osx_key_e = osx_key_E = 0x0e
osx_key_r = osx_key_R = 0x0f
osx_key_y = osx_key_Y = 0x10
osx_key_t = osx_key_T = 0x11
osx_key_1 = osx_key_exclam = 0x12
osx_key_2 = osx_key_at = 0x13
osx_key_3 = osx_key_numbersign = 0x14