Changeset 1679
- Timestamp:
- 02/08/10 15:52:15 (2 years ago)
- Location:
- trunk/loplug/plugins/input
- Files:
-
- 2 edited
-
pginput.py (modified) (8 diffs)
-
test.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/loplug/plugins/input/pginput.py
r1672 r1679 46 46 def addKey( self, key): 47 47 self.__keyText__ += PGInput.keyReference[key] + " " 48 def clearKey( self): 49 self.__keyText__ = "" 48 50 def getKeys( self): 49 51 keys = CmdxxxItem( self.__keyText__) … … 68 70 return False 69 71 70 #print 'MessageName:',event.MessageName71 #print 'Message:',event.Message72 #print 'Time:',event.Time73 #print 'Window:',event.Window74 #print 'WindowName:',event.WindowName75 #print 'Ascii:', event.Ascii, chr(event.Ascii)76 #print 'Key:', event.Key77 #print 'KeyID:', event.KeyID78 #print 'ScanCode:', event.ScanCode79 #print 'Extended:', event.Extended80 #print 'Injected:', event.Injected81 #print 'Alt', event.Alt82 #print 'Transition', event.Transition83 #print '---'72 print 'MessageName:',event.MessageName 73 print 'Message:',event.Message 74 print 'Time:',event.Time 75 print 'Window:',event.Window 76 print 'WindowName:',event.WindowName 77 print 'Ascii:', event.Ascii, chr(event.Ascii) 78 print 'Key:', event.Key 79 print 'KeyID:', event.KeyID 80 print 'ScanCode:', event.ScanCode 81 print 'Extended:', event.Extended 82 print 'Injected:', event.Injected 83 print 'Alt', event.Alt 84 print 'Transition', event.Transition 85 print '---' 84 86 85 87 key = event.KeyID … … 87 89 if key in keyPressed: 88 90 keyPressed.remove( key) 89 PGInput. processKey( pgInputInstance, keyPressed)91 PGInput.emit( pgInputInstance, SIGNAL("keyReleased"), keyPressed) 90 92 else: 91 93 if not ( key in keyPressed): 92 94 keyPressed.append( key) 93 95 PGInput.addKeyReference( pgInputInstance, key, event.Key) 94 PGInput. processKey( pgInputInstance, keyPressed)96 PGInput.emit( pgInputInstance, SIGNAL("keyPressed"), keyPressed) 95 97 96 98 return True … … 236 238 # @param self instance class 237 239 def _start( self ): 238 pass 240 # Get instance of hokk manager 241 self.hookManager = pyHook.HookManager() 242 243 self.connect( self, SIGNAL("keyPressed"), self.__onKeyPressed__ ) 244 245 # Subscribed to keyborad events 246 self.hookManager.SubscribeKeyAll( onKeyBoardEvent) 247 self.hookManager.HookKeyboard() 239 248 #---------------------------------------------------------------- 240 249 # Method invoked by the PGPluginClient parent on restart() … … 289 298 # @param datas datas 290 299 def _selection( self, srcPlugId, list_id, datas): 291 pass 292 #---------------------------------------------------------------- 293 # This method is to be overwrite by the daughter class 294 # It is the entry point of the process thread 295 # @param self instance class 296 # @param datas datas 297 def _process_thread_entry_point( self): 298 # Get instance of hokk manager 299 self.hookManager = pyHook.HookManager() 300 301 # Subscribed to keyborad events 302 self.hookManager.SubscribeKeyAll( onKeyBoardEvent) 303 self.hookManager.HookKeyboard() 304 305 # Subscribe to mouse move events 306 self.hookManager.SubscribeMouseAll( onMouseEvent) 307 # self.hookManager.HookMouse() 308 309 # Enable feature 310 pythoncom.PumpMessages() 311 312 300 pass 313 301 #---------------------------------------------------------------- 314 302 # To shutdown the instance … … 328 316 # INTERFACE METHODS 329 317 #================================================================ 330 #---------------------------------------------------------------- 331 # Wait for shutdown complete 332 # @param self instance class 333 # @param keyTable table of key pressed 334 def processKey( self, keyTable): 318 def addKeyReference( self, keyId, keyName): 319 if not ( keyId in self.keyReference.keys()): 320 self.keyReference[keyId] = keyName 321 322 #================================================================ 323 # LOCAL METHODS 324 #================================================================ 325 326 def __onKeyPressed__( self, keyTable): 327 print keyTable 335 328 if self.workingMode == PGInput.WORKING_MODE_COMBO_EDITION: 336 329 if len( keyTable) ==1: 337 330 self.cmdItem.addKey( keyTable[0]) 338 331 self.__updateUi__() 332 print keyTable[0] 339 333 340 334 elif self.workingMode == PGInput.WORKING_MODE_CONFIGURATION: … … 360 354 self.send_object([keyMap], opCode, szObj ) 361 355 362 363 def addKeyReference( self, keyId, keyName): 364 if not ( keyId in self.keyReference.keys()): 365 self.keyReference[keyId] = keyName 366 367 #================================================================ 368 # LOCAL METHODS 369 #================================================================ 356 370 357 def _updateCmdList__( self, data, list): 371 358 rendered_datas = self.get_list_data_to_render_for() … … 400 387 self.row = index.row() 401 388 self.cmdItem = self.cmdList[self.row] 389 self.cmdItem.clearKey() 390 self.__updateUi__() 402 391 print "Enter combo edition" 403 392 -
trunk/loplug/plugins/input/test.py
r1662 r1679 1 1 import threading 2 from time import * 2 3 import pythoncom 3 4 import pyHook … … 36 37 return True 37 38 38 39 hookManager = pyHook.HookManager() 40 hookManager.SubscribeKeyAll( OnKeyBoardEvent) 41 hookManager.HookKeyboard() 42 pythoncom.PumpMessages() 39 40 def process(): 41 hookManager = pyHook.HookManager() 42 hookManager.SubscribeKeyAll( OnKeyBoardEvent) 43 hookManager.HookKeyboard() 44 pythoncom.PumpMessages() 45 46 47 # ================================================= 48 if __name__ == "__main__": 49 processThread = threading.Thread( target = process) 50 processThread.setDaemon( True) 51 processThread.start() 52 while( 1): 53 sleep( 10)
Note: See TracChangeset
for help on using the changeset viewer.
