Avete bisogno di python 2.6 e win32api installati sul vostro pc!
Script sul cellulare:
"""Mobile Phone"""
import e32
import socket
import sensor
import appuifw
import key_codes
conn = socket.socket(socket.AF_BT, socket.SOCK_STREAM)
address, services = socket.bt_discover()
service = services.keys()[0]
channel = services[service]
conn.connect((address, channel))
f = conn.makefile("rw", 0)
print 'Connected at %s on channel %d' % (service, channel)
click = False
run = True
def mouse(s):
global click
x = s['data_2']
y = s['data_1']
if click:
click = False
print >> f, 'LeftClick'
else:
print >> f, '%d,%d' % (x, y)
def clicka():
global click
click = 'LeftClick'
def quit():
lock.signal()
acc.disconnect()
canvas = appuifw.Canvas()
canvas.bind(key_codes.EKeySelect, clicka)
appuifw.app.body = canvas
sensors = sensor.sensors()
acc = sensor.Sensor(sensors['AccSensor']['id'], sensors['AccSensor']['category'])
acc.connect(mouse)
lock = e32.Ao_lock()
lock.wait()Script sul PC (Sostituisci COM3 con la tua porta COM!):
"""Windows PC running Python with win32api"""
from win32api import GetCursorPos, SetCursorPos, mouse_event
import win32con
c = open('COM3', 'rb', 0)
while True:
x, y = GetCursorPos()
line = c.readline()[:-1]
print line
if line == 'LeftClick':
mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)
mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)
else:
sx, sy = line.split(',')
sx = int(sx)/5
sy = int(sy)/5
x -= sx
y -= sy
SetCursorPos((x, y))Enjoy

Aiuto














Pubblicità