此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, m5 j+ Z! E8 O# |% B% H6 ~
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: ~ B3 o/ m& ]# _! X& k; I# X3 M
方式一:
) z( L0 _' k( v! M# _- F9 d) A$ R 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, E9 ?7 X. X# H, p 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 N; b1 J1 y2 y' S HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% o3 Z8 C' b9 R 方式二:5 s$ d. ~4 y, o3 l3 h1 k
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 K, u4 H9 l- n, \# |1 b5 q# D SetTitleMatchMode RegEx
* [7 D" ]; W1 X3 Z# k0 S+ S- g return
7 D& b+ @% Z# c ; Stuff to do when Windows Explorer is open% |! m; }1 e$ ^& U6 L& J. Z* F3 |. S
;
2 f, c3 O% T0 T% R9 Q( k% [ #IfWinActive ahk_class ExploreWClass|CabinetWClass# {. ~ C, A- F8 H1 ^$ w$ z5 H0 v# W
; open ‘cmd’ in the current directory
9 \! D/ a! | a! c ;3 i- D& d% q8 u/ q- D- U& [
#c::
+ W \/ @+ A* z OpenCmdInCurrent()
7 f B4 m8 M% [$ c" \* l, Z return2 A! p, e* y6 [4 t9 Y. O( d
#IfWinActive
" S+ x6 Z1 U+ ~ Q( F+ p ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 Z' {, W9 R! ~
; Note: expecting to be run when the active window is Explorer.' O, R9 H- X$ p/ V( Z9 L( g
;; `/ m d$ C6 p. ?8 `7 ]9 L
OpenCmdInCurrent()
+ m- X8 W+ E9 Z {3 g" y% G" r5 t% ]5 c# P
; This is required to get the full path of the file from the address bar% K s! E; m. e. r3 @3 b( e
WinGetText, full_path, A
; f3 R8 A9 h' g, n0 T, | ; Split on newline (`n)
2 X5 @+ o3 L( p% v3 I StringSplit, word_array, full_path, `n! i$ j. h, I: g
; Take the first element from the array
- q0 v( s$ v6 |0 I, U full_path = %word_array1%4 [# w1 [+ t$ F( `. c! R$ L6 b+ W
; strip to bare address) ` @% N Q p( ^. x- F
full_path := RegExReplace(full_path, “地址: “, “”); I) `; L( H) ]% e
; Just in case – remove all carriage returns (`r) t. c" O+ x6 }4 x! s& l9 t; ?9 I
StringReplace, full_path, full_path, `r, , all5 _/ {4 Q: p# r3 y
IfInString full_path, \& r. W7 ]6 ~$ x- V1 v6 ]
{
3 t3 t: R. }+ t; B: h0 c Run, cmd /K cd /D “%full_path%”
?% w. X3 ~7 M3 P }% q6 v" l' b% E& ^- f
else
6 w" A( r, W# x9 y& I% u {+ d6 N3 f; R6 Q0 s c+ i
Run, cmd /K cd /D “C:\ ”
+ ?' F$ J0 f! {( h3 T; j }; Y" q) c/ P- E/ N, L
}
7 R" M4 D; ?3 T6 S% L. V 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) p, P8 \; r& Q( l' l6 j
这段小代码肯能有两个你需要修改的地方
0 \$ `# e% @7 ^/ r 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# C' G R9 @3 _# M* l+ k/ D4 {; t
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; u u: i C- {# G+ B7 w
|