Wizzup?
2010-12-01 15:43:57
I played around a bit with pyMML, and it works quite well with SMART. All on a 64 bit machine, native. (64 bit java/smart and 64 bit libMML.) 32 bit should work fine too.
You need the latest pymml code from simba git if you want to play with this. It'll start up SMART from python, initialise the MMLCore object; create a client and also create a SmartMouse object. The SmartMouse object is really just the MML Mouse object with a few methods overridden (surprise surprise it only overrides the actual dll calls). It currently will load SMART, set the mouse position to (100, 100) and then print the SMART mouse position every second. Not too impressive, but it's a start and a good proof of concept. I'm sure that with little extra time we can also add a method to make libMML use the SMART call getSmartArray; we can read colours from SMART.
Save this as "smartmouse.py" in the pymml directory.
And call this what you want, I called it "testsmart.py":
Note that you'll need to have compiled the libmml.so and possible also libsmart.so (if you don't run 32 a bit system)
E: You'll need to at least change the library paths and names.
I'm not too sure if this will work out of the box in windows, either. CTypes might want me to use a different DLL loader. (I think it is called WinDLL or so)
You need the latest pymml code from simba git if you want to play with this. It'll start up SMART from python, initialise the MMLCore object; create a client and also create a SmartMouse object. The SmartMouse object is really just the MML Mouse object with a few methods overridden (surprise surprise it only overrides the actual dll calls). It currently will load SMART, set the mouse position to (100, 100) and then print the SMART mouse position every second. Not too impressive, but it's a start and a good proof of concept. I'm sure that with little extra time we can also add a method to make libMML use the SMART call getSmartArray; we can read colours from SMART.
Save this as "smartmouse.py" in the pymml directory.
from mml.mouse import Mouse
from mml.mtypes import *
class SmartMouse(Mouse):
def __init__(self, MC, cli):
self._mc = MC
pass
def _setMousePos(self, p):
ret = POINT()
ret.x, ret.y = p
r = self._mc.moveMouse(ret.x, ret.y)
def _getMousePos(self):
x, y = c_int(0), c_int(0)
r = self._mc.getMousePos(pointer(x), pointer(y))
return (x.value, y.value)
def _getMouseButtonState(self, button):
pass
def _setMouseButtonState(self, button, state):
pass
And call this what you want, I called it "testsmart.py":
$ cat testsmart.py
#!/usr/bin/env python
from smartmouse import SmartMouse
from mml import MMLCore
from mml.mtypes import *
DLL = MMLCore('../libmml.so')
client = DLL.dll.create_client()
print 'client', client
from ctypes import *
from time import sleep
d = CDLL('/home/merlijn/public-smart/dist/libsmart.so')
d.setup('http://world19.runescape.com/', 'plugin.js?param=o0,a2,m0', \
765, 503, '')
sleep(5)
DLL.dll.set_array_target.restype = c_int
DLL.dll.set_array_target.argtypes = [c_ulong, c_ulong, POINT]
size = POINT()
size.x = 765
size.y = 503
mouse = SmartMouse(d, None)
mouse.setPos((100,100))
d.getImageArray.restype = c_ulong
arr = d.getImageArray()
print 'arr', arr
print 'set target'
DLL.dll.set_array_target(client, arr, size)
DLL.dll.get_color.restype = c_int
DLL.dll.get_color.argtypes = [c_ulong, c_int, c_int, POINTER(c_int)]
while True:
print 'Looping'
sleep(1)
print mouse.getPos()
for i, j in zip(range(100), range(100)):
col = c_int(0)
res = DLL.dll.get_color(client, c_int(i), c_int(j), byref(col))
print 'col:', col
Note that you'll need to have compiled the libmml.so and possible also libsmart.so (if you don't run 32 a bit system)
E: You'll need to at least change the library paths and names.
I'm not too sure if this will work out of the box in windows, either. CTypes might want me to use a different DLL loader. (I think it is called WinDLL or so)