| View previous topic :: View next topic |
| Author |
Message |
RobertMeta
Joined: 10 May 2009 Posts: 9
|
Posted: Sun May 10, 2009 8:53 pm Post subject: How to Find Current Working Directory of Active Window? |
|
|
I want to be able to find the current working directory of the active window.
This would allow me to have Firefox focused, and hit a keybinding, and open a console or explorer window to the C:\Program Files\Mozilla Firefox directory.
Or, more importantly, when editing files with my favorite text editor, which changes the working directory to that of my current file, it lets me simply hit my keybinding to either open explorer or a console right where I am working.
Thanks in advance for any assistance. |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
|
| Back to top |
|
 |
RobertMeta
Joined: 10 May 2009 Posts: 9
|
Posted: Wed May 13, 2009 4:57 am Post subject: |
|
|
Not exactly what I need, but thank you very much. That put me on the right path, I can use a DllCall to GetEnviromentVariable (specifically, the context variable) and I think that will work.
I will post the code once I get it working.
The reason that getting the command line is not a solution, is I need it to follow the app as the app changes it local context (working directory). Just because I started with c:\foo.exe doesn't mean I am still in c:\ |
|
| Back to top |
|
 |
badmojo
Joined: 11 Nov 2005 Posts: 202
|
Posted: Fri May 15, 2009 5:25 pm Post subject: |
|
|
| you can try shimanov's code from this thread here and also check out this working example. |
|
| Back to top |
|
 |
RobertMeta
Joined: 10 May 2009 Posts: 9
|
Posted: Wed May 27, 2009 10:36 pm Post subject: Worst Example Ever... |
|
|
I fear I gave the worst example ever with Firefox. Let me use a much better one, cmd.exe
Let say, I run cmd.exe and do "cd c:\users\robertmeta\projects\personal".
The path is: C:\Windows\system32\cmd.exe
The command line is: "C:\Windows\system32\cmd.exe"
The current directory is: "c:\Users\robertmeta\projects\personal\"
The "current directory" is the data I want to extract. Every application has one -- and the apps I want to use this hotkey in a lot (explorer, vim, etc) keep it set properly.
I currently get exactly the functionality I need for it from HoeKey -- but I want AutoHotKey to do everything I need.  |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Thu May 28, 2009 1:42 pm Post subject: |
|
|
Not sure if this will help you but you can try http://www.nirsoft.net/utils/opened_files_view.html (I had the idea once to use this to create a script to save a "workspace" e.g. save all open files in all applications to a txt file so I can "reload" that particular workspace and continue with all the files I have open) use can use the cmd line switches to output to a file for further processing it works with a CMD.exe _________________ AHK Wiki FAQ
TF : Text files & strings lib, TF Forum |
|
| Back to top |
|
 |
RobertMeta
Joined: 10 May 2009 Posts: 9
|
Posted: Fri May 29, 2009 4:23 am Post subject: |
|
|
I have actually "solved" this sorta via a few third party apps, and I can always use the ultra-small Hoekey which has it native built in.
Obviously, I want a pure way to do it, as in pure Autohotkey. As I continue to research, I think I have found one of the issues. I believe that the current working directory is per THREAD not per PROCESS. |
|
| Back to top |
|
 |
badmojo
Joined: 11 Nov 2005 Posts: 202
|
Posted: Fri May 29, 2009 6:47 am Post subject: |
|
|
| RobertMeta wrote: | | I have actually "solved" this sorta via a few third party apps, and I can always use the ultra-small Hoekey which has it native built in. |
if you don't mind, can you show how to do this via Hoekey? |
|
| Back to top |
|
 |
RobertMeta
Joined: 10 May 2009 Posts: 9
|
Posted: Fri May 29, 2009 10:49 pm Post subject: |
|
|
@t=Run|powershell -noexit -command "cd \"%c\""
@e=Run|explorer "%c"
alt-t and alt-e will open a terminal or explorer where-ever I am, as a developer, it is a life safer.
I am in vim, working in directory c:\foo\bar\blah -- and I just need to run the current file in a terminal, I can just hit alt-t to open a term, already in c:\foo\bar\blah |
|
| Back to top |
|
 |
|