此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: W- b" s4 R+ `1 A! r 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
+ _, j( {' k* @ 方式一:; I, ^" F* h0 `: w3 y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& e+ [; `) c9 b3 F1 s; l 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 ?( e6 v+ j; W- V
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
2 b9 b! d# s! q: _7 G 方式二:/ I3 _. c- j. ^0 ~4 `2 {2 \
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( I8 r" J2 ^3 m p$ ~/ A9 i& ` SetTitleMatchMode RegEx
5 O1 b3 Q' _' w- ^ return- v; g% u3 \( ^7 C+ H* F' P
; Stuff to do when Windows Explorer is open
0 V2 ` e- G8 N8 a ;
# Q% g* v. r( H3 V" `& v' D4 V #IfWinActive ahk_class ExploreWClass|CabinetWClass
. U8 V) `1 g) y x, i ` `2 m! q! | ; open ‘cmd’ in the current directory8 v: Q6 [7 y% S
;
2 m! \3 B5 f( t, } O #c::
4 @$ a$ C! a) b. a; X* h OpenCmdInCurrent()
4 I+ ^+ l' d# C: m' D1 H return
* [+ c8 o+ c) s2 h ~+ g+ b #IfWinActive
6 U( D' t" {# s4 R+ r; X H2 n9 e ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% \, U4 x- u! Z ; Note: expecting to be run when the active window is Explorer.5 R9 t) a1 h$ s9 ?* B8 n* [
;$ t8 s; Y' @- Y( d% v0 p
OpenCmdInCurrent()
$ c/ |. i; W6 x9 v9 x. z/ H {. P0 P8 ]# H! |" A' ]
; This is required to get the full path of the file from the address bar
' W3 n5 N) n& v* j) [2 ? WinGetText, full_path, A
0 C, Q, @" ~/ P ; Split on newline (`n)$ x) v$ d# W7 Y6 h1 m
StringSplit, word_array, full_path, `n$ L4 I- D2 h' Z6 r- ]0 P% L* z) L
; Take the first element from the array
6 I9 C" Y/ P& {; ~$ { full_path = %word_array1%1 y: _; X A& j
; strip to bare address2 I, s- Q- M5 H
full_path := RegExReplace(full_path, “地址: “, “”)$ J" Y; k: l. @
; Just in case – remove all carriage returns (`r)
' C& t5 f7 Y/ z+ U" ?$ s% B StringReplace, full_path, full_path, `r, , all& R) J3 A5 s# F, i9 p4 X
IfInString full_path, \5 [6 n9 Z, ?9 d+ T% p+ @4 F
{
4 q/ `$ K3 N5 @8 M9 o% X7 a Run, cmd /K cd /D “%full_path%”
) z ~( v3 m% g2 ~ }
- v q ~+ t$ c' ^6 P w else* E3 e0 w. y$ D; E
{
; @! ^) _+ ^4 B* z; m% I0 U Run, cmd /K cd /D “C:\ ”
* O: a' N6 `! ?7 O2 L# ? }
3 @ r; Q, \* W$ U) G1 h( |% L% x }
' ?2 S; Y9 u6 t: W/ m' H& Q' t- B 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ S6 b. T$ }' U/ c& |3 I$ _ 这段小代码肯能有两个你需要修改的地方; I4 p7 j' | e6 p4 K: d
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 x- P2 ?! y. }3 R& u: h1 a) x) a 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 ~& x7 q. C" X* P6 L |