Rank: Advanced Member
Groups: Approved
Joined: 3/30/2019(UTC) Posts: 74 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-: ./?%&=]*)?
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 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 Can you give me some example strings which should match?
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 3/30/2019(UTC) Posts: 74 Thanks: 8 times Was thanked: 1 time(s) in 1 post(s)
|
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
So is this just supposed to see if the text is a URL or something?
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 3/30/2019(UTC) Posts: 74 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
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 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");
}
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 3/30/2019(UTC) Posts: 74 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.
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 3/30/2019(UTC) Posts: 74 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()}
}
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 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?
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 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;
}
}
}
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 3/30/2019(UTC) Posts: 74 Thanks: 8 times Was thanked: 1 time(s) in 1 post(s)
|
Thank you, Rob. Excuse me for not replying in time.
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 3/30/2019(UTC) Posts: 74 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;
}
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 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
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 3/30/2019(UTC) Posts: 74 Thanks: 8 times Was thanked: 1 time(s) in 1 post(s)
|
but why the "LBUTTON" does't work?
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 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.
|
|
|
|
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.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close