DonationCoder.com Forum

DonationCoder.com Software => Coding Snacks => Post New Requests Here => Topic started by: SleepingWolf on October 25, 2008, 01:57 PM

Title: Open Containing Folder
Post by: SleepingWolf on October 25, 2008, 01:57 PM
I have a useful context-menu extension created (with instructions from the web) via a registry key; it says "Open Containing Folder" so that right-clicking a file (or shortcut) and selecting that menu item opens explorer at that folder in the directory structure.

I have often wondered if it would be possible to get similar functionality for program windows - right clicking on the title bar will show an extra menu item: "Locate program" that would open explorer at the containing folder.

Also, by extension, other processes could be listed in a listbox (or better) GUI item and selected to open explorer there (or other file manager of course). I would love to try Skrommelling it (in Autohotkey) but I feel it would almost certainly be beyond me so feel it best to throw the idea out there to your tender mercies!
Title: Re: Open Containing Folder
Post by: mouser on October 25, 2008, 02:26 PM
this is one of those great simple ideas.   :up:
Title: Re: Open Containing Folder
Post by: Deozaan on October 25, 2008, 02:30 PM
I don't want to sound like a stick in the mud, but if you're right clicking a file (with the exception of a shortcut) wouldn't you already be exploring that directory?
Title: Re: Open Containing Folder
Post by: mouser on October 25, 2008, 02:40 PM
what he means is, let's say you have a program running on your screen, like notepad or maybe some program started at windows boot time.  so now he's saying it would be nice to have an easy way to jump to that program's directory on disk.

i guess there are process explorers that will do this -- just seems like one of those ideas that should be built into windows so that you could click on a window of a running program somewhere and say "take me to this program's home directory".
Title: Re: Open Containing Folder
Post by: SleepingWolf on October 25, 2008, 02:57 PM
You're both right. The existing Context-Menu item is most useful for shortcuts.

Process explorers (prcView mainly here)  generally give you option to copy path to clipboard ---> perhaps a clip-board monitor could open copied paths automatically.
Title: Re: Open Containing Folder
Post by: cmpm on October 26, 2008, 01:26 PM
one of these may do it

http://search.techrepublic.com.com/search/window+title.html

some of these hits seem to suggest they can
Title: Re: Open Containing Folder
Post by: SleepingWolf on October 28, 2008, 04:00 PM
one of these may do it

http://search.techrepubli.../search/window+title.html

some of these hits seem to suggest they can


Thanks cmpm, I need to read them in detail, but the ones I've checked either need .NET or seem downright un-downloadable as the download links are well hidden.

I'd prefer an open-source Autohotkey solution; wouldn't you?
Title: Re: Open Containing Folder
Post by: cmpm on October 29, 2008, 07:31 AM
Yes I would prefer that too.
That was all I could find with some various search strings.

If the icon in the title bar was actually an icon shortcut that would help.

There should be a way to add the command to to the right click title bar menu. Or make it an address bar. Then Skrommels 'Captain' could be used to paste the text into 'run'.

https://www.donationcoder.com/Software/Skrommel/index.html#Captain

---

this is close but still dealing with the shortcuts

http://www.megaleecher.net/taxonomy/term/1761
Title: Re: Open Containing Folder
Post by: AndyM on October 29, 2008, 04:51 PM
Macro Express might do what you want. 
www.macros.com
Title: Re: Open Containing Folder
Post by: SleepingWolf on October 30, 2008, 02:20 PM
this is one of those great simple ideas.

Yes, Mouser, that's why I thinkthat someone will have solved it before.


Macro Express might do what you want.

Thanks, AndyM. Unfortunately, Macro express seems to be an expensive equivalent of AutoHotkey. Sure it may be able to do it, but then so might AHK and so might Macro Scheduler that I was trying before -so why pay for the possibility of a solution when it may be AHK-solvable with the advantage of using less tools with less of a syntax learning curve? Unless you have experience of a greater (and more relevant) command set...?

No, I think AHK COULD be made to do the trick. I'm also sure that it will take me a while and that maybe someone here would relish the challenge -and may even have solved a similar problem before -hence my reasons for posting.
Title: Re: Open Containing Folder
Post by: cmpm on October 30, 2008, 08:35 PM
Yeah, I think it would be a great convenience.
But not worth a hefty price for a small function.

I found this for $50.
It does everything but what this thread is about.

http://www.actualtools.com/

I found programs that put the time or calendar or both in it.
Also found one that will scroll a text file across the title bar for entertainment.
Found some that will scroll news or stocks.

But no target or address function without copy paste.
Title: Re: Open Containing Folder
Post by: AndyM on October 30, 2008, 10:29 PM
Macro Express might do what you want. 
www.macros.com
Oh no!  This reply was meant for another thread (something about clicking on buttons or controls).  Sorry! :-[
Title: Re: Open Containing Folder
Post by: AndyM on October 30, 2008, 10:42 PM
But I atone.  Here's an ahk script from Skrommel that displays the .exe file and path next to the mouse for whatever window the mouse is hovering over.

You could use the GetModuleFileNameEx(p_pid) subroutine to get the path and open the folder, and put it in an .ahk or .exe file to use as a context menu choice.
;WinProcPath.ahk
; Show the filename of the windows below the mouse
;Skrommel @ 2007

#SingleInstance,Force
#NoEnv

Loop
{
  MouseGetPos,x,y,winid,ctrlid
  WinGet,pid,Pid,ahk_id %winid%
  path:=GetModuleFileNameEx(pid)
  ToolTip,%path%
  Sleep,100
}


GetModuleFileNameEx(p_pid) ;by shimanov at www.autohotkey
{
   If A_OSVersion in WIN_95,WIN_98,WIN_ME
   {
     WinGet,name,ProcessName,ahk_id %p_pid%
     Return,name
   }
   h_process:=DllCall("OpenProcess","uint",0x10|0x400,"int",false,"uint",p_pid) ;  PROCESS_VM_READ=0x0010  PROCESS_QUERY_INFORMATION=0x0400
   If (ErrorLevel or h_process=0)
      Return
   name_size=255
   VarSetCapacity(name,name_size)
   result:=DllCall("psapi.dll\GetModuleFileNameExA","uint",h_process,"uint",0,"str",name,"uint",name_size)
   DllCall("CloseHandle",h_process)
   Return,name
}
Title: Re: Open Containing Folder
Post by: cmpm on October 31, 2008, 09:24 AM
This script has the target following the mouse in a box.
I don't know how to use it except for just showing the directory.
No way to drop in run or open the folder.

The script is missing something or I am.
Title: Re: Open Containing Folder
Post by: AndyM on October 31, 2008, 08:38 PM
This script has the target following the mouse in a box.

And isn't the folder which contains that target the one you want to open?

The script has a subroutine that identifies the executable associated with that window.  One could build on that to write a script to do what you want. 

Writing the subroutine would have been way beyond me, but if I spent the time, I think I could use it to write an ahk script that would do what you want.  It would be a stretch but  if I wanted the utility bad enough I would spend the time and enjoy it as a learning experience.

But I have too much going on at the moment to get sidetracked, so either someone else can do it (Skrommel?), or you could have your own learning experience. ;D
Title: Re: Open Containing Folder
Post by: cmpm on October 31, 2008, 09:53 PM
Thanks AndyM, it is interesting and got me into AHK.

Yes that does show the target of whatever you are on.
Like you, other things to do as well.
But worth the time for the learning.

A program by lanux128 'CopyCap' does what Captain does also.

https://www.donationcoder.com/forum/index.php?action=dlattach;topic=14275.0;attach=31748

Both good programs and good folks.
Title: Re: Open Containing Folder
Post by: cmpm on November 01, 2008, 08:41 AM
Found one.
Uses .Net 3.5 though and it does work.
It's called 'Titlebar'. Free.

http://www.r-nsoft.com/download.html

Version Tracker had it on their site

Title: Re: Open Containing Folder
Post by: lanux128 on November 01, 2008, 09:26 AM
actually this feature can be included as part of CopyCap (https://www.donationcoder.com/forum/index.php?topic=14275.0). the code by AndyM/Shimanov can be inserted easily into my script, which i have done so. please try out and let me know. :)

[ You are not allowed to view attachments ]

Note: this script might require 'psapi.dll'.
Title: Re: Open Containing Folder
Post by: ewemoa on November 01, 2008, 09:43 AM
Seems to work nicely here :)

(I changed MButton to XButton1 as I was already using MButton for something else [1].  In my tired state, I didn't think of any good approaches to work around the issue of multiple programs using the same mouse button -- any ideas on that front?  Is it easy to detect whether something else is already using a particular mouse button for something in AHK (or anything else for that matter)? [2])


[1] Either I configured VirtuaWin to do this or it does it by default -- don't remember...

[2] Ah, I guess Captain has an option to change the hotkey.
Title: Re: Open Containing Folder
Post by: cmpm on November 01, 2008, 09:44 AM
It works good lanux.

If there is a program running with the middle click button taken it won't though.
Such as ipoint.

But that function in ipoint could be changed to a different mouse click i suppose. It's the default setup for ipoint that has the middle click tile open windows.
Title: Re: Open Containing Folder
Post by: lanux128 on November 01, 2008, 11:21 AM
i'm glad to see that it works. as for the hotkey, the script will show the menu only if the middle-click is on the titlebar elsewhere middle-click should work as normal. :)

@ewemoa: hotkey detection is a bit tricky with AHK but it could made configurable instead.

@cmpm: i'm not familiar with ipoint but does the function to tile open windows requires middle-click on the caption/titlebar?

Note: just to clarify things, i've tested the script with the latest version - 1.0.47.06 (http://www.autohotkey.com/changelog/) so if it doesn't work, please provide more details such as AHK version, Windows version and the conflicting programs. :)
Title: Re: Open Containing Folder
Post by: cmpm on November 01, 2008, 11:47 AM
No, just middle click anywhere and ipoint will tile the windows, including the title bar.

ipoint is microsoft's software for their mice
you knew that probably

Anyway ipoint disables CopyCap and Captain as far as using the middle click on the title bar. Which can easily be worked around by changing one of the programs function for the middle click.

So it's not a big deal. Thought I would mention it in case it wasn't working for someone.
Title: Re: Open Containing Folder
Post by: lanux128 on November 01, 2008, 12:03 PM
Anyway ipoint disables CopyCap and Captain as far as using the middle click on the title bar. Which can easily be worked around by changing one of the programs function for the middle click.

okay, now i understand. the iPoint program has a higher priority in intercepting the mouse-clicks than AHK. so if you're in mood for some testing, you can place the following line in the AHK script and see if that solves the problem.

#InstallMouseHook

Title: Re: Open Containing Folder
Post by: cmpm on November 01, 2008, 12:15 PM
ehh, no go
i put it after
'#NoTrayIcon'
is their a different place for it?
Title: Re: Open Containing Folder
Post by: lanux128 on November 01, 2008, 12:24 PM
well it seems that iPoint retains the upper-hand but at least we tried. :)
Title: Re: Open Containing Folder
Post by: cmpm on November 01, 2008, 12:49 PM
killing the ipoint process lets CopyCap and Captain work
then just run ipoint.exe in the run box to have ipoint if you want it

or change ipoint's configuration

thanks for the modified script for getting the directory lanux
Title: Re: Open Containing Folder
Post by: cmpm on November 01, 2008, 12:54 PM
here's the smallest run box i know of
stays on top of everything
so easy access

http://bayden.com/SlickRun/

Title: Re: Open Containing Folder
Post by: f0dder on November 01, 2008, 01:18 PM
It's much less cool than FARR though :)
Title: Re: Open Containing Folder
Post by: lanux128 on November 01, 2008, 09:26 PM
Slickrun (https://www.donationcoder.com/forum/index.php?action=search2;search=slickrun) was one of many launchers that i tried out before discovering Farr. :)
Title: Re: Open Containing Folder
Post by: ewemoa on November 02, 2008, 04:33 AM
hotkey detection is a bit tricky with AHK but it could made configurable instead.

Understood.  Thanks for the consideration.
Title: Re: Open Containing Folder
Post by: SleepingWolf on November 02, 2008, 05:01 AM
Thanks guys: I haven't tried the scripts and downloads yet, but I'm going to try adjusting the scripts so that pressing CNTL and C -or double tapping C maybe -when the pointer is on the title-bar will copy the path of the app and pressing HOME will run the file-manager associated with folders.

The issue of middle-clicking and Ipoint can probably be solved by appending within  the MButton::{    } hotkey code block the command send {MButton} or words to that effect. This is working off the back of my head and I haven't read the code yet so it may need adjusting...

-----------------------------------------------------------------

Having now tried the script I am pleased how well it works and will post my customized version when it is ready. Thanks all concerned especially of course lanux128 and the original authors of copycap. I should add though that lanux128 has provided an excellent script that does not really need too  much customizing, it's just that a) I'm sharpening my coding fangs and b) I prefer to use keyboard hotkeys.
Title: Re: Open Containing Folder
Post by: lanux128 on November 03, 2008, 07:35 PM
@SleepingWolf: i'm glad that you find the script useful. CopyCap is something that i use almost daily therefore much work & thought had been put into it as not to interrupt my work-flow. in fact, i'm constantly adding other windows management features to it so feel free to customise for your own needs. :)
Title: Re: Open Containing Folder
Post by: SleepingWolf on November 04, 2008, 02:42 PM
i'm constantly adding other windows management features to it

So am I now. Perhaps we can compare notes after I've posted my customizations...
Title: Re: Open Containing Folder
Post by: lanux128 on November 04, 2008, 07:41 PM
Perhaps we can compare notes after I've posted my customizations...

sure, let me know if you need any help with my code. :)
Title: Re: Open Containing Folder
Post by: SleepingWolf on November 24, 2008, 05:41 PM
I'm going to try adjusting the scripts so that pressing CNTL and C -or double tapping C maybe -when the pointer is on the title-bar will copy the path of the app and pressing HOME will run the file-manager associated with folders.

Having now tried the script I am pleased how well it works and will post my customized version when it is ready.

 :huh:Well, inevitably, I now have a few other jobs to do and it will be a while before I post this. I do hope nobody is holding his/her breath.
Title: Re: Open Containing Folder
Post by: Kamel on November 25, 2008, 07:13 PM
what he means is, let's say you have a program running on your screen, like notepad or maybe some program started at windows boot time.  so now he's saying it would be nice to have an easy way to jump to that program's directory on disk.

i guess there are process explorers that will do this -- just seems like one of those ideas that should be built into windows so that you could click on a window of a running program somewhere and say "take me to this program's home directory".

Sorry for not reading every reply... someone may have noted this, but this actually IS built in to vista. It makes a ton of sense to me to be able to jump to the directory of a shortcut. Can't wait to see this made if it hasn't already been.
Title: Re: Open Containing Folder
Post by: SleepingWolf on November 26, 2008, 03:39 PM
Kamel, lanux128 posted a solution called CopyCap+LocateFolder.ahk about 3/4 of the way down Page 1 (https://www.donationcoder.com/forum/index.php?topic=15488.msg136431#msg136431) of this post. No changes are made to the "system menu" but the program uses another menu of it's own. I highly recommend it and shall donate to him shortly.
  As you can tell from the above, my paltry but hotkey-enhanced version will take a few weeks (I guess) before I feel confident to post.
Title: Re: Open Containing Folder
Post by: SleepingWolf on November 26, 2008, 03:46 PM
As for Vista, I don't have it and haven't played with it but I'm glad to know MS do occasionally come up with logical ideas and give us what we want! :Thmbsup:
Title: Re: Open Containing Folder
Post by: SleepingWolf on December 02, 2008, 05:08 PM
It makes a ton of sense to me to be able to jump to the directory of a shortcut.
I didn't notice this bit before. We're discussing right clicking a windows' title-bar system-menu to access an option to open the folder containing the program to which the window belongs. Are you with me now...
Title: Re: Open Containing Folder
Post by: Kamel on August 25, 2009, 12:10 PM
well, it's been a long time, but better late than never i guess....

yea, i was confused about what was being requested. Thanks for the clarity. I'm also going to be getting and using the autohotkey script :D
Title: Re: Open Containing Folder
Post by: MilesAhead on August 26, 2009, 11:28 PM
well, it's been a long time, but better late than never i guess....

yea, i was confused about what was being requested. Thanks for the clarity. I'm also going to be getting and using the autohotkey script :D

I have a utility that is similar called Home Folder.  It has hotkeys to either open the Home Folder of the active window(would be the folder the .exe is in for programs) or opens a command prompt in that folder.  You can download from here if you'd like to try it:

http://www.favessoft.com/hotkeys.html