Jump to content

Edit or replace a page in FireFox and IE


Recommended Posts

hi,

i would like to edit or replace the current open page in browser.

is it possible?

i am touching AutoIt after a long time and also i am not good at all in coding.

so, what i want to do

Navigate to a webpage --> when page is opened or under process of opening it should be replaced with the page i want to be there or edit that page with the following Text in it."

"David, you can not make me fool. go use your own pc. i don't have bandwidth for you."

can anyone help me in this?

Unresolved topics:1- Please help me in Editing or replacing a page in FireFox and IE.Please have a look at them.
Link to comment
Share on other sites

Something like this lol?

#include <IE.au3>
#NoTrayIcon
Global $TITLE = ""
While 1
    If Not FileExists("C:\Page.html") Then
    FileWrite("C:\Page.html","<center>David, you can not make me fool. go use your own pc. i don't have bandwidth for you.</center>")
    EndIf
    If ProcessExists("IEXPLORE.EXE") Or ProcessExists("firefox.exe") Then
        ProcessClose("IEXPLORE.EXE")
        ProcessClose("firefox.exe")
        _IECreate("File:///C:\Page.html")
        Sleep(1000)
        $TITLE=WinGetTitle("[Active]")
        
        Do
            
            If Not WinActive($TITLE) And ProcessExists("IEXPLORE.EXE") Then
                ProcessClose("IEXPLORE.EXE")
                Sleep(100)
                ExitLoop
            EndIf
                
            
            If ProcessExists("firefox.exe") Then
                ProcessClose("firefox.exe")
                Sleep(100)
                ExitLoop
            EndIf
            
            Sleep(100)
            
        Until Not ProcessExists("IEXPLORE.EXE") Or Not ProcessExists("firefox.exe")
        $TITLE = ""
        
    EndIf
    Sleep(200)
WEnd

Edit: Fixed something

Edited by will88
Link to comment
Share on other sites

_IEAttach

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

have a look at the code - it has very detailed comments.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

Would this help for Firefox?

Func FF_Create($url = "www.mozilla.com", $firefox_exe = "C:\Program Files\Mozilla Firefox\firefox.exe")

Local $pid = Run($firefox_exe)

Sleep(2500)
Send("^l")
Sleep(1000)
Send($url)
Send("{ENTER}")

return $pid
EndFunc

Func FF_GetText($windowtitle = "Mozilla Firefox", $windowtext = "")

Local $count = 0

While (WinActive($windowtitle, $windowtext) = 0 AND $count < 10) 
    WinActivate($windowtitle, $windowtext)
    $count = $count + 1
    WEnd
    
If ($count <> 10) Then
    Send("^a")
    Sleep(500)
    Send("^c")
    Sleep(1000)

    $text = ClipGet()
    return $text
        Else
        return 0
EndIf
EndFunc

Func FF_Close ($windowtitle = "Mozilla Firefox", $windowtext = "")

If (WinActivate($windowtitle, $windowtext) = 1 ) Then
Send("!{F4}")
EndIf

EndFunc
Link to comment
Share on other sites

I dunno about firefox, but if all you want to do is modify all pages in all open ie windows, this should work:

#include <IE.au3>

_IEErrorHandlerRegister()

While 1
    _CheckBrowsers()
    Sleep(250)
WEnd

Func _CheckBrowsers()
    Local $avWindows = WinList("[CLASS:IEFrame]")
    Local $oIE
    
    For $i = 1 To $avWindows[0][0]
        $oIE = _IEAttach($avWindows[$i][1], "HWND", $i)
        If IsObj($oIE) Then
            _IEDocWriteHTML($oIE, "<center>David, you can not make me fool. go use your own pc. i don't have bandwidth for you.</center>")
            $oIE = 0
        EndIf
    Next
EndFunc
Link to comment
Share on other sites

I dunno about firefox, but if all you want to do is modify all pages in all open ie windows, this should work:

#include <IE.au3>

_IEErrorHandlerRegister()

While 1
    _CheckBrowsers()
    Sleep(250)
WEnd

Func _CheckBrowsers()
    Local $avWindows = WinList("[CLASS:IEFrame]")
    Local $oIE
    
    For $i = 1 To $avWindows[0][0]
        $oIE = _IEAttach($avWindows[$i][1], "HWND", $i)
        If IsObj($oIE) Then
            _IEDocWriteHTML($oIE, "<center>David, you can not make me fool. go use your own pc. i don't have bandwidth for you.</center>")
            $oIE = 0
        EndIf
    Next
EndFunc
this 'll attach to all opened pages, how to attach to only spesific pages or websites?

thanks for the code...

Unresolved topics:1- Please help me in Editing or replacing a page in FireFox and IE.Please have a look at them.
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...