Sign in to follow this  
Followers 0
javabean

NetBeans & AutoIt

6 posts in this topic

#1 ·  Posted (edited)

I have read through all of the Java/AutoIt threads here and they have been helpful however I have not had success.

What I need is a working example (there are none anywhere!!) of how to call the getPixelColor function with Java (in NetBeans). I'll figure out the rest from there. :)

I'm pretty good with AutoIt (thanks to the wonderful help of this forum) but have not used AutoIt functions from Java in the past.

The simplest method would be preferred, I tried using JACOB but it never found the files even when placed in the root project directory, but I'll take any working method.

Thank you so much for your help. I know Java/AutoIt is probably easy but I couldn't find any real examples! :(

(^_^)

JavaBean~

Previously posted here: http://www.autoitscript.com/forum/index.php?showtopic=34960

Edited by javabean

Share this post


Link to post
Share on other sites



/** @dll.import("autoitx.dll") */
private static native long AU3_PixelGetColor(long nX, long nY);

...

public static void Main(String[] args)
{
long pixel = AU3_PixelGetColor(100, 100);
}

I hope this helps. Just modify the native line for other AutoItX functions.

Share this post


Link to post
Share on other sites

I have had success running AutoItX from java using a java-com bridge.

I believe J-Integra is the best out there, but it is big $$

I had success with Comfy-J (www.jniwrapper.com/pages/comfyj) and is about $250.00.

I believe JACOB just came out with a new release, but I haven't checked to see if it works well.

I couldn't be bothered with figuring the intricate details of linking java and com. It is a BIG deal and I thought best to leave it to the supergeeks. I just wanted to try and script AutoItX from a java application.

One of the interesting ways I want to use AutoItX is have an Eclipse application send AutoIt commands to a REMOTE machine. The eclipse application will also be running an integrated VNC session and be able to see the script running on the remote machine. There is a plugin for eclipse called VNClipse (vnclipse.simplicit.de).

I don't know if all this stuff will work, but I think with all of those propietary windows apps out there, Eclipse would make a nice cross platform to command the remote machines from. With VNC and the Java-COM bridge you could step through your java application (just like the SCiTE editor) and watch the results or intervene with VNC session.

There are some scripting capabilities being built into Remote Desktop clients like VNC, but you loose the ability to tap into the windows messaging system and tightly control the applications.

One of the features i have seen in mjtnet (www.mjtnet.com) is the ability to "see" the screen as opposed to watching the message exchages. This utility will compare the sections of the screen to bitmap files to detect buttons and other visible items not passed through messages.

I know AutoItX can see a pixel, but i I hope that some day can see a section of the screen.

cheers,

Mark J S

Share this post


Link to post
Share on other sites

Just fyi,

http://java.sun.com/j2se/1.4.2/docs/api/ja...xelGrabber.html

There is already class for doing this kind of thing in Java. Personally though, I do use AutoIt for this kind of thing anyways, as I find there are lots of other tasks that are greatly simplified in AutoIt vs. Java. I use AutoIt all the time, as I find it easier to use than Java. However, AutoIt not really being OO does have it's drawbacks, and I wish there were a way to create my own objects in AutoIt. I have so far gotten around this limitation by extending the StringSplit() to ignore all whitespace, kind of like the Scanner class in Java, and then basically passing around a string representation of an object:

func _StringScanner($string, $delimiter=" ", $element=0, $ignoreWhiteSpace=true)
    ;values start with 1....., like a 1 based array
    $LMNTs = 0
    $strArr = StringSplit($string,$delimiter,1)
    if ($ignoreWhiteSpace) then
        For $i = 1 to (UBound($strArr)-1)
            if (NOT(StringStripWS($strArr[$i],3)=="")) Then
                $LMNTs+=1
            EndIf
        Next
        if ($element<=0) Then
            return $LMNTs
        Else
            if ($LMNTs=0) then
                Return $strArr
            Else
                dim $2return[$LMNTs]
            EndIf
            $idx=0
            For $i = 1 to (UBound($strArr)-1)
                if (NOT(StringStripWS($strArr[$i],3)=="")) Then
                    $2return[$idx]=StringStripWS($strArr[$i],3)
                    $idx+=1
                EndIf
            Next
            return $2return[$element-1]
        EndIf
    Else
        if ($element<=0) Then
            return $strArr[0]
        Else
            Return $strArr[$element]
        EndIf
    EndIf
EndFunc

I totally feel what you are saying about Java not being so COM-friendly. It's almost as if when M$ set up the method to expose the COM interface to Java, they said "Let's make this as convoluted as possible, so that Java developers will just give up on Java and use some form of .NET".

If you find a good and free way to access COM objects in Java, I'd love to know what it is...

Share this post


Link to post
Share on other sites

I dislike java. I prefer languages that target an OS. You get more power.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0