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 : Sunday, June 16, 2019 11:32:32 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)
Problems of Regular Expressions
Ask everyone how to put this rule into JS. Thanks.

([/w-]+/.)+[/w-]+.([^a-z])(/[/w-: ./?%&=]*)?|[a-zA-Z/-/.][/w-]+.([^a-z])(/[/w-: ./?%&=]*)?
Rob  
#2 Posted : Sunday, June 16, 2019 1:25:53 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)
It's too early in the morning for me to try to determine what this pattern is supposed to be matching BigGrin

Can you give me some example strings which should match?
zyxi  
#3 Posted : Sunday, June 16, 2019 1:36: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)
Hello, Rob
I use this to match websites, but I always make mistakes in S + and I don't know why.
For example: https://forum.strokesplu...stmessage?t=6047&f=6
Rob  
#4 Posted : Sunday, June 16, 2019 1:39:38 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)
So is this just supposed to see if the text is a URL or something?
zyxi  
#5 Posted : Sunday, June 16, 2019 2:45:39 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)
Yeah,you are right.
This is just supposed to see if the text is a URL
Rob  
#6 Posted : Sunday, June 16, 2019 3:26:38 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)
I mean, it seemed easier to just Google "javascript regex detect url" and used that.

This may or may not be the right regex for your needs, if you're not trying to match on full URLs or something. But you should be able to do some Google searches and find the right one.

Code:
var s = 'https://forum.strokesplus.net/postmessage?t=6047&f=6';
if(s.match(/(https?:\/\/[^\s]+)/g)) {
    sp.MessageBox(`String:\r\n${s}\r\nIS a URL`, "URL Match");
} else {
    sp.MessageBox(`String:\r\n${s}\r\nis NOT a URL`, "URL Match");
}
zyxi  
#7 Posted : Sunday, June 16, 2019 4:10:53 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)
Thank you. Here's another question.
I don't know why this script is wrong. If it weren't “Kill Process“ , the script, such as "sp.SendVKey(vk.BROWSER_BACK)", would work.

UserPostedImage
zyxi  
#8 Posted : Sunday, June 16, 2019 4:15:43 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)
Thank you. Here's another question. I don't know why this script is wrong.
If it weren't " Kill Process", the script , such as "sp.SendVKey(vk.BROWSER_BACK)", would work.

Code:

if(sp.GetKeyState(vk.LCONTROL)& 0x8000) { 
// WAIT FOR KEY TO BE RELEASED
while (sp.GetKeyState(vk.LCONTROL)& 0x8000) {
sp.Sleep(50);
action.Window.Process.Kill()}
}


UserPostedImage
Rob  
#9 Posted : Sunday, June 16, 2019 4:31:08 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)
Would you mind translating the error message so I can have an idea of what it is complaining about?
Rob  
#10 Posted : Sunday, June 16, 2019 4:55:57 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)
Your loop logic was bad, it killed the process, but the loop was trying to kill it again, but the process was already killed.

Try this:
Code:
if(sp.GetKeyState(vk.LCONTROL)& 0x8000) { 
    // WAIT FOR KEY TO BE RELEASED
    while (true) {
        sp.Sleep(50);
        if((sp.GetKeyState(vk.LCONTROL)& 0x8000) == 0) {
            action.Window.Process.Kill()
            break;
        }
    }
}
zyxi  
#11 Posted : Monday, June 17, 2019 10:59:43 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)
Thank you, Rob. Excuse me for not replying in time.
zyxi  
#12 Posted : Monday, June 17, 2019 12:15:55 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)
Hi, Rob, What's wrong with it? It doesn't work.

Code:
if(sp.GetKeyState(vk.LBUTTON)0x8000) { 
    // WAIT FOR KEY TO BE RELEASED
    while (true) {
        sp.Sleep(50);
        if((sp.GetKeyState(vk.LBUTTON)0x8000) == 0) {
            sp.SendModifiedVKeys([vk.LWIN], [vk.VK_E])
            break;
        } 


UserPostedImage
Rob  
#13 Posted : Monday, June 17, 2019 12:28:15 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)
It looks like the forum didn't handle the & characters (HTML reserved character) correctly when I copied and pasted. Put them back in on the GetKeyState lines before the 0x8000
zyxi  
#14 Posted : Monday, June 17, 2019 12:47:00 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)
but why the "LBUTTON" does't work?
Rob  
#15 Posted : Monday, June 17, 2019 1:18:44 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)
You're not giving any time for the LBUTTON to be pressed before it's evaluated in the first line. When you draw the plus and release the Right button, it immediately checks to see if the Left button is down, which it wouldn't be (except for the case below), and the script exits.

How (when) are you pressing the Left button?

You can't press it during the gesture or it would be considered a modifier.
The only way to make this work is if you press and continue to hold the Left button down before you press the Right button to start a gesture. Then you can release Left after you release the Right button.
But this means the Left press down will be received by the window below the mouse.

The only other way is to add a pause at the top of the script, so you draw the gesture, let go of the Right button, then press and hold the Left button before the pause time has passed.

For example, like this:
Code:
sp.Pause(2);
if(sp.GetKeyState(vk.LBUTTON) & 0x8000) { 
    // WAIT FOR KEY TO BE RELEASED
    while (true) {
        sp.Sleep(50);
        if((sp.GetKeyState(vk.LBUTTON) & 0x8000) == 0) {
            sp.SendModifiedVKeys([vk.LWIN], [vk.VK_E])
            break;
        } 
    }
}

This is only for example purposes, it's not really the best way to do it. I think you could do a loop and wait until the Left button is pressed, then continue the script. But I don't know what your expectations are for the UX of this.
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.