此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ Y7 l; ]4 B1 i% U3 Y' f
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
) E: A$ y6 X' C3 y 方式一:7 X+ h* H2 i( l: [* [
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# @5 q3 k0 O6 \* h; q4 @9 ~ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; n$ v% R# _+ [+ ?3 o I
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。; `2 P% m% d3 P. Z5 @
方式二:9 D; p. j- W- _2 d/ ~+ x# n
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* e7 A- P: s7 L8 H7 q$ Q- ` SetTitleMatchMode RegEx; g; C5 t, F: y, \% s( l; q
return
3 b7 k% ?# G3 q$ H; j ; Stuff to do when Windows Explorer is open
/ M, C& D) j r- y ;
1 x1 \ t T# S/ L #IfWinActive ahk_class ExploreWClass|CabinetWClass
! Q; E O& ]" n; ^! _4 | ; open ‘cmd’ in the current directory- {) r3 ?4 Q9 |
;( H! O( z- |" L$ g0 Z8 _+ i1 C
#c::
& s# J) H. H) \ OpenCmdInCurrent()# J1 r% {# U4 a/ o7 U, T8 P3 ~/ U
return
/ J; V- m+ G, e$ i+ z #IfWinActive U; ^. ?+ M+ X* a; s& j' U
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ S& f" F5 s, ?$ ?* V' x) t& ~1 k ; Note: expecting to be run when the active window is Explorer.
! R3 N! ?& a$ w, O; ? ;
( c( @. f X3 N5 j OpenCmdInCurrent()8 k! B1 r& c" v w t8 ~% R
{& s9 I5 J' l5 F3 z, `
; This is required to get the full path of the file from the address bar
# h2 t8 g" f0 {; X b5 ]) q WinGetText, full_path, A. e( {+ w! N. l* w, e3 X# j
; Split on newline (`n)$ r* O u4 M: E7 |2 [, I0 M
StringSplit, word_array, full_path, `n
- \" E8 g/ X0 Z. k/ X+ W ; Take the first element from the array/ ~) k8 ^1 a* s% W- V
full_path = %word_array1%. N9 H/ u) v7 [' S
; strip to bare address) B q( V* @* P0 O: C( v5 ~8 O
full_path := RegExReplace(full_path, “地址: “, “”)
; K) ^5 k7 l+ c$ h0 I' l" Q ; Just in case – remove all carriage returns (`r)' d! R0 N) a3 K
StringReplace, full_path, full_path, `r, , all/ `# v6 ~' B: C
IfInString full_path, \
% _0 f8 r' z$ Q, u/ t( S& G {
6 G1 y; a0 e% @$ F6 y' y Run, cmd /K cd /D “%full_path%”1 {% R* A- k* {
}
6 ^* g' b) ]' |$ R8 R1 p else
6 u3 M4 x" \1 ~' ~9 `8 E {/ H3 {8 m. \7 D' a Z
Run, cmd /K cd /D “C:\ ”
3 I4 P5 c6 _1 B6 _' |0 v }
0 z# @% g$ d; t# w }
8 e& Q v' j8 w 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 Q$ C$ T X6 u6 Y8 Q
这段小代码肯能有两个你需要修改的地方* Q1 h: i9 Y) a- c; C6 j
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! H* X2 |6 \& Q 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. v0 q3 ]* [3 ]
|