此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ ~- `8 I) |% f8 d
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ h/ J1 s5 P; J
方式一:
' c4 _# X, L5 k: E: K 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表," }# X) O* ]$ Y% y6 g4 _
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% M0 h d. y R3 m4 x/ ? HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 [5 j2 W8 T2 Y& j
方式二:
; g0 m% X; D2 `6 N! l7 y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% X5 [3 L) K' B3 L9 r SetTitleMatchMode RegEx
8 n) k: `+ d6 F; @9 \ return
2 Z* ?& q- U5 `3 x ; Stuff to do when Windows Explorer is open* K: Y# f4 i& O7 q) H
;
t# p+ T2 B. F6 z5 s9 |" | #IfWinActive ahk_class ExploreWClass|CabinetWClass3 e0 E9 @0 Z8 a# r {
; open ‘cmd’ in the current directory4 ^8 j& Y2 H' E4 n( b: N
;. h* _, ?5 }/ c( T, |
#c::7 N; v+ ?/ Q' s
OpenCmdInCurrent()
' f; B# A% F$ G& V1 e return3 J/ Y R* f- Q* j
#IfWinActive8 E5 U3 N! W# C( B: K( N6 o
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 W( J: `' @$ F! s ; Note: expecting to be run when the active window is Explorer.0 N% J$ t* n/ ]
;2 B# L1 S% h) X v) @
OpenCmdInCurrent()8 x' ^ J2 g9 V
{7 h5 p* U! U$ O' J; A# x7 ~. j( T
; This is required to get the full path of the file from the address bar
- Z9 F, N& R* |% f+ }7 U* S WinGetText, full_path, A
4 u* a4 L" D/ N; `% }. y$ C ; Split on newline (`n)
4 P- l9 ^, p* A% M. r StringSplit, word_array, full_path, `n
. ]5 N6 e. L& L* y ; Take the first element from the array/ ]* p; ?4 z# k
full_path = %word_array1%
0 X' x5 A7 k/ P ; strip to bare address
5 K h. ~& [8 F# k7 r% M/ w full_path := RegExReplace(full_path, “地址: “, “”)
: x, f3 ?. R- u ; Just in case – remove all carriage returns (`r)
2 I" S% s4 v- s( w7 Z StringReplace, full_path, full_path, `r, , all
. Q4 e+ G: S, u IfInString full_path, \
8 D" Q3 T1 D( {* [; [8 F {, c \- d0 M2 \6 p
Run, cmd /K cd /D “%full_path%”
( @! A1 g3 p) c' e7 B }+ F: E9 {3 }, s* e/ B5 X
else% U& F" g1 Y- g# \
{
$ w! S* ^; z$ G6 S Run, cmd /K cd /D “C:\ ”% |1 M' N* s! W9 v0 G$ _2 x
}
9 G) i3 ]5 N4 j1 _, w }
% Q, d9 U0 u, }) v. { 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* [2 U: j" [0 r; x" Y/ m [ 这段小代码肯能有两个你需要修改的地方$ F: m& z. j, y' |' p
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 Z1 p; K- {& f# w/ E: B8 P
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# H* B" ]- S8 n' f! o% ]
|