此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 ^$ s6 E9 x7 T* W% k0 [3 d
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) j( w& L+ Z# K7 `% R
方式一:
( E9 O8 m0 [$ Y3 ~/ i' p 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% i+ X `5 ]; x. i
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 a. ?" O; e9 ]: m5 L HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 ~8 q5 P7 [# p$ U5 z* d( U* f
方式二:: `. W+ l( @1 z K8 y0 h) \4 i
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
6 [( d( h8 j3 O& j SetTitleMatchMode RegEx
+ C) F2 c. O$ H- Y. y return
/ J1 e; x" ^* \3 K5 w, W ; Stuff to do when Windows Explorer is open
9 h3 Z5 e4 o0 F3 V+ E6 {- u ;
( Y) a) Z, p; P! V9 e$ g #IfWinActive ahk_class ExploreWClass|CabinetWClass
* p" M- d+ @. O K" P6 _ ; open ‘cmd’ in the current directory$ }* O+ m6 a, `+ ?$ U% y$ v
;
5 G/ F! Q" i' I% n6 P #c::
- f7 @. _4 h; i8 p+ A OpenCmdInCurrent()" I1 E1 B# J4 t% O! Y1 }
return
2 C0 t: f0 [- w) p+ l4 s d #IfWinActive- ~( ]$ E; b% f$ a5 r& M
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" p2 N7 V4 T5 ~, Y7 l$ \9 \ ; Note: expecting to be run when the active window is Explorer.) v# E( b) u1 n7 u4 p9 ~& {
;
% K! n C$ n( L3 Y7 y OpenCmdInCurrent()
; L! f1 R( G* N j {
: l# B8 [0 C" o' J1 R* @; p+ e f; x" L ; This is required to get the full path of the file from the address bar
' h/ e! Y7 y) _! I. q2 e" |5 Y WinGetText, full_path, A
# b& T! I3 U+ n7 X' b/ q ; Split on newline (`n)
$ W) N) k& U& D+ L StringSplit, word_array, full_path, `n
# _# p2 ?& K0 \1 m9 h" I ; Take the first element from the array, i/ Q% Q2 W% ]5 w$ A& n
full_path = %word_array1%& k. Q1 `8 G" C8 M, _& x
; strip to bare address
) G6 t) v/ D8 E/ N% O$ K6 a full_path := RegExReplace(full_path, “地址: “, “”)5 z) D* f( Q; ]" c$ h
; Just in case – remove all carriage returns (`r)
0 D8 q+ w. S* T& r* R6 v StringReplace, full_path, full_path, `r, , all
* E$ N" |+ f; O4 y IfInString full_path, \
% g3 Y1 f) j* e- e! F {
6 l# F/ {$ b$ J# T# Q Run, cmd /K cd /D “%full_path%”4 R1 y% [; s8 H& `2 V. ^
}5 I# n, z+ q8 n( `/ I
else/ P' s0 L1 J" ]* L1 v$ Z
{* j1 @& E' O5 }9 s2 M" y
Run, cmd /K cd /D “C:\ ”: V$ k7 x8 N0 v" U
}
5 ~% ^3 {$ r- |, e' W3 c4 ^" t } I z N' ^ t9 ^# s
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 f( h5 d; L* N- S7 ~6 d$ b
这段小代码肯能有两个你需要修改的地方, W" T: B. B. V. k" O8 c7 j
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% M( W$ F5 L( f9 A 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# Y P3 d& a b) z+ P8 |
|