Jump to content

click a button on a webpage


Recommended Posts

Hello 

Need help on this, am trying below command to drop down Pod image search box, but this is not happening, can anyone help me to guide what is wrong in this

Local $oIE = _IECreate("http://www.spoton.co.in/","",1)
_IELoadWait($oIE)

local $PodBtn=_IEGetObjById($oIE,"UPPODImages")
_IEAction($PodBtn,"click")

 

Quote

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style>
* {
    margin: 0;
    padding: 0;
}
.form-box {
    float: left;
    width: 190px;
    padding: 5px 0 0 0px;
    background: #FFF6BF;
    margin-bottom: 10px;
}
.menu_body {
    display: none;
}
.menu_list {
    width: 190px;
}
#right-wrap .block-1 .list-box {
    float: left;
    width: 210px;
    padding: 5px 0 0 44px;
}
#right-wrap .block-1 {
    width: 100%;
    float: left;
    background: url(../images/dashed-line.jpg) left top repeat-y;
    padding: 0 0 20px;
}
#right-wrap {
    width: 260px;
    float: right;
    margin-right: 10px;
}
.main-container_bg {
    width: 999px;
    float: left;
    ackground-color: #FFFFFF;
}
#main-container {
    width: 999px;
    margin: 0 auto;
    padding: 0;
    ackground: url(../images/home-page-body-bg.) no-repeat left top #FFFFFF;
}
body {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #8a898a;
    background: url(../images/bg1.jpg) no-repeat center top #FFFFFF;
}
html, body {
    margin: 0;
}
input, textarea, select {
    font-family: "EurostileRegular";
    font-size: 12px;
    color: #8a898a;
}
</style>
</head>
<body><form name="form1" id="form1" action="default.aspx" method="post"><div id="main-container"><div class="main-container_bg"><div id="right-wrap"><div class="block-1"><div class="list-box"><div class="menu_list" id="secondpane"><div class="menu_body" style="display: none;"><div class="form-box"><div id="UPPODImages">
    
                                                <div class="row">
                                                    <p>
                                                        Enter your consignment number to view POD image</p>
                                                </div>
                                                <div class="row">
                                                    <div class="fields">
                                                        Con No.</div>
                                                    <input name="txtpodconno" class="input" id="txtpodconno" type="text">
                                                </div>
                                                <div class="row">
                                                    <div class="submit">
                                                        <input name="btnpodsubmit" class="btn" id="btnpodsubmit" type="submit" value="Submit"></div>
                                                </div>
                                            
</div></div></div></div></div></div></div></div></div></form></body>
</html>

Unquote


 

Link to comment
Share on other sites

  • Moderators

@sumandevadiga you have been around long enough to know better than to resurrect an 11 year old post. AutoIt has changed a lot in 11 years, what worked then may not work as well now. I have broken your post out into its own thread this time; please do not hijack threads in the future.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Hello Dan,

Thanks for the quick reply, yes, am able to open the POD image however tried to download and want to  save in C drive(C:\Print2edoc\Upload_Docs) its not happening

local $oIE = _IECreate("http://www.spoton.co.in/","",1)
_IELoadWait($oIE)
local $Pod1      =_IEGetObjById($oIE,"txtpodconno")
local $submitBtn  =_IEGetObjById($oIE,"btnpodsubmit")
$Pod1.value="514099869"
_IEAction($submitBtn,"click")
_IELoadWait($oIE)
WinActivate('POD View - Internet Explorer')
local $podBtn  =_IEGetObjById($oIE,"podDownloadImg")
_IEAction($podBtn,"click")

Quote

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style>
.style1 {
    width: 75%;
    border-collapse: collapse;
    border: 1px solid #f2682b;
}
</style>
</head>
<body><form name="form1" id="form1" action="PODView.aspx?id=514099869" method="post"><div style="width: 100%; height: 100%; background-color: rgb(255, 255, 255);"><table align="center" class="style1" style="border: thin solid rgb(242, 104, 43); border-image: none;" border="0" frame="box"><tbody><tr><td style="text-align: center;">
                    <input name="imgPath" id="imgPath" type="hidden">
                    <input name="imgType" id="imgType" type="hidden">
                    <input name="strConNo" id="strConNo" type="hidden" value="514099869">
                    <input name="strImgTp" id="strImgTp" type="hidden">
                    <img id="podDownloadImg" style="cursor: pointer;" onclick="WindowOpen();" alt="Click to download POD" src="Images/downPOD.gif">
                </td></tr></tbody></table></div></form></body>
</html>

Unquote
 

screen shot.PNG

Link to comment
Share on other sites

This should get you a little closer to your goal --

#include <IE.au3>

local $oIE = _IECreate("http://www.spoton.co.in/",1)
_IELoadWait($oIE)
local $Pod1      =_IEGetObjById($oIE,"txtpodconno")
local $submitBtn  =_IEGetObjById($oIE,"btnpodsubmit")
$Pod1.value="514099869"
_IEAction($submitBtn,"click")

WinWait('POD View')
Local $oIE2 = _IEAttach('POD View')
local $podBtn  =_IEGetObjById($oIE2,"podDownloadImg")
_IEAction($podBtn,"click")

 

Link to comment
Share on other sites

 Hello Dan,

 

Need help, my script almost completed, am getting attached error due to delay in attached dialog box popup, i tried many ways not sure how to hold the script till popup bar appears

#include <IE.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <ProgressConstants.au3>
#include <DTC.au3>
#include <ExcelConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <InetConstants.au3>
#include <File.au3>
#include <Code128Auto.au3>
#include <IE.au3>
#Include <WinAPI.au3>
 
Local $text1
Local $filepath = "C:\Print2edoc\Upload_Docs"

local $oIE = _IECreate("http://www.spoton.co.in/",1)
_IELoadWait($oIE)
local $Pod1      =_IEGetObjById($oIE,"txtpodconno")
local $submitBtn  =_IEGetObjById($oIE,"btnpodsubmit")
$Pod1.value="514099869"
_IEAction($submitBtn,"click")

WinWait('POD View')
Local $oIE2 = _IEAttach('POD View')
local $podBtn  =_IEGetObjById($oIE2,"podDownloadImg")
_IELoadWait($oIE2)
_IEAction($podBtn,"click")


$hIE = WinGetHandle("[Class:IEFrame]")
$hCtrl = ControlGetHandle($hIE,"","[Class:DirectUIHWND]")
$aPos = ControlGetPos($hIE,"",$hCtrl)
$x = $aPos[2]-160
$y = $aPos[3]-30


WinActivate($hIE) ;doesn't work in the background
ControlClick($hIE,"",$hCtrl,"primary",1,$x,$y) ;this only gives focus to the save button
ControlSend($hIE,"",$hCtrl,"{down}") ;this does work once the save button is focussed
ControlSend($hie, "", "[Class:DirectUIHWND]","a") ;open save as dialog

WinActivate("Save As", "Save");
WinWaitActive("Save As", "Save", 10);
ControlSend("Save As", "", "[CLASS:Edit; INSTANCE:1]", "C:\Print2edoc\"&$Pod1.value&".jpg")
ControlClick("Save As", "", "&Save", "left", 1, 5, 5);
sleep(100)
ControlClick("Confirm Save As","","Button1", "left", 1, 0, 0);

;quit ie
_IEQuit($oIE)

 

Error.PNG

Dailog box popup.PNG

Link to comment
Share on other sites

That's a difficult task, fraught with potential pitfalls. What about something like this instead --

Local $sPath = "C:\Print2edoc\Upload_Docs\"
Local $sID = "514099875"
Local $sURL = "http://spoton.co.in/SPOTTRACK/Advance/getpod.aspx?id=" & $sID & "&mPODDw=Y"

InetGet($sURL, $sPath & $sID & ".jpg", $INET_FORCERELOAD)

 

Link to comment
Share on other sites

Hello Dan,

I have completed my project, this really helping me a lot, saving almost 5 hours a day of individual, only concern is sometime the suggested above command for downloading files doesn't give any result, not sure what exact issue is, rest everything is perfect.

 

 

 

 

#include <Excel.au3>
#include <MsgBoxConstants.au3>

Local $sID,$oExcel,$a,$sURL,$sPath,$INET_FORCERELOAD,$sFilePath,$iFileExists,$b,$c
Local $sPath = "C:\Print2edoc\JPG\"


Run('C:\Program Files (x86)\PlotSoft\PDFill\PDFill_PDF_Tools.exe', "", @SW_MAXIMIZE)
WinWaitActive("[REGEXPTITLE:PDFill PDF Tools 14.0.*]")

$oExcel = _ExcelBookOpen ("C:\Print2edoc\POD.xlsx")
WinActivate('EXCEL')
$c = 0
      Do
    $Text = WinGetTitle("[ACTIVE]")
    $screen1 = StringMid($Text,$c,5)
        $c = $c + 1
      Until $screen1 = "EXCEL"
$a = 2
   Do
    $sID = _ExcelReadCell($oExcel,$a,1)
    $a = $a + 1

    ;Check if file exists.

    Local $sFilePath = "C:\Print2edoc\Upload_Docs\" & $sID & ".jpg"
    Local $iFileExists = FileExists($sFilePath)
   $b = 2
   DO
    ;Display a message after checking the returned value.
    If $iFileExists Then
       $b = 1
       Else
       WinActivate('Program Manager')
       send("{F5}")
       Local $sURL = "http://spoton.co.in/SPOTTRACK/Advance/getpod.aspx?id=" & $sID & "&mPODDw=Y"
       $b = $b + 1
            if $sID <> '' then
              InetGet($sURL, $sPath & $sID & ".jpg", $INET_FORCERELOAD)
              $b = 1
            endif
     EndIf

   Until $b = 1 or $b = 50



Local $destdir,$destfile,$srcdir,$srcfile






$srcDirectory = 'C:\Print2edoc\JPG'
$destDirectory = 'C:\Print2edoc\Upload_Docs'

$destdir = $destDirectory


; change current directory to src directory
FileChangeDir($srcDirectory)


$destfile = $sID & ".pdf"

$srcdir = $srcDirectory
$srcfile = $sID & ".jpg"
                                                
$search = FileFindFirstFile($sID & ".jpg")



If $search = -1 Then
  MsgBox(0, "Error", "No files/directories matched the search pattern")
  Exit
EndIf

While 1
  $file = FileFindNextFile($search)
  If @error Then ExitLoop
  ; MsgBox(4096, "File:", $file)

  $dest = StringReplace($file, ".jpg","") & ".pdf"

WEnd



; Close the search handle
FileClose($search)


   WinWaitActive("[REGEXPTITLE:PDFill PDF Tools 14.0.*]")

  ControlClick("[REGEXPTITLE:PDFill PDF Tools 14.0.*]", "", "[CLASS:Button; TEXT: 9. Convert Images to PDF]")
  WinWaitActive("[TITLE:Free PDF Tools: Convert images to PDF]")

  ; set paper size output to A4
  ControlClick("[TITLE:Free PDF Tools: Convert images to PDF]", "", "[CLASS:ComboBox; INSTANCE:1]") 
  Send("A{ENTER}")

  ; set margins to 0 
  ControlClick("[TITLE:Free PDF Tools: Convert images to PDF]", "", "[CLASS:Edit; INSTANCE:3]") 
  Send("{HOME}{SHIFTDOWN}{END}{SHIFTUP}{DEL}0")

  ControlClick("[TITLE:Free PDF Tools: Convert images to PDF]", "", "[CLASS:Edit; INSTANCE:4]")
  Send("{HOME}{SHIFTDOWN}{END}{SHIFTUP}{DEL}0")

  ControlClick("[TITLE:Free PDF Tools: Convert images to PDF]", "", "[CLASS:Edit; INSTANCE:5]") 
  Send("{HOME}{SHIFTDOWN}{END}{SHIFTUP}{DEL}0")

  ControlClick("[TITLE:Free PDF Tools: Convert images to PDF]", "", "[CLASS:Edit; INSTANCE:6]") 
  Send("{HOME}{SHIFTDOWN}{END}{SHIFTUP}{DEL}0")

  ; add an image
  ControlClick("[TITLE:Free PDF Tools: Convert images to PDF]", "", "[CLASS:Button; TEXT:Add an Image]") 
  WinWaitActive("[TITLE:Select Image files to add into PDF]")

  ; send image location followed by enter 
  ControlClick("[TITLE:Select Image files to add into PDF]", "", "[CLASS:Edit; INSTANCE:1]") 
  Send($srcdir & "\" & $srcfile & "{ENTER}")

  ; wait for window to return
  WinWaitActive("[TITLE:Free PDF Tools: Convert images to PDF]")

  ; click save-as 
  ControlClick("[TITLE:Free PDF Tools: Convert images to PDF]", "", "[CLASS:Button; TEXT:Save As ...]") 
  WinWaitActive("[TITLE:Save all the images as ... ]")

  ; send pdf output location followed by enter 
  ControlClick("[TITLE:Save all the images as ... ]", "", "[CLASS:Edit; INSTANCE:1]") 
  Send($destdir & "\" & $destfile & "{ENTER}")

  ; wait for adobe to open - and then close it down 
  WinWaitActive("[TITLE:" & $destfile & " - Adobe Reader]") 
  WinClose("[TITLE:" & $destfile & " - Adobe Reader]")

Until $sID = ''

; wait for pdf image tools to return - and then close it down
  WinWaitActive("[TITLE:Free PDF Tools: Convert images to PDF]") 
  WinClose("[TITLE:Free PDF Tools: Convert images to PDF]")

  ; wait for main pdf tools to return - and then close it down 
  WinWaitActive("[REGEXPTITLE:PDFill PDF Tools 14.0.*]") 
  WinClose("[REGEXPTITLE:PDFill PDF Tools 14.0.*]")

MsgBox(0,"Title","Script Completed")

 

Link to comment
Share on other sites

Hello Dan,

 

Can you advise why one of my colleague getting this attached error?

 

#include <IE.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

Local $INET_FORCERELOAD,$sURL, $sPath,$sID
Local $iDelete = FileDelete("C:\Print2edoc\JPG\")

ControlSend("[CLASS:Progman; TITLE:Program Manager]", "", "", "{F5}")

$oExcel = _ExcelBookOpen ("C:\Print2edoc\POD.xlsx")

$NumberOfRows = $oExcel.ActiveSheet.UsedRange.Rows.Count

Local $sPath = "C:\Print2edoc\JPG\"

    For $a = 2 To $NumberOfRows
                WinActivate('EXCEL')
        $sID = _ExcelReadCell($oExcel,$a,1)         
        Local $sURL = "http://spoton.co.in/SPOTTRACK/Advance/getpod.aspx?id=" & $sID & "&mPODDw=Y"
        InetGet($sURL, $sPath & $sID & ".jpg", $INET_FORCERELOAD)                 
    Next

_ExcelBookClose($oExcel)

MsgBox(0,"Title","Script Completed")

 

 

 

Error.PNG

Link to comment
Share on other sites

  • 2 weeks later...

Hello Dan,

 

Hello Dan,

thank you very much, am able to complete this task successfully, below is my code.

#include <IE.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>

Local $DLG_NOTONTOP, $DLG_MOVEABLE,$k,$c,$d,$e


Local $INET_FORCERELOAD,$sURL, $sPath,$sID,$INET_DOWNLOADWAIT,$hDownload,$INET_DOWNLOADCOMPLETE,$INET_DOWNLOADBACKGROUND,$b
Local $iDelete = FileDelete("C:\Print2edoc\Downloads\")

ControlSend("[CLASS:Progman; TITLE:Program Manager]", "", "", "{F5}")

$oExcel = _ExcelBookOpen ("C:\Print2edoc\POD.xlsx")



$NumberOfRows = $oExcel.ActiveSheet.UsedRange.Rows.Count

Local $sPath = "C:\Print2edoc\Downloads\"

             If FileExists($sPath) Then


                Else
                    DirCreate($sPath)

             EndIf
              ; Display a progress bar window.
              ProgressOn("POD Downloads", "Progress Bar", "0 File", -1, -1, BitOR($DLG_NOTONTOP, $DLG_MOVEABLE))

              ; Update the progress value of the progress bar window every second.

    For $a = 2 To $NumberOfRows                
                $b = 0
                WinActivate('EXCEL')
        $sID = _ExcelReadCell($oExcel,$a,1)                
        Local $sURL = "http://spoton.co.in/SPOTTRACK/Advance/getpod.aspx?id=" & $sID & "&mPODDw=Y"
        Local $hDownload = InetGet($sURL, $sPath & $sID & ".jpg", $INET_FORCERELOAD,$INET_DOWNLOADBACKGROUND)
                Do
                 Sleep(250)
                $b = $b + 1
                Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE) or $b = 10
                InetClose($hDownload)                    
                $d = $NumberOfRows - 1      
                $c = $a - 1      
                $e = (100*$c/$d) 
                ProgressSet($e,($c & "/" & $d & " " & "Files" ))
    Next
    ; Set the "subtext" and "maintext" of the progress bar window.
          ProgressSet(100, "Done", "100 % Complete")
          Sleep(5000)
          ProgressOff()


_ExcelBookClose($oExcel)

 

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