Jump to content

Show parsed html code in default browser (NOT IE) - (Moved)


Recommended Posts

Is there a way to show parsed html code in default browser but not using any IE functions and not saving a html file?

I want show parsed html code in my default browser Chrome in new tab. Code will be stored in string variable like

$HtmlCode = '<h1>Test</h1><p style="color:red">This is some text</p>'

 

Link to comment
Share on other sites

  • Developers

Moved to the appropriate AutoIt General Help and Support forum, as the AutoIt Example Scripts forum very clearly states:

Quote

Share your cool AutoIt scripts, UDFs and applications with others.


Do not post general support questions here, instead use the AutoIt Help and Support forums.

Moderation Team

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

In my sense, the easiest way with WebDriver is to save your HTML string to a temp file (FileWrite), create a new tab (_WD_NewTab), load the file (_WD_Navigate), and delete the file right after (FileDelete)

 

Link to comment
Share on other sites

2 hours ago, Danyfirex said:

You could do this:

_DefaultBroswerLoadPage()

Func _DefaultBroswerLoadPage()
    Local $sUrl = "http://localhost:80"
    TCPStartup()
    $iMainSocket = TCPListen("127.0.0.1", 80)

    ShellExecute($sUrl)

    Local $iConnectedSocket = -1
    Local $hTimer = TimerInit()
    Local $bErrorTimeout = False
    Do
        Sleep(300)
        $iConnectedSocket = TCPAccept($iMainSocket)
        If TimerDiff($hTimer) > (1000 * 5) Then
            $bErrorTimeout = True
            ExitLoop
        EndIf
    Until $iConnectedSocket <> -1
    If $bErrorTimeout Then
        TCPShutdown()
        Return ""
    EndIf
    Local $sReceived = TCPRecv($iConnectedSocket, 1024)
;~ $sReceived = BinaryToString($sReceived, 4)

    TCPSend($iConnectedSocket, '<h1 style="text-align: center;color: blue;font-size: 40px;">AutoIt Rocks</h1><p style="color: red; font-size: 30px;text-align: center;">@AutoItVersion: ' & @AutoItVersion & '<br><br>' & "@AutoItPID: " &  @AutoItPID & '</p>')
    If $iConnectedSocket <> -1 Then TCPCloseSocket($iConnectedSocket)
    TCPShutdown()
EndFunc   ;==>_DefaultBroswerLoadPage

Saludos

you are master :)

Link to comment
Share on other sites

@Danyfirex that's very nice 👍. Bravo! :)

_DefaultBroswerLoadPage()

Func _DefaultBroswerLoadPage()
    Local $sUrl = "http://localhost:80"
    TCPStartup()
    $iMainSocket = TCPListen("127.0.0.1", 80)

    ShellExecute($sUrl)

    Local $iConnectedSocket = -1
    Local $hTimer = TimerInit()
    Local $bErrorTimeout = False
    Do
        Sleep(300)
        $iConnectedSocket = TCPAccept($iMainSocket)
        If TimerDiff($hTimer) > (1000 * 5) Then
            $bErrorTimeout = True
            ExitLoop
        EndIf
    Until $iConnectedSocket <> -1
    If $bErrorTimeout Then
        TCPShutdown()
        Return ""
    EndIf
    Local $sReceived = TCPRecv($iConnectedSocket, 1024)
;~ $sReceived = BinaryToString($sReceived, 4)

    TCPSend($iConnectedSocket, '<h1 style="text-align: center;color: blue;font-size: 40px;">AutoIt Rocks</h1><p style="color: red; font-size: 30px;text-align: center;">@AutoItVersion: ' & _
            @AutoItVersion & '<br> <img src="https://www.autoitscript.com/forum/uploads/monthly_2019_01/1.thumb.jpg.4e910845fcf6cc195122be1deb540735.jpg" width="100" height="100"> <br>' & _
            "@AutoItPID: " & @AutoItPID & '</p>')
    If $iConnectedSocket <> -1 Then TCPCloseSocket($iConnectedSocket)
    TCPShutdown()
EndFunc   ;==>_DefaultBroswerLoadPage

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

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