此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ c" z( s" {4 }- V
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 c$ u) F1 z% b6 c" g F- N 方式一:
9 Y0 Q* ]: `3 B( m 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
l% y7 n5 J- i8 A, G 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 d" T' Z7 x8 p7 P HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 u% \0 p& G1 R; f8 f9 p5 P1 J
方式二:
& K2 k6 ] f: d2 R" c' z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& ~- W5 t6 P0 k( e5 |! L SetTitleMatchMode RegEx! V0 k! u% g! l, Q7 q9 ]
return
( }6 } c9 o) o/ Z& a- e* N0 y ; Stuff to do when Windows Explorer is open! p2 N$ A0 z! g0 L2 O3 _4 J
;
" O, D$ K E! }7 a #IfWinActive ahk_class ExploreWClass|CabinetWClass. R9 B& [8 O% x
; open ‘cmd’ in the current directory# M% J' N, M. j. n8 h/ z- n7 K
;0 P3 F+ K6 k! w
#c::
0 G' ?- x* v% ~6 l+ X- z& `7 R OpenCmdInCurrent()
/ F# y" ^. N3 r1 i+ M, _9 c) a6 h! Q4 f return1 ^; e% F6 U* }% J0 N& y5 \
#IfWinActive
1 y5 s; ^1 r ^ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 P# i5 U% W( U4 e9 G ; Note: expecting to be run when the active window is Explorer.
. x! l E: U. u% @ ;
$ ~# P1 u8 f$ z6 F1 U; t OpenCmdInCurrent()
, Q" x! @$ Z) W2 ^# l+ g( P# t {
# L) o5 c# V/ y2 x( z5 S5 v ; This is required to get the full path of the file from the address bar
8 T9 M6 x5 a# r q5 Z WinGetText, full_path, A1 w% W, O. r% v4 o/ y5 U8 t u( s4 _
; Split on newline (`n)
* w* R! f4 ~9 D: H. T5 e1 ] StringSplit, word_array, full_path, `n( m( U Q) z7 q7 S4 ]9 `5 g
; Take the first element from the array$ S Y) X- M# Z
full_path = %word_array1%9 I# z/ R$ ^# C% t, g
; strip to bare address: C t! ~0 p9 ?, C
full_path := RegExReplace(full_path, “地址: “, “”)6 E9 H3 l5 e! B8 s
; Just in case – remove all carriage returns (`r)# V. g, j4 h$ b, t' m! D4 k* J
StringReplace, full_path, full_path, `r, , all
# Z) } [' _3 ]- v! `" o IfInString full_path, \ `/ P1 O+ ~' M5 }$ ^* J. B
{
3 p, Q, J, ^( ~. n! A4 v Run, cmd /K cd /D “%full_path%”5 i% \2 ^2 ^/ s, _/ {
}; \0 n9 ]. k3 I
else4 a( c$ U9 X% H$ o
{
. i% [( l( ?1 ~$ V Run, cmd /K cd /D “C:\ ”
7 x! J8 P4 M9 v. p }2 f5 s! Q# R! j$ R! I" f H1 p
}
, s7 A( y' Y- j9 E# n 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 q' j z$ q/ [ I( T* W; t* Z8 g
这段小代码肯能有两个你需要修改的地方
7 S5 v4 w* D) ] }; X* F 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: n# P7 N* {- n' N; o 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. g) Z( T8 i. K6 }( [. `
|