此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
4 H3 C( B" n5 |6 B6 `. H" a 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" l7 o3 F! N& t; }3 y# h8 f
方式一:
/ ?: S( j$ l3 B 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 n; D3 T/ A% b5 G+ E6 C
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 {9 R2 k* m* l* d. ?$ \% I% k
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 N/ U! C" N' c3 \4 Z7 l/ K
方式二:; y+ R6 L0 W# s( \( q' p2 N! M5 Q+ ]! \7 _
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! [) d4 ^! h7 n7 H SetTitleMatchMode RegEx
9 J4 j: ?9 ]( t8 e( Q3 g5 D1 I return
( d0 `0 c1 G' U) C ; Stuff to do when Windows Explorer is open
3 e4 T7 X1 ^% U, }9 S ;4 g2 x5 m% g9 I; M; I2 t
#IfWinActive ahk_class ExploreWClass|CabinetWClass
% z) g* ~: o9 L( X8 } ; open ‘cmd’ in the current directory
$ X! A5 ]9 g w& Q$ D, ^ ;4 w& l0 T3 W1 f8 R) n$ V) ^
#c::
! _% @# U2 M6 Y% D OpenCmdInCurrent()! ?$ [3 b: i5 T7 ?' }
return
& V+ U! P& F8 p$ v6 l' Z4 K, ~ #IfWinActive
. {3 u: ]% G; k& n; Z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 F6 d4 ~* Y9 g5 y9 d ; Note: expecting to be run when the active window is Explorer.
+ \ t! J; ?9 E5 ` q ;3 N5 H4 g- Y# M- ?% t" E
OpenCmdInCurrent()* {4 g$ L) E+ l, i
{* g f! t% ?" L
; This is required to get the full path of the file from the address bar0 {* B9 O5 V B B
WinGetText, full_path, A' ?1 g* c4 ?2 o c
; Split on newline (`n)
# v( o! ]3 Z* s7 M StringSplit, word_array, full_path, `n
7 `! h# _; n0 T7 e+ B. G; \- w ; Take the first element from the array
m* X7 f3 i3 T7 n9 c) I full_path = %word_array1%
9 W) R; F3 u3 }1 w0 ~ ; strip to bare address
- r9 J: [; j( j$ l( m) [! M2 E full_path := RegExReplace(full_path, “地址: “, “”)
9 E8 z+ v' s. O' s$ | ; Just in case – remove all carriage returns (`r)
/ T: z2 K1 ^ M0 a# \4 G StringReplace, full_path, full_path, `r, , all
2 q/ S0 k- k3 |4 Z/ I/ E% Y: A+ n IfInString full_path, \$ A# ]; l4 s4 K* ]! M
{
( F; h$ C1 E7 e' G0 h Run, cmd /K cd /D “%full_path%”; B9 M4 I0 {" K2 r- w
}
; c, q# d9 W& K+ y else
: g& n0 r' k9 [& X2 g {
7 N) M1 [; I t, c8 G9 u$ a5 {/ Q Run, cmd /K cd /D “C:\ ”
7 p! m; J: W% g }
0 ]' T4 A f. H4 c$ q }
2 ?! _& z6 F$ K6 x 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 K% v8 D6 k, B 这段小代码肯能有两个你需要修改的地方# F; j. q- @, Z
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键4 ^* V9 j7 \0 C1 Y; ?
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" l8 t5 B' p1 H9 e( }8 A+ ~ |