此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 t8 z- Y5 k: v: N0 ~2 ?: k, H, c
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。# `/ B9 ?( M$ N0 ~) R
方式一:! N( `) i. w" J9 C. `3 `
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ C6 ?( K& a3 u# Q% p
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 R1 N# t7 `4 |- C1 k6 ~! J HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. C, m4 O' j; i8 y5 A/ N( P3 K( g$ W 方式二:
& S8 m1 K7 a/ L, I1 R! j$ q 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 B1 s, L+ Q5 o, J( j
SetTitleMatchMode RegEx
) E! r* W$ U) ~/ S return* {+ ?$ p y ]) e$ t1 h7 L* X* m& q
; Stuff to do when Windows Explorer is open
( w& `3 |: {6 r# m ;
+ D: r* i m G. y1 Q' \; h- H% p #IfWinActive ahk_class ExploreWClass|CabinetWClass. y* V$ z- ^9 C& t
; open ‘cmd’ in the current directory* o# _; k, {3 M& c- V5 b5 ^
;0 _1 A1 }( L5 p$ ~6 o
#c::0 n( ?; @6 @! F, r {8 U! O; W
OpenCmdInCurrent()- q3 t! Z4 _( B
return0 ?, v+ o0 T# N' q; I8 W4 f$ W
#IfWinActive
/ E: u8 s3 ^+ X- |8 t9 R4 v7 k' o ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 O9 `5 @% m& c C: |, U* k ; Note: expecting to be run when the active window is Explorer.
9 w' \! Z4 T: z$ }' p& J2 v0 W ;
0 n) M, X( f; Z/ j( M OpenCmdInCurrent()4 \1 I/ c5 E9 ^; Y
{
, j& W; X, q: `8 X, [( T6 |" k ; This is required to get the full path of the file from the address bar
1 ^( j1 T5 L7 c+ U: T$ `; T( O. F WinGetText, full_path, A+ f5 h. T5 Y( M& i. m: u
; Split on newline (`n)
9 \5 b* U: X! I# P. i StringSplit, word_array, full_path, `n( s. ^- y. D1 r
; Take the first element from the array1 g! U! ^% V o
full_path = %word_array1%
* j) R, q& f8 x8 Y" {/ a5 p- @! u g ; strip to bare address2 q/ j' W" r" r) Z8 _9 u7 c5 W
full_path := RegExReplace(full_path, “地址: “, “”)
r* t8 L. E1 ~$ o ; Just in case – remove all carriage returns (`r)
8 g: I% ^+ _. w5 l) P0 \! } StringReplace, full_path, full_path, `r, , all" [; s O1 t: l1 p, Y' t* W+ X
IfInString full_path, \
7 l6 C Q0 b* B; F/ a5 ` { P/ Z, [( d1 ]4 y+ ?
Run, cmd /K cd /D “%full_path%”1 T/ c- D* g1 l
}1 a8 T* u0 z3 k. }
else% r: b4 e- M4 h. s
{
/ a4 V2 C& Q' e4 I Run, cmd /K cd /D “C:\ ”
7 F4 x; X+ b+ x$ a9 K0 P5 ?* w }
+ u" A" c, L6 `6 K: ^0 L, A }
% j- [' K6 g# E, {( y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 E1 E) Z P2 C+ i; }/ t5 |8 g 这段小代码肯能有两个你需要修改的地方
* B- `. ^# \) v 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% C* p& A& Y; t( W% T
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! l4 D" F! G. G% t Q* R, e4 n- J* m |