此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
! {+ c( q& l: L' |* A5 V% I 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 w7 D+ @, C& u; t* \/ k* {$ s/ N) y
方式一:
$ `$ v6 D! l7 ]" g9 L0 n* |9 o 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% n; g# p( F# p( b9 r2 }, p8 _5 i 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' d& c4 u9 A9 V7 g HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 f; n: e7 W/ H; ^) ?; d2 k 方式二: B: q, J' z3 C
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 u) P8 e, X) z0 ?4 h7 x( ^ SetTitleMatchMode RegEx
; ~, c P/ d* Z h/ A" _% x return+ z; i0 u+ b$ U3 q& q5 {! h
; Stuff to do when Windows Explorer is open7 S, b4 p/ R- D) A" G, B/ O" w
;* ^* I+ i: U5 p* Q
#IfWinActive ahk_class ExploreWClass|CabinetWClass
: {6 i% E4 l; l$ ~ ; open ‘cmd’ in the current directory
& K1 U5 h' H9 F ;& ~$ U3 k8 T, `. e3 A- _9 h
#c::! g" h$ P/ v" o: \; ^3 j* r
OpenCmdInCurrent()
- H7 t. f, R* [! Z7 r( a return
1 `6 ]* Z9 @+ @, g j! |2 W6 Y #IfWinActive
^* y: @6 }0 B! [$ O ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 l6 h8 R( o* l$ E4 b- |% W ; Note: expecting to be run when the active window is Explorer.% J5 l6 R9 ^' t
;
. l6 e3 C6 w4 ^4 R- ]- E* W OpenCmdInCurrent(). k+ k7 e9 S) {8 ^3 j
{
0 V) t5 r' n* ]5 i! H ; This is required to get the full path of the file from the address bar
0 z) J! l% g- Y WinGetText, full_path, A/ k1 o) b' I+ B) a# P4 v; W
; Split on newline (`n)
' n# Z8 r% p3 c, U' o StringSplit, word_array, full_path, `n
. r9 a/ z0 U# Y$ A ; Take the first element from the array
& B0 z, v8 f. {! g full_path = %word_array1%* A0 H0 D: Y7 r0 f# M7 I, W
; strip to bare address
% E C" f+ I3 |) I3 M full_path := RegExReplace(full_path, “地址: “, “”)
7 R$ o9 T& n3 N2 O3 }# Y; w ; Just in case – remove all carriage returns (`r)
- T# B9 \! Z5 Q7 o8 l: B StringReplace, full_path, full_path, `r, , all
+ V6 f. M9 n5 g0 h IfInString full_path, \
- ?, W. g6 v2 E% G# f s) t& Q {
7 c6 D Q1 q/ x. ^; h Run, cmd /K cd /D “%full_path%”
" }; t" |/ }, ^3 v% l }
8 Y) v N5 v( _( U( `) @1 V else
) `1 w1 Z& w8 J1 h4 ?7 s {
7 f0 f7 ~% [. K Run, cmd /K cd /D “C:\ ”
* \6 k+ ^% ^; k- ~2 n }
* K) j+ Q: |( i* ]9 w }
) @ ?( m7 T9 Q; g* U 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) q$ D3 z C) D! q% X3 O5 _ 这段小代码肯能有两个你需要修改的地方
" ^. p) t# l' Q6 ]% k8 f. D 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 r Y) ~) Z& v8 I- e 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- t$ m1 r# b8 L9 I/ a
|