此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ b! k. K( ?5 A6 i: k6 H
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 I- j; K! T" ~+ q4 b 方式一:: _. n/ |2 U. g' q/ n
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 I! E3 p/ A) v1 j% W6 A0 S 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% j% C5 f6 w* }- h
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。' s9 n. u/ ]1 y$ h9 v
方式二:1 e; ?: x( P3 [: p+ T# {
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 I6 P. F3 G, g( K1 |& ]; K- R5 Z5 }
SetTitleMatchMode RegEx
8 K9 f- i9 e+ H2 X( d3 r return/ b' M" V6 M+ {) i# O$ q
; Stuff to do when Windows Explorer is open
- Z% E" j/ _* ^ ;
y# L+ n+ K* j/ g( W4 D. D$ S #IfWinActive ahk_class ExploreWClass|CabinetWClass
5 h) ]. `' v7 r; N" \/ `/ \ ; open ‘cmd’ in the current directory% `* u2 G# b( m2 \ S
;
. k7 U0 Y, { K* A( Q4 L #c::( k7 s o4 K+ F; }, g; {
OpenCmdInCurrent()
( T3 `# F2 |& t2 c \ return# G7 {+ \6 B3 g
#IfWinActive
' o; s! Q9 i$ |4 C ; Opens the command shell ‘cmd’ in the directory browsed in Explorer., o6 f0 G- T/ d3 g* W/ M. d
; Note: expecting to be run when the active window is Explorer.
; c$ |. i. E9 s ;% O3 z& t6 r1 a* R' ^4 m
OpenCmdInCurrent()
7 |2 }+ o1 ^* n' x' N {: F. I% P- w' w$ e
; This is required to get the full path of the file from the address bar' G* s! K* ?1 o( q% l& c/ S
WinGetText, full_path, A
1 b) w* E# Y) t! E) I. i8 t$ E ; Split on newline (`n)2 T9 D7 T& H; }- R b Q0 P
StringSplit, word_array, full_path, `n
# L4 Q9 G1 @( i& I ; Take the first element from the array9 x9 y8 S. R! n6 e ]2 l/ z
full_path = %word_array1%
. Q" i' g; L7 g2 i8 z& R ; strip to bare address; z2 O; H3 T; l4 N
full_path := RegExReplace(full_path, “地址: “, “”)4 B9 {% A( |3 G7 b8 `% `
; Just in case – remove all carriage returns (`r)
0 S. e+ S+ c$ F O! _. U J. p! G7 h StringReplace, full_path, full_path, `r, , all
, T4 {" O7 s3 r6 i. s) r* G6 g IfInString full_path, \
7 {. A% c; k# t' E {. O2 Z0 j! q8 @7 T: T/ s
Run, cmd /K cd /D “%full_path%”
1 }1 k; k8 e7 K4 M; T' A }
0 e' b+ t. V% ^* V, C. m# K' y else3 u8 k2 o$ w, x. A5 Y
{
' \- m' J, o7 `: n2 H+ x% \; t Run, cmd /K cd /D “C:\ ”
+ a9 K9 Q' W( d }7 U5 v* a1 @ [& U
}
6 p6 P8 {- b9 I; N 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: O) K$ S# }6 ]7 }4 g) j# D9 S 这段小代码肯能有两个你需要修改的地方, U, G2 _. e3 k, M" } _
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) p- V" f" _" m1 a9 M* @: G [
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( k1 T t3 q6 ^, ?/ o* _
|