当我按下Win + i时,我有以下脚本设置来更改环境变量(Mirus_Active_Directory)。它在Windows 7中运行良好,但似乎无法在Windows 10上运行。
如何修改代码以使其适用于Windows 10?
由于
SetTitleMatchMode RegEx
return
#IfWinActive ahk_class ExploreWClass
#i::
SetPath()
return
#IfWinActive ahk_class CabinetWClass
#i::
SetPath()
return
#IfWinActive
; Opens the command shell 'cmd' in the directory browsed in Explorer.
; Note: expecting to be run when the active window is Explorer.
;
SetPath()
{
; 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
; Take the first element from the array
full_path = %word_array1%
; 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, \
{
RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\Session Manager\Environment, Mirus_Active_Directory, %full_path%\
RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SYSTEM\ControlSet001\Control\Session Manager\Environment, Mirus_Active_Directory, %full_path%\
EnvUpdate
}
}