此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- i3 h6 `/ w! z- x8 G: s 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 ~0 a( b5 x) y& i9 {% i 方式一:
, |- _$ o& n3 V" q0 s! S 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 G) L& |6 y. P5 t- n L$ {
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! S' T3 Y& b* y4 y) h2 z2 x HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) v# [3 _0 f4 `+ ?, I" A
方式二:* C/ r# u/ X: r' h! x
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* c9 q- `* q+ O2 O0 D SetTitleMatchMode RegEx
) e! h& ^# \1 E; b return* g7 F6 x6 Z+ N' U' A2 j
; Stuff to do when Windows Explorer is open
; t4 z: q, ? N' }1 S& k8 K ;
' Z C' _. S# F3 o) D4 q #IfWinActive ahk_class ExploreWClass|CabinetWClass
* }0 R. a' P- d/ U2 J ; open ‘cmd’ in the current directory7 z# \$ p* t; y6 T- ]2 ?
;
3 l* F/ \7 h! h+ j #c::4 @5 N) j- A7 R
OpenCmdInCurrent()2 X7 V! f2 y8 P
return( l' \$ g0 ~* z) I' }1 w
#IfWinActive8 u, Z) w& l. t* c' e5 I
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& m9 H3 Y* x9 @# f0 s# B
; Note: expecting to be run when the active window is Explorer.
S3 p( M4 F3 S4 m5 d ;0 z8 Y' C6 {* }3 ^/ [, a& L
OpenCmdInCurrent()
; K5 r& w6 z$ d7 |7 _ {& ?$ s6 q* c2 C
; This is required to get the full path of the file from the address bar" L- b9 i2 {+ Q, M
WinGetText, full_path, A
) _% d& U, r s ; Split on newline (`n)
) A k9 Y/ U0 Q6 `; k, ? StringSplit, word_array, full_path, `n
! W/ s5 R% n+ X4 s ; Take the first element from the array6 c9 \" S' ^; `# X
full_path = %word_array1%
" K( h6 }* J" o6 ~* @1 [1 U# V ; strip to bare address/ ]9 h! M) h! ~7 r( Z
full_path := RegExReplace(full_path, “地址: “, “”)
X$ K; I8 o, L/ `7 q, @5 D ; Just in case – remove all carriage returns (`r)) g, B3 @4 S4 [- g# R7 U! P) e
StringReplace, full_path, full_path, `r, , all1 S; L6 \! X: P, }# f9 U4 k% l! h0 N+ S
IfInString full_path, \
2 b6 i1 I6 D7 `0 v7 ~ {) V# X6 u1 F+ y3 S7 j
Run, cmd /K cd /D “%full_path%”
1 I# d$ Q/ @6 B' q3 b }
$ R- U# h3 o9 ^7 g% L else: P5 j! R7 I" Y: Q/ h1 r! \
{; i& v# V/ I, C. `6 b
Run, cmd /K cd /D “C:\ ”+ {* L! g4 M' N- d& f4 V
}; {7 s& c1 V5 O v, ?
}
& B' m5 e1 o, d# A. D) ? 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 u* x7 d% @6 P: Y 这段小代码肯能有两个你需要修改的地方
" y$ B3 P0 g, N2 b; U 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ g- M+ K' A# F9 D; }
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ A8 z# u5 `& {
|