AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Get Text From HTML?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
HelpMe2
Guest





PostPosted: Mon May 12, 2008 7:43 am    Post subject: Get Text From HTML? Reply with quote

I have a program which outputs text in HTML format. Therefore, i cant use the WinGetText command - it doesnt find anything.

is there anyway i can read the text from the actual program or from the HTML file it saves in real time?

thanks
Back to top
Guest






PostPosted: Mon May 12, 2008 7:46 am    Post subject: Reply with quote

use RegExMatch
Back to top
HelpMe2
Guest





PostPosted: Mon May 12, 2008 4:12 pm    Post subject: Reply with quote

Can you be more specific please? The help file on regexmatch is very confusing.
How do i call on the html file to check whether a change has happened to it and read that change?
Back to top
n-l-i-d
Guest





PostPosted: Mon May 12, 2008 4:50 pm    Post subject: Reply with quote

Is this program a browser? If so, you might be able to grab the text with a JavaScript Bookmarklet. If you know the address/url of the file, you could use the AutoHotkey command URLDownloadToFile, or the URLDownloadToVar function in the Forum. If that fails, try curl.exe.

HTH
Back to top
HelpMe2
Guest





PostPosted: Mon May 12, 2008 10:47 pm    Post subject: Reply with quote

yea i know where it saves the file temporarily on the computer so i want to constantly look for if it changed. More specifically, i want to be able to tell if it changed to a number in the range of 1-15 - if yes, then a mouse click will be performed.
Im just having problem with figuring out how to detect that change as soon as possible from the html.
Back to top
n-l-i-d
Guest





PostPosted: Mon May 12, 2008 11:07 pm    Post subject: Reply with quote

If the file is locally stored, create a timer with SetTimer, and on the timed check, look at the modification date of the file with FileGetTime, compare it with the previous modification date of the file, if changed, use Loop, Read or FileReadLine with InStr() (or FileRead with RegExMatch) to get your specific text inside the file, which you then again can compare with the previous text you got from the file to see if it changed.

HTH
Back to top
HelpMe2
Guest





PostPosted: Tue May 13, 2008 2:05 am    Post subject: Reply with quote

Thanks for the advice.
i think in my case it would be better to just constantly track a change by using a loop and sleep.

Lets say this is the code that i know will change and only this, how do i make it scan only this part of the htm file and if the number changes:
Code:
<TD ALIGN='CENTER' VALIGN='MIDDLE'  BGCOLOR='#CC99FF'     colspan='1'><font face='verdana' size='-4'> <B>54/169</B></TD>
</TR>

The numbers 54/169 is what changes. Everything else stays the same. In fact, the htm file is much larger than this.
Therefore, can i simply make the AHK search for a change in numbers, then if the first value is in the 1-20 range, open a program.

Thank you very much for the help. I think i was unclear at first, hopefully this is more clear.
Back to top
Ian



Joined: 15 Jul 2007
Posts: 1077
Location: Enterprise, Alabama

PostPosted: Tue May 13, 2008 2:14 am    Post subject: Reply with quote

xpath v3 - read and write XML documents with XPath syntax [Titan]
_________________
1,000 Posts achieved on Saturday April 26, 2008 1:45 am
Back to top
View user's profile Send private message
Guest






PostPosted: Tue May 13, 2008 2:19 am    Post subject: Reply with quote

HelpMe2 wrote:
I think i was unclear at first, hopefully this is more clear.

ok it seems clear now Smile
below will work only if the html source has only one unique text pattern

Code:
SetTimer, WatchForChange, 60000 ;put your desired interval here 60000=1 minute
Return

WatchForChange:
FileRead, Str, THEHTMLSOURCEFILENAMEHERE
RegExMatch(Str,"verdana' size='-4'> <B>([\d/]+)</B>",OutPut)
StringSplit, Found, OutPut1, /
If Found1 Between 1 and 20
  Run, Notepad.exe ;put your desired program here
Return
Back to top
HelpMe2
Guest





PostPosted: Tue May 13, 2008 6:25 am    Post subject: Reply with quote

Worked great!! Thank you so much Smile

I just needed to add #Persistent to the top so that it constantly runs
Back to top
tank



Joined: 21 Dec 2007
Posts: 220

PostPosted: Tue May 13, 2008 3:01 pm    Post subject: Reply with quote

while xpat will work on well formed html it breaks when you get imporperly formated html
you may also use javascript dom model with this
http://www.autohotkey.com/forum/viewtopic.php?t=30599&highlight=
_________________
RTFM
apply
break-it
learn from it
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group