此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: {! v# f' i+ Q: C
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
. }- r5 h- M+ ?$ B: S 方式一:3 F" C! m+ j ^% a, J: x
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,; J0 u. s: }2 N+ Z" \
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 |' N% s8 e0 w HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# F8 E1 D5 I# ^4 `: _6 \
方式二:2 K5 E( G- Q4 U9 ?
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 H* J7 e- j5 ]# [4 \4 l SetTitleMatchMode RegEx
/ D; i" x1 K/ X; R; S: R& k return5 e! B$ X' @4 r& u; @) o
; Stuff to do when Windows Explorer is open7 F5 z) b# v( M3 x3 Z$ {- E
;
) S+ F) N$ q' O' J j #IfWinActive ahk_class ExploreWClass|CabinetWClass
* ^7 l& N* c# l4 ?9 ] ; open ‘cmd’ in the current directory
( C( i4 f" I- x ;
2 y( Q5 b8 R4 Y0 r9 K #c::
% b; N3 x" P. ~) k6 |- [! K OpenCmdInCurrent()" k: q4 {6 u2 L7 j; }5 y) F- z
return
6 v5 t! Q& p+ D: n% d1 F #IfWinActive
) C1 e% M1 c' |9 C" ?" e1 b ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 b$ k2 W& T" S; { ; Note: expecting to be run when the active window is Explorer.
& U9 y, k. m/ r( I$ B# s" V ;, E7 K Y t q9 v$ p
OpenCmdInCurrent()8 C" q' w5 Y/ ~$ w" P& g# ^1 B
{& ]- w, n+ l1 c& o9 [1 Q8 d) L
; This is required to get the full path of the file from the address bar: o8 b$ y/ B' _
WinGetText, full_path, A
1 l$ @9 T |4 \: D4 d ; Split on newline (`n)
, z; z6 s- O, r! H9 T5 J& b$ Y9 n StringSplit, word_array, full_path, `n1 J* u$ T, ?2 I* j! ?( X
; Take the first element from the array# R% a0 S9 A) \( f( O2 O/ o
full_path = %word_array1%. t2 @$ Y! c' @' ~! U6 F
; strip to bare address
& E6 x4 r9 ~( M8 ^ full_path := RegExReplace(full_path, “地址: “, “”)
4 Z$ n. h: Y2 u! ~; l. ]9 n$ [ ; Just in case – remove all carriage returns (`r)" s/ n* ^$ n- J S: B* Y
StringReplace, full_path, full_path, `r, , all& Y( R! g. f8 T( m! C
IfInString full_path, \- _. e( u9 \# k! s0 q
{2 C# V# G( B y0 A2 I
Run, cmd /K cd /D “%full_path%”
' C) M; E& J( {, h; o) [ c) n }$ t# c, L" h4 q j! q1 {
else* H+ B0 `6 Q, l6 l4 p; Y
{9 M; T% q+ U3 \( g# E( a" ^8 Q
Run, cmd /K cd /D “C:\ ”
0 B8 _" g' v& l; g }
( J3 Z& h4 m) E+ V }3 j& E9 U* K# R$ c8 t \2 G! p* _1 m$ E6 e
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* m* H. d6 B! K% o5 N, `3 K1 Z
这段小代码肯能有两个你需要修改的地方
) ?' s1 \& R, c" h$ P3 U: b 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- p u3 U5 B, ]- z; {5 N4 K. [ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
0 M `% G9 U; P- C& h! y8 M |