此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 p: T& ?" S2 E3 B8 \ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: m! I: G8 V, s. g3 S 方式一:
* U+ n% D) y! H9 U; S' S0 u8 S: L 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 L0 d, D7 [1 e* \. C& r 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 O L5 D0 Y# w# z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。3 G* M7 h# L; g. K
方式二:( Y6 h- z9 I: p9 C u- g
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; M/ ~# o& N0 f5 B" \2 ]7 S0 w6 ` SetTitleMatchMode RegEx
( _( o0 U. n& ? return
k6 S( Y6 a7 t2 p/ Z( R ; Stuff to do when Windows Explorer is open
2 D8 U+ [2 Y% V5 j9 |* @" I5 k ;
5 t6 o) P0 s* k Y! T- w6 T #IfWinActive ahk_class ExploreWClass|CabinetWClass
* B+ g9 c/ \; \) M3 ] ; open ‘cmd’ in the current directory" Q3 ?3 [- j- A
;
' V; C4 S, t8 e2 s #c::
) j" M* C) ^# P8 f OpenCmdInCurrent()
3 j! k) M! o3 i& J, E) ~& a return# D" f/ {6 o Q0 |4 ~
#IfWinActive
3 D/ b$ o2 @9 C4 P- D4 y: S ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 t6 g1 m6 X1 v5 |5 S/ Z. p; t# _0 I( x ; Note: expecting to be run when the active window is Explorer.2 U2 d& j7 x9 l/ }6 o* F
;/ E7 W7 P8 y5 G4 C( q
OpenCmdInCurrent()4 D- `; L' w+ H) c
{: |% J( I8 u7 L6 A: D. O( I
; This is required to get the full path of the file from the address bar
- h9 H$ E$ m/ d5 `9 U9 W WinGetText, full_path, A
5 H( M% @( N: ^+ q3 F% f ; Split on newline (`n)
: r" s) g5 |9 H+ ?" ^( ~ v. E StringSplit, word_array, full_path, `n
" _, k X( p+ w" x* e- ? ; Take the first element from the array
; P8 h' `: y6 R4 c/ k full_path = %word_array1%
+ C7 {2 P j) r7 I" M ; strip to bare address
9 `8 H& U3 t9 |7 m. ~3 B5 e' D$ e full_path := RegExReplace(full_path, “地址: “, “”)
( O9 @. N/ w1 A ; Just in case – remove all carriage returns (`r)
O9 ^2 O ^: V& Q1 q7 n7 |7 Y StringReplace, full_path, full_path, `r, , all4 y& ^" ?5 o+ J" d$ ?
IfInString full_path, \
3 S# H6 y: t' T+ Y {
9 V. D3 R9 ]' E" s% Z4 S/ }6 A Run, cmd /K cd /D “%full_path%”" Q$ \2 |7 Z$ y* P
}
- y$ Z% o% w& ^1 v0 N3 Q0 b0 u. v else
$ h) W6 b" n( ~* I/ j# B {
* {: d: p7 e& ~2 m6 _ Run, cmd /K cd /D “C:\ ”
) o' ^$ g7 O& o5 z0 q7 a }! R u" `# D8 S. u
}
7 i: B) u' N, M# _1 o2 y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 ~5 v* Y# r2 f+ W; I* p
这段小代码肯能有两个你需要修改的地方
8 x N1 a, Y. @2 i6 s& V 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 y' i) M! n7 G0 v: p! g 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# [' H+ u; K* C
|