Jump to content

Ruby in Autoit!


Nakuribon
 Share

Recommended Posts

this plugin allows you to use the scripting language Ruby inside AutoIt. The two functions are RubyEval and RubyPrivateEval. In the non-private function, all variables can be accessed between function calls, while variables definded in a private function can only be accesed within the same function. I know that doesn't make much sense, so here's an example:

RubyPrivateEval("a='hello'")

$ret = RubyEval("a") ;throws an "a isn't defined" error and sets @error to 1

Yes, its true, when there is an error in your syntax, it returns the error number and a description instead of the evaluation, and sets @error to 1. The only argument they take are a string containing Ruby code. To insert multi-line bits of code, either make a string with @crlfs where you want newlines (hard way) or just seperate the lines with a semicolon (;) (easy way).

enjoy folks!

ruby.au3

ruby.dll

Edited by Nakuribon
i own this sig... php rulezlinks:My PSP Web Portal
Link to comment
Share on other sites

First word that came to my head when reading this : inbreeding :P

This is the weirdest plugin ever...a script language in another.

I haven't tried Ruby, so maybe this is more useful than I think..

Edit : missing char.

Edited by Helge
Link to comment
Share on other sites

there is a lot Ruby can do that autoit can't, and vice versa. For instance, Ruby has a mysql api, and all thats needed is the line "require 'mysql'" and then you call mysql functions within ruby, and now within autoit. no more of that odedb crap lol. Programs that use these languages together effectively will be incredible.

edit: i just remembered the mysql ruby extension for windows is very rare. here it is for those that want it.

edit 2: i also forgot to mention, as of right now, these functnios always return a string representation of the result. I dont think it can return some of its objects yet, but that will come in time. I just need to figure out how to get AutoIt plugins to return a result that isnt dependent on type....

mysql.zip

Edited by Nakuribon
i own this sig... php rulezlinks:My PSP Web Portal
Link to comment
Share on other sites

nice one :lmao:

there is a file missing: 'msvcrt-ruby18.dll'

at least my pc demandet it...

found inside ruby-1.8.3-i386-mswin32.zip in '/bin' dir.

are you interested in doing something like that with php?

i know it's possible, there is a dll for windows web servers that evaluates php code.

but i have only very (very!!) basic c/c++ knowledge :P

(i'll try finding it if you are...)

CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Link to comment
Share on other sites

i have an apache extension that lets me use ruby scripts as web pages, ill find the link if u want

edit: woops yea i thought it might need that dll

i couldnt tell on my own because it wouldnt let me move it lol

yea just put that dll in the same dir as the plugin dll and u should b fine

Edited by Nakuribon
i own this sig... php rulezlinks:My PSP Web Portal
Link to comment
Share on other sites

  • 3 years later...

I know I might ressurect a dead-old thread (no posts for the last 4 years).

I was searching today to see if there is a way that ruby code can be excecuted from within a *.au3 script.

However - I couldn't figure how to get this working.

if I use the example provided here:

$handle = PluginOpen("ruby.dll")
$retval = RubyPrivateEval("a='hello world';a")
msgbox(0,"",$retval & "   @error: " & @error & " @extended: " & @extended)
$retval = RubyEval("a")
msgbox(0,"",$retval & "   @error: " & @error & " @extended: " & @extended)
RubyEval("a=2")
$retval = RubyEval("a")
msgbox(0,"",$retval & "   @error: " & @error & " @extended: " & @extended)
PluginClose($handle)

I get an error about functions being "undefined"

Since I didn't find any refference to PluginOpen() or PluginClose() in the help file, I presumed that these commands were replaced with something else.

I've modified the code:

$handle = DllOpen("ruby.dll")
$retval =DllCall($handle, "str", "RubyPrivateEval", "str", "a='hello world';a")
msgbox(0,"",$retval & "   @error: " & @error & " @extended: " & @extended)
DllClose($handle)

I don't get the error about "undefined" functions anymore but the script exits with an error "-1073741819"

Can anyone please help me understand what's happening?

Thank you.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

These are plugins. I assume you're getting the errors running from scite, so you have to add the following atop your script for scite to work properly.

#AutoIt3Wrapper_Plugin_Funcs= someFuncName1, someFuncName2, ... someFuncNameN

Plugins are handy little beasts. :)

Link to comment
Share on other sites

Hi!

The (implicite) print in your Ruby's code will have some problems.

Other solution (see my prior message, in this thread), is RubyScript.

An example with Autoit:

$code=""
$code=$code & @CRLF & "def tst(a,b)"
$code=$code & @CRLF & "   c=a+b"
$code=$code & @CRLF & "   return c"
$code=$code & @CRLF & "end"
$code=$code & @CRLF & "tst(111,222)"

MsgBox(0,"Code RubyScript :",$code)

$as = ObjCreate("ScriptControl")
$as.language="RubyScript"
$retour = $as.eval($code)
MsgBox(0,"Valeur de retour : ",$retour)
Edited by Michel Claveau
Link to comment
Share on other sites

@JRowe @Michel Claveau

Thank you very much to both of you.

I have the way to continue my work now :)

EDIT:

@JRowe - that worked wonderfully :)

@Michel Claveau

Very nice approach. Unfortunately it didn't work - somehow it gave an error about $as.language="RubyScript", guess it didn't like "RubyScript".

Because this is not a support thread and I presume not many people are interrested in Ruby - may I have your permission to PM you some questions about a ruby script? (about how to include "require" statements ...)

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

Re !

Very nice approach. Unfortunately it didn't work - somehow it gave an error about $as.language="RubyScript", guess it didn't like "RubyScript".

Because this is not a support thread and I presume not many people are interrested in Ruby - may I have your permission to PM you some questions about a ruby script? (about how to include "require" statements ...)

The ActiveScripting technology is not restricted to Ruby. I use it often. Very much JSCRIPT & VBSCRIPT, and very Python(Script). Very (very) few Ruby & Perl. But no directly from Autoit (rather from HTA & Python).

From Autoit, I use very very very much Python, via the COM way. With a software named PONX (http://ponx.org ; warning, huge installation). And Ponx give me (contain) ActiveScripting. With the combination of Ponx + ActiveScripting + RubyScript, functions written in Ruby (or Python) can become functions of Autoit.

Your problem is not easy to solve, because I no have the problem, on my installations (more than 200 computers of my customers). But, my method to configure Windows is perhaps the key...

You can try to send me direct mails. But my antiSpam is hard (it delete 1500 mails by day). Therefore, give your e-mail of sender, if you want be included in the white-list ...or prefix yours message's subjects with: [AUTOIT]

@-salutations, and sorry for my bad english.

Edited by Michel Claveau
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...