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

Notification

Icon
Error

Options
Go to last post Go to first unread
zyxi  
#1 Posted : Monday, June 17, 2019 11:15:01 AM(UTC)
zyxi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/30/2019(UTC)
Posts: 74
China

Thanks: 8 times
Was thanked: 1 time(s) in 1 post(s)
Google Search Enhanced Edition
Add a regular matching websites. URL can be opened directly by adding regular matching websites, .
Because the website is too complex, you may need to revise it further.



Code:
sp.SendKeys("^c");
var tmp = clip.GetText();
var reg = /([\w-]+\.)+[\w- ]+.([^a-z])(\/[\w-: ./?%&=]*)?|[a-zA-Z\-\.][\w- ]+.([^a-z])(\/[\w-: ./?%&=]*)?/;
if(reg.test(tmp)){
     sp.RunProgram("chrome.exe", tmp, "open", "normal", true, false, false);
}
else{
   var tem = "https://www.baidu.com/s?ie=UTF-8&wd="+tmp.replace(' ', '+');
   sp.RunProgram("chrome.exe", tem, "open", "normal", true, false, false);
}
zyxi  
#2 Posted : Tuesday, June 18, 2019 12:37:33 PM(UTC)
zyxi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/30/2019(UTC)
Posts: 74
China

Thanks: 8 times
Was thanked: 1 time(s) in 1 post(s)
Dear Rob, when I search for "chrome. exe" with this script, it turns out to be "chrome. exe /".
I don't know what caused an extra "/". Can you give me some guidance or suggestions?
Rob  
#3 Posted : Tuesday, June 18, 2019 1:14:45 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 418 time(s) in 356 post(s)
"chome.exe" matches your regex, so it thinks it's a website and is trying to send you to "http://chrome.exe/".

I believe the "/" is being added by Chrome in the address bar.
thanks 1 user thanked Rob for this useful post.
zyxi on 6/18/2019(UTC)
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.