此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& _! G8 A. U* K, s$ R/ Z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
. y$ Z; W2 {+ B! M 方式一:
- t" n4 S) Y' {+ Z% L8 ? 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( ]/ n4 _3 _" h- T/ c6 ~ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 n! H1 `: u: J HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
# Y* V) G$ V9 h 方式二:9 ^8 I2 X$ o; f: [$ B) M+ B
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 {4 O% f# J& t& w8 k, D3 W
SetTitleMatchMode RegEx; d, K7 }6 I, F
return8 D+ G _$ j. p- E* T6 q& r
; Stuff to do when Windows Explorer is open
|7 W1 I5 e- o ;# ?8 g1 t* H/ e+ Y! A, K' v% j" ~- C" B
#IfWinActive ahk_class ExploreWClass|CabinetWClass$ x( N. \: ]2 u9 I( G/ S
; open ‘cmd’ in the current directory' `+ I2 ]( G: Q8 T5 w: ], d
;
2 _9 ~# {! r. D( u6 x. k #c::) D) ?* N. z' v
OpenCmdInCurrent()
" f/ e# s4 o# {6 J" S4 _' X return, _% @: R9 s' Z" N* F0 p% M0 W
#IfWinActive2 ~1 L! F# J1 `
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 X' F# t8 L/ R2 I. T1 z) F
; Note: expecting to be run when the active window is Explorer.% ?* `+ C) R; v2 z, L7 D: o
;
4 R: A8 r) t" x Y2 v, m$ B5 Y& F OpenCmdInCurrent()+ ]1 }4 ?: w' _2 k: X6 X: z
{
$ Q% N7 X* s+ e ; This is required to get the full path of the file from the address bar
3 N) o3 ^4 ?4 T U5 ?* {8 M WinGetText, full_path, A. D( C4 I' E! h ?5 G
; Split on newline (`n)
7 b' H% _' G( m& l+ w3 v* { StringSplit, word_array, full_path, `n
& y# M( W7 O; w! s6 ]" e% G ; Take the first element from the array
3 J- E4 k, n. `2 P! F: ^ full_path = %word_array1%
h- V$ o( v! _+ I ; strip to bare address; i M1 {1 ?: i5 ^ T+ J3 t; ^
full_path := RegExReplace(full_path, “地址: “, “”)
& p w O" q# }7 |9 \% J( { ; Just in case – remove all carriage returns (`r)
& {& a6 N8 T: e! z StringReplace, full_path, full_path, `r, , all \; I! @) H+ A; q* Z
IfInString full_path, \: T, M) Z; ]* Y% C; ^9 f
{( m h+ P+ J2 S' Z2 ?
Run, cmd /K cd /D “%full_path%”
2 {; V w4 s) b% k5 K }
; v& m5 d8 I, j: x else9 w6 b6 D- Y [' n' O
{& ^# B9 l' h9 y1 F8 e% I
Run, cmd /K cd /D “C:\ ”
, `- Z1 n9 U* v8 O }
8 Y, k' Z% r0 R# z! \ }
+ |7 E- c5 M6 R3 m8 B4 y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 ^! ]) g+ T$ ]8 o. Q
这段小代码肯能有两个你需要修改的地方5 F+ ?! k8 p7 }6 ~' @
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 R: R8 @% g8 {! P" O# C9 ` 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 ?$ A0 h4 ]$ t3 I |