Jump to content

IE Automation


Generator
 Share

Recommended Posts

This thread is a collection of my IE automation script, turned out i will be making many of them, i will update when i made a new 1. Also, if anyone have requests just post below and i will try to get it done.

;All these functions do not have error check, please make sure enter everything correctlyoÝ÷ Úȳz,¥©ì·)^oÝ÷ Û÷b¼Z+ºd^¦¡×£®¶­sb672ÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÐ  gVæ7Föã¢&WÇF&VBöâWFôBf÷'VÒ¥&WV&VB&RÖÆövà &ÖWFW'3¢b33cµF&VDCÔBöbFRF&V@ b33c¶õ&WÇFWCÔÖW76vRFò&WÇ b33c¶õFÖV÷WCÔRÆöBFÖV÷W@ ¢66RÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒТ6æ6ÇVFRfÇC´RæS2fwC°¢b33cµF&VBÒS¢b33cµFÖV÷WBÒS¢b33c´×6rÒgV÷CµF2v÷&·2b333²gV÷C° ¥ôf÷'VÕ&WÇb33cµF&VBÂb33c´×6rÂb33cµFÖV÷WB ¤gVæ2ôf÷'VÕ&WÇb33cµF&VDBÂb33cµ&WÇFWBÂb33c¶õFÖT÷WB Æö6Âb33c¶ôRÂb33c¶ôf÷&ÒÂb33c¶õVW'Âb33c¶õ7V&Ö@ ôTÆöEvEFÖV÷WBb33c¶õFÖT÷WB ôTW'&÷$æFÆW%&Vv7FW" b33c¶ôRÒôT7&VFRgV÷C¶GG¢ò÷wwræWFöG67&Bæ6öÒöf÷'VÒöæFWç÷6÷wF÷3ÒgV÷C²fײb33cµF&VDB ôTÖt6Æ6²b33c¶ôRÂgV÷C¶GG¢ò÷wwræWFöG67&Bæ6öÒöf÷'VÒ÷7GÆUöÖvW2öWFöB÷E÷&WÇævbgV÷C²ÂgV÷C·7&2gV÷C² b33c¶ôf÷&ÒÒôTf÷&ÔvWD6öÆÆV7Föâb33c¶ôR b33c¶õVW'ÒôTf÷&ÔVÆVÖVçDvWDö&¤'æÖRb33c¶ôf÷&ÒÂgV÷C¶VBÓ÷FWF&VgV÷C² b33c¶õ7V&ÖBÒôTf÷&ÔVÆVÖVçDvWDö&¤'æÖRb33c¶ôf÷&ÒÂgV÷C¶F÷7V&ÖBgV÷C² ôTf÷&ÔVÆVÖVçE6WEfÇVRb33c¶õVW'Âb33cµ&WÇFWB ôT7Föâb33c¶õ7V&ÖBÂgV÷C¶6Æ6²gV÷C² ôTW'&÷$æFÆW$FU&Vv7FW" ôUVBb33c¶ôR¤VæDgVæ2³ÓÒfwCµôf÷'VÕ&WÇoÝ÷ Û÷b¾È³z,¥©ì·)^oÝ÷ Û÷b¼(Zµ«n±Êyº1jëh×6#cs------------------------------------------

    Function: Change Status on Facebook
    Parameters: $oEmail=User Email
                $oPassword=User Password
                $oStatus=Status to change to
                $oTimeout=IE load timeout

#ce------------------------------------------
#include<IE.au3>

$Mail = ""
$Pass = ""
$Status = ""
$Timeout = 5000

_ChangeStatus($Mail, $Pass, $Status, $Timeout)

Func _ChangeStatus($oEmail, $oPassword, $oStatus, $oTimeout)
    Local $oIE, $oForm, $oQuery, $oSubmit, $oElement, $oObj
    _IEErrorHandlerRegister()
    _IELoadWaitTimeout($oTimeout)
    $oIE = _IECreate("http://www.facebook.com/", 0, 0, 1)
    $oForm = _IEFormGetObjByName($oIE, "loginform")
    $oQuery = _IEFormElementGetObjByName($oForm, "email")
    $o_Query = _IEFormElementGetObjByName($oForm, "pass")
    $oSubmit = _IEFormElementGetObjByName($oForm, "doquicklogin")
    _IEFormElementSetValue($oQuery, $oEmail)
    _IEFormElementSetValue($o_Query, $oPassword)
    _IEAction($oSubmit, "click")
    _IELoadWait($oIE, $oTimeout, $oTimeout)
    _IENavigate($oIE, "http://www.facebook.com/statusupdates/")
    _IELoadWait($oIE, $oTimeout, $oTimeout)
    $oElement = _IEGetObjByName($oIE, "edit_status_text")
    _IEFormElementSetValue($oElement, $oStatus)
    $oObj = _IEGetObjByName($oIE, "edit_status_text")
    $oObj.fireEvent ("onblur")
    _IELoadWait($oIE, $oTimeout, $oTimeout)
    _IELinkClickByText($oIE, "logout", 0, 1)
    _IELoadWait($oIE, $oTimeout, $oTimeout)
    _IEErrorHandlerDeRegister()
    _IEQuit($oIE)
EndFunc   ;==>_ChangeStatusoÝ÷ Û÷b¼"jèºr 7(uæèÅ«­¢+ØÌ´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´((%չѥ½¸è)½¥¸É½ÕÀä%½¸½½¬(%AɵÑÉÌèÀÌØí½µ¥°õUÍȵ¥°($$$$ÀÌØí½AÍÍݽÉõUÍÈAÍÍݽÉ($$$$ÀÌØí½É½ÕÀõɽÕÀ%($$$$ÀÌØí½Q¥µ½ÕÐõ%±½Ñ¥µ½ÕÐ((´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´(%¹±Õ±Ðí%¹ÔÌÐì((ÀÌØí5¥°ôÅÕ½ÐìÅÕ½Ðì(ÀÌØíAÍÌôÅÕ½ÐìÅÕ½Ðì(ÀÌØíɽÕÁ%ô(ÀÌØíQ¥µ½ÕÐôÔÀÀÀ()})½¥¹É½ÕÁ    å% ÀÌØí5¥°°ÀÌØíAÍÌ°ÀÌØíɽÕÁ%°ÀÌØíQ¥µ½ÕФ()Õ¹})½¥¹É½ÕÁ    å% ÀÌØí½µ¥°°ÀÌØí½AÍÍݽɰÀÌØí½É½ÕÀ°ÀÌØí½Q¥µ½ÕФ(%1½°ÀÌØí½%°ÀÌØí½½É´°ÀÌØí½EÕÉä°ÀÌØí½}EÕÉä°ÀÌØí½MÕµ¥Ð°ÀÌØí½=¨(%}%ÉɽÉ!¹±ÉI¥ÍÑÈ ¤(%}%1½]¥ÑQ¥µ½ÕÐ ÀÌØí½Q¥µ½ÕФ($ÀÌØí½%ô}%
ÉÑ ÅÕ½Ðí¡ÑÑÀè¼½ÝÝܹ½½¬¹½´¼ÅÕ½Ðì°À°À°Ä¤($ÀÌØí½½É´ô}%½ÉµÑ=©    å9µ ÀÌØí½%°ÅÕ½Ðí±½¥¹½É´ÅÕ½Ðì¤($ÀÌØí½EÕÉäô}%½Éµ±µ¹ÑÑ=©   å9µ ÀÌØí½½É´°ÅÕ½Ðíµ¥°ÅÕ½Ðì¤($ÀÌØí½}EÕÉäô}%½Éµ±µ¹ÑÑ=© å9µ ÀÌØí½½É´°ÅÕ½ÐíÁÍÌÅÕ½Ðì¤($ÀÌØí½MÕµ¥Ðô}%½Éµ±µ¹ÑÑ=©    å9µ ÀÌØí½½É´°ÅÕ½Ðí½ÅÕ¥­±½¥¸ÅÕ½Ðì¤(%}%½Éµ±µ¹ÑMÑY±Õ ÀÌØí½EÕÉä°ÀÌØí½µ¥°¤(%}%½Éµ±µ¹ÑMÑY±Õ ÀÌØí½}EÕÉä°ÀÌØí½AÍÍݽɤ(%}%Ñ¥½¸ ÀÌØí½MÕµ¥Ð°ÅÕ½Ðí±¥¬ÅÕ½Ðì¤(%}%1½]¥Ð ÀÌØí½%°ÀÌØí½Q¥µ½ÕаÀÌØí½Q¥µ½ÕФ(%}%9Ù¥Ñ ÀÌØí½%°ÅÕ½Ðí¡ÑÑÀè¼½ÝÝܹ½½¬¹½´½É½ÕÀ¹Á¡Àý¥ôÅÕ½ÐìµÀìÀÌØí½É½ÕÀ¤(%}%1¥¹­
±¥­  åQáÐ ÀÌØí½%°ÅÕ½Ðí)½¥¸Ñ¡¥ÌɽÕÀÅÕ½Ðì°À¤($ÀÌØí½=¨ô}=©  å% ÀÌØí½%°ÅÕ½Ðí¥±½}ÕÑѽ¸ÄÅÕ½Ðì¤(%}%Ñ¥½¸ ÀÌØí½=¨°ÅÕ½Ðí±¥¬ÅÕ½Ðì¤(%}%1½]¥Ð ÀÌØí½%°ÀÌØí½Q¥µ½ÕаÀÌØí½Q¥µ½ÕФ(%}%1¥¹­
±¥­  åQáÐ ÀÌØí½%°ÅÕ½Ðí±½½ÕÐÅÕ½Ðì°À°Ä¤(%}%1½]¥Ð ÀÌØí½%°ÀÌØí½Q¥µ½ÕаÀÌØí½Q¥µ½ÕФ(%}%ÉɽÉ!¹±ÉI¥ÍÑÈ ¤(%}%EեРÀÌØí½%¤)¹Õ¹ìôôÐí})½¥¹É½ÕÁ  å%oÝ÷ Û÷b¾È³z,¥©ì·)^oÝ÷ Û÷b¾È³z,¥©ì·)^
Edited by Generator
Link to comment
Share on other sites

  • Replies 55
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Scite just gives me this:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "E:\Autoit Scripts\test3.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams

+>09:35:21 Starting AutoIt3Wrapper v.1.9.2

>Running AU3Check (1.54.7.0) from:C:\Program Files\AutoIt3

+>09:35:21 AU3Check ended.rc:0

>Running:(3.2.4.9):C:\Program Files\AutoIt3\autoit3.exe "E:\Autoit Scripts\test3.au3"

--> IE.au3 Warning from function _IEImgClick, $_IEStatus_NoMatch

--> IE.au3 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType

+>09:35:24 AutoIT3.exe ended.rc:0

+>09:35:25 AutoIt3Wrapper Finished

>Exit code: 0 Time: 3.878

Link to comment
Share on other sites

[Testing v2] Works!

Had to edit it abit. Probly because my internets being dodgy lately and pages dont load completely, And IE never loads completely for me.

Added a timeout parameter. And, To anyone who cant get it working, Be sure to be logged into the autoit forum with IE before running the script.

#include<IE.au3>
$thread="http://www.autoitscript.com/forum/index.php?showtopic=51198"
$Msg="[Testing v2] Works!"

_ForumReply($thread,$Msg,1000)

Func _ForumReply($ThreadLink,$ReplyText,$oTimeOut)
    Local $oIE,$oForm,$oQuery
    $oIE=_IECreate($ThreadLink,0, 1, 0)
    $oTimer = TimerInit()
    Do
        Sleep(1)
        If TimerDiff($oTimer) > $oTimeOut Then ExitLoop
    Until Not _IEPropertyGet($oIE, "busy")
    _IEImgClick($oIE,"http://www.autoitscript.com/forum/style_images/autoit/t_reply.gif","src",0,0)
    $oTimer = TimerInit()
    Do
        Sleep(1)
        If TimerDiff($oTimer) > $oTimeOut Then ExitLoop
    Until Not _IEPropertyGet($oIE, "busy")
    $oForm = _IEFormGetCollection ($oIE, 1)
    $oQuery = _IEFormElementGetCollection ($oForm, 13)
    _IEFormElementSetValue ($oQuery, $Msg)
    _IEFormSubmit ($oForm,1)
    _IEQuit($oIE)
EndFunc
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

After multiple testing, i have to say, the obj that you return from the collection might be different depends on the progress of loading the page, i just ran another nest loop to find out and the index for this is 16 instead of 13.

Final working version:

#include<IE.au3>
$Thread = 51198
$Msg = "Testing"
$Timeout = 5000

_ForumReply($Thread, $Msg, $Timeout)

Func _ForumReply($ThreadID, $ReplyText, $oTimeOut)
    Local $oIE, $oForm, $oQuery
    $oIE = _IECreate("http://www.autoitscript.com/forum/index.php?showtopic=" & $ThreadID, 0, 0, 0)
    $oTimer = TimerInit()
    Do
        Sleep(1)
        If TimerDiff($oTimer) > $oTimeOut Then ExitLoop
    Until Not _IEPropertyGet($oIE, "busy")
    _IEImgClick($oIE, "http://www.autoitscript.com/forum/style_images/autoit/t_reply.gif", "src", 0, 0)
    $oTimer = TimerInit()
    Do
        Sleep(1)
        If TimerDiff($oTimer) > $oTimeOut Then ExitLoop
    Until Not _IEPropertyGet($oIE, "busy")
    $oForm = _IEFormGetCollection($oIE, 1)
    $oQuery = _IEFormElementGetCollection($oForm, 13)
    $o_Query = _IEFormElementGetCollection($oForm, 16)
    _IEFormElementSetValue($oQuery, $Msg)
    _IEFormElementSetValue($o_Query, $Msg)
    _IEFormSubmit($oForm, 1)
    _IEQuit($oIE)
EndFunc   ;==>_ForumReply

Edit: Tidied, changed flag for IE to invisible

Edited by Generator
Link to comment
Share on other sites

You go to a lot of work to reproduce what _IELoadWait does for you automatically in IE.au3 (when gets called automatically by many of the functions you used).

I would change your approach like this:

#include<IE.au3>
$Msg = "Testing"
$TestingThread = "34748"
$Thread = $TestingThread

_ForumReply($Thread, $Msg)

Func _ForumReply($ThreadID, $ReplyText)
    Local $oIE, $oForm, $oQuery
    
    Local $oIE = _IECreate("http://www.autoitscript.com/forum/index.php?showtopic=" & $ThreadID, 0, 0, 1)
    _IEImgClick($oIE, "http://www.autoitscript.com/forum/style_images/autoit/t_reply.gif", "src")

    Local $oForm = _IEFormGetCollection($oIE, 1)
    Local $oQuery = _IEFormElementGetObjByName($oForm, "ed-0_textarea")
    Local $oSubmit = _IEFormElementGetObjByName($oForm, "dosubmit")
    
    _IEFormElementSetValue($oQuery, $ReplyText)
    _IEAction($oSubmit, "click")
    _IEQuit($oIE)
EndFunc   ;==>_ForumReply

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

Link to comment
Share on other sites

You can use _IELoadWaitTimeout() and reduce how long it waits if you choose. Setting to 5000 milliseconds could be too show and could explain the trouble you experience in some of your tests.

If you are intent on playing with that behaviour, I'd suggest tooking at the .readyState property instead of .busy and wait for it to get to 3 or "interactive" -- this is the point that the page is ready for interaction, even if all images and such have not loaded. _IELoadWait waits for it to get to 4 or "complete". You can use _IEPropertyGet($oIE, "readyState") if you like.

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

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