Example #1
1
    def tick(self):
        now = time.asctime(time.localtime())
        changed, modifiers, keys = kl.fetch_keys()
        if(self.previous_key == "<caps lock>") :
            if(keys == "<esc>") :
                return False            
            elif(not keys and modifiers["left shift"] ) :
                self.caps = False
                self.selected+=1
                if(self.selected > (self.lines - 1) or self.selected > len(self.result)) :
                    self.selected = 0
                self.previous_key = ""
        if keys : 
            if(len(keys) == 1 and keys not in self.end_chars) :
                self.word += str(keys)
            elif(keys == "<backspace>"):
                self.word = self.word[0:-1]
            elif(self.result and keys == "<caps lock>" and self.previous_key == "<caps lock>") :
                v = virtkey.virtkey()
                for i in range(len(self.word), len(self.result[self.selected])) :
                    v.press_unicode(ord(self.result[self.selected][i]))
                    v.release_unicode(ord(self.result[self.selected][i]))
                v.press_unicode(ord(" "))
                v.release_unicode(ord(" "))
                self.selected = 0
                self.word = ""
                self.result = []
            elif(keys == "<caps lock>") :
                self.caps = True
                self.previous_key = keys
            else:
                self.word = ""

            if(keys != "<caps lock>") :
                self.caps = False

            self.previous_key = keys

            if(self.word):
                #raw_result = subprocess.Popen(['look', self.word], stdout=subprocess.PIPE).communicate()[0]
                #self.result = string.split(raw_result)
                self.result = self.wb.getWords(self.word)
            else:
                self.result = []

        if(self.caps) :
            self.osd.set_colour("green")
        else :
            self.osd.set_colour("white")

        for i in range(10):
            if(len(self.result) > i):
                if(i == self.selected):
                    self.osd.display("[ " + self.result[i] + " ]", line = i)
                else :
                    self.osd.display("  " + self.result[i], line = i)
            else :
                self.osd.display("", line = i)
                
        return True
Example #2
0
 def __init__(self):
     self.src = 0
     try:
         import virtkey
         self.v = virtkey.virtkey()
     except:
         print 'virtkey module not available'
Example #3
0
    def init_xtest(self):
        """
        Initialise XTEST if it is available.
        """
        if self.x_test_available == None:
            logger.info("Initialising macro output system")
            
            # Load Python Virtkey if it is available

            # Use python-virtkey for preference
            
            self.virtual_keyboard = None
            try:
                import virtkey
                self.virtual_keyboard = virtkey.virtkey()
                self.x_test_available = False
            except Exception as e:
                logger.warn("No python-virtkey, macros may be weird. Trying XTest", exc_info = e)
    
                # Determine whether to use XTest for sending key events to X
                self.x_test_available  = True
                try :
                    import Xlib.ext.xtest
                except ImportError as e:
                    logger.warn("No XTest, falling back to raw X11 events", exc_info = e)
                    self.x_test_available = False
                     
                self.local_dpy = Xlib.display.Display()
                
                if self.x_test_available  and not self.local_dpy.query_extension("XTEST") :
                    logger.warn("Found XTEST module, but the X extension could not be found")
                    self.x_test_available = False
Example #4
0
    def init_xtest(self):
        """
        Initialise XTEST if it is available.
        """
        if self.x_test_available is None:
            logger.info("Initialising macro output system")

            # Load Python Virtkey if it is available

            # Use python-virtkey for preference

            self.virtual_keyboard = None
            try:
                import virtkey
                self.virtual_keyboard = virtkey.virtkey()
                self.x_test_available = False
            except Exception as e:
                logger.warning("No python-virtkey, macros may be weird. Trying XTest", exc_info=e)

                # Determine whether to use XTest for sending key events to X
                self.x_test_available = True
                try:
                    import Xlib.ext.xtest
                except ImportError as e:
                    logger.warning("No XTest, falling back to raw X11 events", exc_info=e)
                    self.x_test_available = False

                self.local_dpy = Xlib.display.Display()

                if self.x_test_available and not self.local_dpy.query_extension("XTEST"):
                    logger.warning("Found XTEST module, but the X extension could not be found")
                    self.x_test_available = False
Example #5
0
def tapCtrlChar(char, delay):
    v = virtkey.virtkey()  # 调用系统键盘
    v.press_keysym(65507)  # Ctrl键位
    v.press_unicode(ord(char))  # 模拟字母V
    v.release_unicode(ord(char))
    v.release_keysym(65507)
    time.sleep(delay)
    def __init__(self):
        self.__current_acc = None 
        if binary == True:
            self._morse = Morse()
            self._morse.registerListener(caribouwindow.update)
	    self._morse.fireToListener() #get the caribouwindow to do everything on startup
	    self.vk = virtkey.virtkey()
Example #7
0
def op_syscall(process):

    state = process.syscall_state
    syscall = state.event(FunctionCallOptions())

    words = get_words()

    if syscall.name == 'write':
        co = re.sub(r'(\\x.*?m)', '', syscall.format())
        matched = re.match(r".*\,(.*)\,.*", co)

        if matched:
            cleanup = re.sub(r'(\\r|\'|\\n)+', '', matched.group(1))

            if cleanup:
                splitted = cleanup.split(" ")
                for word in words:
                    for captured in splitted:
                        if captured.startswith(word):
                            v = virtkey.virtkey()

                            for key in word:
                                key_value = gtk.gdk.keyval_from_name(key)
                                v.press_unicode(key_value)
                                v.release_unicode(key_value)

                            v.press_keysym(enter_key)
                            v.release_keysym(enter_key)
    process.syscall()
Example #8
0
    def __init__(self, engine):
        import eekboard, virtkey

        self.__engine = engine
        self.__input_mode = None
        self.__typing_mode = None

        self.__client = eekboard.Client()
        self.__context = self.__client.create_context("ibus-skk")

        self.__keyboard_type_to_id = {
            KEYBOARD_TYPE_US: self.__context.add_keyboard("us"),
            KEYBOARD_TYPE_JP: self.__context.add_keyboard("jp-kana")
            }
        self.__keyboard_id_to_type = dict()
        for k, v in self.__keyboard_type_to_id.iteritems():
            self.__keyboard_id_to_type[v] = k

        self.__keyboard_type = None
        self.__group = 0
        self.__set_keyboard_type(KEYBOARD_TYPE_US)
        self.__set_group(0)
        self.__context.connect('key-pressed', self.__key_pressed_cb)
        self.__context.connect('notify::keyboard', self.__notify_keyboard_cb)
        self.__context.connect('notify::group', self.__notify_group_cb)
        self.__virtkey = virtkey.virtkey()
Example #9
0
	def __init__(self):
		self.src = 0
		try:
			import virtkey
			self.v = virtkey.virtkey()
		except:
			print 'virtkey module not available'
def op_syscall(process):

    state = process.syscall_state
    syscall = state.event(FunctionCallOptions())

    words = get_words()

    if syscall.name == 'write':
        co = re.sub(r'(\\x.*?m)', '', syscall.format())
        matched = re.match(r".*\,(.*)\,.*", co)

        if matched:
            cleanup = re.sub(r'(\\r|\'|\\n)+', '', matched.group(1))

            if cleanup:
                splitted = cleanup.split(" ")
                for word in words:
                    for captured in splitted:
                        if captured.startswith(word):
                            v = virtkey.virtkey()

                            for key in word:
                                key_value = gtk.gdk.keyval_from_name(key)
                                v.press_unicode(key_value)
                                v.release_unicode(key_value)

                            v.press_keysym(enter_key)
                            v.release_keysym(enter_key)
    process.syscall()
def send_tab_key():

    v = virtkey.virtkey()
    sleep(3)
    print('click tab key one time')
    v.press_keysym(65289)
    v.release_keysym(65289)
    print('end to click')
Example #12
0
 def __init__(self):
     self.__current_acc = None
     if binary == True:
         self._morse = Morse()
         self._morse.registerListener(caribouwindow.update)
         self._morse.fireToListener(
         )  #get the caribouwindow to do everything on startup
         self.vk = virtkey.virtkey()
Example #13
0
def simulate():
    v = virtkey.virtkey()
    while True:
        time.sleep(1)
        v.press_unicode(ord("a"))
        v.release_unicode(ord("a"))
        v.press_keysym(65363)
        v.release_keysym(65363)
    pass
Example #14
0
def simulate():
    v = virtkey.virtkey()
    while True:
    	time.sleep(1)
    	v.press_unicode(ord("a"))
   	v.release_unicode(ord("a"))
    	v.press_keysym(65363)
    	v.release_keysym(65363)
    pass
Example #15
0
    def __init__(self,parent = None):
        QtGui.QWidget.__init__(self,parent)

        self.setGeometry(300,300,250,150)
        self.setWindowTitle('Virtual NumLock')
        self.quit = QtGui.QPushButton('VirtNuLk',self)
        self.quit.setGeometry(10,10,80,55)
	self.virtk = virtkey.virtkey()

        self.connect(self.quit,QtCore.SIGNAL('clicked()'),self.virtNuLk)
Example #16
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.setGeometry(300, 300, 250, 150)
        self.setWindowTitle('Virtual NumLock')
        self.quit = QtGui.QPushButton('VirtNuLk', self)
        self.quit.setGeometry(10, 10, 80, 55)
        self.virtk = virtkey.virtkey()

        self.connect(self.quit, QtCore.SIGNAL('clicked()'), self.virtNuLk)
Example #17
0
	def __init__(self):
		self.settings = {'FMse_s':(275,425), 'FMse_e':(200,75),'FApp_s':(100,21),'FApp_e':(200,75),'FGam_s':(500,21),'FGam_e':(310,75),'FPaint_s':(850,21),'FPundo':(100,21),'FPnew':(300,21),'FPsave':(500,21),'FPexit':(800,21),'FPend':(150,75),'FSet':(850,101)}
		self.letter= {'ru':' ','luldrdrulurdru':'a','luldrdrurdru':'a','ldrdrulurdru':'a','ldrdrurdru':'a','luldrdrurd':'a','rululdrdrululd':'b','ldlururdldlu':'b','rdrurdld':'b','ldrurdldlu':'b','ldrurdld':'b','rdrurdldluld':'b','rdrurdldlu':'y','rululdrurdldlu':'b','ruldrdrulu':'b','rululdrdrululd':'b','ruldrdrululd':'b','ldluldrdru':'c','luldrdru':'c','ldrdru':'c','ldrdruldrd':'d','luldrdruldrdru':'d','luldrdrulurd':'d','rululdrdru':'e','rdrululdrdru':'e','rdrululdrdrulu':'e','ruldrdrululdru':'f','rululdrdrululdru':'f','luldrdruldlu':'g','luldrdrurdldluru':'g','luldrdrurdldluld':'g','ldrdruldlu':'g','luldrdrurdldlu':'g','rululdrdrurdru':'h','ldlururd':'h','ldrurd':'n','rurdru':'n','rululdrurdru':'h','ruldrurd':'h','ld':'i','ldrd':'i','rd':'i','rdld':'i','ruldluru':'j','rurdldluru':'j','ruldlu':'j','ldruldrdru':'k','ldruldlurdru':'k','ldlururdldrdru':'k','rdruldrdru':'k','rdruldrd':'k','rululdrd':'l','ruldluldrdru':'l','rululdrdru':'l','ruldru':'l','rurdrurdrurdld':'m','rurdldlururdrurdru':'m','ldrurdlururdld':'m','rdrurdrurdldru':'m','rdrurdrurd':'m','rdrurdldlururdld':'m','rurdrurdru':'n','rdrurdldrurdru':'n','ruldrurdld':'n','rurdldlururd':'n','rurdldrurdldrdru':'n','rdldrdrurd':'n','rurdldlururdld':'n','luldrdrulu':'o','ldrdrulu':'o','rdrululd':'o','ldrdrululd':'o','lururdld':'p','rulururdldlu':'p','rurdlururdld':'p','rdrulururdldlu':'p','rurdldrurd':'n','ldlururdld':'p','luldrdruldru':'q','luldrdruldru':'q','ldrdrululdru':'q','luldrdrululdrdru':'q','rurdluru':'r','rdldlururd':'r','rululdrdrurdru':'r','rdlururd':'r','rurdldlururd':'r','luldrdrurdldlu':'s','luldrdldlu':'s','rdluldrdldlu':'s','ldrdld':'s','luldrdrurdldlu':'s','luldruldrdru':'t','luldluruldrdrurd':'t','rdrurdru':'u','rurdrurd':'u','rurdrululdrdru':'u','rurdruldrdru':'u','rdru':'v','rdrululdrd':'v','rdrurdru':'w','ldrurdru':'w','rdrurdrulu':'w','rdruldrdrululd':'w','rdldruldrdru':'x','rurdldruldrdru':'x','rdldrurdldrd':'x','rdrurdldluru':'y','rdruldrdldluru':'y','rurdrurdldluru':'y','rurdruldlu':'y','rurdruldru':'y','ruldru':'z','ruldrurd':'z','rurdldrdru':'z','rdldrd':'z'}
		self.xx,self.yy=0,0
		self.xxl,self.yyl,self.xxr,self.yyr=0,0,0,0
		self.ptr = (250,132,123)
		self.lbtn=False
		self.rbtn = False
		self.gptr,self.gptl=(255,255,255),(255,255,255)
		self.capture = cv.CaptureFromCAM(0)
		self.camres_x = 1280.0
		self.camres_y = 1024.0
		self.pt = None
		self.win_size = 10
		self.MAX_COUNT = 500
		self.display = Xlib.display.Display()
		self.screen = self.display.screen()
		self.pbrushc = (255,0,0)		
		self.root = self.screen.root	
		self.res_x,self.res_y = self.get_screen_resolution()	
		self.res_x,self.res_y=float(self.res_x),float(self.res_y)
	    	self.mx = self.res_x/self.camres_x
	   	self.my = self.res_y/self.camres_y
		cv.SetCaptureProperty( self.capture, 3, 1280 )
		cv.SetCaptureProperty( self.capture, 4,1024  )
		self.hsv_img = self.mir_img  = self.image = self.img = self.frame = cv.QueryFrame(self.capture)
		self.relimage = cv.CreateImage (cv.GetSize (self.frame), 8, 3)
		cv.NamedWindow ('MirrorX  by VMX', cv.CV_WINDOW_NORMAL)
		#cv.NamedWindow ('sCollor', cv.CV_WINDOW_NORMAL)
		cv.SetMouseCallback ('sCollor', self.on_mouse, None)
		cv.SetMouseCallback ('MirrorX  by VMX', self.on_mousew, None)
		self.hsv_img2 = cv.CreateImage (cv.GetSize (self.relimage), 8, 3)
		self.text = " Music "
		self.fnt =cv.InitFont(2, 2, 1,0,4,8) 
		self.selection = None
        	self.drag_start = None
		self.drag = None
		self.Setting=self.writpad=self.Mousecntl=self.GameMode=self.NonStop=self.PaintA = False
		self.clicked = None
		self.sett = False		
		self.mosppp=self.mospp= self.mosp = []
		self.lettr=['|']
		self.train=""
		self.nowltr=""
		self.count_color = 1
        	self.tracking_state = 0
		self.ptrlu=(5, 166, 101)
		self.ptrld=(8, 215, 255)
		self.ptrru=(21, 148, 142)
		self.ptrrd=(27, 198, 243)
		self.ptrmu=(0, 159, 131) 
		self.ptrmd=(4, 183, 162)
		self.pbrushc=(0,0,255)
		self.pbrushs=5
		self.v = virtkey.virtkey()
Example #18
0
File: musca.py Project: solos/musca
    def __init__(self, config=None, **kargs):
        if config:
            self.Mod4 = config['Mod4']
            self.Mod1 = config['Mod1']
            self.Shift = config['Shift']
        else:
            self.Mod4 = 'Super_L'
            self.Mod1 = 'Alt_L'
            self.Shift = 'Shift_L'

        self.v = virtkey.virtkey()
Example #19
0
File: musca.py Project: lowks/musca
    def __init__(self, config=None, **kargs):
        if config:
            self.Mod4 = config['Mod4']
            self.Mod1 = config['Mod1']
            self.Shift = config['Shift']
        else:
            self.Mod4 = 'Super_L'
            self.Mod1 = 'Alt_L'
            self.Shift = 'Shift_L'

        self.v = virtkey.virtkey()
Example #20
0
    def get_vk(self):
        if not self._vk:
            try:
                # may fail if there is no X keyboard (LP: 526791)
                self._vk = virtkey.virtkey()

            except virtkey.error as e:
                t = time.time()
                if t > self._vk_error_time + .2: # rate limit to once per 200ms
                    _logger.warning("vk: " + unicode_str(e))
                    self._vk_error_time = t

        return self._vk
Example #21
0
    def get_vk(self):
        if not self._vk:
            try:
                # may fail if there is no X keyboard (LP: 526791)
                self._vk = virtkey.virtkey()

            except virtkey.error as e:
                t = time.time()
                if t > self._vk_error_time + .2:  # rate limit to once per 200ms
                    _logger.warning("vk: " + unicode_str(e))
                    self._vk_error_time = t

        return self._vk
Example #22
0
def worker_4(interval):

    c = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    c.connect(('192.168.0.101',8080))
    while(1):
        
        control_data = c.recv(4)
        cv = virtkey.virtkey()
        cv.press_unicode(ord(control_data))
        cv.release_keysym(ord(control_data))

        cv.press_keysym(65421)#按下ENTER
        cv.release_keysym(65421)#释放ENTER
Example #23
0
    def __init__(self, protoPathList, metaPath, mesgHandle):
        cmd.Cmd.__init__(self)
        PeaView.__init__(self, protoPathList, metaPath, mesgHandle)

        self.connectParamPattern = re.compile(
            '(\w+|(?:\d+\.){3}(?:\d+))\s+(\d+)')
        self.historyLoaded = False

        self.setPattern = re.compile('(\w+)\s*=\s*(\$[\w?%]+|\w+:\w*)')
        self.deferredActions = []
        self.isExited = False
        import virtkey
        self.keyboard = virtkey.virtkey()
Example #24
0
 def on_personalise_button_clicked(self, widget):
     new_layout_name = show_ask_string_dialog(
         _("Enter name for personalised layout"), self.window)
     if new_layout_name:
         vk = virtkey()
         keyboard = KeyboardSVG(vk, config.layout_filename,
                                    config.color_scheme_filename)
         layout_xml = utils.create_layout_XML(new_layout_name,
                                              vk,
                                              keyboard)
         utils.save_layout_XML(layout_xml, self.user_layout_root)
         self.update_layoutList()
         self.open_user_layout_dir()
Example #25
0
def type_keycode(code, mask1="", mask2=""):
	v = virtkey.virtkey()
	if mask1 != "" and mask1 in mask_names: 
		v.lock_mod(masks[mask1])
	if mask2 != "" and mask2 in mask_names: 
		v.lock_mod(masks[mask2])

	v.press_keycode(code)
	v.release_keycode(code) #Release must be called IMMEDIATLEY after 'press'!

	if mask1 != "" and mask1 in mask_names:
		v.unlock_mod(masks[mask1])
	if mask2 != "" and mask2 in mask_names:
		v.unlock_mod(masks[mask2])
Example #26
0
class kb_input():
	_kb = virtkey.virtkey()
	keycodes = [ 0xff0d, 0xff55, 0xff53, 0xff56, 0xff51 ]
	#left: sw 7, ord(0xff51) L arrow
	#down: sw 6, ord(0xff56) PgDn
	#right: sw 5, ord(0xff53) R arrow
	#up: switch 4, ord(0xff55) PgUp
	#button: sw 3, ord(0xff0d) enter

	def press(self, mask):
		for i in range(3,8):
			if (mask & ( 1 << i )):
				self._kb.press_keysym(self.keycodes[i-3])
				self._kb.release_keysym(self.keycodes[i-3])
Example #27
0
	def type_keycode(code, mask1="", mask2=""):
		v = virtkey.virtkey()
		if mask1 != "" and mask1 in mask_names: 
			v.lock_mod(masks[mask1])
		if mask2 != "" and mask2 in mask_names: 
			v.lock_mod(masks[mask2])

		v.press_keycode(code)
		v.release_keycode(code) #Release must be called IMMEDIATLEY after 'press'!

		if mask1 != "" and mask1 in mask_names:
			v.unlock_mod(masks[mask1])
		if mask2 != "" and mask2 in mask_names:
			v.unlock_mod(masks[mask2])
Example #28
0
def simulate_keys(keys):
    """ simulate the keys using python-virtkey
        :param keys: (modifiers, keysym); returned by keystroke_to_x11
    """
    modifiers, key = keys

    v = virtkey.virtkey()
    if modifiers:
        v.lock_mod(modifiers)
    try:
        v.press_keysym(key)
        v.release_keysym(key)
    finally:
        if modifiers:
            v.unlock_mod(modifiers)
Example #29
0
 def __init__(self):
     self.os_type = os.name
     self.keyapi = None
     if self.os_type == 'posix':#UNIX
         try:
             import virtkey
             self.keyapi = virtkey.virtkey()
         except ImportError: 
             raise Exception('Module virtkey is not installed, virtual keyboard feature will be disabled!')
         
     if self.os_type == 'nt': #WINDOWS
         try:
             import SendKeys
             self.keyapi = SendKeys
         except ImportError: 
             raise Exception('Module SendKeys is not installed, virtual keyboard feature will be disabled!')
    def __init__(self, app=None):
        import virtkey

        self.keyEmulator = virtkey.virtkey()
        self.app = app
        self.keymap = { 'pgdn': 0xFF9B,
                        'pgup': 0xFF9A,
                        'crup': 0xFF97,
                        'crdn': 0xFF99,
                        'crlt': 0xFF96,
                        'crrt': 0xFF98,
                        'alttab': 0xFF09, 
                        'bkspc': 0xFF08, 
                        'space': 0xFF80,
                        '@': 0x040,
                        'enter': 0xFF8D}
Example #31
0
 def __init__(self):
     self.key_emulator = virtkey.virtkey()
     self.keys = { 'ctrl_left':0xffe3, 'super_left':0xffeb, 'alt_left':0xffe9, 'alt_gr':0xfe03, 'super_right':0xffec, 'ctrl_right':0xffe4,
                 'shift_left':0xffe1, 'shift_right':0xffe2, 'caps_lock':0xffe5, 'enter':0xff0d, 'tab':0xff09, 'backspace':0xff08,
                 'esc':0xff1b, 'f1':0xffbe, 'f2':0xffbf, 'f3':0xffc0, 'f4':0xffc1, 'f5':0xffc2, 'f6':0xffc3, 'f7':0xffc4, 'f8':0xffc5, 'f9':0xffc6, 'f10':0xffc7, 'f11':0xffc8, 'f12':0xffc9,
                 'scroll_lock':0xff14, 'pause':0xff13, 'insert':0xff63, 'home':0xff50, 'page_up':0xff55, 'delete':0xffff, 'end':0xff57, 'page_down':0xff56,
                 'arrow_up':0xff52, 'arrow_down':0xff54, 'arrow_left':0xff51, 'arrow_right':0xff53, 'num_lock':0xff63,
                 'num_divide':0xffaf, 'num_multiply':0xffaa, 'num_subtract':0xffad, 'num_add':0xffab, 'num_enter':0xff8d, 'num_0':0xffb0, 'num_1':0xffb1, 'num_2':0xffb2, 'num_3':0xffb3,
                 'num_4':0xffb4, 'num_5':0xffb5, 'num_6':0xffb6, 'num_7':0xffb7, 'num_8':0xffb8, 'num_9':0xffb9, 'num_separator':0xffac,
                 'xf86modelock':0x1008ff01, 'xf86monbrightnessup':0x1008ff02, 'xf86monbrightnessdown':0x1008ff03, 'xf86kbdlightonoff':0x1008ff04, 'xf86kbdbrightnessup':0x1008ff05, 'xf86kbdbrightnessdown':0x1008ff06,
                 'xf86standby':0x1008ff10, 'xf86audiolowervolume':0x1008ff11, 'xf86audiomute':0x1008ff12, 'xf86audioraisevolume':0x1008ff13, 'xf86audioplay':0x1008ff14, 'xf86audiostop':0x1008ff15,
                 'xf86modelock':0x1008ff01, 'xf86monbrightnessup':0x1008ff02, 'xf86monbrightnessdown':0x1008ff03, 'xf86kbdlightonoff':0x1008ff04, 'xf86kbdbrightnessup':0x1008ff05,
                 'xf86kbdbrightnessdown':0x1008ff06, 'xf86standby':0x1008ff10, 'xf86audiolowervolume':0x1008ff11, 'xf86audiomute':0x1008ff12, 'xf86audioraisevolume':0x1008ff13,
                 'xf86audioplay':0x1008ff14, 'xf86audiostop':0x1008ff15, 'xf86audioprev':0x1008ff16, 'xf86audionext':0x1008ff17, 'xf86homepage':0x1008ff18,
                 'xf86mail':0x1008ff19, 'xf86start':0x1008ff1a, 'xf86search':0x1008ff1b, 'xf86audiorecord':0x1008ff1c, 'xf86calculator':0x1008ff1d,
                 'xf86memo':0x1008ff1e, 'xf86todolist':0x1008ff1f, 'xf86calendar':0x1008ff20, 'xf86powerdown':0x1008ff21, 'xf86contrastadjust':0x1008ff22,
                 'xf86rockerup':0x1008ff23, 'xf86rockerdown':0x1008ff24, 'xf86rockerenter':0x1008ff25, 'xf86back':0x1008ff26, 'xf86forward':0x1008ff27,
                 'xf86stop':0x1008ff28, 'xf86refresh':0x1008ff29, 'xf86poweroff':0x1008ff2a, 'xf86wakeup':0x1008ff2b, 'xf86eject':0x1008ff2c,
                 'xf86screensaver':0x1008ff2d, 'xf86www':0x1008ff2e, 'xf86sleep':0x1008ff2f, 'xf86favorites':0x1008ff30, 'xf86audiopause':0x1008ff31,
                 'xf86audiomedia':0x1008ff32, 'xf86mycomputer':0x1008ff33, 'xf86vendorhome':0x1008ff34, 'xf86lightbulb':0x1008ff35, 'xf86shop':0x1008ff36,
                 'xf86history':0x1008ff37, 'xf86openurl':0x1008ff38, 'xf86addfavorite':0x1008ff39, 'xf86hotlinks':0x1008ff3a, 'xf86brightnessadjust':0x1008ff3b,
                 'xf86finance':0x1008ff3c, 'xf86community':0x1008ff3d, 'xf86audiorewind':0x1008ff3e, 'xf86backforward':0x1008ff3f, 'xf86launch0':0x1008ff40,
                 'xf86launch1':0x1008ff41, 'xf86launch2':0x1008ff42, 'xf86launch3':0x1008ff43, 'xf86launch4':0x1008ff44, 'xf86launch5':0x1008ff45,
                 'xf86launch6':0x1008ff46, 'xf86launch7':0x1008ff47, 'xf86launch8':0x1008ff48, 'xf86launch9':0x1008ff49, 'xf86launcha':0x1008ff4a,
                 'xf86launchb':0x1008ff4b, 'xf86launchc':0x1008ff4c, 'xf86launchd':0x1008ff4d, 'xf86launche':0x1008ff4e, 'xf86launchf':0x1008ff4f,
                 'xf86applicationleft':0x1008ff50, 'xf86applicationright':0x1008ff51, 'xf86book':0x1008ff52, 'xf86cd':0x1008ff53, 'xf86calculater':0x1008ff54,
                 'xf86clear':0x1008ff55, 'xf86close':0x1008ff56, 'xf86copy':0x1008ff57, 'xf86cut':0x1008ff58, 'xf86display':0x1008ff59,
                 'xf86dos':0x1008ff5a, 'xf86documents':0x1008ff5b, 'xf86excel':0x1008ff5c, 'xf86explorer':0x1008ff5d, 'xf86game':0x1008ff5e,
                 'xf86go':0x1008ff5f, 'xf86itouch':0x1008ff60, 'xf86logoff':0x1008ff61, 'xf86market':0x1008ff62, 'xf86meeting':0x1008ff63,
                 'xf86menukb':0x1008ff65, 'xf86menupb':0x1008ff66, 'xf86mysites':0x1008ff67, 'xf86new':0x1008ff68, 'xf86news':0x1008ff69,
                 'xf86officehome':0x1008ff6a, 'xf86open':0x1008ff6b, 'xf86option':0x1008ff6c, 'xf86paste':0x1008ff6d, 'xf86phone':0x1008ff6e,
                 'xf86q':0x1008ff70, 'xf86reply':0x1008ff72, 'xf86reload':0x1008ff73, 'xf86rotatewindows':0x1008ff74, 'xf86rotationpb':0x1008ff75,
                 'xf86rotationkb':0x1008ff76, 'xf86save':0x1008ff77, 'xf86scrollup':0x1008ff78, 'xf86scrolldown':0x1008ff79, 'xf86scrollclick':0x1008ff7a,
                 'xf86send':0x1008ff7b, 'xf86spell':0x1008ff7c, 'xf86splitscreen':0x1008ff7d, 'xf86support':0x1008ff7e, 'xf86taskpane':0x1008ff7f,
                 'xf86terminal':0x1008ff80, 'xf86tools':0x1008ff81, 'xf86travel':0x1008ff82, 'xf86userpb':0x1008ff84, 'xf86user1kb':0x1008ff85,
                 'xf86user2kb':0x1008ff86, 'xf86video':0x1008ff87, 'xf86wheelbutton':0x1008ff88, 'xf86word':0x1008ff89, 'xf86xfer':0x1008ff8a,
                 'xf86zoomin':0x1008ff8b, 'xf86zoomout':0x1008ff8c, 'xf86away':0x1008ff8d, 'xf86messenger':0x1008ff8e, 'xf86webcam':0x1008ff8f,
                 'xf86mailforward':0x1008ff90, 'xf86pictures':0x1008ff91, 'xf86music':0x1008ff92, 'xf86battery':0x1008ff93, 'xf86bluetooth':0x1008ff94,
                 'xf86wlan':0x1008ff95, 'xf86uwb':0x1008ff96, 'xf86audioforward':0x1008ff97, 'xf86audiorepeat':0x1008ff98, 'xf86audiorandomplay':0x1008ff99,
                 'xf86subtitle':0x1008ff9a, 'xf86audiocycletrack':0x1008ff9b, 'xf86cycleangle':0x1008ff9c, 'xf86frameback':0x1008ff9d, 'xf86frameforward':0x1008ff9e,
                 'xf86time':0x1008ff9f, 'xf86select':0x1008ffa0, 'xf86view':0x1008ffa1, 'xf86topmenu':0x1008ffa2, 'xf86red':0x1008ffa3,
                 'xf86green':0x1008ffa4, 'xf86yellow':0x1008ffa5, 'xf86blue':0x1008ffa6, 'xf86_switch_vt_1':0x1008fe01, 'xf86_switch_vt_2':0x1008fe02,
                 'xf86_switch_vt_3':0x1008fe03, 'xf86_switch_vt_4':0x1008fe04, 'xf86_switch_vt_5':0x1008fe05, 'xf86_switch_vt_6':0x1008fe06, 'xf86_switch_vt_7':0x1008fe07,
                 'xf86_switch_vt_8':0x1008fe08, 'xf86_switch_vt_9':0x1008fe09, 'xf86_switch_vt_10':0x1008fe0a, 'xf86_switch_vt_11':0x1008fe0b, 'xf86_switch_vt_12':0x1008fe0c,
                 'xf86_ungrab':0x1008fe20, 'xf86_cleargrab':0x1008fe21, 'xf86_next_vmode':0x1008fe22, 'xf86_prev_vmode':0x1008fe23 }
     self.toggled_keys = []
 def  __init__(self):
     self.tree_update_callback = None
     self.mt = get_morse_tree()
     self.dot_down = False
     self.dash_down = False
     self.select_state = False
     self.firstkeydowntime = 0
     self.twokeys_starttime = 0
     self.backspace = False
     self.newline = False
     self.vk = virtkey.virtkey()
     self.morse_enabled = True
     
     # The following is a hack to make this program initially type with
     # lower-case letters instead of upper-case; because we're using
     # l-shift and r-shift as our two buttons, it capitalizes whatever
     # we type. We'll start with caps-lock on to reverse that.
     self.vk.press_keycode(66)    # 66 is capslock
     self.vk.release_keycode(66)
    def __init__(self):
        self.tree_update_callback = None
        self.mt = get_morse_tree()
        self.dot_down = False
        self.dash_down = False
        self.select_state = False
        self.firstkeydowntime = 0
        self.twokeys_starttime = 0
        self.backspace = False
        self.newline = False
        self.vk = virtkey.virtkey()
        self.morse_enabled = True

        # The following is a hack to make this program initially type with
        # lower-case letters instead of upper-case; because we're using
        # l-shift and r-shift as our two buttons, it capitalizes whatever
        # we type. We'll start with caps-lock on to reverse that.
        self.vk.press_keycode(66)  # 66 is capslock
        self.vk.release_keycode(66)
Example #34
0
def worker_3(interval):  #开启GDB加载elf文件

    print("worker_3")

    print('\n')
    os.system('pwd')
    os.chdir('../')
    os.chdir('workspace/simple-gcc-stm32-project/')
    os.system('arm-none-eabi-gdb -q -x t.py LED_project.elf')

    print("end worker_3")

    #当进程运行到这里时,说明gdb已经已经正常退出了
    v = virtkey.virtkey()

    v.press_keysym(65507)  #按下左CTRL
    v.press_unicode(ord('c'))  #按下C
    v.release_keysym(ord('c'))  #释放C
    v.release_keysym(65507)  #释放左CTRL
Example #35
0
def tapPageDownToEnd():
    '''
    @ 通过判断屏幕是否改变来判断是否到底了,并做2min超时
    @
    @ return
    @
    @ param
    @ exception
    @ notice
    @   需要安装截屏库pyscreenshot
    '''
    srcImg = 'out/screen0.png'
    dstImg = 'out/screen1.png'
    start = time.time()
    v = virtkey.virtkey()  # 调用系统键盘
    while True:
        ImageGrab.grab_to_file(srcImg)
        v.press_keysym(65366)
        v.release_keysym(65366)
        time.sleep(0.5)
        ImageGrab.grab_to_file(dstImg)
        imsrc = ac.imread(srcImg)
        imdst = ac.imread(dstImg)
        pos = ac.find_template(imsrc, imdst)
        if(pos == None):
            print('---pos is None---')
        elif(pos['confidence'] > 0.97):
            print('---confidence %s , break---' % str(pos['confidence']))
            break
        else:
            print('---confidence %s---' % str(pos['confidence']))

        end = time.time()
        if((end - start) > 120): #2min
            print('---time out,break.---')
            break
    os.remove(srcImg)
    os.remove(dstImg)
Example #36
0
def virtkey_test():
    #v = virtkey.virtkey()
    v = virtkey.virtkey()
    v.press_keysym(65507)
    v.press_unicode(ord('v'))
    v.release_unicode(ord('v'))
Example #37
0
def testcontrol():
    def forward(v):
        v.press_unicode(ord('w'))
        v.release_unicode(ord('w'))
        time.sleep(1)

    def backward(v):
        v.press_unicode(ord('s'))
        v.release_unicode(ord('s'))
        time.sleep(1)

    def left(v):
        v.press_unicode(ord('a'))
        v.release_unicode(ord('a'))
        time.sleep(1)

    def right(v):
        v.press_unicode(ord('d'))
        v.release_unicode(ord('d'))
        time.sleep(1)

    def turnleft(v):
        v.press_unicode(ord('q'))
        v.release_unicode(ord('q'))
        time.sleep(1)

    def turnright(v):
        v.press_unicode(ord('e'))
        v.release_unicode(ord('e'))
        time.sleep(1)

    def stop(v):
        v.press_unicode(ord(' '))
        v.release_unicode(ord(' '))
        time.sleep(1)

    def esc(v):
        v.press_unicode(0x1B)
        v.release_unicode(0x1B)
        time.sleep(1)

    os.system(
        """gnome-terminal -e 'bash -c \"source /home/moce/demo_ws/devel/setup.bash; rosrun manual_control manual_ctrl; exec bash\"'"""
    )
    import virtkey
    v = virtkey.virtkey()
    time.sleep(1)
    for i in range(5):
        forward(v)
    time.sleep(5)
    stop(v)
    for i in range(5):
        backward(v)
    time.sleep(5)
    stop(v)
    for i in range(5):
        left(v)
    stop(v)
    for i in range(5):
        right(v)
    time.sleep(5)
    stop(v)
    for i in range(5):
        turnleft(v)
    time.sleep(5)
    stop(v)
    for i in range(5):
        turnright(v)
    time.sleep(5)
    esc(v)
Example #38
0
def simulate():
    #while 1:
    v = virtkey.virtkey()
    print v.press_unicode(ord('a'))
Example #39
0
def tapEnter(delay):
    v = virtkey.virtkey()  # 调用系统键盘
    v.press_keysym(65421) # enter
    v.release_keysym(65421)
    time.sleep(delay)
Example #40
0
def main(argc, argv):
    if argc != 2:
        sys.stderr.write("Usage: %s <base64-text-file>\n" % argv[0])
        return 1

    b64file = argv[1]

    from pymouse import PyMouse
    mouse = PyMouse()

    n = 5
    print "please move the mouse to drop your anchor in %d secs ..." % n
    while n > 0:
        x, y = mouse.position()
        print "mouse is at point(%d, %d), %d secs left ..." % (x, y, n)
        time.sleep(1)
        n -= 1
    x, y = mouse.position()
    print "mouse is locked to point(%d, %d) ..." % (x, y)

    print "please move your mouse away if you'd like to in 5 secs ..."
    time.sleep(5)

    print "move mouse to point(%d, %d) and click ..." % (x, y)
    x0, y0 = mouse.position()
    mouse.move(x, y)
    mouse.click(x, y)

    print "start to write ..."
    import virtkey
    v = virtkey.virtkey()

    with open(b64file, 'r') as f:
        i = 0
        for line in f.readlines():
            i += 1
            s0 = b64str2hex(line.rstrip())
            print "%010d %s %s" % (i, line.rstrip(), s0)

            # input lineno
            s = "%010d " % i
            for c in s:
                v.press_unicode(ord(c))
                v.release_unicode(ord(c))
                time.sleep(0.02)

            # input line
            s = s0
            for c in s:
                v.press_unicode(ord(c))
                v.release_unicode(ord(c))
                time.sleep(0.02)

            # print '\n' (Enter)
            v.press_keysym(65421)
            v.release_keysym(65421)
            time.sleep(0.02)

    print "sleep 5 secs ..."
    time.sleep(5)

    print "move mouse back to (%d, %d)" % (x0, y0)
    mouse.move(x0, y0)

    print "good bye ..."

    return 0
def TypeKey(keysym):
    vk = virtkey.virtkey()
    vk.press_keysym(keysym)
    vk.release_keysym(keysym)
def PressKey(keysym):
    vk = virtkey.virtkey()
    vk.press_keysym(keysym)
Example #43
0
 def __init__(self, name, default=False):            
     import virtkey
     self.v = virtkey.virtkey()
     Player.__init__(self, name, dbus_name="xbmc")        
    class _KeyboardLayout:
        vk = virtkey.virtkey()
	colorHandler = colorhandler.ColorHandler()

        def __init__(self, kdbdef):
            count = 1
            self.layers, self.switch_layer_buttons = [], []
            for layer in kdbdef.layers:
                layervbox = gtk.VBox(homogeneous = True)
                self.layers.append(layervbox)
                layervbox.set_name(layer)
                # get the layer tuple from the string
                layer = getattr(kdbdef, layer)
                for row in layer:
                    rowhbox = gtk.HBox(homogeneous = True)
                    for key in row:
                        # check if the key is defined by a string or a tuple
                        if isinstance(key, str):
                            #print key
                            if key == "pf":
                                # preferences key
                                button = gtk.Button()
                                button.set_use_underline(False)
                                image = gtk.image_new_from_pixbuf(
                                    button.render_icon(gtk.STOCK_PREFERENCES,
                                                       gtk.ICON_SIZE_BUTTON))
                                button.set_image(image)
                                button.connect("clicked", self._open_prefs)
                                self.colorHandler.addButton(button, key);
                            else:
                                # single utf-8 character key
                                button = gtk.Button(key)
                                button.set_use_underline(False)
                                char = ord(key.decode('utf-8'))
                                button.connect("clicked", self._send_unicode, char)
                                self.colorHandler.addButton(button, key);
                        elif isinstance(key, tuple):
                            button = gtk.Button(key[0])
                            button.set_use_underline(False)

                            # check if this key is a layer switch key or not
                            if isinstance(key[1], str):
                                # switch layer key
                                # set layer name on button and save to process later
                                button.set_name(key[1])
                                self.switch_layer_buttons.append(button)
                                if key[0] == "abc":
                                    self.colorHandler.addButton(button, key[0]);
                                else:
                                    self.colorHandler.addButton(button, key[1]);
                            else:
                                # regular key
                                button.connect("clicked", self._send_keysym, key[1])				
                                self.colorHandler.addButton(button, key[1]);
			
                        else:
                            pass # TODO: throw error here

                        rowhbox.pack_start(button, expand = False, fill = True)

                    layervbox.pack_start(rowhbox, expand = False, fill = True)
		    

        def _open_prefs(self, widget):
            KeyboardPreferences()

        def _send_unicode(self, widget, char):
            self.vk.press_unicode(char)
            self.vk.release_unicode(char)

        def _send_keysym(self, widget, char):
            self.vk.press_keysym(char)
            self.vk.release_keysym(char)
 def __init__(self, mapper):
     self.__mapper = mapper
     self.__virtkey = virtkey.virtkey()
Example #46
0
def put_key(key):
    v = virtkey.virtkey()
    for i in str(key):
        v.press_unicode(ord(i))
        v.release_unicode(ord(i))
Example #47
0
def main ():
	global data
	global TouchpadSizeH
	global TouchpadSizeW
	global xMinThreshold
	global yMinThreshold
	global vscrolldelta
	global hscrolldelta
	global v


	#def parseTouchConfig()
	synvars = {}
	p1 = subprocess.Popen(['synclient', '-l'], stdout=subprocess.PIPE)
	for line in p1.stdout:
		line = str(line, encoding='utf8').split()
		if len(line) == 3:
			synvars[line[0]] = line[2]
	p1.stdout.close()
	p1.wait()

	LeftEdge = int(synvars['LeftEdge'])
	RightEdge = int(synvars['RightEdge'])
	TopEdge = int(synvars['TopEdge'])
	BottomEdge = int(synvars['BottomEdge'])

	TouchpadSizeH = BottomEdge - TopEdge
	TouchpadSizeW = RightEdge - LeftEdge
	xMinThreshold = TouchpadSizeW * baseDist;
	yMinThreshold = TouchpadSizeH * baseDist;

	vscrolldelta = int(synvars['VertScrollDelta'])
	hscrolldelta = int(synvars['HorizScrollDelta'])

	print("LeftEdge: " + str(LeftEdge))
	print("RightEdge: " + str(RightEdge))
	print("TopEdge: " + str(TopEdge))
	print("BottomEdge: " + str(BottomEdge))
	print("TouchpadSizeH: " + str(TouchpadSizeH))
	print("TouchpadSizeW: " + str(TouchpadSizeW))
	print("xMinThreshold: " + str(xMinThreshold))
	print("yMinThreshold: " + str(yMinThreshold))
	print("VScroll: " + str(vscrolldelta))
	print("HScroll: " + str(hscrolldelta))


	print("End of Initialisation")
	print()
	time = 0
	lasttime = -1

	#Get Finger Configuration
	fingers = parseConfig()

	v = virtkey.virtkey()
	p = subprocess.Popen(['synclient -m 10'], stdout=subprocess.PIPE, stderr = subprocess.STDOUT, shell = True)
	for line in p.stdout:
		data = str(line, encoding='utf8' ).split() 
		#	0	1	2	3	4	5	6	7	8	9	10	11	12	13	14	15	16
		#	time	x	y	z	f	w	l	r	u	d	m	multi	gl	gm	gr	gdx	gdy
	#	print(data);
		if data[0] == 'time':
			continue
		elif data[0] == 'Parameter':
			continue
		else:
			time = float(data[0])
		action = ['0', '0', 0] #  [axis, rate, touchstate] 
		if data[4] == '1':
			cleanHistButNot(1)
		elif data[4] == '2':
			cleanHistButNot(2)
		elif data[4] == '3':
			action = detect(3)
		elif data[4] == '4':
			action = detect(4)
		elif data[4] == '5':
			action = detect(5)

	

		if not (action[0] == '0') and (time - lasttime) > timedif:
			cleanHistButNot(0)
			if action[2] == 3:
				if action[0] == 'y' and action[1] == '+':		#Up
					#print("Up")
					pressKeys(fingers[('3', 'up')])
				elif action[0] == 'y' and action[1] == '-':	#Down
					#print("Down")
					pressKeys(fingers[('3', 'down')])
				elif action[0] == 'x' and action[1] == '+':
					#print("Left")
					pressKeys(fingers[('3', 'left')])
				elif action[0] == 'x' and action[1] == '-':
					#print("Right")
					pressKeys(fingers[('3', 'right')])
			elif action[2] == 4:
				if action[0] == 'y' and action[1] == '+':		#Up
					#print("Up")
					pressKeys(fingers[('4', 'up')])
				elif action[0] == 'y' and action[1] == '-':	#Down
					#print("Down")
					pressKeys(fingers[('4', 'down')])
				elif action[0] == 'x' and action[1] == '+':
					#print("Left")
					pressKeys(fingers[('4', 'left')])
				elif action[0] == 'x' and action[1] == '-':
					#print("Right")
					pressKeys(fingers[('4', 'right')])
			elif action[2] == 5:
				if action[0] == 'y' and action[1] == '+':		#Up
					#print("Up")
					pressKeys(fingers[('5', 'up')])
				elif action[0] == 'y' and action[1] == '-':	#Down
					#print("Down")
					pressKeys(fingers[('5', 'down')])
				elif action[0] == 'x' and action[1] == '+':
					#print("Left")
					pressKeys(fingers[('5', 'left')])
				elif action[0] == 'x' and action[1] == '-':
					#print("Right")
					pressKeys(fingers[('5', 'right')])

			lasttime = time
	p.stdout.close()
	p.wait()
Example #48
0
def control_shell(data):
    instruct = data.split(' ')
    # print(instruct[0], instruct[1])
    if instruct[0] == '1':  # 基本移动模式
        if instruct[1] == 'mode':  # 进入该模式
            os.system(
                "gnome-terminal -e 'bash -c \"rosrun team202 manual_ctrl\"'")
        elif instruct[1] == 'forward':  # 前进
            v = virtkey.virtkey()  # 调用系统键盘
            v.press_unicode(ord('w'))  # 模拟字母w
            v.release_unicode(ord('w'))
            time.sleep(1)
        elif instruct[1] == 'backward':  # 后退
            v = virtkey.virtkey()
            v.press_unicode(ord('s'))  # 模拟字母s
            v.release_unicode(ord('s'))
            time.sleep(1)
        elif instruct[1] == 'left':  # 左移
            v = virtkey.virtkey()
            v.press_unicode(ord('a'))  # 模拟字母a
            v.release_unicode(ord('a'))
            time.sleep(1)
        elif instruct[1] == 'right':  # 右移
            v = virtkey.virtkey()
            v.press_unicode(ord('d'))  # 模拟字母d
            v.release_unicode(ord('d'))
            time.sleep(1)
        elif instruct[1] == 'stop':  # 停止
            v = virtkey.virtkey()
            v.press_unicode(ord(' '))  # 模拟空格键
            v.release_unicode(ord(' '))
            time.sleep(1)
        elif instruct[1] == 'exit':  # 退出此模式
            v = virtkey.virtkey()
            v.press_keysym(65307)  # 模拟Esc建
            v.release_keysym(65307)
            time.sleep(1)
            os.system("exit")
    elif instruct[0] == '2':  # 建立环境地图
        if instruct[1] == 'mode':  # 进入该模式
            os.system(
                "gnome-terminal -e 'bash -c \"roslaunch team202 gmapping.launch\"'"
            )
            time.sleep(3)
            os.system(
                "gnome-terminal -e 'bash -c \"rosrun team202 manual_ctrl\"'")
        elif instruct[1] == 'forward':  # 前进
            v = virtkey.virtkey()  # 调用系统键盘
            v.press_unicode(ord('w'))  # 模拟字母w
            v.release_unicode(ord('w'))
            time.sleep(1)
        elif instruct[1] == 'backward':  # 后退
            v = virtkey.virtkey()
            v.press_unicode(ord('s'))  # 模拟字母s
            v.release_unicode(ord('s'))
            time.sleep(1)
        elif instruct[1] == 'left':  # 左移
            v = virtkey.virtkey()
            v.press_unicode(ord('a'))  # 模拟字母a
            v.release_unicode(ord('a'))
            time.sleep(1)
        elif instruct[1] == 'right':  # 右移
            v = virtkey.virtkey()
            v.press_unicode(ord('d'))  # 模拟字母d
            v.release_unicode(ord('d'))
            time.sleep(1)
        elif instruct[1] == 'stop':  # 停止
            v = virtkey.virtkey()
            v.press_unicode(ord(' '))  # 模拟空格键
            v.release_unicode(ord(' '))
            time.sleep(1)
        elif instruct[1] == 'exit':  # 保存地图
            v = virtkey.virtkey()
            v.press_unicode(ord(' '))  # 模拟空格键
            v.release_unicode(ord(' '))
            time.sleep(1)
            v.press_keysym(65307)  # 模拟Esc建
            v.release_keysym(65307)
            time.sleep(3)
            os.system("rosrun map_server map_saver -f map; exit")
            os.system("gnome-terminal -e 'bash -c \"rosnode kill rviz\"'")
            os.system("exit")
            os.system("exit")
    elif instruct[0] == '3':  # 导航模式
        if instruct[1] == 'mode':  # 进入该模式
            os.system(
                "gnome-terminal -e 'bash -c \"roslaunch team202 navigation.launch\"'"
            )
        elif 'Destination' in instruct[1]:
            place = instruct[2]
            os.system("gnome-terminal -e 'bash -c \"rosrun team202 nav " +
                      place + "\"'")
            os.system("exit")
        elif instruct[1] == 'exit':  # 退出此模式
            os.system("gnome-terminal -e 'bash -c \"rosnode kill rviz\"'")
            os.system("exit")
            os.system("exit")
    elif instruct[0] == '4':  # 抓取模式
        if instruct[1] == 'mode':  # 进入该模式
            os.system(
                "gnome-terminal -e 'bash -c \"roslaunch team202 obj_recog.launch\"'"
            )
        elif instruct[1] == 'exit':  # 退出此模式
            os.system("gnome-terminal -e 'bash -c \"rosnode kill rviz\"'")
Example #49
0
 def setUp(self):
     print ('setUp...')
     self.v = virtkey.virtkey()
     self.username = os.getlogin()
     self.filename = 'abcd'
     self.clean_screenshot()
Example #50
0
 def __init__(self):
     self.map_dic = {}
     self.map_dic2 = {}
     self.v = virtkey.virtkey()
def ReleaseKey(keysym):
    vk = virtkey.virtkey()
    vk.release_keysym(keysym)
Example #52
0
 def __init__(self, roomId):
     super(danmuProc, self).__init__(roomId)
     self.comments = queue.Queue(maxsize=0)
     t = threading.Thread(target=self.cmdProc)
     t.start()
     self.v = virtkey.virtkey()
Example #53
0
#from pymouse import PyMouse

acceptableInputs = "Aa Bb 	Cc 	Dd 	Ee 	Ff 	Gg 	Hh 	Ii 	Jj 	Kk 	Ll 	Mm 	Nn 	Oo 	Pp 	Qq 	Rr 	Ss 	Tt 	Uu 	Vv 	Ww 	Xx 	Yy 	Zz .,!"

aCmnds = ["Ee Nn "]  #13+7
bCmnds = ["Rr Dd"]  # 10
leCmnds = ["Tt Ff Uu Xx Yy ; Zz"]  # 9 +2 + 3
riCmnds = ["Aa Kk Pp Qq .,!  Vv"]  # 9 +2 +3
upCmnds = ["Oo Bb Hh"]  # 9 +6
dnCmnds = ["Ii Gg Ss"]  # 9 +6
lCmnds = ["Ww "]  # 2.3
rCmnds = ["Mm "]  # 2.4
seCmnds = ["Cc Jj"]  # 2.7
stCmnds = ["Ll "]  # 4

v = virtkey.virtkey()


def pressA():
    v.press_unicode(ord("a"))
    v.release_unicode(ord("a"))


def pressB():
    v.press_unicode(ord("b"))
    v.release_unicode(ord("b"))


def pressUp():
    v.press_unicode(ord("u"))
    v.release_unicode(ord("u"))
Example #54
0
import random
import time
import thread

# TODO: write command line argument to enable/disable gummi debug mode
# TODO: Options for stress test with limited time, typing speed
# TODO: Start with question whether to proceed, else exit program

# aliases for to be used X.org keysyms, see complete list at:
# http://wiki.linuxquestions.org/wiki/List_of_Keysyms_Recognised_by_Xmodmap
ENTER = 0xFF0D
DOWN = 0xFF54
UP = 0xFF52

# set up keyboard simulator
v = virtkey.virtkey()

# create a new document with default text
_, filenm = tempfile.mkstemp()
tmp = open(filenm, "w")
tmp.write("""\\documentclass{article}
\\begin{document}
\n!\n
\\end{document}""")
tmp.close()

# start a gummi process in a different thread
thread.start_new_thread(lambda: os.system('gummi %s' % filenm) ,())
time.sleep(5)

# set the cursor in the right position:
Example #55
0
def main():
    global data
    global TouchpadSizeH
    global TouchpadSizeW
    global xMinThreshold
    global yMinThreshold
    global vscrolldelta
    global hscrolldelta
    global v

    #def parseTouchConfig()
    synvars = {}
    p1 = subprocess.Popen(['synclient', '-l'], stdout=subprocess.PIPE)
    for line in p1.stdout:
        line = str(line, encoding='utf8').split()
        if len(line) == 3:
            synvars[line[0]] = line[2]
    p1.stdout.close()
    p1.wait()

    LeftEdge = int(synvars['LeftEdge'])
    RightEdge = int(synvars['RightEdge'])
    TopEdge = int(synvars['TopEdge'])
    BottomEdge = int(synvars['BottomEdge'])

    TouchpadSizeH = BottomEdge - TopEdge
    TouchpadSizeW = RightEdge - LeftEdge
    xMinThreshold = TouchpadSizeW * baseDist
    yMinThreshold = TouchpadSizeH * baseDist

    vscrolldelta = int(synvars['VertScrollDelta'])
    hscrolldelta = int(synvars['HorizScrollDelta'])

    print("LeftEdge: " + str(LeftEdge))
    print("RightEdge: " + str(RightEdge))
    print("TopEdge: " + str(TopEdge))
    print("BottomEdge: " + str(BottomEdge))
    print("TouchpadSizeH: " + str(TouchpadSizeH))
    print("TouchpadSizeW: " + str(TouchpadSizeW))
    print("xMinThreshold: " + str(xMinThreshold))
    print("yMinThreshold: " + str(yMinThreshold))
    print("VScroll: " + str(vscrolldelta))
    print("HScroll: " + str(hscrolldelta))

    print("End of Initialisation")
    print()
    time = 0
    lasttime = -1

    #Get Finger Configuration
    fingers = parseConfig()

    v = virtkey.virtkey()
    p = subprocess.Popen(['synclient -m 10'],
                         stdout=subprocess.PIPE,
                         stderr=subprocess.STDOUT,
                         shell=True)
    for line in p.stdout:
        data = str(line, encoding='utf8').split()
        #	0	1	2	3	4	5	6	7	8	9	10	11	12	13	14	15	16
        #	time	x	y	z	f	w	l	r	u	d	m	multi	gl	gm	gr	gdx	gdy
        #	print(data);
        if data[0] == 'time':
            continue
        elif data[0] == 'Parameter':
            continue
        else:
            time = float(data[0])
        action = ['0', '0', 0]  #  [axis, rate, touchstate]
        if data[4] == '1':
            cleanHistButNot(1)
        elif data[4] == '2':
            cleanHistButNot(2)
        elif data[4] == '3':
            action = detect(3)
        elif data[4] == '4':
            action = detect(4)
        elif data[4] == '5':
            action = detect(5)

        if not (action[0] == '0') and (time - lasttime) > timedif:
            cleanHistButNot(0)
            if action[2] == 3:
                if action[0] == 'y' and action[1] == '+':  #Up
                    #print("Up")
                    pressKeys(fingers[('3', 'up')])
                elif action[0] == 'y' and action[1] == '-':  #Down
                    #print("Down")
                    pressKeys(fingers[('3', 'down')])
                elif action[0] == 'x' and action[1] == '+':
                    #print("Left")
                    pressKeys(fingers[('3', 'left')])
                elif action[0] == 'x' and action[1] == '-':
                    #print("Right")
                    pressKeys(fingers[('3', 'right')])
            elif action[2] == 4:
                if action[0] == 'y' and action[1] == '+':  #Up
                    #print("Up")
                    pressKeys(fingers[('4', 'up')])
                elif action[0] == 'y' and action[1] == '-':  #Down
                    #print("Down")
                    pressKeys(fingers[('4', 'down')])
                elif action[0] == 'x' and action[1] == '+':
                    #print("Left")
                    pressKeys(fingers[('4', 'left')])
                elif action[0] == 'x' and action[1] == '-':
                    #print("Right")
                    pressKeys(fingers[('4', 'right')])
            elif action[2] == 5:
                if action[0] == 'y' and action[1] == '+':  #Up
                    #print("Up")
                    pressKeys(fingers[('5', 'up')])
                elif action[0] == 'y' and action[1] == '-':  #Down
                    #print("Down")
                    pressKeys(fingers[('5', 'down')])
                elif action[0] == 'x' and action[1] == '+':
                    #print("Left")
                    pressKeys(fingers[('5', 'left')])
                elif action[0] == 'x' and action[1] == '-':
                    #print("Right")
                    pressKeys(fingers[('5', 'right')])

            lasttime = time
    p.stdout.close()
    p.wait()
Example #56
0
def simulate():
	v = virtkey.virtkey()
	time.sleep(3)
	v.press_unicode(ord("a"))
	v.release_unicode(ord("a"))
#!/usr/bin/env python3

import virtkey  #模拟按键的。。。
####sudo apt install python3-virtkey####
import time
from MyPython3 import *

vk = virtkey.virtkey()


def press_key(KEY, v=vk):
    v.press_unicode(ord(KEY))
    v.release_unicode(ord(KEY))
    time.sleep(0.3)


key_list1 = 'gkdtkd rlQjgkfk '  #항상 기뻐하라
key_list2 = 'tnlwl akfrh rlehgkfk '  #쉬지 말고 기도하라
key_list3 = 'qjatkdp rkatkgkfk '  #범사에 감사하라
key_list4 = 'eptkffhslrkwjstj 5:16-18 '

key_list = [key_list1, key_list2, key_list3, key_list4]

while True:
    for key_ in key_list:
        for key in key_:
            press_key(key)
        vk.press_keysym(65293)
        vk.release_keysym(65293)
        time.sleep(0.5)
        vk.press_keysym(65293)
Example #58
0
 def setUp(self):
     print('setUp...')
     self.v = virtkey.virtkey()
     self.username = os.getlogin()
     self.filename = 'abcd'
     self.clean_screenshot()
Example #59
0
def tapTab(delay):
    v = virtkey.virtkey()  # 调用系统键盘
    v.press_keysym(65289) # Tab
    v.release_keysym(65289)
    time.sleep(delay)
Example #60
0
def simulate():
    v = virtkey.virtkey()
    time.sleep(3)
    v.press_unicode(ord("a"))
    v.release_unicode(ord("a"))