此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 I0 E9 Q+ s3 O" q: | 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 `/ E) w' D& X O7 y
方式一:* H% x) ^9 S) f" E
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ [" a0 I7 R8 A6 _& [/ p* A5 N 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" U8 ]5 D% k0 R3 Z8 g
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。$ i- |; x0 W# K0 |/ S
方式二:
5 V1 V3 k9 l% Q0 ^0 K" L5 H& F z% I# L 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" P2 z) B2 y) S5 U7 b( M SetTitleMatchMode RegEx
, u! H2 w7 v* o1 _7 N8 }2 R$ } return
# U. ~/ T4 G- N+ t- k6 w ; Stuff to do when Windows Explorer is open4 i* |8 z( b: w c: n6 y
;8 Y& |5 J0 c1 [- ~3 L8 t
#IfWinActive ahk_class ExploreWClass|CabinetWClass
4 E9 \* F$ I9 k ; open ‘cmd’ in the current directory! s7 R8 J& A0 A
;
/ f7 k$ B) \! `+ V- T #c::
: C7 e5 R4 \" {# c. p OpenCmdInCurrent()
) S& H( P1 T5 {3 ` return8 m6 X G# d1 x( b3 z
#IfWinActive
- U" N Q1 W, H0 u, Q ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 C$ ?$ T; Y$ W* g0 \0 r
; Note: expecting to be run when the active window is Explorer.6 F( V* n2 `, X
;
" G- K" O+ Y# p- z+ O5 q OpenCmdInCurrent()' ^9 f+ J4 `" J
{ m3 w( C4 T( W; H* m! |: ~4 ?
; This is required to get the full path of the file from the address bar- e5 X: J0 Z5 e2 S+ O, g v& A
WinGetText, full_path, A/ [; k9 c9 D+ d
; Split on newline (`n)
9 G' ~. V9 p: L StringSplit, word_array, full_path, `n
. U j! p( U# w" ]- }6 T ; Take the first element from the array; u! N9 _9 I3 |* W
full_path = %word_array1% L* A7 O+ H# E* L
; strip to bare address
" G* k% k. }* N" s full_path := RegExReplace(full_path, “地址: “, “”)
7 J) M, Z; |8 S9 K# A- o ; Just in case – remove all carriage returns (`r)
# _& i- a1 ^- v+ a StringReplace, full_path, full_path, `r, , all9 D G/ _; F% i9 \3 W
IfInString full_path, \/ U! U! b L) V, q8 t
{2 u" S' r0 n. ]* c3 x6 z: z* ]
Run, cmd /K cd /D “%full_path%”- \+ _7 l5 Q3 w" c4 v) {2 r
}
- t! o( |7 @( d else9 E" v, C* ^5 K; h, e/ t2 S/ ~. P1 J
{
; u+ H8 c! V9 S Run, cmd /K cd /D “C:\ ”
* m' y, ?, q, u/ e$ o }* i" \& G u) h: H. m U$ [
}
9 Z- {0 O4 J: u; ~+ q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
' W H* Q2 Z( k3 |- l 这段小代码肯能有两个你需要修改的地方
( b3 y4 l) f. `( \/ f# T 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键. W- e7 B' U& D0 V
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! b7 u) n) Z' q) |4 D |