Jump to content

Use Autoit commands in perl (Creation of EXE)


sathish
 Share

Recommended Posts

Hi Forum,

I am a perl developer (Medium) and Autoit (Beginner),

I wrote a perl script using my $Au3 = Win32::OLE->new("AutoItX3.Control");

My code is below

use strict;
use warnings;
use Win32;
use Win32::API;
use Win32::OLE;
my $Au3 = Win32::OLE->new("AutoItX3.Control");

my ($fname, $Curr, $fname1, $bbox, $bbox1, $file1, $error, $path, $filex, $filexx, $contentopf, $tocncx, $filess, $ebookmetadata1, $filecc, $bbox99, $snocounter);
my ($Line, $Variable, $PreMatch, $taglist, $taglist1, $mapfile, $mapbox, $maptext, $find, $replace);
my ($foottxt)  = ("");
my $fpath = $ARGV[0];
my $fpath2 = $ARGV[1];

Win32::MsgBox("SET MATHTYPE TRANSLATIONS IF NOT!!!", MB_ICONSTOP, "SET MATHTYPE TRANSLATIONS IF NOT");
opendir (FF, $fpath) or die Win32::MsgBox("Directory not found!!!", MB_ICONSTOP, "DIRECTORY NOT FOUND");
my @contents3 = grep /(\.eps$)/, readdir FF;
foreach $file1 ( @contents3 )
    {
        #print "$file1 processing\n";
        $file1=~s/\.eps$//g;
        open($path, ">$fpath\\$file1\.txt");
        close($path);
        $Au3->run ('C:\Program Files\MathType\MathType.exe');
        $Au3->WinWaitActive('MathType - Untitled 1');
        $Au3->Sleep (500);
        $Au3->Send ('^o');
        $Au3->WinWaitActive('Open');
        $Au3->Sleep (1000);
        $Au3->send ("$fpath\\$file1\.eps");
        $Au3->Sleep (1500);
        $Au3->Send ('{ENTER}');
        $Au3->WinWaitActive('[CLASS:EQNWINCLASS]');
        $Au3->Sleep (1000);
        $Au3->Send ('^a');
        $Au3->Sleep (1000);
        $Au3->Send ('^c');
        $Au3->Sleep (1000);
        $Au3->run ('notepad.exe');
        $Au3->WinWaitActive('Untitled - Notepad');
        $Au3->Sleep (500);
        $Au3->Send ('^o');
        $Au3->WinWaitActive('Open');
        $Au3->send ("$fpath\\$file1\.txt");
        $Au3->Sleep (500);
        $Au3->Send ('{ENTER}');
        $Au3->WinWaitActive("$file1\.txt");
        $Au3->Send ('^v');
        $Au3->Sleep (1500);
        $Au3->Send ('!fx');
        $Au3->WinWaitActive('Notepad');
        $Au3->Send ('!y');
        $Au3->ProcessClose('mathtype.exe');                
        $Au3->Sleep (1000);
        print "$file1 completed\n";
    }

After packing this script it works fine in my pc, but when i execute this exe in the computer which doesn't have autoit, it throws the error that, Autoitx3 cannot found, how to overcome this,

The objective is i want to execute this script in which autoit is not installed

Please suggest,

Thanks & Regards

Sathish V.

Link to comment
Share on other sites

The AutoItX3.dll is needed and has to be registered on the computer where you want to run your skript.

Pleas see the AutoItX.chm file in the AutoItX directory.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

The AutoItX3.dll is needed and has to be registered on the computer where you want to run your skript.

Pleas see the AutoItX.chm file in the AutoItX directory.

Thanks for your reply,

I tried regestering the autoitX3.dll and it worked,

But my problem is I cant able to register this dll on all systems (say 100), because the user running the tool will be having guest rights only in their systems,

The script will be in a common server, the user will use this from the server, so is there any possibility to use the AutoitX3.dll from server or any other way to overcome this,

Thanks & Regards

Sathish V.

Link to comment
Share on other sites

Your script doesn't look too complex. So why not translate the whole script to AutoIt? Then you can run the exe from whereever you like.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Your script doesn't look too complex. So why not translate the whole script to AutoIt? Then you can run the exe from whereever you like.

Thanks for your reply,

I just pasted a sample script in the forum,

There a lot more scripts, In my Work place, all scripts should be in perl scripts, so that it will be easier for them to modify or edit the script in future (If i resigned)

So i should use the autoit as a module in perl

Link to comment
Share on other sites

I think a mixture of perl + AutoIt (COM) is more complex to maintain than a simple AutoIt script. As the code already contains AutoIt the guy/girl who has to maintain the scripts later already has to learn AutoIt.

I think taking out complexity from your scripts is what I would like to see as a future maintainer.

But as you are talking about a lot of scripts you will have to register the DLL on every PC for now (maybe you can use the login script or something similar).

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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...