此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 h+ S0 {- b, y/ M T
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 V/ i. H; p9 ]% Q: G4 P 方式一:7 [0 t& P# o( B- ?! Y, d
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, {1 }( P ^+ B 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 e8 I/ l' Y) Y7 N( [
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 r0 z+ A# w6 r) B6 \ K# p 方式二:
' @! D& o6 @- b& w; b5 k 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 I f' e H- o$ g7 ^9 n
SetTitleMatchMode RegEx
! \% ^. ~, s7 r5 e. D2 f: F return
: a, S2 d' t3 I( R ; Stuff to do when Windows Explorer is open
6 M1 @7 \1 t! H9 n7 W) d ;% n9 T! b4 ?0 k6 Z! i# Q& _
#IfWinActive ahk_class ExploreWClass|CabinetWClass
( a' J/ ?$ W! \# M: i ; open ‘cmd’ in the current directory
/ B1 Z, K, T( } ;" Q7 y) s% o" t1 Z
#c::+ b4 h- d; ^- i p
OpenCmdInCurrent()$ k; F- T9 R; S# M- J
return: f4 n/ ~" B! e: C; V
#IfWinActive7 G& c) x0 }1 O" R7 [) t7 K* I& Q
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' u8 @1 d9 Y# ^7 a
; Note: expecting to be run when the active window is Explorer.' h+ _! X# M5 m% d# p
;% Q' b; J" l/ |# p1 D4 W
OpenCmdInCurrent()
# O z* D7 G" P; S0 y. Q {- J1 b- o& b0 d7 K* J, [
; This is required to get the full path of the file from the address bar8 k: g1 ^0 M7 |/ e: C! f
WinGetText, full_path, A0 Y1 r7 }1 z) f( a8 \# {; I
; Split on newline (`n)
4 ?- N9 y; e7 z StringSplit, word_array, full_path, `n
: K$ w" v* N! C1 T ; Take the first element from the array
: x' j8 D% z) H- D full_path = %word_array1%3 u8 T1 d7 _8 L ?& @
; strip to bare address
* N: G8 g1 U) ^) n+ G( T full_path := RegExReplace(full_path, “地址: “, “”)
/ G9 \3 l: ?- n9 z ; Just in case – remove all carriage returns (`r)) @2 h1 j7 D4 ?- m- X4 L& c
StringReplace, full_path, full_path, `r, , all) Y, Y# w7 ]# A6 v ? d% H
IfInString full_path, \
' n- e3 g! f5 |5 p- O {7 t4 H( K( H2 {0 F% m8 |( u
Run, cmd /K cd /D “%full_path%”
1 Y/ ~ L- l+ {& M0 p }/ {# \# ]0 u9 t! I7 \- E* `
else p2 z% _6 ]+ j4 s$ b( S7 R+ A
{
+ H0 R, A$ o# W! u Run, cmd /K cd /D “C:\ ”4 |0 G; b. z9 B2 D: P
}
$ y" y2 H1 ]7 o6 W0 S; e }) j" i3 W, o" F) K0 K3 J
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! |' i1 c* o+ v2 ~/ G
这段小代码肯能有两个你需要修改的地方+ r8 @6 H% z, m4 e3 _5 q. O, [
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* @$ i' V# N( N2 f6 z$ e% s- {
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' D8 D! |& b4 }6 R: ]/ T. R6 k
|