此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& v9 R# h+ |; D5 j$ v2 R
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* h2 F2 K7 J2 K& J! u: _1 v5 k 方式一:" y/ A. o* `# f7 y3 Q
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 |1 _. b7 s' x0 S' G/ } Z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, `7 Z* t7 Z3 M5 |5 y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( Y- e* M) j) ~
方式二:
, G4 ^. k7 U) l 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 w% Z/ T. q) ?8 Y
SetTitleMatchMode RegEx
$ B D! R0 R) K9 k' B O. U return7 T8 G- y4 l1 W
; Stuff to do when Windows Explorer is open6 ^) S( N- z {1 J, o
;
2 g) l# C, F/ |7 z) d, @, h* y #IfWinActive ahk_class ExploreWClass|CabinetWClass
: u& h) ]& H6 t/ b; b( @* k ; open ‘cmd’ in the current directory
8 d9 J5 h' o% J* {# x ;8 o5 M1 K6 _1 s/ {; W7 V! T
#c::/ n6 a$ e1 T8 |- M7 F- O/ V
OpenCmdInCurrent()8 D' p7 ?' T6 f# T- c1 U* Q
return; a$ A0 G1 x' z# L
#IfWinActive: C5 A* R" t/ u6 r3 D2 V. T
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: B% R" X6 s& T. X3 g/ N
; Note: expecting to be run when the active window is Explorer.
7 P! `* z6 ^/ \$ C8 C ;
! T0 }3 j3 I" L: C OpenCmdInCurrent()( W. ]# x% Q1 P3 J" ]& V- `
{
+ ]: V9 s$ L- `1 E* R2 ~ ; This is required to get the full path of the file from the address bar
$ {6 F' U$ B9 V) E WinGetText, full_path, A
( ^" d u& h7 i0 ? ; Split on newline (`n)7 \ |; |. F4 u8 A/ ?( n
StringSplit, word_array, full_path, `n
: S+ v) s& m _- _+ j v: Q ; Take the first element from the array6 K( h' i" `1 [' I& d2 z5 A
full_path = %word_array1%% U$ D5 d' p' ~
; strip to bare address2 v) m8 u9 ?1 o1 ^# k3 m
full_path := RegExReplace(full_path, “地址: “, “”)5 I5 K+ ?2 K0 ^
; Just in case – remove all carriage returns (`r) v" Z9 Y) K# @0 l
StringReplace, full_path, full_path, `r, , all+ c3 z. ~6 f2 g8 Z0 q
IfInString full_path, \& ]2 ?$ F1 w: c1 c/ B9 `
{
6 u; k# L/ b1 y u, Z* H Run, cmd /K cd /D “%full_path%”
3 R! z, i; l8 |% l }: n- f- }; i2 d+ v/ W
else
0 ~, c$ u# Z! } \7 k {+ n$ P& K1 w# b k
Run, cmd /K cd /D “C:\ ”# G! {9 t! I! Q
}
) _" g9 i6 ~; A5 J }
: w F9 v( K/ y( S 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! a4 p _! d$ z 这段小代码肯能有两个你需要修改的地方9 p' y, E( F) ?; ^0 Z
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% @. C0 T) [& k9 s 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 c# l( ]2 P; s |