此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 K# {; d1 a6 m4 ` c% w+ `
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
G1 S' `# ^8 X' [: c1 _ 方式一:/ E: u- L1 u3 y% \2 S4 {1 L: y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表," V8 r6 h7 T1 W
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ n Q; D$ _" d; I1 O HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ D1 @2 A* v6 o 方式二:% Y, h7 R' Q7 t
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; ~8 ^5 u# C- ~" o2 w& U SetTitleMatchMode RegEx
- C. W* d6 i4 `" |* r7 b return
8 p5 Q, D2 h) c7 d* Q/ y# ^4 i; O ; Stuff to do when Windows Explorer is open
& \% t, e% h: R( q ;
+ ^- E" |7 a( `# ^; T #IfWinActive ahk_class ExploreWClass|CabinetWClass
( U- @2 p3 t9 d& ~ ; open ‘cmd’ in the current directory
" p3 A5 c+ |! [8 H# p' {" M ;
z2 l- U9 E g' }$ W1 g #c::
; }" t1 ^6 s. G OpenCmdInCurrent()( w' c3 [( j' D
return
: h4 ~7 P: j' X3 p6 B1 \* v# Y. ? #IfWinActive
" B+ A& n+ T% n1 F1 J! b \ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. X$ o2 Q$ Q! z& V( V1 I ; Note: expecting to be run when the active window is Explorer.
* [) h+ s! @0 e9 h, z9 h* L# u+ I ;" p0 X1 B- A# r/ X7 g: C
OpenCmdInCurrent()
7 q5 K& G8 T; @4 S; s {, Z, O3 P% ~1 ]5 b5 x4 l5 p, D
; This is required to get the full path of the file from the address bar
# u8 X' ^0 E: C3 \5 U) h }- J WinGetText, full_path, A
; O% g7 s3 C* x* l' g ; Split on newline (`n): f) o( b" f2 @3 \- T% s/ i1 M2 {
StringSplit, word_array, full_path, `n
C' R: E5 I/ E8 T3 S/ R ; Take the first element from the array
% s7 e6 o1 Y) C- v" x9 ] full_path = %word_array1%
0 H4 A; y% v2 j; l- Q7 R4 y- m4 I ; strip to bare address7 D0 _& Y) _8 H2 z& F! t
full_path := RegExReplace(full_path, “地址: “, “”)
( z$ M0 U$ x3 {. ] W5 t: f ; Just in case – remove all carriage returns (`r)
0 L( m5 @+ A! e5 E2 M5 x% I) w/ y4 l4 M StringReplace, full_path, full_path, `r, , all7 m% k8 }/ J Y
IfInString full_path, \. {. k p# W" l) c& `% \
{' y+ z' u* x* ^3 X8 D
Run, cmd /K cd /D “%full_path%”% r% A/ L. ` L' @- G: V
}2 P/ ~) j& U# W( ?3 }2 f
else% R" ^! a& A( W8 t% K6 g6 h
{
& O& ]- }' C3 A Run, cmd /K cd /D “C:\ ”
: N; F, D, l- y }
" a# R$ y( }0 q# }$ U$ ] }) z, k# J: j0 |0 Q; _7 X& g0 w0 h9 f6 T
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* j# N9 J' T9 K0 A/ t# {
这段小代码肯能有两个你需要修改的地方
# ^7 Q% E( c$ B" a" s 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" ]9 o( G' P& z! e4 R4 v, i2 G 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* [7 d4 `3 V( t& R' o |