Sign in to follow this  
Followers 0
Mouse

Replacing The Text In A Webpage

5 posts in this topic

Well, i have been using autoit for about 2 years now.

I find it very fun and all, but i was never able to fully grasp the concept of _IE.

Basically... my program will open up a webpage and then after the webpage is loaded and all, i will press another button which will search for text inside that webpage and then replace that text.

Anyhelp please? I can show some source of what i have done already

#include

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Local $oIE = _IECreateEmbedded()
$Form1 = GUICreate("LOL", 819, 668, 186, 114)
$Input1 = GUICtrlCreateInput("", 0, 0, 817, 21)
$Button1 = GUICtrlCreateButton("Button1", 0, 584, 193, 81)
$Button2 = GUICtrlCreateButton("Button2", 200, 584, 185, 81)
$Button3 = GUICtrlCreateButton("Button3", 392, 584, 185, 81)
$Button4 = GUICtrlCreateButton("Button4", 584, 584, 233, 81)
$Pic1 = GUICtrlCreateObj($oIE, 0, 24, 817, 561)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit





Case $Button2

$sText = _IEBodyReadText($oIE)
If StringInStr($sText, "StringToReplaceHere") Then
;;; I found it
Msgbox(1,"Found it","Yay, i found it.")
StringReplace($sText,"","Replaced")

Else
;;; didn't find it
;;; do something else
EndIf


Case $Button1
_IENavigate($oIE,"WEBSITEHERE")
EndSwitch
WEnd

Share this post


Link to post
Share on other sites



#4 ·  Posted (edited)

;stringreplace() returns the string with replacements
;so
$new_string= stringreplace($sText, "match_string", "replacement_string")

Edited by Xandy

I am not a lawyer.  (-_-) Xandy About  (^o^) Discord - Xandy Programmer

Share this post


Link to post
Share on other sites

_IEBodyReadText reads and makes a copy of the text in a webpage. If you alter it, nothing happens to the webpage - it is a copy.

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

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  
Followers 0