Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

One task that I do all day that is very annoying is working on files and moving them around or adding new files to a folder in my localhost dev server and then I have to go to the browser and navigate to get to the file.

I would assume there has to be a way to be able to add a right click context menu option to "Open File in browser" but to not just open the file in a browser because then it would probably open at the file path to it so my 2 questions

1) Is it possible to add a context menu option using Windows 7 that will alow me to open files in the browser

2) If question 1 is possible, could I then set it to open based off a defined path. Example if the file is located at

E:\Server\htdocs\Labs\javascript\socialbuttons\socialable

And I access the file in the browser at

http://localhost/Labs/javascript/socialbuttons/socialable

it would just need to always replace

E:\Server\htdocs

with...

http://localhost/

And append the rest on and open in browser.

Any help or ideas appreciated

share|improve this question
1  
AutoHotkey can handle this. I don't have time right now (on my phone, away from computer), but later, I can will write up a script. (If anyone else is savvy with AutoHotkey, feel free to take on this script in the meantime.) –  iglvzx Dec 11 '11 at 23:21
    
@iglvzx that would be simply amazing and I use AHK I just don't have the skill to write a script to do that, have wrote a couple scripts for uploading screenshots and stuff, I forgot AHK can do almost anything, if you get the time I would greatly appreciate it –  jasondavis Dec 12 '11 at 0:00
    
I should clarify. You do not need to add a context menu if you can get the job done with AutoHotkey. –  iglvzx Dec 12 '11 at 1:05

1 Answer 1

up vote 1 down vote accepted

We can accomplish this by editing the Registry and by using AutoHotkey. I called my script OpenAsLocalhost.ahk, and used similar names for my example.

  • Compile the following AutoHotkey script:
file = %1%
server = E:\Server\htdocs\
StringReplace, url, file, %server%, http://localhost/
StringReplace, url, url, \, /, All
Run, %url%
ExitApp
  • Open the Registry Editor (regedit.exe).
  • Navigate to HKEY_CLASSES_ROOT\*\shell
  • Create a new Key under shell\ named OpenAsLocalhost.
  • Set the (Default) value to Open as localhost.
  • Create a new Key under OpenAsLocalhost\ called command
  • Set the (Default) value to "C:\OpenAsLocalhost.exe" "%1"
  • Done!
share|improve this answer
1  
Thank you this works flawlessly, I am using Windows 7 x64 and I did not have to hide known extensions, when F2 is sent, it just copies the first part of the name and doesn't select the .extension part so that worked out good. I would like to incorporate this into a context menu eventually so I think this is a great starting point as it does the functionality part. I saw some other AHK scripts that added a custom context menu so I'm pretty sure it is possible, if I find the solution for that part I will post it here for you or others to know about. I appreciate your time thanks again! –  jasondavis Dec 13 '11 at 7:31
    
You are welcome! :) –  iglvzx Dec 13 '11 at 7:44
    
@jasondavis We did it. See my revised answer. –  iglvzx Dec 13 '11 at 8:22
    
That is awesome! I am having a little trouble so far though, were you able to get it working on your system? If I access the program directly 'OpenAsLocalhost.exe` then I get the error in the attached image d3j5vwomefv46c.cloudfront.net/photos/full/… –  jasondavis Dec 13 '11 at 9:13
    
...continued I am not sure, possibly I am not suppose to ever access the program created directly? Now after I create the registry entry, I have the menu item. When I right click on a file and then click the menu item to open in localhost, I get the popup window "Open With" dialog asking me to pick a program to open this file with (even on files that have a default program) If I then pick a program, it will then simply open the file in that program. If I choose a web browser to open, then it opens it at the file path instead of a web path –  jasondavis Dec 13 '11 at 9:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.