此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 ^$ E; [# T" J" M* z7 b 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ v2 m& J1 i2 `+ ?7 O3 R( G
方式一:4 H- o, R0 ]: D# ?. X- `5 m" F
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 X' `+ z# W' m3 B 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 G( A: M* S4 z6 ]6 T8 ?
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 C' _3 `! {1 b. s$ D/ {# l
方式二:
; u' l9 i5 D& ~4 o8 o6 i 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' I; }5 ^* E& |# i, ^8 V4 B SetTitleMatchMode RegEx* I! H4 B: H9 C! ]. b
return
6 `. P( _$ B \% T% k* ? ; Stuff to do when Windows Explorer is open
: M" A+ B. X, O) |$ v ;
- E; w5 i7 L: q #IfWinActive ahk_class ExploreWClass|CabinetWClass
" J! Z: [, l9 m4 T* l& l ; open ‘cmd’ in the current directory
, t. _0 B) ]. d4 s+ W5 y! G) B+ M ;
) Y2 v# J/ @) d8 z8 ` #c::* I' b9 l: T' r2 O, ?) W( @
OpenCmdInCurrent()
9 Y! U% b/ \4 V' I8 n return5 G4 ]: A7 U) E* X# @2 f0 A1 p
#IfWinActive( c4 _, x+ B2 x( j
; Opens the command shell ‘cmd’ in the directory browsed in Explorer." l+ X0 h5 y8 m# J# e- V
; Note: expecting to be run when the active window is Explorer.
) j3 | m% `( [( l( T& ? ;, l f% a; r& K2 Q: V; W
OpenCmdInCurrent()
2 B. J- I; D2 I' E {
, @# q+ K! \5 C% o) ~1 Y9 F: x ; This is required to get the full path of the file from the address bar6 C! h# s+ r6 ]) d! |9 L
WinGetText, full_path, A$ C4 X( e d1 m& t" a: J; m
; Split on newline (`n)
/ `7 ?: P# E1 ]) A& J, T StringSplit, word_array, full_path, `n& A$ \# h% d& \7 B. ?' p. O4 S' h
; Take the first element from the array
4 I5 d/ q4 q5 V3 G3 o1 I full_path = %word_array1%& A L! g, v; T8 E
; strip to bare address
' F" ?: C: o! c/ Y( {3 ~+ s: F# v- Z full_path := RegExReplace(full_path, “地址: “, “”)
) [7 A) l, l9 G ; Just in case – remove all carriage returns (`r) W9 ~' }; c \
StringReplace, full_path, full_path, `r, , all
: H( e2 y" S3 ^4 B% v a; a IfInString full_path, \
# i" |) T! K, S( F6 X4 P! D {- S% M' N! |! D9 l" G$ c/ [
Run, cmd /K cd /D “%full_path%”
7 C% Z4 ^- c1 w4 y7 N& M+ ^ }
1 I5 H. i5 x6 x6 j5 f else
+ F* w, Y- ^# Y {* f( H! l; |& z- x- w: [
Run, cmd /K cd /D “C:\ ” C: h. L( X% \2 a+ b# J, l
}
% T) T* o! a2 Q' W+ R# d }' V7 ?3 I+ n+ ]) |- Z1 A$ l
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 | v3 l& p& e2 U2 ] 这段小代码肯能有两个你需要修改的地方
+ b0 p- h- g/ k) h' @ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. O% [9 D' Q% x d! p 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 i+ \# z z. q8 e |