此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& [4 Y) C# q r% e( i 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 `# a6 O2 |" Y* g# J, C
方式一:
6 I% K$ `7 P! \8 J0 y7 H5 l7 o3 d3 Z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# n3 z+ W# |8 A, j& \/ ?& g1 F
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 ^- c1 @$ |! i/ ~9 _9 Y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( O9 t& G0 u; _6 j8 n
方式二:
, Z; I% K; w" g0 p 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ G+ ^$ E8 k9 Q7 d1 }3 V5 f4 @+ U
SetTitleMatchMode RegEx; f" J3 i2 {5 J6 v) K7 d; m- T& |
return; L6 M( }! E. n9 g% O/ Y1 W6 l8 g7 D
; Stuff to do when Windows Explorer is open4 L9 p$ J9 e; S/ m7 K; D
;
5 O2 G5 z3 U' D: a1 L; Z #IfWinActive ahk_class ExploreWClass|CabinetWClass
$ ^. h0 ?0 C" v9 t; F2 `0 Y ; open ‘cmd’ in the current directory# R7 x. B/ u, v0 R9 W$ {
;1 E9 Q) V v$ @6 E! }) A
#c::3 Q. {2 g4 U S" C' S' H6 v
OpenCmdInCurrent()$ S9 e% R0 x1 q6 K, W) \; n# u
return
% V# z/ C5 N' ^ #IfWinActive
2 \; f5 F3 H) |) ? ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 _. b I8 f4 S/ E8 s' q
; Note: expecting to be run when the active window is Explorer.
/ M3 m. P) @ ^* T* S ;
) O. |5 K7 _% ^( D4 p OpenCmdInCurrent()
" q! s1 Q; U, r( C( @5 @ {
% w& X. ?- L( \7 d! ]1 m ; This is required to get the full path of the file from the address bar
( P: E! D G& J WinGetText, full_path, A
! ^6 t! R( Z7 N5 u4 T ; Split on newline (`n)
: x5 ~) F( W1 [, F+ _ StringSplit, word_array, full_path, `n0 m) Q' ?/ Y5 f( v/ O* w
; Take the first element from the array
a) x* O0 R( N' m full_path = %word_array1%
9 K5 H4 W$ b" ?" U6 p/ t+ n5 G ; strip to bare address& ?" O) Q5 l' ~& v$ R& E$ ?! W2 m
full_path := RegExReplace(full_path, “地址: “, “”). _7 S& H# p8 Z; M2 M; T
; Just in case – remove all carriage returns (`r)
[' d- V$ p7 ~) r6 g3 }: ~5 O StringReplace, full_path, full_path, `r, , all5 y8 a" u& T& o
IfInString full_path, \
" ^3 Q7 f9 ^, R! t {. X+ z' ?' V# k
Run, cmd /K cd /D “%full_path%”
8 h! z( d8 M5 A0 L }. ?& ]# y2 Q1 H, e
else
6 d* T# Q6 b- U) ?& P {4 C% v' x% h/ E& A) y& Y' o; R
Run, cmd /K cd /D “C:\ ”
- V% f h4 C$ N1 G$ m }2 b7 d/ Y9 F, x1 h" t! B2 Z
}7 F- Q0 ~; e+ N1 v! @, q+ b
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: |/ B3 n A, f- G! c A% \0 A9 e
这段小代码肯能有两个你需要修改的地方" \5 w9 s/ c# {/ @
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ e2 \% T* U; T P: }/ ~6 Z2 Q1 @ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “5 D' l# ~3 S8 g F
|