tutor2000 Posted November 26, 2006 Posted November 26, 2006 (edited) 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 timerThanksRick$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")EndIfSleep(1000)$tsec = $tsec + 1until not winexists("Workout Timer by Kirkham Count","")Exit Edited November 26, 2006 by tutor2000
DaleHohm Posted November 26, 2006 Posted November 26, 2006 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
tutor2000 Posted November 27, 2006 Author Posted November 27, 2006 You don't explain what your code has to do with an hta DaleSorryEasier to use vbscript in an hta for my workout timerThanks I'll try what you say, but it's my first time using this so I may have to ask more questionsAppreciate itRick
tutor2000 Posted November 27, 2006 Author Posted November 27, 2006 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
DaleHohm Posted November 27, 2006 Posted November 27, 2006 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 RickHere 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
tutor2000 Posted November 28, 2006 Author Posted November 28, 2006 Thanks bradah Can't wait to try it Rick
tutor2000 Posted November 29, 2006 Author Posted November 29, 2006 I used run and got rid of _iecreate which got rid of the file download run save window Thanks a lot for your help Rick
DaleHohm Posted November 29, 2006 Posted November 29, 2006 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
tutor2000 Posted November 29, 2006 Author Posted November 29, 2006 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 expandcollapse popup$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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now