StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Register | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Lua Scripts
 General Action Scripts
 Parent Directory
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Naysan Mojgani

USA
3 Posts

Posted - 10/29/2012 :  18:25:05  Show Profile  Reply with Quote
I'm new to StrokesPlus. Love it. When I migrated to Chrome from Opera, I tried several extensions to recreate the built in gestures from Opera. Now that I've moved on to using StrokesPlus, though, I'm trying, yet again, to recreate those browser gesture functions that I've grown used to.
The only one that I'm having trouble with is navigating to the parent directory of a webpage. It's most useful when browsing directory listings, but it comes in handy with many other websites as well.
So, I guess I'm looking for a way to grab the url, drop the end (everything after the last slash), and resend it to the browser? I tried checking Chrome shortcut keys to see if there was a built-in command to "go to parent directory" without any luck. It's kind of standard issue it seems for the Chrome extensions I've tried, so I feel that there must be either a hidden command for it that Chrome recognizes, or the implementation shouldn't be too difficult. But, it's definitely beyond my comfort level. Any help would be really appreciated. Thanks!

Rob

USA
2516 Posts

Posted - 10/29/2012 :  18:47:41  Show Profile  Visit Rob's Homepage  Reply with Quote
Does this work for you?
acSendKeys("%d") --change to address bar
acDelay(150)
acSendKeys("^c") --copy the URL
acDelay(150)
local sTemp = acGetClipboardText() --get the URL from the clipboard
acSetClipboardText(string.reverse(string.sub(string.reverse(sTemp),string.find(string.reverse(sTemp), "/", 1),string.len(sTemp)))) --set the clipboard to the parent directory
acDelay(150)
acSendKeys("%d") --check to the address bar
acDelay(150)
acSendKeys("^v") --paste the modified URL
acDelay(150)
acSendKeys("~") --press Enter

Tested in Chrome, Firefox, and IE on my machine. You may have to play with the acDelay(150) numbers (increase) if you're having timing issues (I had to increase to 150 for IE to work properly)
Go to Top of Page

Naysan Mojgani

USA
3 Posts

Posted - 10/29/2012 :  18:54:09  Show Profile  Reply with Quote
Hm. Close. It will go up one level, but it won't go past that.
For instance:
At "http://www.english.emory.edu/classes/Shakespeare_Illustrated/Boydell.html", it will drop the "Boydell.html" but repeating the gesture doesn't drop the "Shakespeare_Illustrated/".
If I'm understanding the code properly, it searches for the last slash, and drops everything after that, yes? How would you change it to either drop the slash as well, or recognize if the slash is the last character and drop everything after the second-to-last slash?
Go to Top of Page

breakcore

Russia
74 Posts

Posted - 10/29/2012 :  18:55:53  Show Profile  Reply with Quote
or this)

acSendKeys("^l{DELAY 50}^c")
url=acGetClipboardText()
new_url=string.gsub(url,"(.+)/.+/?","%1")
acSetClipboardText(new_url)
acSendKeys("^v{DELAY 50}{ENTER}")

Edited by - breakcore on 10/29/2012 18:57:18
Go to Top of Page

Rob

USA
2516 Posts

Posted - 10/29/2012 :  18:56:55  Show Profile  Visit Rob's Homepage  Reply with Quote
There you go!
Go to Top of Page

Naysan Mojgani

USA
3 Posts

Posted - 10/29/2012 :  18:58:05  Show Profile  Reply with Quote
Breakcore's version seems to solve that problem I had with the first one. Thanks so much for the help!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000