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.
Easy way to command prompt at current folder
Re: Easy way to command prompt at current folder
Ill have to try that!
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: Easy way to command prompt at current folder
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
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
Nice!
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: Easy way to command prompt at current folder
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
*poke*
Is it December 21, 2012 yet?
Re: Easy way to command prompt at current folder
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
Unfortunately, this doesn't work in WIN7.garry wrote:this I used (XP) to open cmdCode: 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
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
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.
}
Re: Easy way to command prompt at current folder
awesome thankslexikos 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.
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 usagelexikos 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...
Re: Easy way to command prompt at current folder
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.
Return to “Off-topic Discussion”
Who is online
Users browsing this forum: No registered users and 30 guests