How to run AutoIt script from perl

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Anuja T
    New Member
    • Jan 2012
    • 12

    #1

    How to run AutoIt script from perl

    Hi!
    I am automating one web application using perl and selenium which works irrespective of browser. As the selenium is built to work entirely on web technology,it can not handle dialog box or save as window. so autoit is the tool which can be used with perl to handle dialog box.
    Here is the autoit script which handles dialog box.

    Code:
    f $CmdLine[0] < 2 then
    ; Arguments are not enough
    msgbox(0,"Error","Supply all the Arguments, Dialog title,Save/Cancel a
    +nd Path to save(optional)")
    Exit
    EndIf
    
    ; wait until dialog box appears
    WinWait($CmdLine[1]) ; match the window with substring
    $title = WinGetTitle($CmdLine[1]) ; retrives whole window title
    WinActive($title);
    
    ; if user choose to save file
    If (StringCompare($CmdLine[2],"Save",0) = 0) Then
    
    WinActivate($title)
    WinWaitActive($title)
    Sleep(1)
    
    ; If firefox is set the save the file on some specif location without 
    +asking to user.
    ; It will be save after this point.
    ;If not A new Dialog will appear prompting for Path to save
    Send("{ENTER}")
    
    if ( StringCompare(WinGetTitle("[active]"),$title,0) = 0 ) Then
    WinActivate($title)
    Send("{ENTER}")
    EndIf
    
    if WinExists("Enter name") Then
    $title = WinGetTitle("Enter name")
    if($CmdLine[0] = 2) Then
    ; Save File
    WinActivate($title)
    ControlClick($title,"","Button2")
    Else
    ;Set path and save file
    WinActivate($title)
    WinWaitActive($title)
    ControlSetText($title,"","Edit1",$CmdLine[3])
    ControlClick($title,"","Button2")
    EndIf
    
    Else
    ;Firefox is configured to save file at specific location
    Exit
    EndIf
    
    EndIf
    ; do not save the file
    If (StringCompare($CmdLine[2],"Cancel",0) = 0) Then
    WinWaitActive($title)
    Send("{ESCAPE}")
    EndIf
    whenever dialog box or save_as window appears, i have to call this script by
    Save_Dialog_FF "dialog_box name" "save" using command prompt and it works.
    Now i have to call it through perl.
    can anybody help me out?
    Thank you.
Working...