Jump to content

Problem dealing with "Message from webpage" popup


Recommended Posts

Hey All,

I'm trying to understand this problem in going forward with how to deal with a script I have where this popup is encountered about 200 times in a loop to create several online shipments with a website.  Has anyone found a great way to deal with this?  WinWait will not work from what I've been reading.  Any suggestions are greatly appreciated.  Here is the summary attached of the OK button standing in my way of glory.

>>>> Window <<<<
Title: Message from webpage
Class: #32770
Position: 408, 441
Size: 470, 189
Style: 0x94C801C5
ExStyle: 0x00010101
Handle: 0x001904CC

>>>> Control <<<<
Class: Button
Instance: 1
ClassnameNN: Button1
Name: 
Advanced (Class): [CLASS:Button; INSTANCE:1]
ID: 1
Text: OK
Position: 271, 124
Size: 88, 26
ControlClick Coords: 44, 12
Style: 0x50030000
ExStyle: 0x00000004
Handle: 0x0019030A

>>>> Mouse <<<<
Position: 726, 602
Cursor ID: 0
Color: 0x599DDD

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
OK
Cancel
At shipment tender, charges will be applied accordingly to your account.
Are you sure that all booking information is correct and you want to proceed?

>>>> Hidden Text <<<<

Link to comment
Share on other sites

this seems a normal window
doesn't WinWait(" Message from webpage") catch it?
how do you try to intercept this windows?

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Hey Pin!  Sorry for the delayed response.  I've tried it and when I program the script like that it doesn't continue, like it can't find the window; so the loop doesn't continue.  I've tried WinActivate, Wingethandle.  Someone had suggested in another similiar issue that it doesn't work like normal winactivates because it's like a pop-up from the website.  I'm just a bit perplexed how to go about dealing with it.  I've tried ControlSend, Send for enter commands.  Nothing seems to be working so far.  I'm just hoping that someone might have found a solution in an abstract way.  I am pretty new with autoit and it could be i just don't know how to go about the solution.  Thanks!

Link to comment
Share on other sites

Hey Pin!  Thanks for the help.  The script doesn't stop when I click the button or hit Enter when the popup occurs.  I just can't find a way to automate the click or _ieaction to press enter on that window, for whatever reason.  I read the example you sent a bit.  Is it suggested that a second script can be called to deal with that pop up window? 

Link to comment
Share on other sites

  I read the example you sent a bit.  Is it suggested that a second script can be called to deal with that pop up window? 

 

... the second script is only necessary if the main script "freezes" when it opens the popup, so it avoids the stop of the main script,

anyway, also if you want to use the second script (but in your case it seems not necessary) you always have to _IEAttach() to that popup, but as I read, your problem is just that, to get control ( _IEAttach) of the popup.

can you post the code that you use to try to attach the popup window?

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

The problem lies with the winwait function.  The script stops because it can't locate the window.  Here is my code below.  It stops at WinWait("Message from webpage") and the popup is on the screen.  The window details are on my first post.  Thanks for helping!

If $value = 2 Then;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CREATESHIPMENTS;;;;;;;;;;;;;;;;;;;;;;;;;2
    $webuser = InputBox("Forward Air Bulk Book Script", " ENTER WEBSITE USERNAME")
    If @error = 1 Then Exit ; Cancel button pressed
    $webpw = InputBox("Forward Air Bulk Book Script", " ENTER Password")
    If @error = 1 Then Exit ; Cancel button pressed
    $oExcel = _ExcelBookOpen("F:\Scripting\NAT\autoit\bulkbook.xlsx")
    $aArray = _ExcelReadSheetToArray($oExcel)
    ;_ArrayDisplay($aArray)
    $currentbranch = $aArray[2][17]
    $counter = $aArray[0][0]
    $first = _ExcelReadCell($oExcel, 2, 18)
    $last = _ExcelReadCell($oExcel, 2, 19)
    $user = $first & " " & $last
    $uphone = _ExcelReadCell($oExcel, 2, 21)
    $uemail = _ExcelReadCell($oExcel, 2, 20)
    $oIE = _IECreate("http://forwardair.com", 0, 1, 1)
    WinSetState("Welcome to Forward Air Home Page - Windows Internet Explorer", "", @SW_MAXIMIZE)
    $oForm = _IEFormGetObjByName($oIE, "loginForm");enter the form id or name
    $uname = _IEFormElementGetObjByName($oForm, "UserName")
    $pw = _IEFormElementGetObjByName($oForm, "Password")
    _IEFormElementSetValue($uname, $webuser);;;;;ENTER PASSWORD
    _IEFormElementSetValue($pw, $webpw)
    $login = _IEGetObjByName($oIE, "B1")
    _IEAction($login, "click")
    _IELoadWait($oIE)
    Do
        _IENavigate($oIE, "http://forwardair.com/servlet/fwrd.unix.servlet.StartOnlineShippingServlet", 1)
        _IELoadWait($oIE)
        $c1 = 1
        $c2 = 3
        $c3 = 2
        $c4 = 4
        $c5 = 5
        $c6 = 6
        $c7 = 7
        $c8 = 8
        $c9 = 9
        $c10 = 10
        $c11 = 11
        $c12 = 12
        $c13 = 13
        $c14 = 14
        $c15 = 15
        $c16 = 16
        $c17 = 17
        $c18 = 18
        $c19 = 19
        $c20 = 20
        $c21 = 21
        _IELoadWait($oIE)
        ;;SET VARIABLE FROM EXCEL ARRAY
        $eiref = $aArray[$row][$c1]
        $pcs = $aArray[$row][$c2]
        $wgt = $aArray[$row][$c3]
        $origin = $aArray[$row][$c4]
        $dest = $aArray[$row][$c5]
        $type = $aArray[$row][$c6]
        $date = $aArray[$row][$c7]
        $special = $aArray[$row][$c8]
        $destoffice = "Expeditors International " & $dest
        ;;variables set from current row in excel book
        $shipForm = _IEFormGetObjByName($oIE, "onlineShipping")
        $forg = _IEFormElementGetObjByName($shipForm, "origin");;;;;;;;;;DROP DOWN BOX EXAMPLE
        $fdest = _IEFormElementGetObjByName($shipForm, "destination")
        $goods = _IEFormElementGetObjByName($shipForm, "description")
        $shipdate = _IEFormElementGetObjByName($shipForm, "shipmentDate1")
        $fpieces = _IEFormElementGetObjByName($shipForm, "pieces")
        $fwgt = _IEFormElementGetObjByName($shipForm, "weight")
        $ref1 = _IEFormElementGetObjByName($shipForm, "referenceNumber_0")
        $instr = _IEFormElementGetObjByName($shipForm, "instructions")
        $continue = _IEGetObjByName($oIE, "B1")
        _IEFormElementSetValue($shipdate, $date)
        _IEFormElementOptionSelect($forg, $origin, 1, "byValue")
        _IEFormElementOptionSelect($fdest, $dest, 1, "byValue")
        _IEFormElementSetValue($fpieces, $pcs)
        _IEFormElementSetValue($fwgt, $wgt)
        _IEFormElementSetValue($goods, $type)
        _IEFormElementRadioSelect($shipForm, "rHazmatNo", "rHazmat")
        _IEFormElementRadioSelect($shipForm, "rInbondNo", "rInbond")
        _IEFormElementSetValue($ref1, $eiref)
        _IEFormElementSetValue($instr, $special)
        _IEAction($continue, "click")
        _IELoadWait($oIE);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;On Shipment info Screen
        $onlineshipping = _IEFormGetObjByName($oIE, "onlineShipping")
        $fwdntable = _IETableGetCollection($oIE, 8)
        $fwdnarray = _IETableWriteToArray($fwdntable, True)
        $fwtender = $fwdnarray[4][1]
        $fweta = $fwdnarray[5][1]
        _ExcelWriteCell($oExcel, $fwtender, $row, 10)
        _ExcelWriteCell($oExcel, $fweta, $row, 11)
        $next = _IEGetObjByName($oIE, "B1")
        _IEAction($next, "click")
        _IELoadWait($oIE);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;On Consignee info Screen
        $consigneeform = _IEFormGetObjByName($oIE, "shipperConsigneeInfo")
        $sphone = _IEFormElementGetObjByName($consigneeform, "sphone")
        $scontact = _IEFormElementGetObjByName($consigneeform, "scontact")
        $semail = _IEFormElementGetObjByName($consigneeform, "semail")
        $scemail = _IEFormElementGetObjByName($consigneeform, "scemail")
        $cname = _IEFormElementGetObjByName($consigneeform, "cname")
        $caddress1 = _IEFormElementGetObjByName($consigneeform, "caddress1")
        $caddress2 = _IEFormElementGetObjByName($consigneeform, "caddress2")
        $ccity = _IEFormElementGetObjByName($consigneeform, "ccity")
        $cprovincestate = _IEFormElementGetObjByName($consigneeform, "cprovincestate")
        $czip = _IEFormElementGetObjByName($consigneeform, "czip")
        $ccountry = _IEFormElementGetObjByName($consigneeform, "ccountry")
        $cphone = _IEFormElementGetObjByName($consigneeform, "cphone")
        $ccontact = _IEFormElementGetObjByName($consigneeform, "ccontact")
        $emrgyContact = _IEFormElementGetObjByName($consigneeform, "emrgyContact")
        $emrgyPhone = _IEFormElementGetObjByName($consigneeform, "emrgyPhone")
        $emrgyEmail = _IEFormElementGetObjByName($consigneeform, "emrgyEmail")
        $con_go = _IEGetObjByName($consigneeform, "B1")
        ;;;setting consigneeformvalues
        _IEFormElementSetValue($sphone, $uphone)
        _IEFormElementSetValue($scontact, $user)
        _IEFormElementSetValue($semail, $uemail)
        _IEFormElementSetValue($scemail, $uemail)
        _IEFormElementSetValue($cname, $destoffice)
        _IEFormElementSetValue($caddress1, "Notify on Arrival")
        _IEFormElementSetValue($ccity, $dest)
        _IEFormElementSetValue($czip, "99999")
        _IEFormElementSetValue($cphone, $uphone)
        _IEFormElementSetValue($ccontact, "Transcon")
        _IEFormElementSetValue($emrgyContact, $user)
        _IEFormElementSetValue($emrgyPhone, $uphone)
        _IEAction($con_go, "click")
        _IELoadWait($oIE)
        ;;;;shipment summary form
        $shipsummaryform = _IEFormGetObjByName($oIE, "onlineShipmentSummary")
        _IEFormElementCheckBoxSelect($shipsummaryform, "yes", "agree", 1, "byValue")
        $finalgo = _IEGetObjByName($shipsummaryform, "B1")
        _IEAction($finalgo, "click")
        WinWait("Message from webpage")
        $popup = WinGetHandle("Message from webpage")
        ControlClick($popup, "", "[CLASS:Button; INSTANCE:1]")
        ;WinWait("Message from webpage")
        ;$webgo = WinGetTitle("Message from webpage")
        ;;;;;;completed form to print truckbill
        _IELoadWait($oIE)
        $bookingform = _IEFormGetObjByName($oIE, "premierShipmentBooking")
        $finaltable = _IETableGetCollection($oIE, 8)
        $finalarray = _IETableWriteToArray($finaltable, True)
        $fastbook = $finalarray[6][1]
        $edocnumber = $finalarray[8][1]
        $print = _IEGetObjByName($oIE, "pdfButton")
        _IEAction($print, "click")
        WinWaitActive("http://forwardair.com/servlet/fwrd.unix.servlet.GetAirbillPDFServlet - Windows Internet Explorer")
        Sleep(5000)
        ;;;go to airbill print
        Send("{CTRLDOWN}")
        Send("{p}")
        Send("{CTRLUP}")
        WinWaitActive("Print")
        Send("{ENTER}")
        WinWaitActive("Output Source")
        Send("{Enter}")
        WinClose("http://forwardair.com/servlet/fwrd.unix.servlet.GetAirbillPDFServlet - Windows Internet Explorer")
        WinWait("Print2edoc")
        $edoc = WinGetTitle("Print2edoc")
        $checkbillforedoc = StringLeft($edocnumber, 3)
        If $currentbranch = $checkbillforedoc Then ControlSend($edoc, "", "[CLASS:TComboBox; INSTANCE:2]", "CONSOL")
        If $currentbranch <> $checkbillforedoc Then ControlSend($edoc, "", "[CLASS:TComboBox; INSTANCE:2]", "HOUSE_BILL")
        ClipPut($eiref)
        ControlSetText($edoc, "", "[CLASS:TScaleMemo; INSTANCE:2]", $eiref)
        ControlSend($edoc, "", "[CLASS:TComboBox; INSTANCE:1]", "Truck Bill")
        ControlClick($edoc, "Send", "[CLASS:TButton; INSTANCE:2]", "left", "1")
        ControlClick($edoc, "", "[CLASS:TButton; INSTANCE:2]")
        _ExcelWriteCell($oExcel, $fastbook, $row, 9)
        ;WinWaitActive("http://forwardair.com/servlet/fwrd.unix.servlet.GetAirbillPDFServlet - Windows Internet Explorer")
        ;$ieclose = WinGetTitle("http://forwardair.com/servlet/fwrd.unix.servlet.GetAirbillPDFServlet - Windows Internet Explorer")
        $row = $row + 1
    Until $row = $counter + 1
    Sleep(3000)
    MsgBox("", "", "Script Completed" & @LF & "" & @LF & "Check All Data Before Linking IC's")

EndIf
Edited by Jos
added codebox and formatted the code
Link to comment
Share on other sites

maybe the problem is not in WinWait("Message from webpage") but just in the precedent line _IEAction($finalgo, "click")

you can try in this way:

1) compile this script and call it "clickit.exe"

; this script should _IEAttach to the web page already opened by the main script
; and click to $finalgo
#include <IE.au3>
$oIE = _IEAttach("Welcome to Forward Air Home Page")
$shipsummaryform = _IEFormGetObjByName($oIE, "onlineShipmentSummary")
; _IEFormElementCheckBoxSelect($shipsummaryform, "yes", "agree", 1, "byValue")
$finalgo = _IEGetObjByName($shipsummaryform, "B1")
_IEAction($finalgo, "click")

2) save the compiled clickit.exe in the same directory of your script

3) change the line  _IEAction($finalgo, "click") in  Your main script with this  Run(".clickit.exe")

. . . . . .

        $finalgo = _IEGetObjByName($shipsummaryform, "B1")


; _IEAction($finalgo, "click") ; <--- instead of this

Run(".\clickit.exe") ; <--- use this


        WinWait("Message from webpage")
        $popup = WinGetHandle("Message from webpage")

. . . . . .

4) try it and....  good luck
5) let know the result

bye

Edited by Pincopanco

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Hey Pin.  I replaced and ran it only it doesn't click the button to get the pop-up to come up.  I'll keep playing around with it.  I like the idea of running another script to get the handle of the pop-up to press the button.  I could do that and try to have the main script winwait until i get to the very last screen that will populate the pdf forms.

Link to comment
Share on other sites

... I am sorry, I give up

just another thing:

if you put a test MsgBox immediately after the _IEAction($finalgo, "click"),

$finalgo = _IEGetObjByName($shipsummaryform, "B1")

 _IEAction($finalgo, "click")

 MsgBox(0,"Test","just opened Message from webpage") ; <-- add this

WinWait("Message from webpage")
$popup = WinGetHandle("Message from webpage"

the 'test' MsgBox opens together (immediately after) with your "Message from webpage" popup or it opens only after that you close your "Message from webpage" popup?

thanks
bye

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

  • 2 years later...

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