Jump to content
Sign in to follow this  
Crazyace

Using IE.au3

Recommended Posts

Crazyace

Hello everyone,

I need some guidance on how to best use the IE.au3 to do the following task. I have a gui built and ready to go, I just need to finish the COM coding.

Here is the code that I have so far.

#include <GUIConstants.au3>
#include <IE.au3>

GUICreate("Drivers/Manuals/Warranty", 280, 110)

$Driver = GUICtrlCreateCheckbox("Drivers", 10, 10)
GUICtrlSetState(-1, $GUI_CHECKED)
$Manual = GUICtrlCreateCheckbox("Manual", 80, 10)
$Warranty = GUICtrlCreateCheckbox("Warranty", 150, 10)
GUICtrlCreateLabel("Service Tag #:", 10, 45)
$Input = GUICtrlCreateInput("", 90, 40)
$Submit = GUICtrlCreateButton("Submit", 40, 70, 50)
$Exit = GUICtrlCreateButton("Cancel", 150, 70, 50)

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Submit
            $serv_tag = GUICtrlRead($Input)
            If IsChecked($Driver) Then _Fire($serv_tag)
        Case $msg = $Exit
            ExitLoop
    EndSelect
WEnd

Exit 0

Func _Fire($sServiceTag)
   $oIE = _IECreate("http://www.dell.com/support/drivers/us/en/04/DriversHome/NeedProductSelection",1 ,1 ,0)
   _IELoadWait($oIE)

EndFunc

Func _Fire2($sServiceTag)
   $oIE = _IECreate("" & $sServiceTag, 1, 1, 0)

Func IsChecked($control)
    Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
EndFunc

When it navigates to the http://www.dell.com/support/drivers/us/en/04/DriversHome/NeedProductSelection URL we need to have the service tag box populated with the service tag that the user inputs. I have this working with AutoHotKey but I'm converting some scripts from AHK to AU3 and understand that the same COM commands will not work.

AHK Code

url = http://www.dell.com/support/drivers/us/en/04/DriversHome/NeedProductSelection
  pwb :=   ComObjCreate("InternetExplorer.Application")
  ;navigates to the url
  pwb.Navigate(url)
  pwb.visible := true
  While ((pwb.readyState <> 4) || pwb.busy)
    ;Sleep, 10
  frame :=   pwb.document.all["iFramePSHost"].contentWindow
  frame.document.all["TheProductSelectorResultsModel_ServiceTagCode"].value := Tag
  frame.document.all.btnSubmit[0].click()

So far I have replicated the code up until the frame start. I am able to navigate to the page and have it wait for it to load. Now I just need some help with using the right IE commands to complete the task of inserting the service tag and clicking submit.

Edited by Crazyace

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
Share on other sites
Crazyace

Anyone have any tips they can give me on this that may help me out?


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
Share on other sites
Crazyace

Anyone care to lend a hand with this?


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
Share on other sites
DaleHohm

If I follow you, you need _IEFrameGetObjByName(), _IEGetObjById(), _IEFormElementSetValue() and _IEAction(xxx, "click")

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites
Crazyace

If I follow you, you need _IEFrameGetObjByName(), _IEGetObjById(), _IEFormElementSetValue() and _IEAction(xxx, "click")

Dale

That sounds right yes. Would you mind helping me build the code for that? Here is the code for my current app that would use that. In the code it will be the first _Fire() function.

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..faviconBX.ico
#AutoIt3Wrapper_Res_Comment=Beta
#AutoIt3Wrapper_Res_Fileversion=3.0.0.0
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Run_Obfuscator=n
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.9.4 (beta)
Author:      Crazyace

Script Function:
Allows you to look up your service tag, drivers, warranty and manual
Script Version:
Beta 1.3

#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
#include <GUIConstants.au3>
#include <IE.au3>
#include <Constants.au3>
#include <file.au3>
#include <string.au3>
#include <array.au3>
GUICreate("Dell Drivers/Manuals/Warranty", 296, 110)
$Driver = GUICtrlCreateCheckbox("Drivers", 23, 10)
GUICtrlSetState(-1, $GUI_CHECKED)
$Manual = GUICtrlCreateCheckbox("Manual", 113, 10)
$Warranty = GUICtrlCreateCheckbox("Warranty", 203, 10)
GUICtrlCreateLabel("Service Tag #:", 21, 44)
$Input = GUICtrlCreateInput("", 120, 40, 155)
GUICtrlSetState(-1, $GUI_FOCUS)
$Submit = GUICtrlCreateButton("Submit", 20, 70, 70)
$Exit = GUICtrlCreateButton("Cancel", 110, 70, 70)
$FTag = GUICtrlCreateButton("Your Tag", 200, 70, 75)
Local $aAccelKeys[1][2] = [["{ENTER}", $Submit]]
GUISetAccelerators($aAccelKeys)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Select
  Case $msg = $GUI_EVENT_CLOSE Or $msg = $Exit
   ExitLoop
  Case $msg = $Submit
   $serv_tag = GUICtrlRead($Input)
   If Not IsChecked($Driver) And Not IsChecked($Manual) And Not IsChecked($Warranty) Then
    MsgBox(48, "Selection Error", "Pleaes make a selection first")
   ElseIf Not StringRegExp($serv_tag, "^([a-zA-Z0-9]{4}|[a-zA-Z0-9]{6})[a-zA-Z0-9]$") Then
    MsgBox(16, "Service Tag Error", "Service tag must be 5 or 7 alphanumeric characters with no spaces!")
   Else
    If IsChecked($Driver) Then _Fire($serv_tag)
    If IsChecked($Manual) Then _Fire2($serv_tag)
    If IsChecked($Warranty) Then _Fire3($serv_tag)
    ExitLoop
   EndIf
  Case $msg = $FTag
   _FindTag()
EndSelect
WEnd
Exit 0
Func _Fire($sServiceTag)
$oIE = _IECreate("http://www.dell.com/support/drivers/us/en/04/DriversHome/NeedProductSelection", 0, 1, 0)
EndFunc   ;==>_Fire
Func _Fire2($sServiceTag)
$oIE = _IECreate("http://support.dell.com/support/topics/global.aspx/support/my_systems_info/manuals?c=us&l=en&s=biz&~ck=ln&lnki=0&ServiceTag=" & $sServiceTag, 0, 1, 0)
EndFunc   ;==>_Fire2
Func _Fire3($sServiceTag)
$oIE = _IECreate("http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&cs=555&l=en&s=biz&~ck=anavml&ServiceTag=" & $sServiceTag, 0, 1, 0)
EndFunc   ;==>_Fire3

Func _FindTag()
Local $pid = Run("wmic csproduct list brief", @SystemDir, @SW_HIDE, $STDOUT_CHILD) ;wmic isn't an internal command to CMD
ProcessWaitClose($pid) ;better than loops
$output = StdoutRead($pid)
$tag = StringRegExpReplace($output, "(?s)^(?:.+?v+.+?h{2,})(.+?)h{2,}.*$", "$1" & @LF)
If $tag = "" Then
  MsgBox(16, "Access Denied", "Only the administrator group members can use WMIC.EXE" & @CR & @CR & "Reason:WIN32 Error: Access is Denied!")
EndIf
GUICtrlSetData($Input, $tag)
EndFunc   ;==>_FindTag
Func IsChecked($control)
Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>IsChecked
Edited by Crazyace

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
Share on other sites
DaleHohm

Yep, happy to help. Write it for you, not so much. Take a shot at it, work trough some examples, search the forum for related code, post your attempt and explain where you're having issues and you'll get lots of help here.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites
Crazyace

Yep, happy to help. Write it for you, not so much. Take a shot at it, work trough some examples, search the forum for related code, post your attempt and explain where you're having issues and you'll get lots of help here.

Dale

Thanks Dale for the support. Also I want to point out my poor wording. What I mean is just see an order of which _IE functions should be in. That way I have a lot more time to focus on getting the right info into the functions. I'm also going to guess that it may not have an order at all, and that it may just depend on what you're looking to do.

But with the ones that you listed before, should they go roughly in that order?


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
Share on other sites
DaleHohm

> But with the ones that you listed before, should they go roughly in that order?

Yes


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites
Crazyace

Func _Fire($sServiceTag)
$oIE = _IECreate("http://www.dell.com/support/drivers/us/en/04/DriversHome/NeedProductSelection", 0, 1, 0)
$oFrame = _IEFormGetObjByName($oIE, "iFramePSHost")
$oID = _IEGetObjById($oFrame, "TheProductSelectorResultsModel_ServiceTagCode")
_IEFormElementSetValue($oID, $sServiceTag)
_IEAction()

EndFunc   ;==>_Fire

Here is what I have so far but I think I'm way off base with this.


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
Share on other sites
DaleHohm

Why are you passing 0, 1, 0 to _IECreate? The last 0 prevents it from waiting for the page to load and the rest of what you do will fail.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites
Crazyace

Opps, I was doing that for testing before. Going to change it.


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.""Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience"

Share this post


Link to post
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
Sign in to follow this  

  • Similar Content

    • careca
      By careca
      Hi, i feel im close to getting it to work, but there must be something im missing that's probably easy for you experts.
      #include <IE.au3> #include <File.au3> #include <MsgBoxConstants.au3> $Visible = 1 Local $oIE $oIE = _IECreate("https://beemp3s.net/mp3-download.html", 0, $Visible, 1, 1) _IELoadWait($oIE) If $oIE <> @error Then ;_ArrayText() _QuerySite('Finding Hope - Without You') ;_IEQuit($oIE) ;Exit Else MsgBox(64 + 262144, 'Fail', 'Could not create a new window') EndIf ;============================================================================= Func _QuerySite($Name) Local $oIE_ObjectToSearch = _IEGetObjById($oIE, 'query') _IEDocInsertText($oIE_ObjectToSearch, $Name) Local $oIE_ObjectToClick = _IEGetObjById($oIE, "search-action") _IEAction($oIE_ObjectToClick, 'click') _IELoadWait($oIE, 2000) ;============================================================================= Local $oSubmitClick = _IEGetObjById($oIE, "col-md-12") _IEAction($oSubmitClick, "click") _IELoadWait($oIE, 2000) ;============================================================================= Local $oBtns = _IETagNameGetCollection($oIE, "div") For $oBtn In $oBtns If String($oBtn.classname) = "col-md-12" Then If String($oBtn.innertext) = "Download / Play" Then ConsoleWrite($oBtn.innertext & @CRLF) _IEAction($oBtn, 'click') EndIf EndIf Next ;============================================================================= ;Local $oElements = _IETagNameAllGetCollection($oIE) ;For $oElement In $oElements ; If $oElement.id Then MsgBox($MB_SYSTEMMODAL, "Element Info", "Tagname: " & $oElement.tagname & @CRLF & "id: " & $oElement.id & @CRLF & "innerText: " & $oElement.innerText) ;Next ;============================================================================= ;_IEQuit($oIE) ;Exit ;============================================================================= EndFunc ;==>_QuerySite ;============================================================================= Func _ArrayText() If FileExists('Titles.txt') Then Local $FO = FileOpen('Titles.txt') Local $R2A = FileReadToArray($FO) Local $iLineCount = @extended FileClose($FO) For $f = 0 To $iLineCount - 1 ConsoleWrite($f & ' - ' & $R2A[$f] & @CRLF) _QuerySite($R2A[$f]) Next Else MsgBox(64 + 262144, 'Fail', 'Could not find the file Titles.txt') EndIf EndFunc ;==>_ArrayText ;============================================================================= The idea is to get into this site, write into the search and click, which i did, but now the problem is clicking in any of the buttons in the results page, im looking for a way to click the first one, it always matches to what i want, so no need to fiddle around.
      Site
      Thanks for help in advance.

    • yoschga
      By yoschga
      is there a possibility to let ie.au3 click into a form? i use on a project where i need to click into a form where items are loaded just writing it in or fill the form is no option
       

    • RamaKrishna9
      By RamaKrishna9
      What are the minimum system requirements(like Windows OS version, IE browser version, etc,.) for IE.au3(3.3.14.2) to work properly?
    • MakzNovice
      By MakzNovice
      Hello Experts,
      I am working on modifying table data of a browser currently in IE (soon in FF)
      My sequence of operations:
      1. Activate Browser
      2. Get Browser table
      3. Modify data  in table
      4. Suppress any warning/error message from webpage
      5. Activate the Webpage again 
      6. Send {F11} key sequence twice to achieve some update without Updating form ( {F5})
       
      My problem is at Step 5, as it activates the wrong window ( last used application rather than my browser window)
      My code snippet for it as follows
      $bFoundWindow = False Local $aList = WinList("[REGEXPTITLE:(?i)(.*Internet Explorer.*)]") Local $hWND = 0 For $i = 1 To $aList[0][0] If False = $bFoundWindow And $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 1) Then WinActivate($aList[$i][1]) ; 1. Activate Browser window WinSetState ( $aList[$i][1], "", @SW_MAXIMIZE) $hWND = $aList[$i][1] $objEditIE = _IEAttach ($aList[$i][1], "hwnd") $oTitles = _IETagNameGetCollection($objEditIE, "TITLE") For $oTitle In $oTitles $sTitle = $oTitle.innerText If $sTitle = $searchString Then MsgBox(0,"APPLICATION Found", "Got Edit List Window", 1) $bFoundWindow = True ExitLoop EndIf Next EndIf Next If False = $bFoundWindow Then MsgBox(0,"Error","Please launch Edit window for updating values in Browser prior to script execution",10) Exit EndIf ; MY CODE HERE TO MODIFY TABLE ; 2. Get Browser table ; 3. Modify data  in table ; Check if message from webpage pop-up window exists if so click ok on it Local $nCounter = 0 Local $nMaxCounter = 5 while 1 If WinExists("Message from webpage","") Then ControlClick("Message from webpage","","Button1","primary",1) ;4. Suppress any warning/error message from webpage Else $nCounter = $nCounter + 1 Sleep(100) ;MsgBox(0,"Counter", $nCounter, 1) If $nCounter = $nMaxCounter Then ExitLoop EndIf WEnd ;5. Activate the Webpage again  WinActivate($hWND) ; have already tried WinActivate($aList[$i][1]) but no success ;6. Send {F11} key sequence twice to achieve some update without Updating form ( {F5}) Send("{F11}") WinActivate($hWND) ;WinActivate($aList[$i][1]) Sleep(100) Send("{F11}") Any support will be highly appreciated
    • MakzNovice
      By MakzNovice
      Hello Experts,
      I am working on custom application details of which I am unable to share.
      But here is statement of my problem, I have two IE windows one window with Title "Parent " and other with "TableEdit", but for some reason when I get WinList they are shown as 2 processes each. ( see attached image)
      Since my most important motive is to modify table data in 'TableEdit' I try to access the table in it
      My code snippet is 
      ***********************************************************************************************
      $searchString = "TableEdit"
      Local $aList = WinList("[REGEXPTITLE:(?i)(.*Internet Explorer.*)]")
      _ArrayDisplay($aList)
      For $i = 1 To $aList[0][0]
          If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then
              ;MsgBox($MB_SYSTEMMODAL, "", "Title: " & $aList[$i][0] & @CRLF & "Handle: " & $aList[$i][1])
              If 0 <> StringInStr($aList[$i][0],"TableEdit") Then
                  $objEditIE = _IEAttach ($aList[$i][1])
                  ExitLoop
              EndIf
          EndIf
      Next
      WinActivate($objEditIE)
      $oPageContentListFrame = _IEFrameGetObjByName($objEditIE, "iframe_1")
      $iNumFrames = @extended
      MsgBox(0,"Got pagecontent",@error) ; returns 3, indicating invalid data type
      MsgBox(0,"Number of Frame",$iNumFrames) ; returns 1, expected value is 1 
      ***********************************************************************************************
      and If I do code as below the return value is different
      $searchString = "TableEdit"
       $objEditIE = _IEAttach ($searchString, "title")
      WinActivate($objEditIE)
      $oPageContentListFrame = _IEFrameGetObjByName($objEditIE, "iframe_1")
      $iNumFrames = @extended
      MsgBox(0,"Got pagecontent",@error) ; returns 0
      MsgBox(0,"Number of Frame",$iNumFrames) ; returns 0. expected value is 1
      ***********************************************************************************************
      What is wrong with my code? 
      Why do I see two process each for IE for each window?
       
      WinListImage.bmp
×