此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 u: ?4 T* E X 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- N2 Q# ]$ |$ S: S8 A
方式一:
5 [$ E3 x. b/ p; K) U( b5 ~ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 B7 x$ G( c9 {5 v/ }# u& z7 S
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 M+ b& h* o2 f4 a6 l HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 p5 D- l0 t' q; e! k
方式二:
" p* r) |0 S- d" k: t9 `- o- W 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) X7 t* |. T2 K% m7 [+ {: s SetTitleMatchMode RegEx$ E* ?4 R8 A- E: X
return8 ]; D0 P# \) X: r/ G% n
; Stuff to do when Windows Explorer is open" S$ q) R: q& s7 L9 e- U7 ^$ w" y& v
;4 T) l: \. j2 L2 f2 N/ k
#IfWinActive ahk_class ExploreWClass|CabinetWClass
/ H! ]1 D5 ^. w8 s0 o- V, P ; open ‘cmd’ in the current directory
A, J0 b* `2 d* ` ;8 n# n" v$ M# _2 B* E
#c::
2 D/ F! F7 B% f3 e3 k( `3 T& t8 Y8 B OpenCmdInCurrent()
R. g3 t5 _6 h5 U, X; y5 E+ @& X return* S! `# C; I9 i- Z" T& C1 x4 q
#IfWinActive
) ?; c( T( D( O2 _" q ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% l- K Z0 w, k% q
; Note: expecting to be run when the active window is Explorer., e, O8 e B W, d5 `
;
$ }5 u3 m1 ^$ S4 R OpenCmdInCurrent()
% v% \$ f. V7 Q {
% V8 @ ]: ^$ `& E ; This is required to get the full path of the file from the address bar! l" ], ^ D: U1 d
WinGetText, full_path, A7 |! \8 ?2 R2 l% N' z2 u* d
; Split on newline (`n)
6 ?* g H6 p& P; C# ]; j StringSplit, word_array, full_path, `n
; b/ x7 C1 ?9 k" R4 ]# i ; Take the first element from the array o% m4 ?3 I" d: j: S& z
full_path = %word_array1%6 E' P3 Y' h0 Y) z9 C
; strip to bare address
, O% a* }8 M+ f0 X/ O# w4 J: ~ full_path := RegExReplace(full_path, “地址: “, “”) k9 P p) w' ]7 _' U
; Just in case – remove all carriage returns (`r)
& Z; V" N8 z; J# D4 c StringReplace, full_path, full_path, `r, , all
9 n' @+ t. ^: v$ j# A# x+ T' p" A IfInString full_path, \& Z. b1 [! L, | u9 S7 T
{9 d* {2 p x& X3 `* O1 p7 g2 e: f* Y
Run, cmd /K cd /D “%full_path%”
% `7 Q3 Z$ y @0 A. G }
! u* T8 \* P3 ]: m3 x: g+ \ else6 y+ R, j9 F( M# i
{9 {3 i1 P0 {! ]& N, Z! g, l4 U: L- {. U
Run, cmd /K cd /D “C:\ ”- o8 j8 |; k; d
}1 @2 S/ T; O$ e( Z2 g0 a8 G
}9 M i. [3 \% H2 C! Q) ^
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( Q4 i2 ]* L$ Y* u2 K 这段小代码肯能有两个你需要修改的地方! }) Y1 @6 q! s0 S
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& i7 P4 Z$ s; f) s 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “6 ?7 Y% J! E9 P4 v8 o4 B1 U
|