Cookie Notice

As far as I know, and as far as I remember, nothing in this page does anything with Cookies.
Showing posts with label sikuli. Show all posts
Showing posts with label sikuli. Show all posts

2011/01/24

Sikuli X Stress Test



This video is of a stress test I built for Sikuli, a GUI scripting engine. It uses CV libraries to identify and interact with visual elements on your desktop. I've talked about it, but I haven't shown it, as I haven't had A means to. I'm now running Windows 7 on a fast computer, and I have Microsoft Expression Encoder installed. So, likely I'll have more screenvids in the future.

As you'll see in the code, I'm writing in modules. The first code I show is meant to provide functions for the second code I show.


checking_test


from sikuli.Sikuli import *

def clickAllLikeThis( image ):
for i in findAll(image):
click(i)

def checkAll():
a_unchecked = findAll(unchecked)
for u in a_unchecked:
click(u)

def uncheckAll():
a_checked = findAll(checked)
for c in a_checked:
click(c)


module_test


# works on all platforms
import sys
import os
# get the directory containing your running .sikuli
myPath = os.path.dirname(getBundlePath())
if not myPath in sys.path: sys.path.append(myPath)
import checking_test
unchecked = "1295894889335.png"
checked = "1295894985817.png"
popup( "Checking all unchecked" )
checking_test.clickAllLikeThis( unchecked )
popup("Unchecking all Checked")
checking_test.clickAllLikeThis( checked )
#clickAllLikeThis( checkbox )

The PNG strings are converted in the Sikuli editor, which has screengrab capabilities and converts the file name to the image. 

I'm very glad that I'm able to separate functions into separate modules. I'm somewhat disturbed that I'm not getting 100% coverage from the elements I'm trying to get clicked. But it's a neat thing nonetheless.

2010/06/16

Python Grrr

As mentioned earlier, I'm trying to code Sikuli, which is a tool for scripting GUI events. Sikuli uses Python, or more accurately, Jython, as the scripting syntax. I have tried to get beyond print "Hello World" in Python a few times, and have largely failed. It's simple inline stuff so far, so not much problem. But I'm wanting to group. Consider this Perl code:

use subs qw{ myFunction } ;
myFunction('x') ;

sub myFunction {
    my $x = shift @_ ;
    print qq{$x\n} ;
    }

I open the file in the editor and my function is at the bottom and my logic is on top. This makes it easier to understand the code when it's more than one line of logic and one function.

def myFunction(x):
    print x 

myFunction('x')

This is functionally the same. Some might look at the syntax and prefer it. Fine. But if you put myFunction() before def myFunction():, you have an undefined function and an error. Which means you 1) get your logic at the bottom or 2) put your functions into a module, or whatever the term of art is in Python. I'm writing Sikuli, so I don't know exactly how many Python trics I can really do.

So, is that it? Must I put my logic at the bottom?

2010/06/09

Trying The Automation Thing

I think I might have it.

Sikuli, an MIT project, uses the CV library to pattern-recognize places to click. (I'll add links later, or you can Google it.) LINK

It's a bit flaky on Ubuntu, but I got it working out-of-the-box on XP. Which makes me sad, but also gives me progress.

Well, Sikuli on XP on VirtualBox on Ubuntu on old Dell hardware. This is not a fast process. But it seems to be working.



Not a replacement for having access to the API in the first place, but as it doesn't require me to a) decompile a program and b) code Java, I'll accept it.