此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ I: n9 I: o4 p) m4 o 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; {/ R" `) J- k. Z
方式一:$ a& Z5 C- g4 @% P' |
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 }8 k, W; a4 W \1 I+ {
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
0 n% q* Y* T4 x$ f+ A+ y" O HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 G1 c F' ]; n5 { 方式二:
$ q7 b/ Y% ?9 m0 `; O) n- {. \! I 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( l, V/ V+ e3 }( ?9 j SetTitleMatchMode RegEx
4 ?2 Y% d5 E' f0 l' ^3 V1 b' Y return
! [1 v1 ]6 \# t v6 e4 } ; Stuff to do when Windows Explorer is open0 |& x( K2 g. @# t
;
- |7 O$ h" E$ d. X: I# \ #IfWinActive ahk_class ExploreWClass|CabinetWClass
' ]+ { x8 H$ E9 Q* b* W ; open ‘cmd’ in the current directory
6 p/ D! {" J( l7 u+ `$ i ;
2 Q& h" I! H; u: a: S #c::& \- c) r, {9 S3 ?5 R: T
OpenCmdInCurrent()
% n1 E z) s8 I, k2 o, ~0 x: \1 h return$ i% L5 s: l, ]- ~% J
#IfWinActive
$ x; L( t1 p S! R6 b ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& c. o( j# V7 Y6 y5 h! B ; Note: expecting to be run when the active window is Explorer.
% ^9 a+ T/ I4 P7 j, Y ;2 _5 r( ^* i, m) r
OpenCmdInCurrent()
2 `0 P5 T" C4 W$ H9 _* p5 q {
, ~) g5 e+ B# u* o ; This is required to get the full path of the file from the address bar
. E# J& ~0 ~3 l, C WinGetText, full_path, A) m6 ]; r) C8 d7 f" t5 M
; Split on newline (`n)
3 y% R+ D K8 y' o StringSplit, word_array, full_path, `n
9 T1 b0 M8 k o$ e4 |" E Q' @% g4 W: a ; Take the first element from the array% Z7 n6 P" A9 x0 Y1 y% T
full_path = %word_array1%* V& C4 {5 v f# v( |6 y3 s% K
; strip to bare address
" U; e% F& m" N full_path := RegExReplace(full_path, “地址: “, “”)
3 U, o* v8 N* l: ]! ?6 f3 V' N ; Just in case – remove all carriage returns (`r)
* Q9 ?/ D6 k# _. e+ [ StringReplace, full_path, full_path, `r, , all
! {% Q1 L$ ~, s' e. ]/ Y IfInString full_path, \0 G; S _5 ^* C1 p1 J( x
{8 X1 L0 V% X( Y
Run, cmd /K cd /D “%full_path%”
5 b( B: V4 l0 n/ { }* d- I! O; w# o+ M5 |: a2 a
else
. u- E! D- Q. @: |$ t$ W {
- W/ k6 t( A6 |& f5 o6 b Run, cmd /K cd /D “C:\ ”* O4 k" L( N$ p: Y4 S6 w
}
- |, W. u' m( e- o" t( t* Q& H }
1 `; z% S' H" s) Z* I' `! g* B1 f 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: V9 m1 J% ^% X& I 这段小代码肯能有两个你需要修改的地方
* G+ A8 ?+ x2 v p 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
* P. c. j! ?' C6 C' ]# c 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ ^' c/ w5 `( j/ }/ O
|