此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* i f' ]) E! ?6 r7 p) w
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& E, p+ s7 o. k; x7 f 方式一:( Q$ x0 c2 g( C3 Z
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 {* S- n8 V; z m1 |4 X 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 v7 ?- y; Q9 ~ H; ^7 Q HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 a. a% f2 T% w) s8 { 方式二:
! A8 G6 o: c4 C$ b* N 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ j8 [: F' S/ `7 ]8 I7 `0 C
SetTitleMatchMode RegEx6 `9 _4 k. W2 b7 v, R
return
5 h N7 Z8 h- W1 h) X* k ; Stuff to do when Windows Explorer is open, b4 H$ J6 G+ Z0 u* y
;
# e6 E. ^7 m. b8 e #IfWinActive ahk_class ExploreWClass|CabinetWClass* V" W& E. V9 {& j% L- ^
; open ‘cmd’ in the current directory- b' v d; C8 B
;
- f( C b4 m8 c; l #c::! F' L1 }$ X4 B2 @8 E% S1 l. w
OpenCmdInCurrent()
7 i% \- e& H. e* [$ V6 [ return; D" [" a$ L! o" V8 V! u" D5 [
#IfWinActive
& S S# o# d3 K# e0 { ; Opens the command shell ‘cmd’ in the directory browsed in Explorer." h' y' ~6 g+ N/ \
; Note: expecting to be run when the active window is Explorer.6 j. z/ P+ m5 f7 L3 o
;5 L0 ]8 u& ~2 C0 ^
OpenCmdInCurrent()
1 C9 ~6 b' s1 u1 X {
4 K: K0 W! ~% }3 O ; This is required to get the full path of the file from the address bar( j' Z1 A1 ?* Q8 E' q0 E Q
WinGetText, full_path, A6 ?& r9 l6 j# i; w
; Split on newline (`n)4 W7 M4 {* x3 {: R7 x$ }6 g4 l# D$ |
StringSplit, word_array, full_path, `n
* b O8 J/ o) x' B0 g ; Take the first element from the array, ?: z6 D# {" r- m0 p# d8 V. {
full_path = %word_array1%
& ?# Y. o% ]& l" ? ]0 r. x ; strip to bare address+ A) ~7 P6 `" {! i
full_path := RegExReplace(full_path, “地址: “, “”)
- C6 `" g) d: @! Y5 l ; Just in case – remove all carriage returns (`r)
( R- U% N4 X' a) Y5 G H) [$ I StringReplace, full_path, full_path, `r, , all9 k6 k4 ?3 k9 [( ?
IfInString full_path, \
0 c5 K+ r6 Z- L. a9 _. L+ }& l {0 T$ Z! E" T8 c, u2 a2 g4 q$ n1 M
Run, cmd /K cd /D “%full_path%”
5 A- q+ J+ d; g* `5 j4 H/ ` }) M, [0 k7 v5 }
else
. i7 x8 @* j6 Y# B {4 K# [! `$ Y- s1 u$ g$ k% N
Run, cmd /K cd /D “C:\ ”
& E8 a. N8 m& ~& i- \ } c. |1 R1 ~& Y6 I
}
) J8 i6 |; C$ { 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 ?/ {) U: m) ]/ u% \3 @ 这段小代码肯能有两个你需要修改的地方
& W3 d3 ~2 ?5 r 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. \- Y, N* B' f. y 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- M/ y+ R! e& q. v$ X, d6 m$ n
|