AutoHotkey Community

It is currently May 26th, 2012, 7:09 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: May 10th, 2009, 9:53 pm 
Offline

Joined: May 10th, 2009, 9:47 pm
Posts: 9
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 12th, 2009, 8:54 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
GetCommandLine
http://www.autohotkey.com/forum/viewtopic.php?t=16575
use the A parameter with WinGet for active window

Alternatively you may try use WinTitle for applications that
display the filepath in the windows title.

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 13th, 2009, 5:57 am 
Offline

Joined: May 10th, 2009, 9:47 pm
Posts: 9
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:\


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 15th, 2009, 6:25 pm 
Offline

Joined: November 11th, 2005, 3:13 am
Posts: 202
you can try shimanov's code from this thread here and also check out this working example.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Worst Example Ever...
PostPosted: May 27th, 2009, 11:36 pm 
Offline

Joined: May 10th, 2009, 9:47 pm
Posts: 9
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. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 28th, 2009, 2:42 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
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 FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2009, 5:23 am 
Offline

Joined: May 10th, 2009, 9:47 pm
Posts: 9
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2009, 7:47 am 
Offline

Joined: November 11th, 2005, 3:13 am
Posts: 202
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2009, 11:49 pm 
Offline

Joined: May 10th, 2009, 9:47 pm
Posts: 9
@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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Cephei1, Google Feedfetcher, Miguel, rbrtryn, Xx7 and 66 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group