StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
liuchina  
#1 Posted : Monday, October 28, 2019 1:04:02 AM(UTC)
liuchina

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 9/26/2018(UTC)
Posts: 73
China
Location: 北京

Thanks: 18 times
Was thanked: 1 time(s) in 1 post(s)
Similar to 'document. ReadyState', I want to make sure that s + net starts executing a script after the page is loaded.
Thank you.
Rob  
#2 Posted : Monday, October 28, 2019 2:11:48 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
If you're referring to a web page in the browser, there's no direct way for S+ to look inside the browsers code to know that.

You can usually find a way to make this work, but it can be a little bit of trial and error to get it just right.

For example, I have this script which I run to log into my bank's website. Read the comments in the script for an explanation of how it works.
Code:
    sp.SendKeys("my_bank_username~");
    sp.StoreHandle("BankName", action.Window.HWnd);
    sp.CreateTimer("BankNameTimer", 
                              1000, 
                             -1, 
                              String.raw`var ct = 0;
                                                 var wnd = sp.WindowFromHandle(sp.GetStoredHandle("BankName"));
                                                 //Wait until the tital of the window changes to the banking login area
                                                 while(wnd.Title.indexOf("Bank_Website_Partial_Title") == -1){
                                                     sp.Sleep(500);
                                                     ct++;
                                                     if(ct > 20){
                                                         //If more than 20 attempts (10 seconds), just try to continue anyway
                                                         break;
                                                     }
                                                 }
                                                 ct = 0;
                                                 //Get the pixel color from the CENTER of the Chrome Stop/Refresh icon
                                                 //While the page is loading, the center of the icon is a different color since it's an "X" 
                                                 //instead of the Refresh icon, which is a like a circle
                                                 var bclr = sp.GetPixelColorFromPoint(new Point(85,50));
                                                 //While the color is NOT the standard theme color (because the page is loading and the icon is the "X"
                                                 //keep witing
                                                 while(bclr.B != 87 && bclr.G != 87 && bclr.R != 87) {
                                                     sp.Sleep(500);
                                                     ct++;
                                                     if(ct > 20){
                                                         break;
                                                     }                                        
                                                    bclr = sp.GetPixelColorFromPoint(new Point(85,50));
                                                 }
                                                 bclr = sp.GetPixelColorFromPoint(new Point(85,50));
                                                 //If the pixel color is the same as the other theme background colors, then it must be 
                                                 //showing the Refresh icon, meaning the page is finished loading
                                                 if(bclr.B == 87 && bclr.G == 87 && bclr.R == 87) {
                                                     //Send the Enter key to login (Chrome autofills the password)
                                                     sp.SendKeys("~");
                                                 }
                                                 //Clean up - remove the timer and stored handle
                                                 sp.DeleteStoredHandle("BankName");
                                                 sp.DeleteTimer("BankNameTimer");`
                              );
liuchina  
#3 Posted : Tuesday, October 29, 2019 12:15:53 AM(UTC)
liuchina

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 9/26/2018(UTC)
Posts: 73
China
Location: 北京

Thanks: 18 times
Was thanked: 1 time(s) in 1 post(s)
Thank you Rob.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.