Easy way to command prompt at current folder

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Easy way to command prompt at current folder

Re: Easy way to command prompt at current folder

Post by lexikos » 08 Jan 2015, 01:34

No, I use the keyboard more often. In this particular case I was alt-tabbing to the folder just to get the path, because I kept the folder open but not the command prompts.

Re: Easy way to command prompt at current folder

Post by guest3456 » 08 Jan 2015, 01:02

lexikos wrote: So I realized that I didn't even need the directory; when you type a command in the address bar, it uses the working directory of the folder you're looking at. So:

Press Alt+D, type cmd and press Enter.
awesome thanks
lexikos wrote:I'm usually in the folder I want to open. You can right click in empty space instead of on a folder item, but that requires having one hand on the mouse...
if you're using Folders, don't you usually already have a hand on the mouse? usually people using only the shell are the ones complaining about mouse usage

Re: Easy way to command prompt at current folder

Post by tmplinshi » 07 Jan 2015, 03:27

Code: Select all

#c::cmdHere()

cmdHere() {
	If WinActive("ahk_class CabinetWClass") || WinActive("ahk_class ExploreWClass")
		WinGetText, data
	Run, cmd, % RegExMatch(data, "i`am)^Address: \K.*", dir) ? dir : A_Desktop
	; You'll need to change the word "Address" to your os language.
}
Found the idea from http://www.autohotkey.com/board/topic/5 ... /?p=432380.

Re: Easy way to command prompt at current folder

Post by tmplinshi » 07 Jan 2015, 02:50

garry wrote:this I used (XP) to open cmd

Code: Select all

 ;-- DOSCOMMANDHERE XP ctrl+alt+d :
 ^!d::
 ID := WinExist("A")
 WinGetClass, Class, ahk_id %ID%
 ControlGetText,ePath, Edit1, ahk_id %ID%
 if epath=
    epath=%A_desktop%
 Run, %comspec%, %epath%
return
Unfortunately, this doesn't work in WIN7.

Now I'm using this one:

Code: Select all

#c::cmdHere()
 
cmdHere() {
	If WinActive("ahk_class CabinetWClass") || WinActive("ahk_class ExploreWClass") {
		WinHWND := WinActive()
		For win in ComObjCreate("Shell.Application").Windows
			If (win.HWND = WinHWND) {
				dir := SubStr(win.LocationURL, 9) ; remove "file:///"
				dir := RegExReplace(dir, "%20", " ")
				Break
			}
	}
	Run, cmd, % dir ? dir : A_Desktop
}

Re: Easy way to command prompt at current folder

Post by lexikos » 06 Jan 2015, 16:51

I'm usually in the folder I want to open. You can right click in empty space instead of on a folder item, but that requires having one hand on the mouse...

Re: Easy way to command prompt at current folder

Post by tidbit » 06 Jan 2015, 15:53

or shift+right click the parent folder:
http://i.imgur.com/UtK24WY.gif
Image

Re: Easy way to command prompt at current folder

Post by Morpheus » 05 Jan 2015, 16:00

You can also drag and drop a folder onto the command prompt to enter the path.

Re: Easy way to command prompt at current folder

Post by garry » 05 Jan 2015, 15:32

this I used (XP) to open cmd

Code: Select all

 ;-- DOSCOMMANDHERE XP ctrl+alt+d :
 ^!d::
 ID := WinExist("A")
 WinGetClass, Class, ahk_id %ID%
 ControlGetText,ePath, Edit1, ahk_id %ID%
 if epath=
    epath=%A_desktop%
 Run, %comspec%, %epath%
return

Re: Easy way to command prompt at current folder

Post by joedf » 04 Jan 2015, 01:56

Ill have to try that!

Easy way to command prompt at current folder

Post by lexikos » 03 Jan 2015, 21:21

I have a hotkey to open up a command prompt for the active window. Since I use git quite a bit, it opens a git shell instead of cmd if it finds a git repository. But sometimes I don't want a git shell; I want cmd.exe.

So after typing win+r, cmd, enter and cd'ing to the copy-pasted path several times in one day, I had a random idea: in the address bar, prefix the current path with cmd /k cd and hit enter. It worked. Somehow that seemed easier.

The second time around, I got a message "The directory name is invalid." What was even more odd was that the command prompt was at the right directory anyway. So I realized that I didn't even need the directory; when you type a command in the address bar, it uses the working directory of the folder you're looking at. So:

Press Alt+D, type cmd and press Enter.

I can't believe I never thought of that before. Now, I could make a hotkey to open cmd.exe, but it's still useful to know. (But Alt+D probably depends on the OS language.)

Later, I realized the reason for the error: when you run an exe from the address bar in Windows 7, the address bar's content changes to the full path of the exe. :headwall:

Top