Jump to content

IEBodyReadHTML & Hta Question


 Share

Recommended Posts

This is a for a workout timer I'm working on using an hta (not done yet)

How can I use iereadhtml on the hta so I can replace the ie browser with an hta for the timer

Thanks

Rick

$minte = 0

$hour = 0

$sec = 0

$tsec = 0

$tmin = 0

$thour = 0

#include <IE.au3>

$oIE = _IECreate()

_IENavigate($oIE, "c:\blah\modules\WorkOutTimerCount.html")

;$oIE = "c:\blahmodules\WorkOutTimerCount.hta"

;run(@ComSpec & " /c start "&$oIE, @ScriptDir,@SW_HIDE)

;WinWait("Workout Timer by Kirkham Count","")

Do

if not winexists("Workout Timer by Kirkham Count","") Then

Exit

EndIf

$body = _IEBodyReadHTML($oIE)

If StringInStr($body, "Seconds: "&$tsec) Then

;MsgBox(0, "Success", "The string was found")

$newbody = StringReplace($body, "Seconds: "&$tsec, "Seconds: "&$tsec + 1)

_IEBodyWriteHTML($oIE, $newbody)

Else

;MsgBox(0, "Fail", "The string was NOT found")

EndIf

Sleep(1000)

$tsec = $tsec + 1

until not winexists("Workout Timer by Kirkham Count","")

Exit

Edited by tutor2000
Link to comment
Share on other sites

You don't explain what your code has to do with an hta (since you have all of that commented out) or what specific trouble you are having... however, I'll tell you that when you start an hta, the object variable you get back from _IECreate is not useful to you since it starts a new browser process to run the hta. You use _IECreate to start it, but then you must use _IEAttach(window-title, "embedded") to connect to the resulting hta browser -- from that point forward it will work normally.

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

Grrrrrrrr

Can you give me an example how to attach this

#include <IE.au3>

$oIE = _IECreate()

_IENavigate($oIE, "c:\blahmodules\WorkOutTimerCount.html")

;_IENavigate($oIE, "c:\blah\modules\WorkOutTimerCount.hta")

;$oIEhta = _IEAttach ("Workout Timer by Kirkham Count","embedded")

Thanks

Rick

Link to comment
Share on other sites

Grrrrrrrr

Can you give me an example how to attach this

#include <IE.au3>

$oIE = _IECreate()

_IENavigate($oIE, "c:\blahmodules\WorkOutTimerCount.html")

;_IENavigate($oIE, "c:\blah\modules\WorkOutTimerCount.hta")

;$oIEhta = _IEAttach ("Workout Timer by Kirkham Count","embedded")

Thanks

Rick

Here is a self-contained example of creating and attaching to an hta:

#include <IE.au3>

; Create a .hta file on disk --------
$file = FileOpen("C:\test.hta", 2)
FileWrite($file, "<HTML>" & @CR)
FileWrite($file, "<HEAD>" & @CR)
FileWrite($file, "<Title>Test hta file</Title>" & @CR)
FileWrite($file, "</HEAD>" & @CR)
FileWrite($file, "<BODY>" & @CR)
FileWrite($file, "This is a test hta file..." & @CR)
FileWrite($file, "</BODY>" & @CR)
FileWrite($file, "<HTML>")
FileClose($file)
; -----------------------------------

; Initial browser simply launches the hta and exits, so don't wait for it
Local $tryAttach = False, $visible = False, $wait = False
_IECreate("c:\test.hta", $tryAttach, $visible, $wait)
WinWaitActive("Test hta file")
$oIE = _IEAttach("Test hta file", "embedded")

$sHTML = _IEBodyReadHTML($oIE)
_IEBodyWriteHTML($oIE, "We read the text and wrote it back:<p>" & $sHTML)

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

Ah, good call. Can you post what you did do please?

Thanks,

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

Ah, good call. Can you post what you did do please?

Thanks,

Dale

It's a mess and it's not done yet, but I'm happy to share what I can. I used start to avoid having to find the mshta file which is in a different location depending on the os

I'm sure it could be improved upon by a real programmer

Rick

$min = 0

$hour = 0

$sec = 0

$tsec = 0

$tmin = 0

$thour = 0

$goalmin = 0

$goalsec = 0

$goalhour = 0

$testsec = 0

$oldtime = 0

$time = 0

$rounds = 1

$trounds = 30

#include <IE.au3>

run(@comspec & " /c start c:\blah\modules\WorkOutTimerCount.hta", @ScriptDir, @SW_HIDE)

WinWaitActive("Workout Timer by Kirkham","")

WinSetState ( "Workout Timer by Kirkham", "", @SW_MAXIMIZE )




$oIE = _IEAttach("Workout Timer by Kirkham", "embedded")

$body = _IEBodyReadHTML($oIE)

$time = @HOUR&":"&@MIN&":"&@SEC

$oldtime = @HOUR&":"&@MIN&":"&@SEC

$body = StringReplace($body, "Time:", "Time: "&$time )

 _IEBodyWriteHTML($oIE, $body)

Do
    
$oldtime = @HOUR&":"&@MIN&":"&@SEC
    
    if not winexists("Workout Timer by Kirkham","") Then
        
        Exit
        
    EndIf
    

$body = _IEBodyReadHTML($oIE)


;Sleep(1000)


changetimer()



until not winexists("Workout Timer by Kirkham","")

Exit


Func changetimer()
    
    $testsec = @SEC
    
    while $testsec = @SEC
        
        sleep(100)
        
    WEnd
    
    
    if not winexists("Workout Timer by Kirkham","") Then
        
        Exit
        
    EndIf
    
    $body = StringReplace($body, "Seconds: "&$sec, "Seconds: "&$sec + 1)
    
    $sec= $sec + 1
    
    $goalsec = $goalsec + 1
    
    if not winexists("Workout Timer by Kirkham","") Then
        
        Exit
        
    EndIf
    
    if $sec >= 60 Then
        
        $sec = 0
        
        $body = StringReplace($body, "Minutes: "&$min, "Minutes: "&$min + 1)
        
        $body = StringReplace($body, "Seconds: 60", "Seconds: 0")
        
        $min  = $min + 1
                
    EndIf
    
    if $min >= 60 Then
        
        $min = 0 
        
        $body = StringReplace($body, "Hours: "&$hour, "Hours: "&$hour + 1)
        
        $body = StringReplace($body, "Minutes: 60", "Minutes: 0")
        
        $body = StringReplace($body, "Seconds: 60", "Seconds: 0")
        
        $hour = $hour + 1
        
    EndIf
    
    if not winexists("Workout Timer by Kirkham","") Then
        
        Exit
        
    EndIf
    
    $tsec = $tsec + $sec
    
    if $goalsec >= $trounds Then
        
        $body = StringReplace($body, "Round: "&$rounds, "Round: "&$rounds + 1 )
        
        $rounds = $rounds + 1
        
        $goalsec = 0
        
    EndIf
    
    
        $time = @HOUR&":"&@MIN&":"&@SEC
    
    $body = StringReplace($body, "Time: "&$oldtime, "Time: "&$time )
    

    
     _IEBodyWriteHTML($oIE, $body)
    
    
    Return
    
EndFunc
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...