此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 p( g9 k; w% X 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: B& _, x) s& Z' { 方式一:
& u& l& y: l0 E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 \. w9 x% u" y9 | }+ p 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 L* S& ^/ F: d8 _6 ~1 C HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ @) z+ U- R& o4 V. v+ ^ 方式二:6 d c, u4 M7 d# m
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 X I4 n. `7 l
SetTitleMatchMode RegEx
$ e t0 p4 _# O+ u6 O return
' [! a+ x, R5 E2 w# j ; Stuff to do when Windows Explorer is open" K5 d7 V( e1 e6 ]2 Q
;
; @. R8 q6 t I" K9 T# K$ Z #IfWinActive ahk_class ExploreWClass|CabinetWClass
9 m/ t! R% v- ^: ~+ D" g ; open ‘cmd’ in the current directory& B2 E/ g: b' W& @
;' B' a# m9 `+ _' `$ t9 p
#c::4 [. l- d' ~) Y d
OpenCmdInCurrent()& [2 G6 [8 C6 d
return
" q- x1 v. _) U #IfWinActive/ n" b) Z' c' g' d4 I0 S
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) ?* X4 F* M: f H- @% M' Y _ ; Note: expecting to be run when the active window is Explorer." X2 y) z: W1 Z" B6 ~" s5 k
;/ f, _& e# p o% N2 u( V, J* C
OpenCmdInCurrent()
# O9 P2 M \# P3 h$ t {
9 l6 d c, g6 G0 r ; This is required to get the full path of the file from the address bar+ d4 H% S6 a6 b
WinGetText, full_path, A# Q U1 r# i6 l( c) u5 x9 J: I
; Split on newline (`n)
/ W' d! h2 e4 J StringSplit, word_array, full_path, `n( j# `0 S! g* D' l0 H3 p3 ?8 v/ T
; Take the first element from the array6 s2 w3 _1 w* L6 f3 i, n
full_path = %word_array1%
/ D4 z# k' K- F q( r0 N ; strip to bare address0 J) j; V- e% X4 t; M$ Y7 {
full_path := RegExReplace(full_path, “地址: “, “”)1 y" |4 r: h* T) i
; Just in case – remove all carriage returns (`r)& [; P; y6 u: ~' }% c
StringReplace, full_path, full_path, `r, , all
6 [4 E2 S1 x. J4 W IfInString full_path, \
, X3 m2 K `9 U, Q( { {5 C. A1 i% {7 {! Q- ]
Run, cmd /K cd /D “%full_path%”
9 l& G9 @; D' g' P: L0 m, x }3 ?4 T5 w& Z( H' _6 |$ D' a
else
- |# O" {( \# O) Y: @ {/ k7 L6 Y& P+ U( ?% f5 {
Run, cmd /K cd /D “C:\ ”
3 y8 E* Y5 N# E% c }, o) G, o. L: @" [
}
; j4 m5 t* _/ m# _& c0 B 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- B: c2 i) O+ n* G6 U% [" z 这段小代码肯能有两个你需要修改的地方* t% W& b9 C; C4 I0 B' z
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) D3 b+ J7 t4 ?% X' `: p) t 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “5 c1 v6 m; l6 _- m4 F
|