此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 ~8 J+ [! k$ Q1 U; D9 Q+ {1 L$ L 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 v5 i) s" g- D/ o* Z 方式一:7 z# q: Q5 D e/ _ X
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. z m" }: W8 A+ W$ D
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 B' w( _8 ]! \+ i! K, E HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" I9 {+ O4 c4 A k$ p! D 方式二:
: E4 r/ @2 V7 r9 D5 [6 A) [) T n5 m# u 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, e. F0 {: a: T* H9 S2 J
SetTitleMatchMode RegEx
( f Z) z9 J. v- Y7 P- S- e return6 E, t9 u( j1 u7 w- ], ?; i# `
; Stuff to do when Windows Explorer is open
1 c1 P4 r9 M2 e, O; J$ {9 ]) w' G ;- C4 D/ [& T5 [8 I w ~0 r
#IfWinActive ahk_class ExploreWClass|CabinetWClass% Z; i6 b. z- @9 d L; _# Z
; open ‘cmd’ in the current directory8 I- Z& T3 Q: }3 i: `! T
;
% o( s( [* _% ~" T; Z/ u #c::! ^5 q* h5 H9 V, f3 |" \% R; K
OpenCmdInCurrent()& n0 f+ R! L! S0 _# e
return& U( b, x4 C$ ]( C
#IfWinActive
; e- d4 w+ r9 C: X ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 M, J" i J' Y! m# v6 r ; Note: expecting to be run when the active window is Explorer.
2 z- Y# u0 y. C8 _ ;
. g: |0 I! b; m5 K% Z, z& g OpenCmdInCurrent()
! {2 y" |! Y/ N, V {3 ~) w- Z! ]% a
; This is required to get the full path of the file from the address bar2 G$ a2 `- ^5 e9 t/ f5 t7 U
WinGetText, full_path, A- i4 V3 i' k4 c9 |7 z
; Split on newline (`n)
2 S7 i" @2 Y9 T o" ~ StringSplit, word_array, full_path, `n
! e& @- i) N7 P5 i5 F ; Take the first element from the array# @3 \7 n B# _. |& T6 d+ Y6 |8 i
full_path = %word_array1%
" }8 S- y0 j. e& j# B ; strip to bare address
. ~: ^# K! c# F1 F6 b full_path := RegExReplace(full_path, “地址: “, “”)
2 g% G+ c( y6 P! o ; Just in case – remove all carriage returns (`r). a! d) N/ r4 ~0 c$ x- i( a6 [
StringReplace, full_path, full_path, `r, , all
$ [5 h; `# T/ ?1 j IfInString full_path, \% Y" n0 ~# R; L# ?5 M
{
0 i- X' r' x! z( @$ ~4 N+ @ Run, cmd /K cd /D “%full_path%”6 I8 ]7 r" P5 o8 F+ a" A
}9 w; A$ z8 i" d8 L H7 @ b
else
* l2 j9 P; l7 X% w' Y {
- C$ k8 p% u, I" x) x Run, cmd /K cd /D “C:\ ”: n8 d7 D" ~4 ?2 L2 o( ?' U: P
}& N5 G5 i: t4 q
}+ e; }$ ]5 ?& U5 S+ a
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: N( G& e9 W+ a6 s 这段小代码肯能有两个你需要修改的地方
( D; D+ `6 k q% @ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' j5 R `7 R2 t8 g$ r5 `- c. R 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 \0 Y6 @5 r* ~# P( I% U |