Jump to content

Autoit 1-2-3 Update - for _IE.au3


Valuater
 Share

Recommended Posts

This is the list of the old IE examples in Autoit 1-2-3, I realize there are examples in help, however, I was hoping to get a little more of the "most requested" actions in scriptlets

Posted Image

Anyone can submit, just note the commentary on each scripts actions

Thanks, Valuater

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

OK, here's one. I'll add links to posts as I write them or find them.

; Display Information for all Links
#include <IE.au3>
#include <Array.au3>

$oIE = _IECreate("http://www.autoitscript.com")

$oLinks = _IELinkGetCollection($oIE)
$cntLinks = @extended

Local $aLinkInfo[$cntLinks + 1][4]

$aLinkInfo[0][0] = "Index"
$aLinkInfo[0][1] = "Link Text"
$aLinkInfo[0][2] = "href"
$aLinkInfo[0][3] = "Target"

$cnt = 1
For $oLink in $oLinks
    $aLinkInfo[$cnt][0] = $cnt - 1
    $aLinkInfo[$cnt][1] = _FixNull($oLink.innerText)
    $aLinkInfo[$cnt][2] = _FixNull($oLink.href)
    $aLinkInfo[$cnt][3] = _FixNull($oLink.target)
    $cnt +=1
Next

_ArrayDisplay($aLinkInfo, "LinkInfo")

; AutoIt sees NULL return values from COM funtions as numeric 0, 
;    replace with an empty string
Func _FixNull($value)
    If IsInt($value) Then $value = ""
    Return $value
EndFunc

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

Link to comment
Share on other sites

Well, because I am going to need these soon ( almost at 100,000 views )

I am going to post some here and evaluate the best I can find

; Save a web page to computer
; author - PSaltyDS

#include <IE.au3>

$oIE = _IECreate("http://www.google.com", 1)
$hIE = _IEPropertyGet($oIE, "hwnd")
WinActivate($hIE)
WinWaitActive($hIE)
ConsoleWrite("Debug: Google window active" & @LF)

ControlSend($hIE, "", "", "!f") ; File
ControlSend($hIE, "", "", "a") ; SaveAs

WinWait("Save Web Page", "", 5)
$hSave = WinGetHandle("Save Web Page", "")
WinActivate($hSave)

ControlFocus($hSave, "", "Edit1")
ControlSend($hSave, "","[CLASS:Edit; INSTANCE:1]", "html_save")
ControlClick($hSave, "","[CLASS:Button; TEXT:&Save; INSTANCE:2]")

8)

NEWHeader1.png

Link to comment
Share on other sites

; Mini Pandora Radio
; Created By: Frostfel

#include <GUIConstants.au3>
#include <IE.au3>
Opt ("TrayIconHide", 1)

$PanTask = _IECreateEmbedded()
GUICreate("Pandora Radio", 608, 242)
$PanGUI = GUICtrlCreateObj($PanTask, -62, -136, 1024, 1024)
GUISetState()
_IENavigate ($PanTask, "http://www.pandora.com", 0)

While 1
    $GUI = GUIGetMsg()
    Select
        Case $GUI = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

8)

NEWHeader1.png

Link to comment
Share on other sites

; Embeded Multi-Search Engine
; Author - PsaltyDS

#include <guiconstants.au3>
#include <IE.au3>

Opt("GuiOnEventMode", 1)

$iFind = "Autoit"

Global $avLinks[4] = ["http://www.altavista.com/web/results?itag=ody&q=" & $iFind & "&kgs=1&kls=0", _
        "http://uk.search.yahoo.com/search?ei=utf-8&fr=sfp&p=" & $iFind & "&iscqry=&rd=r1", _
        "http://www.google.com/search?hl=en&q=" & $iFind & "", _
        "http://www.alltheweb.com/search?cat=web&cs=utf8&q=" & $iFind & "&rys=0&itag=crv&_sb_lang=pref"  ]
Global $iNext = 0

$hGUI = GUICreate("Test", 800, 600)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$InterNetComOBJ = _IECreateEmbedded() ; Create Internet Explorer application
$InterNetComOBJ_ctrl = GUICtrlCreateObj($InterNetComOBJ, 10, 10, 780, 550)
GUICtrlCreateButton("NEXT", 350, 560, 100, 30)
GUICtrlSetOnEvent(-1, "_Next")
GUISetState()
_Next()

While 1
    Sleep(20)
WEnd

Func _Next()
    $BrowserHomePage = $avLinks[$iNext]
    WinSetTitle($hGUI, "", "Test " & $iNext & ": " & $BrowserHomePage)
    _IENavigate($InterNetComOBJ, $BrowserHomePage)
    $iNext += 1
    If $iNext > UBound($avLinks) - 1 Then $iNext = 0
EndFunc   ;==>_Next

Func _Quit()
    Exit
EndFunc   ;==>_Quit

8)

NEWHeader1.png

Link to comment
Share on other sites

Get the value of a Javascript variable from the browser context:

#include <IE.au3>

$oIE = _IECreate()
_IEDocWriteHTML($oIE, "<html><head><script luanguage = 'javascript'>foo='bar';</script></head><body></body></html>")

ConsoleWrite("foo = " & $oIE.document.parentwindow.eval('foo') & @CR)

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

Link to comment
Share on other sites

Thx Dale

; Sprint SMS Sender
; author - Senton-Bomb

#include <IE.au3>
$oIE = _IECreate("http://messaging.sprintpcs.com/textmessaging/compose"); Creates IE window - 0, 1 = hidden IE window
;~ $oIE = _IECreate("http://messaging.sprintpcs.com/textmessaging/compose", 0, 0)crates hidden IE window
$oForms = _IEFormGetObjByName($oIE, "composeForm"); Finds the "Form" to send the SMS
$oNum1 = _IEFormElementGetObjByName($oForms, "phoneNumber"); Finds the "Phone Number" Field
$intNumber = InputBox("Phone Number", "Input the phone number here", "5555555"); Asks for the phone number
_IEFormElementSetValue($oNum1, $intNumber); Sets the phone number field
$oMessage = _IEFormElementGetObjByName($oForms, "message"); Finds the "Message" field
$sMessage = InputBox("Message", "Please input the message"); Asks for the message
_IEFormElementSetValue($oMessage, $sMessage); Sets the Message field
$oCallBack = _IEFormElementGetObjByName($oForms, "callBackNumber"); Finds the Callback Field
$intCall = InputBox("Callback Number", "Input callback number here")
_IEFormElementSetValue($oCallBack, $intCall)
_IEFormSubmit($oForms)

8)

NEWHeader1.png

Link to comment
Share on other sites

; Download Web-site Traffic Cost Estimator in .csv format
; Author - Scatterp / edited by Valuater


#include <GuiConstants.au3>
#include <IE.au3>

$keywords = "Football"

$oIE = _IECreate ("https://adwords.google.com/select/TrafficEstimatorSandbox", 0, 1, 0)
_IELoadWait ($oIE)
$oForm = _IEFormGetObjByName ($oIE, "TESandbox")
$GridBodyHtml = _IEFormElementGetObjByName($oForm,"keywords")
_IEFormElementSetValue ($GridBodyHtml, $keywords)

$oSelect= _IEGetObjByName($oForm, "countryList")
_IEFormElementOptionselect ($oSelect, "All Countries and Territories", 1, "byText")
$oQuery = _IEFormElementGetObjByName ($oForm, "add")
$oQuery.Click
$oQuery = _IEFormElementGetObjByName ($oForm, "continue")
$oQuery.Click
_IELoadWait ($oIE)
_IELinkClickByText ($oIE, "Download as .csv")

; your IE may need permission to download this file

WinWaitActive("File")
ControlFocus("File","","32770")
Sleep(500)
ControlClick("File", "" ,"[CLASS:Button;TEXT:&Save;INSTANCE:2]")

WinWaitActive("Save As")
Send("Estimated.csv")
ControlClick("Save As", "","[CLASS:Button;TEXT:&Save;INSTANCE:2]")

WinWaitActive("Download")
ControlClick("Download", "","[CLASS:Button;TEXT:&Open;INSTANCE:2]")

8)

NEWHeader1.png

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