StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
Navigation to a Parent Directory (URL) of a Webpage
Rank: Newbie
Groups: Approved
Joined: 6/26/2020(UTC) Posts: 7
Thanks: 4 times
|
Hi, Everyone! I have used StrokesPlus for some years and I am new to StrokesPlus.net. Would you tell me how to write a script which can navigate to a parent directory (URL) of a webpage? (Example: https://abc.def/ghi/jkl/ -> https://abc.def/ghi/ ) The script for StrokesPlus was like this (Lua Script): acActivateWindow(nil, gex, gey) acSendKeys("^l{DELAY 50}^c") url=acGetClipboardText() new_url=string.gsub(url,"(.+)/.+/?","%1") acSetClipboardText(new_url) acSendKeys("^v{DELAY 50}{ENTER}") Thanks in advance.
|
|
|
|
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)
|
Haven't tested this with a large variety of URLs, but it seems like it should be good. Code:sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_L]); //Control+L
sp.Sleep(40);
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_C]); //Control+C
//Take URL from clipboard and remove last segment, then save result to clipboard
clip.SetText(clip.GetText().split("/").slice(0,-1).join("/"));
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_V]); //Control+V
sp.SendVKey(vk.RETURN); //Enter
Edited by user Saturday, June 27, 2020 10:15:41 AM(UTC)
| Reason: Not specified
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Newbie
Groups: Approved
Joined: 6/26/2020(UTC) Posts: 7
Thanks: 4 times
|
Rob, thank you for your quick reply! Your script worked well in my environment. I got occasional error (related to Text? Null?, I could not understand), but it was not a big problem. I'll try to learn more about JavaScript and your code by myself. Anyway, thanks for your help!
|
|
|
|
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)
|
Let me know what the error is next time it happens. Odds are it may be a timing issue - for example it didn't get to copy the URL or something in time before it tried to parse the string from the clipboard. We may need to increase the delay or add in some other logic to check and catch those conditions, etc. Or it might be that the URL didn't have enough "/" in it, like http://abc.com/test so it had trouble parsing off the last directory. Edited by user Sunday, June 28, 2020 1:38:21 PM(UTC)
| Reason: Not specified
|
|
|
|
StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
Navigation to a Parent Directory (URL) of a Webpage
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