Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Usage of parameters to script with Adlibregister

$
0
0
Hi All ,

I'm new to this forum and to AutoIT as well. I'm basically testing a web application through selenium RC , using Eclipse and Java for this purpose.
I'm using AutoIt script to download and save a excel file . This script takes 2 params, title and operation, but on using this recently some of my files get corrupted and not able to open.

I'm confidently able to say that when file comes out of AutoIT it is corrupt because, I debugged till the point of just opening the 'File Download' Dialog and then saved a file manually and was able to see that the file was downloaded correctly, but trying the same with  AutoIt the file was corrupted.

1) Can anyone please tell me if this ia a common issue.

2) Thinking that this problem araised because I open and close AutoIt for every testcase, this could abruptly stop the thread or so....I tried to tweak the code so that AutoIT is started at the satrt of the script and as and when it spots a File Download it has to immediately download the file and also iterating it for every 2 secs, but I was not able to do it.

I used AdlibRegister to do this.


Unable to post my code within the Code layout. Pasting below

AutoItSetOption("WinTitleMatchMode","2") ; set the select mode to select using substring
While 1
If $CmdLine[0] < 2 then
   ; Arguments are not enough
   msgbox(0,"Error","Supply all the arguments, Dialog title,Run/Save/Cancel and Path to save(optional)")
   Exit
  
Else
   AdlibRegister("SaveDialog",2000)
EndIf

WEnd

Func SaveDialog
; wait Until dialog box appears
WinWaitActive($CmdLine[1]) ; match the window with substring
$title = WinGetTitle($CmdLine[1]) ; retrives whole window title
WinActivate($title)

If (StringCompare($CmdLine[2],"Open",0) = 0) Then
WinActivate($title)
ControlClick($title,"","Button1")
EndIf

If (StringCompare($CmdLine[2],"Save",0) = 0) Then
WinWaitActive($title)
ControlClick($title,"","Button2")
; Wait for the new dialogbox to open
Sleep(2)
WinWait("Save As")
$title = WinGetTitle("Save As")
;$title = WinGetTitle("[active]")

If($CmdLine[0] = 2) Then
;click on the save button
Sleep(1000)
WinWaitActive($title)
;ControlSetText($title,"","ToolbarWindow323","Address: Desktop")
ControlSend("$title","","ToolbarWindow323","Address: Desktop")
Sleep(1000)
Send("{Enter}")
ControlClick($title,"&Save","Button1")
$title = WinGetTitle("Export Data - Windows Internet Explorer")
sleep(2)
WinWaitActive($title)
sleep(2)
WinClose("Export Data - Windows Internet Explorer","");

Else
;Set path and save file
WinWaitActive($title)

ControlSetText($title,"","Edit1",$CmdLine[3])
ControlClick($title,"&Save","Button1")
$title = WinGetTitle("Export Data - Windows Internet Explorer")
sleep(2)
WinWaitActive($title)
sleep(2)
WinClose("Export Data - Windows Internet Explorer","");

EndIf
EndIf
If (StringCompare($CmdLine[2],"Cancel",0) = 0) Then
WinWaitActive($title)
ControlClick($title,"","Button3")
EndIf
EndFunc


Please suggest if there are any mistakes in my code and how I should make it work the way I want it to...Thanks in advance

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>