此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
! h% M* c; H% E9 O6 {. N 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* \' p; w* @8 N9 k
方式一:
' s/ ? ^' O+ H 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 f3 Q% i) u E9 L3 {
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ z) s Y, X/ U
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 |# m) s6 c! O, q5 ~! B 方式二:- K8 c# L3 o* w1 j
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' b4 Z' w! R; A SetTitleMatchMode RegEx" h6 @$ D9 E" \ b& x- N' B0 q
return- @) v0 L/ T* d1 `* p4 X' A" I3 s
; Stuff to do when Windows Explorer is open
( c2 l$ D/ X$ y( U ;6 _# {- N9 `0 c0 h" C7 W
#IfWinActive ahk_class ExploreWClass|CabinetWClass6 w, {7 \& u8 C: w
; open ‘cmd’ in the current directory1 |, i! j4 _0 }5 K, F1 w* v b# j
;
% `# m1 l1 }8 _. m+ U6 E #c::
! z7 Q$ ~$ T- D, W OpenCmdInCurrent()
* A- R, ^/ C+ _! O return5 e/ d' u7 e6 F/ _& M) f, m
#IfWinActive
' ~- ~( ~3 o$ v4 U4 r, f- Q ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' X9 W/ V1 P8 s0 l- ~ ; Note: expecting to be run when the active window is Explorer.& v. D1 W$ E% I; s _
;
" K1 X. i/ ~; ]4 {4 T) B! | OpenCmdInCurrent()% [ G" ]; r6 n$ C' ]; }
{
7 ^5 q! v; ?7 J* F2 h ; This is required to get the full path of the file from the address bar1 z1 e9 }! B% o) k% a
WinGetText, full_path, A$ S0 c5 \6 P p9 U% F: |
; Split on newline (`n)2 j9 c! P; `# m& ?" `6 [
StringSplit, word_array, full_path, `n7 z! _/ ?6 o: ~3 ^& {6 w
; Take the first element from the array
5 |2 Y# l2 C& @( m) ?# K full_path = %word_array1%% | g1 } Z S; s6 c- W1 [1 i6 r
; strip to bare address
2 L" g9 H7 X# T/ @9 S full_path := RegExReplace(full_path, “地址: “, “”)
( v9 j- R, i& w* L' a# p. [6 b ; Just in case – remove all carriage returns (`r)
; m- g' H, O- Y8 h StringReplace, full_path, full_path, `r, , all
# |6 J( a. ?9 `, O1 j IfInString full_path, \
- x' ~) [& K2 \& y9 S3 t {# ^. u: H: Y1 o/ M* @
Run, cmd /K cd /D “%full_path%”
! ?% O9 `& r2 X5 v" g- N }
) E* C& L) M: K; o else- W, E% [& v" S" V& l1 Q% F$ E
{
2 ?; m( i" D; ]& u6 Z Run, cmd /K cd /D “C:\ ”5 |- L7 F6 K7 l* x4 }0 |/ L; k
}+ J1 A: A6 _1 a
}/ O+ [7 Z# ?. ?* p" I/ d0 l7 Y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& ~: e# B( k6 \ V$ [5 Q
这段小代码肯能有两个你需要修改的地方& R% S- N. x( s( J% S2 Y7 X K
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 k/ h, B N* M5 P# n6 k2 {* _. g 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' `0 b8 E' _! a |