Page 1 of 1

Windows 10/11 slow text Operation

Posted: Sat Apr 01, 2023 6:32 pm
by mikelpapamike
Hello Everyone,

I have a simple script running on windows that is running quite slowly. I tried the same script in MacOS and is running perfectly. Any way to improve it inside windows?

The problem specifically is that i want to read the text of an html page from the browser widget every 100 milliseconds, to take a running time field at a fraction of 100 milliseconds.

The codee:

Code: Select all

on mouseUp
   rCommand
end mouseUp


command rCommand
   lock screen
   
   get matchText(Text of widget "browser", "<td class=" & quote & "r_27899h_2g_2l_4c_6  tg tw align_right" & quote & ">(.*.)</td>", R )
   set the itemDel to "</td"
   put item 1 of R into fld "Field2"
   //unlock screen
   if the hilite of button "check" then
      send rCommand to me in 50 millisec
   end if
end rCommand

Re: Windows 10/11 slow text Operation

Posted: Sat Apr 01, 2023 6:43 pm
by stam
Does grabbing the text and putting it into a variable before scraping it help?

Re: Windows 10/11 slow text Operation

Posted: Sat Apr 01, 2023 7:24 pm
by mikelpapamike
Nope, no difference at all. Maybe slightly worse sometimes.

Re: Windows 10/11 slow text Operation

Posted: Sat Apr 01, 2023 7:30 pm
by stam
mikelpapamike wrote:
Sat Apr 01, 2023 7:24 pm
Nope, no difference at all. Maybe slightly worse sometimes.
well, it was a thought...

looking at your regex, this may be a bit malformed - you don't escape the slash in </td>, but you could also probably shorten it to:

Code: Select all

r_27899h_2g_2l_4c_6.+>(.*)<\/td>
Impossible to test without source text to search, but this *should* work...
if it doesn't, can you post a some of the text you're scraping?
Mind you, not sure this will speed things up in Windows - but probably makes it easier to manage the regex ;)

S.

Re: Windows 10/11 slow text Operation

Posted: Sat Apr 01, 2023 8:04 pm
by mikelpapamike
Thanks a lot again for your prompt reply. I tried your code,but for some reason,which ever text i try to scrap,it always reads one speecific field.

I'm not sure if I can post here the data I'm scraping as it is a website where ski results come realtime from US races, which is the same APP/Web page that the local races in my country use,so i'm preparing the scraping using the US page. But you can find it easily at vola dot ussalivetiming dot com

Re: Windows 10/11 slow text Operation

Posted: Sat Apr 01, 2023 8:36 pm
by stam
mikelpapamike wrote:
Sat Apr 01, 2023 8:04 pm
Thanks a lot again for your prompt reply. I tried your code,but for some reason,which ever text i try to scrap,it always reads one speecific field.
I should have said I'm at work and occasionally checking not the phone while waiting for stuff to happen... (yep, lots of waiting for staff...)
if you mean that only the first result is found, perhaps try

Code: Select all

(?msixU)r_27899h_2g_2l_4c_6.+>(.*)<\/td>
Ultimately you probably need Thierry's input for the regex (I am but a mere amateur!) but he doesn't really frequent the forum any more...

Re: Windows 10/11 slow text Operation

Posted: Sun Apr 02, 2023 9:27 am
by stam
I tried the URL you provided - it works in a normal browser but for the life of me I can't get it to load in a widget browser (it only loads the top header bar, none of the results...). I'm on MacOS 13.2.1, using LC 10 DP4, and practically all sites load normally but this one doesn't....

Re: Windows 10/11 slow text Operation

Posted: Sun Apr 02, 2023 10:51 am
by FourthWorld
Will usually require some additional cleanup, but:

Code: Select all

set the htmlText of fld "Converter" to \
 the text of widget "browser"

Re: Windows 10/11 slow text Operation

Posted: Sun Apr 02, 2023 10:52 am
by Klaus
Hi stam,

no problem with that URL in LC 9.6.9 rc3 on macOS 12.6.4!?


Best

Klaus

Re: Windows 10/11 slow text Operation

Posted: Sun Apr 02, 2023 12:54 pm
by stam
the text of the widget "browser" is empty on this site and as mentioned only the top banner loads for me. No idea why as sites with complex layout work just fine...

Re: Windows 10/11 slow text Operation

Posted: Sun Apr 02, 2023 5:31 pm
by jacque
The interval is short enough that there may be stacked pending messages in the queue. I also removed the lockscreen command since there's no redraw happening until the field content changes at the end. That may not be necessary. Try this:

Code: Select all

command rCommand 
   get matchText(Text of widget "browser", "<td class=" & quote & "r_27899h_2g_2l_4c_6  tg tw align_right" & quote & ">(.*.)</td>", R )
   set the itemDel to "</td"
   put item 1 of R into fld "Field2"
   if the hilite of button "check" and "rCommand" is not in the pendimgMessages then
      send rCommand to me in 50 millisec
   end if
end rCommand