Question

I am trying to use Autoit with Ruby. There are some user defined functions in Autoit which I need for my Gui automation like the window tab access etc. The problem is that unlike normal autoit APIs I am not able to access the UDFs of the autoit from the ruby win32ole object handle for autoit dll. Is there any way of accessing these UDFs in my Ruby code? These are actually some functions defined in autoit scripts and I think that what I want is not possible. I want some opinion from someone who may have tried this before and came to some conclusion.

Thanks and Regards, Anjali

Was it helpful?

Solution

It can't be done, according to the autoit forum. I guess you'll have to rewrite the UDF's in Ruby.

OTHER TIPS

Rewriting the UDFs in Ruby is a simple solution. However, that is not a solution in all cases due to the amount of work involved. There is no direct way to call AutoIt functions from Ruby, because there is no way that you can compile AutoIt to a dll or COM or similar.

What you can do is rewrite your AutoIt UDFs to enable interprocess communication. You can either do this via command line parameters:

If $CmdLine[0] > 1 Then
    Switch $CmdLine[1]
        Case "/1"
            Method1()
        Case "/2"
            Method2()
    EndSwitch
EndIf

Func Method1()
    ConsoleWrite("This is the 1st Method" & @CRLF)
EndFunc

Func Method2()
    ConsoleWrite("This is the 2nd Method" & @CRLF)
EndFunc

You compile the above script as a CUI (check the option in the AutoIt compiler) and then run it from Ruby. You can then grab the output via standard streams. Alternatively, you can write the output of your script to a file on the disk, then use Ruby to read the contents of the file.

Other options for more non-traditional interprocess communication include:

Possibilities are endless. :) This post should get you started.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top