Nokioteca [Nokia] Forum: [aiuto] Vibra Quando Premo I Tasti... - Nokioteca [Nokia] Forum

Salta al contenuto

Pagina 1 di 1
  • Non puoi iniziare una nuova discussione
  • Non puoi rispondere a questa discussione

[aiuto] Vibra Quando Premo I Tasti...

#1 L   r0m3o 

  • Advanced Member
  • PuntoPuntoPuntoPunto
  • Gruppo: Utente
  • Messaggi: 265
  • Iscritto: 09 aprile 2008
  • Cellulare:N95 8GB

Inviato 09 novembre 2009 - 10:59

Hi to all!
I wanna write a simple application that when i press any key, my phone vibrate.

I have read this article:
Per visualizzare questo link registrati o esegui il log in.


Code:

# import modules
import appuifw, e32, key_codes, miso
# define functions to show notifications
def up():
miso.vibrate(250,5)

def two():
miso.vibrate(250,5)

def quit():
app_lock.signal()
# Create Canvas object
canvas = appuifw.Canvas()
appuifw.app.body = canvas
# Bind keys
canvas.bind(key_codes.EKeyUpArrow, up)
canvas.bind(key_codes.EKey2, two)
# Exit handling
appuifw.app.exit_key_handler = quit
app_lock = e32.Ao_lock()
app_lock.wait()

and this article
Per visualizzare questo link registrati o esegui il log in.


Code:

import keycapture, key_codes, globalui, miso


#Define a method to be called when a key press event occurs
def cb_key_capture(key):
#TODO: Handle events here
#For example, tell the user what key was pressed
for i in dir(key_codes):
if key == eval("key_codes." + i):
miso.vibrate(250,5)
break
#Make the application close when the right softkey is pressed
if key == key_codes.EKeyRightSoftkey:
capturer.stop()

#Create a KeyCapturer object, specifying the method
capturer = keycapture.KeyCapturer(cb_key_capture)

#All keys should be captured
capturer.keys = keycapture.all_keys
#Alternatively, if only certain keys need to be handled, they can be specified as a tuple of keycodes

#Start detecting key presses
capturer.start()

and i have modify it but there is a problem.

the "keycapture mode" is on only when python app is on foreground (first script) or that the original key function are disabled (second script)

key anyone help me to create a simple application that vibrate my phone when i press any key???


thanks
0

Condividi questa discussione:


Pagina 1 di 1
  • Non puoi iniziare una nuova discussione
  • Non puoi rispondere a questa discussione