Jump to content

How to install AutoIt ActiveX so that javascript can run in other computers


Recommended Posts

Hi

I just stumbled on AutoIt and managed to get it working in IE with something like this:

<script type="text/javascript">
    if (navigator.appName == 'Microsoft Internet Explorer') var ai = new ActiveXObject("AutoItX3.Control.1"); 
    function sendAddress() {
        if (navigator.appName != 'Microsoft Internet Explorer') {
            alert('Please use IE!');
        } else {              
            ai.WinActivate("Customer Details");
            ai.ControlFocus("Customer Details", "", 23)
            aiSend($('building').value);
            aiSend($('unit_number').value);
            aiSend($('street').value);
            aiSend($('area').value);
            aiSend($('street_type').value);          
            aiSend($('garden').value);
            aiSend($('state').value);
            aiSend($('city').value);
            aiSend($('postal_code').value);
            aiSend($('remark').value);           
        }
    }
    
    function aiSend(_keys) {
        ai.WinActivate("Customer Details");                   
        if (_keys) {
          ai.Send("{HOME}+{END}");
          ai.Send(_keys, 1);
        }
        ai.Send("{TAB}");
    }
</script>

That is working really well in my PC. My question is how do I make it run on another PC without installing the full AutoIt? Is it something to do with AutoItX?

Just found this in AutoItX Help:

Before you can use the COM interface to AutoItX it needs to be "registered" (This is done automatically when you install the full version of AutoIt but you may need to do it manually if you are using AutoItX seperately).

To register the COM interface:

1. Open a command prompt

2. Change directory (using CD) to the directory that contains AutoItX3.dll

3. Type regsvr32.exe AutoItX3.dll and press enter

Edited by kiatng
Link to comment
Share on other sites

Welcome to AutoIt. :)

The other computer will have to register AutoItX3.dll. In your example, the browser rendering the HTML that contains that script is able to create the ActiveXObject (by 'ActiveXObject("AutoItX3.Control.1")') because AutoItX3.dll is already registered on that local machine. So the javascript engine in the browser asks Windows for access to the "AutoItX3" service ".Control.1" object, and Windows looks it up in the registry to see what .dll file provides that interface. If it isn't registered, that operation will fail.

There is a syntax to provide a remote server location for the service object, but it would only work if default security in IE is disabled first, which no user in their right mind would allow.

:mellow:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • 2 weeks later...

@PsaltyDS Thanks for the explanation.

@JohnOne Thanks for admin note.

And sorry for the late reply :mellow: I thought there would be email when there are replies.[edit: I hope I managed to set the settings correctly now to receive email notification.]

Another noob question which I can't find a conclusive answer: is there a way to run AutoIt in Chrome or FF from a windows machine?

Edited by kiatng
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...