此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
! \( q& z2 H$ X- v: q. I, i 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。# m) |3 C8 H, |$ |) T, i
方式一:) R; u- t' \; Q& C: p& s
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
+ M* T2 B( Q$ S 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) o- X$ T0 j% r o4 Q/ w& `6 J HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 q) ]4 `5 D a) B
方式二:) A- V; f2 L9 L; q, T) P
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# r8 C+ Z( ?5 C" g% Q5 @ SetTitleMatchMode RegEx
1 |* ~' {) N: y: `7 v return
7 t+ C, h( g8 H q7 W ; Stuff to do when Windows Explorer is open
% R4 o" k2 g7 w. P. ~. P, w ;
% J% Y+ J- d. ~" R) J/ [" ` #IfWinActive ahk_class ExploreWClass|CabinetWClass
6 Y) N- d, N0 f, \7 n5 Y ; open ‘cmd’ in the current directory
7 h" o8 X" v3 }3 d+ o* F& M& E' b, y ;
* M( f+ @. r, R5 Z# j1 r #c::
( Y* n% k" q7 |4 ?9 X OpenCmdInCurrent()' \, C7 ?- ]- P# w" K
return
5 G1 }) J- O# }- d( s3 L3 f- a5 _ #IfWinActive
8 I3 a, g& w- w4 P- U ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 p$ C9 J. A% X. J3 k- O ; Note: expecting to be run when the active window is Explorer.
+ z9 i! e/ z( |9 f# F: y$ S8 F ;0 N1 j+ q! f" `& g2 B
OpenCmdInCurrent()
" P' g8 X3 G1 D4 |5 y {4 F% I- T7 J- @; \) R3 M
; This is required to get the full path of the file from the address bar) T: c) U8 P3 K+ q( m, s
WinGetText, full_path, A1 ^' W! N( I" f# G
; Split on newline (`n)
3 M- K9 l7 `( C7 k; @( w3 ^4 R! N$ c StringSplit, word_array, full_path, `n$ d! x' A/ Q+ g8 s7 T8 l. z
; Take the first element from the array7 i8 W4 j2 G. p9 |7 b# d' W7 k
full_path = %word_array1%1 n3 y8 E& a5 w5 U& x8 |' t* E
; strip to bare address
; @+ y' e8 t" A% K/ h6 Y full_path := RegExReplace(full_path, “地址: “, “”)
( B* j8 F- D5 Q ; Just in case – remove all carriage returns (`r)* ~. Z6 x" |7 u; g& z9 w
StringReplace, full_path, full_path, `r, , all
2 _% L8 j0 `1 T IfInString full_path, \- W1 m+ z) H! v& q
{
/ v& E( B% n/ t Run, cmd /K cd /D “%full_path%”
+ k4 F1 _: N6 G+ z' W4 L* Y) u }
4 e) h, P+ V! H- g! f else
0 v0 e9 v) J5 `6 N* ~ {+ O* z T* p$ T% R6 Z# q9 ?2 C# q
Run, cmd /K cd /D “C:\ ”3 ?( [2 y' q' s& X; b
}
, Z" l) M; u* ^2 T }
: h) c7 C7 c% O3 c# @% U$ Z/ H 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 ~! U8 }2 }" F2 _! [3 O
这段小代码肯能有两个你需要修改的地方
7 U/ F4 U7 O* d0 P- q- r 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 ~- w; F- A' l
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; S9 K) s6 u4 f% h
|