此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 ]3 B. G4 k7 X8 ?, _7 ]/ }
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 x; m3 M$ s- n2 m5 m- R 方式一:
3 o$ Y% G' _ \5 P* C 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- S1 L7 D e+ k) y 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ j h4 m s7 t HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 H2 k$ [: |+ X. ]& N8 G
方式二:
# \7 k* y9 t/ Q* ]8 i) v. n 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: y4 C1 E Y) F) B* J
SetTitleMatchMode RegEx% L% [4 z3 H: m" y3 h' d
return; b' w% g9 a' R7 o4 e; }1 M; H' h
; Stuff to do when Windows Explorer is open5 q' ^# x* T+ ?, W; x
;9 S& ]" V1 d8 D8 a
#IfWinActive ahk_class ExploreWClass|CabinetWClass
/ e2 R4 D( T( ]- `3 }7 f9 m ; open ‘cmd’ in the current directory
; ~$ P7 O* |9 Y7 |7 i6 ^$ o ;
+ d$ k7 a. Y2 j: x! j #c::! C" B$ k0 X- t4 e: R
OpenCmdInCurrent()2 R. h% t+ ]8 v9 q4 S' \8 [
return \5 F* E: N5 z/ ~
#IfWinActive9 @* u ^$ Q9 Y4 x
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 j7 m( Q5 K. h3 s, a
; Note: expecting to be run when the active window is Explorer.3 i/ F( c9 t& g) h
;
' `. |6 |9 l% ]* t OpenCmdInCurrent()
7 \" }, I' V8 I& ~" m {
1 H0 Y2 [2 ?7 y ; This is required to get the full path of the file from the address bar
; @3 X* V* E& u! Y WinGetText, full_path, A( M% r8 F4 R- K* e& D3 c
; Split on newline (`n). U6 v7 v4 \' M
StringSplit, word_array, full_path, `n
/ y3 s# G$ O! @* D( X ; Take the first element from the array3 E. b5 k: \2 o! n+ p! w! C
full_path = %word_array1%) I# R1 Z% z4 o- i# |
; strip to bare address
: M, D9 ^, k4 i3 n/ O full_path := RegExReplace(full_path, “地址: “, “”)
. C! b0 w& W. \6 K/ { ; Just in case – remove all carriage returns (`r)8 ?$ l& i; F( n. B& Q0 O2 K
StringReplace, full_path, full_path, `r, , all `. t/ l/ v% j; {- H) U2 A
IfInString full_path, \
; x" `& w- {5 }5 s {0 ^' H+ U- q$ I4 {1 n3 D
Run, cmd /K cd /D “%full_path%”! U T" P0 O9 c, S
}
5 n( N: E) M* k8 W else
# Y4 q/ f4 s6 [3 q {
% |: G9 t: y7 G5 C: `$ n9 t9 R# j Run, cmd /K cd /D “C:\ ”
- F) k5 ^" @, i5 {3 q }, }1 c3 U0 ^3 O" y
}
8 f# o O0 `3 t& W6 B 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 Z4 Y% d* }# P6 k( E9 c( u- J
这段小代码肯能有两个你需要修改的地方2 X! J8 g- f9 w' d( S" w: n6 Y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& \0 i' F- x( \. i 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ c/ z6 s L3 T" g6 `0 d+ h+ k! @ |