此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
. x" {/ r/ D5 z) m 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
; D' |' K3 E; y/ o# l6 f 方式一:
8 x& d1 v1 t0 U6 ^ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 {3 {6 q1 x" d- ~! r% h" z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ Y. l# j7 }+ J; s; `1 U HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 k9 r: w0 X, Q9 F7 {4 A1 o 方式二:5 y) c4 A" P* l4 L% B
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! {9 \; I8 l7 I, I
SetTitleMatchMode RegEx/ u" T& ]7 q) Q9 C( i
return
: K8 E U( |0 O$ Z4 R+ Y/ H I, l ; Stuff to do when Windows Explorer is open2 C& x* h; ^, T
;
# K$ I5 r6 x* }. p7 @" q #IfWinActive ahk_class ExploreWClass|CabinetWClass Q" H8 _2 ] n4 N: o- W
; open ‘cmd’ in the current directory
! a' ?) m" ]9 c2 Y. K" F ;: ]4 h, |1 X' I) i
#c::, o' b. b% u6 f' h7 r
OpenCmdInCurrent()" E$ @5 b% m/ D A- | \& \! }
return
0 J3 G+ R6 y3 ]9 l/ h! x" Q #IfWinActive
9 [, s% v1 O3 {) p4 H: i$ O6 l5 \ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
/ J( x/ K4 S! Q4 B( ` ; Note: expecting to be run when the active window is Explorer.
; L, v1 C& C/ C! Q4 k0 R ;* D* M( R( L: v( F! n
OpenCmdInCurrent()6 c/ p" \- M1 F! |4 o8 h
{
4 q. T' {$ W0 ^! [8 |. M1 w9 ~; ` ; This is required to get the full path of the file from the address bar5 S: ?. F2 G6 z5 h- I# R6 m2 S1 E
WinGetText, full_path, A- t C" T- |& L! E
; Split on newline (`n)4 a4 i3 ~9 f9 P1 D- \( h
StringSplit, word_array, full_path, `n
2 A1 J7 h# f8 {3 R1 d2 T f( U ; Take the first element from the array
9 W# @+ Y* p/ d0 n/ S8 `6 k full_path = %word_array1%0 B, W5 _5 h$ d" x+ P
; strip to bare address: O( \ X7 x- Z& j8 t2 v
full_path := RegExReplace(full_path, “地址: “, “”)
2 I) b- B& `4 g; A1 s f# Z, \ p ; Just in case – remove all carriage returns (`r)
; Z3 W- z' Z3 V9 Z. w StringReplace, full_path, full_path, `r, , all
8 ?9 L2 I% y# d5 Q IfInString full_path, \
% E- {- P; D$ U7 P6 T: E$ C {
/ t3 D6 I) A I7 h3 h8 T5 } Run, cmd /K cd /D “%full_path%”9 b" {8 X* I4 k
}
, H# X8 y' @& T$ o* d8 }: @ else& a y# ]0 ?+ q9 Q0 r8 A
{
1 |& O# b/ q+ Z: x, a! y Run, cmd /K cd /D “C:\ ”+ C, [9 `8 `* s1 |0 S* q( W& s# z
}. p+ e2 x5 \2 q& u
}
: g; x5 U8 K: K1 {) @ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 N+ e" d' c; {: O7 t# J+ t% y0 ~& j
这段小代码肯能有两个你需要修改的地方! r* I$ |4 T: n7 d
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ Y7 j* Z& J* D1 y% D' X2 r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) R! i- N8 p* Z* @1 s
|