此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。0 K9 f9 N! [; _1 X6 M
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ g) `; l" U6 G: [) u. _
方式一:
; X/ ?9 J/ V1 h) C- _. y 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表," `' ~4 G6 I) \9 u
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 d( a8 j" c" s! b' m' w; q& f
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, Q7 n' M2 n* _' X+ H+ P# i& M
方式二:9 Q9 l1 O; r3 A! X( V& E- M
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, N7 |5 a8 m7 f0 J SetTitleMatchMode RegEx% b) S( \" P# {
return: V; g" L a' t- T6 Y7 ?( W! T+ r
; Stuff to do when Windows Explorer is open& i1 w0 b5 r5 Z* T) H6 z
;
% e" G; M$ R/ m; Q0 \$ l9 m #IfWinActive ahk_class ExploreWClass|CabinetWClass" Z% Z# E( z8 |* {
; open ‘cmd’ in the current directory
$ s6 r. v4 B4 D0 }# C ;
' U$ ?# r9 u' j #c::
' x. f0 m% S0 ]1 M; m& v OpenCmdInCurrent()6 {# k# |8 x6 t% k% y9 h7 E3 i f
return* a0 u. D+ \% n1 {
#IfWinActive
3 e" c: \2 E0 E+ q ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' B% c4 e/ v4 t9 z7 A ; Note: expecting to be run when the active window is Explorer.
1 h8 X& B" T6 x- q, ] ;: ^6 Z8 y0 o% H! c
OpenCmdInCurrent()
3 F# ^2 _4 v K2 A* _ {
' P( z7 X4 }4 \" @' P ; This is required to get the full path of the file from the address bar3 E i7 R" u+ R- D- F/ P5 N
WinGetText, full_path, A
7 a4 X$ Z/ Q' R5 ]" Q4 G- M4 Q ; Split on newline (`n)' K6 n' z0 K: D& V, a5 P
StringSplit, word_array, full_path, `n
! {! z- h8 w0 U# [3 u& D; I ; Take the first element from the array
* f$ D: z. e. i* g9 F* W6 l9 } full_path = %word_array1%! M+ E2 D8 Y* L
; strip to bare address
+ _3 o Y. m& q7 B' V full_path := RegExReplace(full_path, “地址: “, “”)
( m: B! N# X' k7 }2 e ; Just in case – remove all carriage returns (`r). j6 ]7 ]! [$ o& ~1 h. S
StringReplace, full_path, full_path, `r, , all/ A8 p7 V" W2 l# V$ Q. d' y' o6 M
IfInString full_path, \
% s, i% m" F% b( w {& K% W$ i6 C% B3 t7 A, Y
Run, cmd /K cd /D “%full_path%”
! }$ V# x1 J% b) C6 t! P0 x% ?# b }. V" D7 k B* M# L6 w7 d, c
else! I2 d( K! ~0 }" g1 ^7 |' b6 X) z
{- F' e0 V0 k5 X$ s U
Run, cmd /K cd /D “C:\ ”+ v; V6 a2 c- c+ S" v) S
}
. k$ U* q2 o+ Q* M8 ~8 A: W# h" B- \& | }, l" \! C0 e% U% H8 R' U
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- o7 e! r0 N* Y# \7 ]4 s 这段小代码肯能有两个你需要修改的地方6 Q1 l8 M9 ?5 y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键: Z- \$ M9 p, ]3 Q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( Q9 Z/ ]+ |/ k5 J
|