
如何在 Windows 7 中使用鍵盤快速鍵在目前資料夾中開啟命令提示字元?
有沒有辦法實現這個?
我認為 Autohotkey 可以做到這一點,但不知道如何。
答案1
使用此鍵盤快速鍵:Shift+ Menu、W、Enter
Shift+ Menu(或Shift+ F10),(在目前資料夾中開啟擴充右鍵選單)
W(選擇“在此處開啟命令視窗”),
- Enter(啟動選擇;必要的,因為也可以使用 選擇“新建” W)
該Menu鍵是指微軟推出的特殊按鍵,通常位於右鍵的右側Win。
此捷徑在預設安裝的 Windows (7) 上可用,無需任何第 3 方軟體。
AHK 方式。您只需按Win+C(或者你想將其定義為任何內容。):
SetTitleMatchMode RegEx
return
; Stuff to do when Windows Explorer is open
;
#IfWinActive ahk_class ExploreWClass|CabinetWClass
; create new text file
;
#t::Send !fwt
; open 'cmd' in the current directory
;
#c::
OpenCmdInCurrent()
return
#IfWinActive
; Opens the command shell 'cmd' in the directory browsed in Explorer.
; Note: expecting to be run when the active window is Explorer.
;
OpenCmdInCurrent()
{
; This is required to get the full path of the file from the address bar
WinGetText, full_path, A
; Split on newline (`n)
StringSplit, word_array, full_path, `n
; Find and take the element from the array that contains address
Loop, %word_array0%
{
IfInString, word_array%A_Index%, Address
{
full_path := word_array%A_Index%
break
}
}
; strip to bare address
full_path := RegExReplace(full_path, "^Address: ", "")
; Just in case - remove all carriage returns (`r)
StringReplace, full_path, full_path, `r, , all
IfInString full_path, \
{
Run, cmd /K cd /D "%full_path%"
}
else
{
Run, cmd /K cd /D "C:\ "
}
}
作為獎勵,上面的腳本還使用以下快捷方式建立一個新的文字檔案:Win+T
歸功於:伊萊·班德斯基
答案2
按Alt+ D,鍵入cmd
並按Enter。有關更多詳細信息,請參閱博客文章這裡。
答案3
在 windows7 中執行類似操作的本機方法是按住shift滑鼠右鍵到您想要「命令提示字元」的資料夾上,一個新的選單項目將出現在您的上下文功能表中,為您提供準確的資訊: “在此處開啟命令提示字元” ”。
如果你想要純鍵盤操作那麼你必須這麼做:
- 打開
regedit
- 轉到
HKEY_CLASSES_ROOT\Directory\shell\cmd
並將密鑰重命名Extended
為Extended_save
- 轉到
HKEY_CLASSES_ROOT\Drive\shell\cmd
並重命名Extended key to
Extended_save`
這會將“在此處開啟命令視窗”條目永久新增至上下文功能表中。您可以按下以下鍵觸發此條目:
- alt
- 放開,上下文選單打開
- 按“在此處開啟命令視窗”條目的“下劃線”字符,或使用遊標鍵向下並點擊enter
選單項目的名稱會根據作業系統的語言進行標記。
另一種方法是這樣做:
- 透過資源管理器在命令提示字元中開啟所需的資料夾
- f4
- ctrla
- ctrlc
- winr
cmd /k cd
ctrlventer
它從資源管理器的地址欄中獲取當前路徑並執行cmd /k cd PATH
。使用自動熱鍵你可以做同樣的事情,但我不知道自動熱鍵。
答案4
從最新的 Windows 10 更新開始,Leftium 的答案的Shift+ Menu,W方法不再有效。然而,一個小的修改可以提供一個解決方法,儘管需要更多的擊鍵。
問題是命令提示字元在擴充右鍵選單中不再可用。相反,您現在擁有 Windows Powershell。
Shift+ Menu,S在目標資料夾中開啟 Windows Powershell。進入 Windows Powershell 後,鍵入cmd
然後按Enter.
這將使您能夠存取 Windows Powershell 中的命令提示字元。
聚苯乙烯
Ashwin Nanjappa 的Ctrl+方法L,輸入cmd
然後按Enter即可。但是,只有當您不打算返回 Windows 資源管理器視窗以繼續在目錄之間導航時,它才是優雅的。不幸的是,該方法會使 Windows 資源管理器中的遊標遠離主窗口,並且需要多次Tab擊鍵才能將其返回到可以使用箭頭鍵導航資料夾的位置。這可能會令人沮喪,因為當您按下這些Tab按鍵時,視覺確認有限。
雖然Windows Powershell 在大多數方面的工作方式與命令提示字元相同,但我至少遇到過一種情況,其中Windows Powershell 錯誤地誤讀了我的@tags(當我產生javadoc 時)並且沒有產生所需的結果。透過cmd
在 Windows Powershell 中鍵入然後 Enter,您可以使用命令提示字元來克服此類問題。